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
This commit is contained in:
Unknown 2019-02-03 23:59:15 +01:00 committed by unknown
parent d6b8a68489
commit 9569e52d48
2 changed files with 16 additions and 3 deletions

View file

@ -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);

View file

@ -114,7 +114,13 @@ public enum MyCustomModelLoader implements ICustomModelLoader {
final List<BakedQuad> 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<BakedQuad> bakedQuadsOut = Lists.newArrayList();
for(final BakedQuad bakedQuadIn : bakedQuadsIn) {