From 4bd73818270aee041707f9551d0f1c989ec67acd Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 17 Nov 2018 10:54:42 +0000 Subject: [PATCH] Add support for Forge's ISelectiveResourceReloadListener This means we don't reload turtles every time someone just reloads shaders or the language pack. --- .../client/render/TurtleSmartItemModel.java | 11 +++++++---- .../charset/BundledCapabilityProvider.java | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java index 5d9885b38..32f4dfeba 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java @@ -18,12 +18,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import net.minecraftforge.client.resource.IResourceType; +import net.minecraftforge.client.resource.ISelectiveResourceReloadListener; +import net.minecraftforge.client.resource.VanillaResourceType; import org.apache.commons.lang3.tuple.Pair; import javax.annotation.Nonnull; @@ -32,8 +34,9 @@ import javax.vecmath.Matrix4f; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.function.Predicate; -public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReloadListener +public class TurtleSmartItemModel implements IBakedModel, ISelectiveResourceReloadListener { private static final Matrix4f s_identity, s_flip; @@ -155,9 +158,9 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload } @Override - public void onResourceManagerReload( @Nonnull IResourceManager resourceManager ) + public void onResourceManagerReload( @Nonnull IResourceManager resourceManager, @Nonnull Predicate resourcePredicate ) { - m_cachedModels.clear(); + if( resourcePredicate.test( VanillaResourceType.MODELS ) ) m_cachedModels.clear(); } private IBakedModel buildModel( TurtleModelCombination combo ) diff --git a/src/main/java/dan200/computercraft/shared/integration/charset/BundledCapabilityProvider.java b/src/main/java/dan200/computercraft/shared/integration/charset/BundledCapabilityProvider.java index 161bc910d..9879f37d5 100644 --- a/src/main/java/dan200/computercraft/shared/integration/charset/BundledCapabilityProvider.java +++ b/src/main/java/dan200/computercraft/shared/integration/charset/BundledCapabilityProvider.java @@ -69,7 +69,6 @@ final class BundledCapabilityProvider implements ICapabilityProvider emitter = emitters[index] = () -> toBytes( tile.getBundledRedstoneOutput( side ) ); } } - ; return CAPABILITY_EMITTER.cast( emitter ); }