From b86306eb385821a6a84f30ec57cb7ab39c441b2a Mon Sep 17 00:00:00 2001 From: Dries007 Date: Fri, 17 Aug 2018 23:01:40 +0200 Subject: [PATCH] Re-fixed the broken leaves rendering settings. (I forgot the field isn't static, so vanilla only updates it's own leaves) --- .../objects/blocks/wood/BlockLeavesTFC.java | 30 +++++++++++++++++++ .../net/dries007/tfc/types/DefaultOres.java | 1 - .../dries007/tfc/util/CapabilityItemSize.java | 2 -- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLeavesTFC.java b/src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLeavesTFC.java index 800f95eb69..d9a01eec47 100644 --- a/src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLeavesTFC.java +++ b/src/main/java/net/dries007/tfc/objects/blocks/wood/BlockLeavesTFC.java @@ -15,15 +15,19 @@ import net.minecraft.block.BlockPlanks; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import net.dries007.tfc.api.types.Tree; import net.dries007.tfc.util.OreDictionaryHelper; @@ -174,4 +178,30 @@ private void doLeafDecay(World world, BlockPos pos, IBlockState state) world.setBlockToAir(pos); } + + @SideOnly(Side.CLIENT) + @Override + public BlockRenderLayer getRenderLayer() + { + /* + * This is a way to make sure the leave settings are updated. + * The result of this call is cached somewhere, so it's not that important, but: + * The alternative would be to use `Minecraft.getMinecraft().gameSettings.fancyGraphics` directly in the 2 relevant methods. + * It's better to do that than to refer to Blocks.LEAVES, for performance reasons. + */ + leavesFancy = Minecraft.getMinecraft().gameSettings.fancyGraphics; + return super.getRenderLayer(); + } + + @SuppressWarnings("deprecation") + @SideOnly(Side.CLIENT) + @Override + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) + { + /* + * See comment on getRenderLayer() + */ + leavesFancy = Minecraft.getMinecraft().gameSettings.fancyGraphics; + return super.shouldSideBeRendered(blockState, blockAccess, pos, side); + } } diff --git a/src/main/java/net/dries007/tfc/types/DefaultOres.java b/src/main/java/net/dries007/tfc/types/DefaultOres.java index 1369a9f0c9..19101c8527 100644 --- a/src/main/java/net/dries007/tfc/types/DefaultOres.java +++ b/src/main/java/net/dries007/tfc/types/DefaultOres.java @@ -19,7 +19,6 @@ @Mod.EventBusSubscriber(modid = MOD_ID) public class DefaultOres { - private static final ResourceLocation NATIVE_COPPER = new ResourceLocation(MOD_ID, "native_copper"); private static final ResourceLocation NATIVE_GOLD = new ResourceLocation(MOD_ID, "native_gold"); private static final ResourceLocation NATIVE_PLATINUM = new ResourceLocation(MOD_ID, "native_platinum"); diff --git a/src/main/java/net/dries007/tfc/util/CapabilityItemSize.java b/src/main/java/net/dries007/tfc/util/CapabilityItemSize.java index 6f22575e39..88388aa37a 100644 --- a/src/main/java/net/dries007/tfc/util/CapabilityItemSize.java +++ b/src/main/java/net/dries007/tfc/util/CapabilityItemSize.java @@ -1,7 +1,6 @@ /* * Work under Copyright. Licensed under the EUPL. * See the project README.md and LICENSE.txt for more information. - * */ package net.dries007.tfc.util; @@ -52,7 +51,6 @@ public void readNBT(Capability capability, IItemSize instance, EnumFa } }, () -> INSTANCE.getCapability(Size.SMALL, Weight.MEDIUM, true)); - } /**