Added built-in classic textures resource pack (Not fully working yet), removed April Fools easter egg from the Rainbow Hills
141
src/main/java/biomesoplenty/client/BOPClassicPack.java
Normal 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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
After Width: | Height: | Size: 1,002 B |
After Width: | Height: | Size: 928 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 522 B |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 1,001 B |
After Width: | Height: | Size: 983 B |
After Width: | Height: | Size: 631 B |
After Width: | Height: | Size: 515 B |
After Width: | Height: | Size: 652 B |
After Width: | Height: | Size: 337 B |
After Width: | Height: | Size: 426 B |
After Width: | Height: | Size: 446 B |
After Width: | Height: | Size: 598 B |
After Width: | Height: | Size: 594 B |
After Width: | Height: | Size: 573 B |
After Width: | Height: | Size: 502 B |
After Width: | Height: | Size: 331 B |
After Width: | Height: | Size: 430 B |
After Width: | Height: | Size: 498 B |
After Width: | Height: | Size: 772 B |
After Width: | Height: | Size: 559 B |
After Width: | Height: | Size: 454 B |
After Width: | Height: | Size: 663 B |
After Width: | Height: | Size: 517 B |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 808 B |
After Width: | Height: | Size: 754 B |
After Width: | Height: | Size: 411 B |
After Width: | Height: | Size: 587 B |
After Width: | Height: | Size: 530 B |
After Width: | Height: | Size: 509 B |
After Width: | Height: | Size: 340 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 429 B |
After Width: | Height: | Size: 690 B |
After Width: | Height: | Size: 709 B |
After Width: | Height: | Size: 663 B |
After Width: | Height: | Size: 649 B |
After Width: | Height: | Size: 621 B |
After Width: | Height: | Size: 663 B |
After Width: | Height: | Size: 601 B |
After Width: | Height: | Size: 522 B |
After Width: | Height: | Size: 335 B |
After Width: | Height: | Size: 316 B |
After Width: | Height: | Size: 433 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 574 B |
After Width: | Height: | Size: 229 B |
After Width: | Height: | Size: 413 B |
After Width: | Height: | Size: 582 B |
After Width: | Height: | Size: 418 B |
After Width: | Height: | Size: 578 B |
After Width: | Height: | Size: 971 B |
After Width: | Height: | Size: 943 B |
After Width: | Height: | Size: 558 B |
After Width: | Height: | Size: 629 B |
After Width: | Height: | Size: 365 B |
After Width: | Height: | Size: 566 B |
After Width: | Height: | Size: 483 B |
After Width: | Height: | Size: 338 B |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 411 B |
After Width: | Height: | Size: 636 B |
After Width: | Height: | Size: 602 B |
After Width: | Height: | Size: 569 B |
After Width: | Height: | Size: 588 B |
After Width: | Height: | Size: 519 B |
After Width: | Height: | Size: 334 B |
After Width: | Height: | Size: 359 B |
After Width: | Height: | Size: 436 B |
After Width: | Height: | Size: 671 B |
After Width: | Height: | Size: 702 B |
After Width: | Height: | Size: 720 B |
After Width: | Height: | Size: 840 B |
After Width: | Height: | Size: 614 B |
After Width: | Height: | Size: 520 B |
After Width: | Height: | Size: 335 B |
After Width: | Height: | Size: 365 B |
After Width: | Height: | Size: 443 B |
After Width: | Height: | Size: 472 B |
After Width: | Height: | Size: 638 B |
After Width: | Height: | Size: 640 B |
After Width: | Height: | Size: 649 B |
After Width: | Height: | Size: 613 B |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 893 B |
After Width: | Height: | Size: 438 B |
After Width: | Height: | Size: 887 B |
After Width: | Height: | Size: 848 B |
After Width: | Height: | Size: 547 B |
After Width: | Height: | Size: 382 B |
After Width: | Height: | Size: 322 B |
After Width: | Height: | Size: 526 B |