From 1f48c698e824d135136735864293f7befb344ed5 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 9 Jun 2021 23:48:34 +0200 Subject: [PATCH] ITE refactor --- .../crusher/CrushingWheelBlock.java | 77 ++++++++--------- .../crusher/CrushingWheelControllerBlock.java | 72 ++++++++-------- .../components/millstone/MillstoneBlock.java | 9 +- .../fluids/actors/ItemDrainBlock.java | 8 +- .../contraptions/processing/BasinBlock.java | 9 +- .../contraptions/relays/belt/BeltBlock.java | 25 ++---- .../block/chute/AbstractChuteBlock.java | 12 +-- .../block/redstone/AnalogLeverBlock.java | 50 +++++------ .../block/redstone/NixieTubeBlock.java | 84 +++++++++--------- .../block/redstone/RedstoneLinkBlock.java | 16 ++-- .../block/redstone/StockpileSwitchBlock.java | 17 ++-- .../simibubi/create/foundation/block/ITE.java | 86 +++---------------- .../create/foundation/config/CCommon.java | 2 - 13 files changed, 179 insertions(+), 288 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java index 127ed6923..e657e45ae 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelBlock.java @@ -92,34 +92,29 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE if (AllBlocks.CRUSHING_WHEEL.has(otherState)) { controllerShouldExist = true; - try { - CrushingWheelTileEntity te = getTileEntity(world, pos); - CrushingWheelTileEntity otherTe = getTileEntity(world, otherWheelPos); + CrushingWheelTileEntity te = getTileEntity(world, pos); + CrushingWheelTileEntity otherTe = getTileEntity(world, otherWheelPos); - if (te != null && otherTe != null && (te.getSpeed() > 0) != (otherTe.getSpeed() > 0) - && te.getSpeed() != 0) { - Axis wheelAxis = state.get(AXIS); - Axis sideAxis = side.getAxis(); - int controllerADO = Math.round(Math.signum(te.getSpeed())) * side.getAxisDirection().getOffset(); - Vector3d controllerDirVec = new Vector3d(wheelAxis == Axis.X ? 1 : 0 - , wheelAxis == Axis.Y ? 1 : 0 - , wheelAxis == Axis.Z ? 1 : 0) - .crossProduct(new Vector3d(sideAxis == Axis.X ? 1 : 0 - , sideAxis == Axis.Y ? 1 : 0 - , sideAxis == Axis.Z ? 1 : 0)); + if (te != null && otherTe != null && (te.getSpeed() > 0) != (otherTe.getSpeed() > 0) + && te.getSpeed() != 0) { + Axis wheelAxis = state.get(AXIS); + Axis sideAxis = side.getAxis(); + int controllerADO = Math.round(Math.signum(te.getSpeed())) * side.getAxisDirection().getOffset(); + Vector3d controllerDirVec = new Vector3d(wheelAxis == Axis.X ? 1 : 0 + , wheelAxis == Axis.Y ? 1 : 0 + , wheelAxis == Axis.Z ? 1 : 0) + .crossProduct(new Vector3d(sideAxis == Axis.X ? 1 : 0 + , sideAxis == Axis.Y ? 1 : 0 + , sideAxis == Axis.Z ? 1 : 0)); - controllerNewDirection = Direction.getFacingFromVector(controllerDirVec.x * controllerADO - , controllerDirVec.y * controllerADO - , controllerDirVec.z * controllerADO); + controllerNewDirection = Direction.getFacingFromVector(controllerDirVec.x * controllerADO + , controllerDirVec.y * controllerADO + , controllerDirVec.z * controllerADO); - controllerShouldBeValid = true; - } - if (otherState.get(AXIS) != state.get(AXIS)) - controllerShouldExist = false; - - } catch (TileEntityException e) { - controllerShouldExist = false; + controllerShouldBeValid = true; } + if (otherState.get(AXIS) != state.get(AXIS)) + controllerShouldExist = false; } if (!controllerShouldExist) { @@ -149,27 +144,25 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE @Override public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { - try { - CrushingWheelTileEntity te = getTileEntity(worldIn, pos); - if (entityIn.getY() < pos.getY() + 1.25f || !entityIn.isOnGround()) - return; + if (entityIn.getY() < pos.getY() + 1.25f || !entityIn.isOnGround()) + return; + + float speed = getTileEntityOptional(worldIn, pos).map(CrushingWheelTileEntity::getSpeed) + .orElse(0f); - double x = 0; - double z = 0; + double x = 0; + double z = 0; - if (state.get(AXIS) == Axis.X) { - z = te.getSpeed() / 20f; - x += (pos.getX() + .5f - entityIn.getX()) * .1f; - } - if (state.get(AXIS) == Axis.Z) { - x = te.getSpeed() / -20f; - z += (pos.getZ() + .5f - entityIn.getZ()) * .1f; - } - entityIn.setMotion(entityIn.getMotion() - .add(x, 0, z)); - - } catch (TileEntityException e) { + if (state.get(AXIS) == Axis.X) { + z = speed / 20f; + x += (pos.getX() + .5f - entityIn.getX()) * .1f; } + if (state.get(AXIS) == Axis.Z) { + x = speed / -20f; + z += (pos.getZ() + .5f - entityIn.getZ()) * .1f; + } + entityIn.setMotion(entityIn.getMotion() + .add(x, 0, z)); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java index e1175feba..b17ccbb78 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerBlock.java @@ -91,28 +91,28 @@ public class CrushingWheelControllerBlock extends DirectionalBlock }); } - public void checkEntityForProcessing(World worldIn, BlockPos pos, Entity entityIn){ - try { - CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos); - if (te.crushingspeed == 0) - return; - if (entityIn instanceof ItemEntity) - ((ItemEntity) entityIn).setPickupDelay(10); - CompoundNBT data = entityIn.getPersistentData(); - if (data.contains("BypassCrushingWheel")) { - if (pos.equals(NBTUtil.readBlockPos(data.getCompound("BypassCrushingWheel")))) - return; - } - if (te.isOccupied()) - return; - boolean isPlayer = entityIn instanceof PlayerEntity; - if (isPlayer && ((PlayerEntity) entityIn).isCreative()) - return; - if (isPlayer && entityIn.world.getDifficulty() == Difficulty.PEACEFUL) + public void checkEntityForProcessing(World worldIn, BlockPos pos, Entity entityIn) { + CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos); + if (te == null) + return; + if (te.crushingspeed == 0) + return; + if (entityIn instanceof ItemEntity) + ((ItemEntity) entityIn).setPickupDelay(10); + CompoundNBT data = entityIn.getPersistentData(); + if (data.contains("BypassCrushingWheel")) { + if (pos.equals(NBTUtil.readBlockPos(data.getCompound("BypassCrushingWheel")))) return; + } + if (te.isOccupied()) + return; + boolean isPlayer = entityIn instanceof PlayerEntity; + if (isPlayer && ((PlayerEntity) entityIn).isCreative()) + return; + if (isPlayer && entityIn.world.getDifficulty() == Difficulty.PEACEFUL) + return; - te.startCrushing(entityIn); - } catch (TileEntityException e) {} + te.startCrushing(entityIn); } @Override @@ -166,27 +166,27 @@ public class CrushingWheelControllerBlock extends DirectionalBlock @Override public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, - ISelectionContext context) { + ISelectionContext context) { + VoxelShape standardShape = AllShapes.CRUSHING_WHEEL_CONTROLLER_COLLISION.get(state.get(FACING)); + if (!state.get(VALID)) - return AllShapes.CRUSHING_WHEEL_CONTROLLER_COLLISION.get(state.get(FACING)); + return standardShape; Entity entity = context.getEntity(); - if (entity != null) { + if (entity == null) + return standardShape; - CompoundNBT data = entity.getPersistentData(); - if (data.contains("BypassCrushingWheel")) { - if (pos.equals(NBTUtil.readBlockPos(data.getCompound("BypassCrushingWheel")))) - if (state.get(FACING) != Direction.UP) //Allow output items to land on top of the block rather than falling back through. - return VoxelShapes.empty(); - } - - try { - CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos); - if (te.processingEntity == entity) + CompoundNBT data = entity.getPersistentData(); + if (data.contains("BypassCrushingWheel")) + if (pos.equals(NBTUtil.readBlockPos(data.getCompound("BypassCrushingWheel")))) + if (state.get(FACING) != Direction.UP) // Allow output items to land on top of the block rather than falling back through. return VoxelShapes.empty(); - } catch (TileEntityException e) {} - } - return AllShapes.CRUSHING_WHEEL_CONTROLLER_COLLISION.get(state.get(FACING)); + + CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos); + if (te != null && te.processingEntity == entity) + return VoxelShapes.empty(); + + return standardShape; } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneBlock.java index bad0b74f5..d297e8d01 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneBlock.java @@ -99,13 +99,10 @@ public class MillstoneBlock extends KineticBlock implements ITE { if (!heldItem.isEmpty()) { te.internalTank.allowInsertion(); ActionResultType tryExchange = tryExchange(worldIn, player, handIn, heldItem, te); @@ -53,10 +52,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE, IWrenchab BlockRayTraceResult hit) { ItemStack heldItem = player.getHeldItem(handIn); - try { - BasinTileEntity te = getTileEntity(worldIn, pos); + return onTileEntityUse(worldIn, pos, te -> { if (!heldItem.isEmpty()) { if (FluidHelper.tryEmptyItemIntoTE(worldIn, player, handIn, heldItem, te)) return ActionResultType.SUCCESS; @@ -128,10 +127,8 @@ public class BasinBlock extends Block implements ITE, IWrenchab worldIn.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, .2f, 1f + Create.RANDOM.nextFloat()); te.onEmptied(); - } catch (TileEntityException e) { - } - - return ActionResultType.SUCCESS; + return ActionResultType.SUCCESS; + }); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java index b8668229a..1a1c111b2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java @@ -102,11 +102,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE { if (context.getEntity() == null) return shape; - BeltTileEntity belt = getTileEntity(worldIn, pos); - BeltTileEntity controller = belt.getControllerTE(); - + BeltTileEntity controller = te.getControllerTE(); if (controller == null) return shape; - if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity())) { + if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity())) return BeltShapes.getCollisionShape(state); - } - - } catch (TileEntityException e) { - } - return shape; + return shape; + + }).orElse(shape); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/AbstractChuteBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/AbstractChuteBlock.java index 60970e62d..bd886c322 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/AbstractChuteBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/AbstractChuteBlock.java @@ -204,20 +204,14 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I return ActionResultType.PASS; if (world.isRemote) return ActionResultType.SUCCESS; - try { - ChuteTileEntity te = getTileEntity(world, pos); - if (te == null) - return ActionResultType.PASS; + + return onTileEntityUse(world, pos, te -> { if (te.item.isEmpty()) return ActionResultType.PASS; player.inventory.placeItemBackInInventory(world, te.item); te.setItem(ItemStack.EMPTY); return ActionResultType.SUCCESS; - - } catch (TileEntityException e) { - e.printStackTrace(); - } - return ActionResultType.PASS; + }); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverBlock.java index 3d018cb61..688dd8129 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverBlock.java @@ -47,30 +47,25 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE { boolean sneak = player.isSneaking(); - AnalogLeverTileEntity te = getTileEntity(worldIn, pos); te.changeState(sneak); float f = .25f + ((te.state + 5) / 15f) * .5f; worldIn.playSound(null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.2F, f); - } catch (TileEntityException e) {} - - return ActionResultType.SUCCESS; + return ActionResultType.SUCCESS; + }); } @Override public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { - try { - return getTileEntity(blockAccess, pos).state; - } catch (TileEntityException e) { - return 0; - } + return getTileEntityOptional(blockAccess, pos).map(al -> al.state) + .orElse(0); } @Override @@ -86,34 +81,33 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE { + if (te.state != 0 && rand.nextFloat() < 0.25F) addParticles(stateIn, worldIn, pos, 0.5F); - } catch (TileEntityException e) {} + }); } @Override public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { - try { - AnalogLeverTileEntity tileEntity = getTileEntity(worldIn, pos); - if (!isMoving && state.getBlock() != newState.getBlock()) { - if (tileEntity.state != 0) - updateNeighbors(state, worldIn, pos); - worldIn.removeTileEntity(pos); - } - } catch (TileEntityException e) {} + if (isMoving || state.getBlock() == newState.getBlock()) + return; + withTileEntityDo(worldIn, pos, te -> { + if (te.state != 0) + updateNeighbors(state, worldIn, pos); + worldIn.removeTileEntity(pos); + }); } private static void addParticles(BlockState state, IWorld worldIn, BlockPos pos, float alpha) { - Direction direction = state.get(HORIZONTAL_FACING).getOpposite(); + Direction direction = state.get(HORIZONTAL_FACING) + .getOpposite(); Direction direction1 = getFacing(state).getOpposite(); double d0 = (double) pos.getX() + 0.5D + 0.1D * (double) direction.getXOffset() - + 0.2D * (double) direction1.getXOffset(); + + 0.2D * (double) direction1.getXOffset(); double d1 = (double) pos.getY() + 0.5D + 0.1D * (double) direction.getYOffset() - + 0.2D * (double) direction1.getYOffset(); + + 0.2D * (double) direction1.getYOffset(); double d2 = (double) pos.getZ() + 0.5D + 0.1D * (double) direction.getZOffset() - + 0.2D * (double) direction1.getZOffset(); + + 0.2D * (double) direction1.getZOffset(); worldIn.addParticle(new RedstoneParticleData(1.0F, 0.0F, 0.0F, alpha), d0, d1, d2, 0.0D, 0.0D, 0.0D); } @@ -137,7 +131,7 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE getTileEntityClass() { return AnalogLeverTileEntity.class; } - + @Override public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeBlock.java index 8dd81f379..a35938e24 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeBlock.java @@ -42,54 +42,52 @@ public class NixieTubeBlock extends HorizontalBlock implements ITE te.displayCustomNameOf(heldItem, rowPosition)); - BlockPos nextPos = currentPos.offset(right); - if (world.getBlockState(nextPos) != state) - break; - currentPos = nextPos; - index++; - } - } - - } catch (TileEntityException e) { + nixie.clearCustomText(); + updateDisplayedRedstoneValue(state, world, pos); + return ActionResultType.SUCCESS; } + if (heldItem.getItem() == Items.NAME_TAG && heldItem.hasDisplayName()) { + Direction left = state.get(HORIZONTAL_FACING) + .rotateY(); + Direction right = left.getOpposite(); + + if (world.isRemote) + return ActionResultType.SUCCESS; + + BlockPos currentPos = pos; + while (true) { + BlockPos nextPos = currentPos.offset(left); + if (world.getBlockState(nextPos) != state) + break; + currentPos = nextPos; + } + + int index = 0; + + while (true) { + final int rowPosition = index; + withTileEntityDo(world, currentPos, te -> te.displayCustomNameOf(heldItem, rowPosition)); + BlockPos nextPos = currentPos.offset(right); + if (world.getBlockState(nextPos) != state) + break; + currentPos = nextPos; + index++; + } + } + return ActionResultType.PASS; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java index 6c58c7651..b23a5ee79 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java @@ -114,12 +114,8 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE { Boolean wasReceiver = state.get(RECEIVER); boolean blockPowered = worldIn.isBlockPowered(pos); worldIn.setBlockState(pos, state.cycle(RECEIVER) .with(POWERED, blockPowered), 3); te.transmit(wasReceiver ? 0 : getPower(worldIn, pos)); return ActionResultType.SUCCESS; - } catch (TileEntityException e) { - } - return ActionResultType.PASS; + }); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java index ec43d44e9..56035874b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/StockpileSwitchBlock.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.logistics.block.redstone; +import java.util.Random; + import com.simibubi.create.AllItems; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; @@ -33,8 +35,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.items.CapabilityItemHandler; -import java.util.Random; - public class StockpileSwitchBlock extends HorizontalBlock implements ITE, IWrenchable { public static final IntegerProperty INDICATOR = IntegerProperty.create("indicator", 0, 6); @@ -85,19 +85,14 @@ public class StockpileSwitchBlock extends HorizontalBlock implements ITE 15) + .orElse(0); } @Override public void scheduledTick(BlockState blockState, ServerWorld world, BlockPos pos, Random random) { - try { - getTileEntity(world, pos).updatePowerAfterDelay(); - } catch (TileEntityException e) { - } + getTileEntityOptional(world, pos).ifPresent(StockpileSwitchTileEntity::updatePowerAfterDelay); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/block/ITE.java b/src/main/java/com/simibubi/create/foundation/block/ITE.java index 1bc0863c9..83646e4ba 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ITE.java +++ b/src/main/java/com/simibubi/create/foundation/block/ITE.java @@ -2,102 +2,44 @@ package com.simibubi.create.foundation.block; import java.util.Optional; import java.util.function.Consumer; +import java.util.function.Function; -import com.simibubi.create.Create; -import com.simibubi.create.foundation.config.AllConfigs; -import com.simibubi.create.foundation.utility.WorldHelper; +import javax.annotation.Nullable; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; public interface ITE { Class getTileEntityClass(); default void withTileEntityDo(IBlockReader world, BlockPos pos, Consumer action) { - try { - action.accept(getTileEntity(world, pos)); - } catch (TileEntityException e) { - } + getTileEntityOptional(world, pos).ifPresent(action); } + default ActionResultType onTileEntityUse(IBlockReader world, BlockPos pos, Function action) { + return getTileEntityOptional(world, pos).map(action) + .orElse(ActionResultType.PASS); + } + default Optional getTileEntityOptional(IBlockReader world, BlockPos pos) { - try { - return Optional.of(getTileEntity(world, pos)); - } catch (TileEntityException e) { - } - return Optional.empty(); + return Optional.ofNullable(getTileEntity(world, pos)); } + @Nullable @SuppressWarnings("unchecked") - default T getTileEntity(IBlockReader worldIn, BlockPos pos) throws TileEntityException { + default T getTileEntity(IBlockReader worldIn, BlockPos pos) { TileEntity tileEntity = worldIn.getTileEntity(pos); Class expectedClass = getTileEntityClass(); - IWorld world = null; - if (worldIn instanceof IWorld) - world = (IWorld) worldIn; - if (tileEntity == null) - throw new MissingTileEntityException(world, pos, expectedClass); + return null; if (!expectedClass.isInstance(tileEntity)) - throw new InvalidTileEntityException(world, pos, expectedClass, tileEntity.getClass()); + return null; return (T) tileEntity; } - static class TileEntityException extends Throwable { - private static final long serialVersionUID = 1L; - - public TileEntityException(IWorld world, BlockPos pos, Class teClass) { - super(makeBaseMessage(world, pos, teClass)); - } - - public TileEntityException(String message) { - super(message); - report(this); - } - - static String makeBaseMessage(IWorld world, BlockPos pos, Class expectedTeClass) { - return String.format("[%s] @(%d, %d, %d), expecting a %s", getDimensionName(world), pos.getX(), pos.getY(), - pos.getZ(), expectedTeClass.getSimpleName()); - } - - static String getDimensionName(IWorld world) { - String notAvailable = "Dim N/A"; - if (world == null) - return notAvailable; - ResourceLocation registryName = WorldHelper.getDimensionID(world); - if (registryName == null) - return notAvailable; - return registryName.toString(); - } - } - - static class MissingTileEntityException extends TileEntityException { - private static final long serialVersionUID = 1L; - - public MissingTileEntityException(IWorld world, BlockPos pos, Class teClass) { - super("Missing TileEntity: " + makeBaseMessage(world, pos, teClass)); - } - - } - - static class InvalidTileEntityException extends TileEntityException { - private static final long serialVersionUID = 1L; - - public InvalidTileEntityException(IWorld world, BlockPos pos, Class expectedTeClass, Class foundTeClass) { - super("Wrong TileEntity: " + makeBaseMessage(world, pos, expectedTeClass) + ", found " - + foundTeClass.getSimpleName()); - } - } - - static void report(TileEntityException e) { - if (AllConfigs.COMMON.logTeErrors.get()) - Create.LOGGER.debug("TileEntityException thrown!", e); - } - } diff --git a/src/main/java/com/simibubi/create/foundation/config/CCommon.java b/src/main/java/com/simibubi/create/foundation/config/CCommon.java index d95a92f60..beeb7f897 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CCommon.java +++ b/src/main/java/com/simibubi/create/foundation/config/CCommon.java @@ -3,7 +3,6 @@ package com.simibubi.create.foundation.config; public class CCommon extends ConfigBase { public CWorldGen worldGen = nested(0, CWorldGen::new, Comments.worldGen); - public ConfigBool logTeErrors = b(false, "logTeErrors", Comments.logTeErrors); @Override public String getName() { @@ -12,7 +11,6 @@ public class CCommon extends ConfigBase { private static class Comments { static String worldGen = "Modify Create's impact on your terrain"; - static String logTeErrors = "Forward caught TileEntityExceptions to the log at debug level."; } }