Added built-in classic textures resource pack (Not fully working yet), removed April Fools easter egg from the Rainbow Hills

This commit is contained in:
Forstride 2021-06-04 10:59:55 -04:00
parent 7f4c3623df
commit 1eeca25ed0
253 changed files with 164 additions and 13 deletions

View file

@ -0,0 +1,141 @@
/**Copied from Twilight Forest and modified with permission**/
package biomesoplenty.client;
import biomesoplenty.core.BiomesOPlenty;
import com.google.common.base.Joiner;
import net.minecraft.resources.ResourcePack;
import net.minecraft.resources.ResourcePackFileNotFoundException;
import net.minecraft.resources.ResourcePackType;
import net.minecraft.resources.data.IMetadataSectionSerializer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
import javax.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@OnlyIn(Dist.CLIENT)
public class BOPClassicPack extends ResourcePack
{
private final ModFile modFile;
private static final String subDir = "classic/";
public BOPClassicPack(ModFile modFile)
{
super(modFile.getFilePath().toFile());
this.modFile = modFile;
}
@Override
public Set<String> getNamespaces(ResourcePackType type)
{
try
{
Path root = modFile.getLocator().findPath(modFile, subDir + type.getDirectory()).toAbsolutePath();
return Files.walk(root,1).map(path -> root.relativize(path.toAbsolutePath())).filter(path -> path.getNameCount() > 0).map(p->p.toString().replaceAll("/$","")).filter(s -> !s.isEmpty()).collect(Collectors.toSet());
}
catch (Throwable t)
{
BiomesOPlenty.logger.error("BOPClassicPack failed to collect resource namespaces!", t);
return Collections.emptySet();
}
}
@Override
protected InputStream getResource(String location) throws IOException
{
final Path path = modFile.getLocator().findPath(modFile, subDir + location);
if (!Files.exists(path))
{
BiomesOPlenty.logger.error("File does not exist!");
throw new ResourcePackFileNotFoundException(path.toFile(), location);
}
return Files.newInputStream(path, StandardOpenOption.READ);
}
@Override
protected boolean hasResource(String resourcePath)
{
return Files.exists(modFile.getLocator().findPath(modFile, subDir + resourcePath));
}
@Override
public Collection<ResourceLocation> getResources(ResourcePackType type, String namespaceIn, String pathIn, int maxDepthIn, Predicate<String> filterIn)
{
try
{
Path root = modFile.getLocator().findPath(modFile, subDir + type.getDirectory()).toAbsolutePath();
Path inputPath = root.getFileSystem().getPath(pathIn);
return Files.walk(root).map(path -> root.relativize(path.toAbsolutePath())).filter(path -> path.getNameCount() > 1 && path.getNameCount() - 1 <= maxDepthIn).filter(path -> !path.toString().endsWith(".mcmeta")).filter(path -> path.subpath(1, path.getNameCount()).startsWith(inputPath)).filter(path -> filterIn.test(path.getFileName().toString())).map(path -> new ResourceLocation(path.getName(0).toString(), Joiner.on('/').join(path.subpath(1, Math.min(maxDepthIn, path.getNameCount()))))).collect(Collectors.toList());
}
catch (IOException e)
{
return Collections.emptyList();
}
}
@Override
public void close() { }
@Override
public String getName()
{
return "BOP Programmer Art";
}
@Nullable
@Override
public <T> T getMetadataSection(IMetadataSectionSerializer<T> serializer) throws IOException
{
InputStream inputStream = getResource("pack.mcmeta");
Throwable throwable = null;
T resourceMetaData;
try
{
resourceMetaData = getMetadataFromStream(serializer, inputStream);
}
catch (Throwable t)
{
throwable = t;
throw t;
}
finally
{
if (inputStream != null)
{
if (throwable != null)
{
try
{
inputStream.close();
}
catch (Throwable t)
{
throwable.addSuppressed(t);
}
}
else
{
inputStream.close();
}
}
}
return resourceMetaData;
}
}

View file

@ -88,16 +88,12 @@ public class RainbowHillsBiome extends BiomeTemplate
public int getGrassColor(double x, double z)
{
if (ClientProxy.isAprilFools) { return 0xFFFFFF; }
double d0 = Biome.BIOME_INFO_NOISE.getValue(x * 0.0225D, z * 0.0225D, false);
return d0 < -0.1D ? 0x77CE7F : 0x75CE8D;
}
public int getFoliageColor()
{
if (ClientProxy.isAprilFools) { return 0xFFFFFF; }
return 0x75CE8D;
}
}

View file

@ -8,9 +8,15 @@
package biomesoplenty.core;
import biomesoplenty.client.BOPClassicPack;
import biomesoplenty.client.renderer.BoatRendererBOP;
import biomesoplenty.init.*;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourcePackInfo;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

View file

@ -8,25 +8,27 @@
package biomesoplenty.core;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.client.BOPClassicPack;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.item.BlockItem;
import net.minecraft.resources.ResourcePackInfo;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.FoliageColors;
import net.minecraft.world.GrassColors;
import net.minecraft.world.IBlockDisplayReader;
import net.minecraft.world.biome.BiomeColors;
import net.minecraftforge.fml.ModList;
import java.awt.*;
import java.util.Calendar;
public class ClientProxy extends CommonProxy
{
public static boolean isAprilFools = false;
public ClientProxy()
{
@ -35,8 +37,7 @@ public class ClientProxy extends CommonProxy
@Override
public void init()
{
Calendar calendar = Calendar.getInstance();
if (calendar.get(2) + 1 == 4 && calendar.get(5) == 1) { isAprilFools = true; }
addClassicPack();
BlockColors blockColors = Minecraft.getInstance().getBlockColors();
ItemColors itemColors = Minecraft.getInstance().getItemColors();
@ -65,10 +66,15 @@ public class ClientProxy extends CommonProxy
BOPBlocks.palm_leaves, BOPBlocks.willow_leaves, BOPBlocks.willow_vine);
}
public static void addClassicPack()
{
if (Minecraft.getInstance() == null) { return; }
Minecraft.getInstance().getResourcePackRepository().addPackFinder((consumer, iFactory) -> consumer.accept(ResourcePackInfo.create(new ResourceLocation(BiomesOPlenty.MOD_ID, "classic_textures").toString(), false, () -> new BOPClassicPack(ModList.get().getModFileById(BiomesOPlenty.MOD_ID).getFile()), iFactory, ResourcePackInfo.Priority.TOP, iTextComponent -> iTextComponent)));
}
public static int getRainbowBirchColor(IBlockDisplayReader world, BlockPos pos)
{
Color foliage = Color.getHSBColor((((float)pos.getX() + MathHelper.sin(((float)pos.getZ() + (float)pos.getX()) / 35) * 35) % 150) / 150, 0.6F, 1.0F);
if (isAprilFools) { foliage = Color.WHITE; }
return foliage.getRGB();
}

View file

@ -413,9 +413,5 @@
"block.biomesoplenty.yellow_autumn_leaves": "Yellow Autumn Leaves",
"block.biomesoplenty.yellow_autumn_sapling": "Yellow Autumn Sapling",
"argument.biomesoplenty.biome.invalid": "Invalid biome argument",
"commands.biomesoplenty.tpbiome.success": "Teleported %s to biome %s at (%s, %s, %s)",
"commands.biomesoplenty.tpbiome.error": "Couldn't find biome %s!",
"entity.biomesoplenty.boat_bop": "Boat"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,002 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,001 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 709 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Some files were not shown because too many files have changed in this diff Show more