From 9569e52d48c795f1d5130f54aef4a1825ff6f4c6 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 3 Feb 2019 23:59:15 +0100 Subject: [PATCH] Integrated custom rendering with invalid state (namely ICBM flying block) - added log throttle to reduce FPS impact - added a proper default value in case TileEntity is missing altogether --- .../cr0s/warpdrive/render/BakedModelCapacitor.java | 11 +++++++++-- .../cr0s/warpdrive/render/MyCustomModelLoader.java | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/render/BakedModelCapacitor.java b/src/main/java/cr0s/warpdrive/render/BakedModelCapacitor.java index 1df2f162..93ab8e88 100644 --- a/src/main/java/cr0s/warpdrive/render/BakedModelCapacitor.java +++ b/src/main/java/cr0s/warpdrive/render/BakedModelCapacitor.java @@ -35,6 +35,8 @@ public class BakedModelCapacitor implements IBakedModel, IMyBakedModel { private IBakedModel bakedModelOriginal; private IExtendedBlockState extendedBlockStateDefault; + private long timeLastError = -1L; + public BakedModelCapacitor() { } @@ -79,8 +81,13 @@ public class BakedModelCapacitor implements IBakedModel, IMyBakedModel { if (extendedBlockState != null) { final EnumDisabledInputOutput enumDisabledInputOutput = getEnumDisabledInputOutput(extendedBlockState, facing); if (enumDisabledInputOutput == null) { - WarpDrive.logger.error(String.format("%s Invalid extended property for %s\n%s", - this, extendedBlockState, formatDetails() )); + final long time = System.currentTimeMillis(); + if (time - timeLastError > 5000L) { + timeLastError = time; + new RuntimeException("Invalid extended property").printStackTrace(); + WarpDrive.logger.error(String.format("%s Invalid extended property for %s facing %s\n%s", + this, extendedBlockState, facing, formatDetails())); + } return getDefaultQuads(facing, rand); } final IBlockState blockStateToRender = extendedBlockState.getClean().withProperty(BlockCapacitor.CONFIG, enumDisabledInputOutput); diff --git a/src/main/java/cr0s/warpdrive/render/MyCustomModelLoader.java b/src/main/java/cr0s/warpdrive/render/MyCustomModelLoader.java index a865d47b..15403309 100644 --- a/src/main/java/cr0s/warpdrive/render/MyCustomModelLoader.java +++ b/src/main/java/cr0s/warpdrive/render/MyCustomModelLoader.java @@ -114,7 +114,13 @@ public enum MyCustomModelLoader implements ICustomModelLoader { final List bakedQuadsIn = bakedModel.getQuads(blockState, side, rand); final IExtendedBlockState exState = (IExtendedBlockState) blockState; - final EnumForceFieldShape enumForceFieldShape = exState != null ? exState.getValue(BlockForceFieldProjector.SHAPE) : EnumForceFieldShape.NONE; + EnumForceFieldShape enumForceFieldShape = exState != null ? exState.getValue(BlockForceFieldProjector.SHAPE) : EnumForceFieldShape.NONE; + if (enumForceFieldShape == null) { + new RuntimeException("Invalid shape").printStackTrace(); + WarpDrive.logger.error(String.format("Invalid shape for %s side %s", + blockState, side)); + enumForceFieldShape = EnumForceFieldShape.NONE; + } final TextureAtlasSprite spriteShape = spriteShapes.get(enumForceFieldShape); final List bakedQuadsOut = Lists.newArrayList(); for(final BakedQuad bakedQuadIn : bakedQuadsIn) {