ITE refactor

This commit is contained in:
simibubi 2021-06-09 23:48:34 +02:00
parent 2852756a68
commit 1f48c698e8
13 changed files with 179 additions and 288 deletions

View File

@ -92,7 +92,6 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
if (AllBlocks.CRUSHING_WHEEL.has(otherState)) { if (AllBlocks.CRUSHING_WHEEL.has(otherState)) {
controllerShouldExist = true; controllerShouldExist = true;
try {
CrushingWheelTileEntity te = getTileEntity(world, pos); CrushingWheelTileEntity te = getTileEntity(world, pos);
CrushingWheelTileEntity otherTe = getTileEntity(world, otherWheelPos); CrushingWheelTileEntity otherTe = getTileEntity(world, otherWheelPos);
@ -116,10 +115,6 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
} }
if (otherState.get(AXIS) != state.get(AXIS)) if (otherState.get(AXIS) != state.get(AXIS))
controllerShouldExist = false; controllerShouldExist = false;
} catch (TileEntityException e) {
controllerShouldExist = false;
}
} }
if (!controllerShouldExist) { if (!controllerShouldExist) {
@ -149,27 +144,25 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
@Override @Override
public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { 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()) if (entityIn.getY() < pos.getY() + 1.25f || !entityIn.isOnGround())
return; return;
float speed = getTileEntityOptional(worldIn, pos).map(CrushingWheelTileEntity::getSpeed)
.orElse(0f);
double x = 0; double x = 0;
double z = 0; double z = 0;
if (state.get(AXIS) == Axis.X) { if (state.get(AXIS) == Axis.X) {
z = te.getSpeed() / 20f; z = speed / 20f;
x += (pos.getX() + .5f - entityIn.getX()) * .1f; x += (pos.getX() + .5f - entityIn.getX()) * .1f;
} }
if (state.get(AXIS) == Axis.Z) { if (state.get(AXIS) == Axis.Z) {
x = te.getSpeed() / -20f; x = speed / -20f;
z += (pos.getZ() + .5f - entityIn.getZ()) * .1f; z += (pos.getZ() + .5f - entityIn.getZ()) * .1f;
} }
entityIn.setMotion(entityIn.getMotion() entityIn.setMotion(entityIn.getMotion()
.add(x, 0, z)); .add(x, 0, z));
} catch (TileEntityException e) {
}
} }
@Override @Override

View File

@ -92,8 +92,9 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
} }
public void checkEntityForProcessing(World worldIn, BlockPos pos, Entity entityIn) { public void checkEntityForProcessing(World worldIn, BlockPos pos, Entity entityIn) {
try {
CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos); CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos);
if (te == null)
return;
if (te.crushingspeed == 0) if (te.crushingspeed == 0)
return; return;
if (entityIn instanceof ItemEntity) if (entityIn instanceof ItemEntity)
@ -112,7 +113,6 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
return; return;
te.startCrushing(entityIn); te.startCrushing(entityIn);
} catch (TileEntityException e) {}
} }
@Override @Override
@ -167,26 +167,26 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
@Override @Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, 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)) if (!state.get(VALID))
return AllShapes.CRUSHING_WHEEL_CONTROLLER_COLLISION.get(state.get(FACING)); return standardShape;
Entity entity = context.getEntity(); Entity entity = context.getEntity();
if (entity != null) { if (entity == null)
return standardShape;
CompoundNBT data = entity.getPersistentData(); CompoundNBT data = entity.getPersistentData();
if (data.contains("BypassCrushingWheel")) { if (data.contains("BypassCrushingWheel"))
if (pos.equals(NBTUtil.readBlockPos(data.getCompound("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. if (state.get(FACING) != Direction.UP) // Allow output items to land on top of the block rather than falling back through.
return VoxelShapes.empty(); return VoxelShapes.empty();
}
try {
CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos); CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos);
if (te.processingEntity == entity) if (te != null && te.processingEntity == entity)
return VoxelShapes.empty(); return VoxelShapes.empty();
} catch (TileEntityException e) {}
} return standardShape;
return AllShapes.CRUSHING_WHEEL_CONTROLLER_COLLISION.get(state.get(FACING));
} }
@Override @Override

View File

@ -99,13 +99,10 @@ public class MillstoneBlock extends KineticBlock implements ITE<MillstoneTileEnt
return; return;
MillstoneTileEntity millstone = null; MillstoneTileEntity millstone = null;
for (BlockPos pos : Iterate.hereAndBelow(entityIn.getBlockPos())) { for (BlockPos pos : Iterate.hereAndBelow(entityIn.getBlockPos()))
try { if (millstone == null)
millstone = getTileEntity(worldIn, pos); millstone = getTileEntity(worldIn, pos);
} catch (TileEntityException e) {
continue;
}
}
if (millstone == null) if (millstone == null)
return; return;

View File

@ -36,8 +36,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE<ItemDrainT
BlockRayTraceResult hit) { BlockRayTraceResult hit) {
ItemStack heldItem = player.getHeldItem(handIn); ItemStack heldItem = player.getHeldItem(handIn);
try { return onTileEntityUse(worldIn, pos, te -> {
ItemDrainTileEntity te = getTileEntity(worldIn, pos);
if (!heldItem.isEmpty()) { if (!heldItem.isEmpty()) {
te.internalTank.allowInsertion(); te.internalTank.allowInsertion();
ActionResultType tryExchange = tryExchange(worldIn, player, handIn, heldItem, te); ActionResultType tryExchange = tryExchange(worldIn, player, handIn, heldItem, te);
@ -53,10 +52,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE<ItemDrainT
te.notifyUpdate(); te.notifyUpdate();
} }
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} catch (TileEntityException e) { });
}
return ActionResultType.PASS;
} }
protected ActionResultType tryExchange(World worldIn, PlayerEntity player, Hand handIn, ItemStack heldItem, protected ActionResultType tryExchange(World worldIn, PlayerEntity player, Hand handIn, ItemStack heldItem,

View File

@ -92,8 +92,7 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
BlockRayTraceResult hit) { BlockRayTraceResult hit) {
ItemStack heldItem = player.getHeldItem(handIn); ItemStack heldItem = player.getHeldItem(handIn);
try { return onTileEntityUse(worldIn, pos, te -> {
BasinTileEntity te = getTileEntity(worldIn, pos);
if (!heldItem.isEmpty()) { if (!heldItem.isEmpty()) {
if (FluidHelper.tryEmptyItemIntoTE(worldIn, player, handIn, heldItem, te)) if (FluidHelper.tryEmptyItemIntoTE(worldIn, player, handIn, heldItem, te))
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
@ -128,10 +127,8 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
worldIn.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, .2f, worldIn.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, .2f,
1f + Create.RANDOM.nextFloat()); 1f + Create.RANDOM.nextFloat());
te.onEmptied(); te.onEmptied();
} catch (TileEntityException e) {
}
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
});
} }
@Override @Override

View File

@ -102,11 +102,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) {
if (face.getAxis() != getRotationAxis(state)) if (face.getAxis() != getRotationAxis(state))
return false; return false;
try { return getTileEntityOptional(world, pos).map(BeltTileEntity::hasPulley)
return getTileEntity(world, pos).hasPulley(); .orElse(false);
} catch (TileEntityException e) {
}
return false;
} }
@Override @Override
@ -367,22 +364,18 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
return VoxelShapes.empty(); return VoxelShapes.empty();
VoxelShape shape = getShape(state, worldIn, pos, context); VoxelShape shape = getShape(state, worldIn, pos, context);
try { return getTileEntityOptional(worldIn, pos).map(te -> {
if (context.getEntity() == null) if (context.getEntity() == null)
return shape; return shape;
BeltTileEntity belt = getTileEntity(worldIn, pos); BeltTileEntity controller = te.getControllerTE();
BeltTileEntity controller = belt.getControllerTE();
if (controller == null) if (controller == null)
return shape; return shape;
if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity())) { if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity()))
return BeltShapes.getCollisionShape(state); return BeltShapes.getCollisionShape(state);
}
} catch (TileEntityException e) {
}
return shape; return shape;
}).orElse(shape);
} }
@Override @Override

View File

@ -204,20 +204,14 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
return ActionResultType.PASS; return ActionResultType.PASS;
if (world.isRemote) if (world.isRemote)
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
try {
ChuteTileEntity te = getTileEntity(world, pos); return onTileEntityUse(world, pos, te -> {
if (te == null)
return ActionResultType.PASS;
if (te.item.isEmpty()) if (te.item.isEmpty())
return ActionResultType.PASS; return ActionResultType.PASS;
player.inventory.placeItemBackInInventory(world, te.item); player.inventory.placeItemBackInInventory(world, te.item);
te.setItem(ItemStack.EMPTY); te.setItem(ItemStack.EMPTY);
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
});
} catch (TileEntityException e) {
e.printStackTrace();
}
return ActionResultType.PASS;
} }
} }

View File

@ -53,24 +53,19 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE<AnalogL
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} }
try { return onTileEntityUse(worldIn, pos, te -> {
boolean sneak = player.isSneaking(); boolean sneak = player.isSneaking();
AnalogLeverTileEntity te = getTileEntity(worldIn, pos);
te.changeState(sneak); te.changeState(sneak);
float f = .25f + ((te.state + 5) / 15f) * .5f; float f = .25f + ((te.state + 5) / 15f) * .5f;
worldIn.playSound(null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.2F, f); worldIn.playSound(null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.2F, f);
} catch (TileEntityException e) {}
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
});
} }
@Override @Override
public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) {
try { return getTileEntityOptional(blockAccess, pos).map(al -> al.state)
return getTileEntity(blockAccess, pos).state; .orElse(0);
} catch (TileEntityException e) {
return 0;
}
} }
@Override @Override
@ -86,27 +81,26 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements ITE<AnalogL
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
try { withTileEntityDo(worldIn, pos, te -> {
AnalogLeverTileEntity tileEntity = getTileEntity(worldIn, pos); if (te.state != 0 && rand.nextFloat() < 0.25F)
if (tileEntity.state != 0 && rand.nextFloat() < 0.25F)
addParticles(stateIn, worldIn, pos, 0.5F); addParticles(stateIn, worldIn, pos, 0.5F);
} catch (TileEntityException e) {} });
} }
@Override @Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
try { if (isMoving || state.getBlock() == newState.getBlock())
AnalogLeverTileEntity tileEntity = getTileEntity(worldIn, pos); return;
if (!isMoving && state.getBlock() != newState.getBlock()) { withTileEntityDo(worldIn, pos, te -> {
if (tileEntity.state != 0) if (te.state != 0)
updateNeighbors(state, worldIn, pos); updateNeighbors(state, worldIn, pos);
worldIn.removeTileEntity(pos); worldIn.removeTileEntity(pos);
} });
} catch (TileEntityException e) {}
} }
private static void addParticles(BlockState state, IWorld worldIn, BlockPos pos, float alpha) { 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(); Direction direction1 = getFacing(state).getOpposite();
double d0 = (double) pos.getX() + 0.5D + 0.1D * (double) direction.getXOffset() double d0 = (double) pos.getX() + 0.5D + 0.1D * (double) direction.getXOffset()
+ 0.2D * (double) direction1.getXOffset(); + 0.2D * (double) direction1.getXOffset();

View File

@ -42,11 +42,12 @@ public class NixieTubeBlock extends HorizontalBlock implements ITE<NixieTubeTile
@Override @Override
public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
BlockRayTraceResult ray) { BlockRayTraceResult ray) {
try {
ItemStack heldItem = player.getHeldItem(hand); ItemStack heldItem = player.getHeldItem(hand);
NixieTubeTileEntity nixie = getTileEntity(world, pos); NixieTubeTileEntity nixie = getTileEntity(world, pos);
if (nixie == null)
return ActionResultType.PASS;
if (player.isSneaking()) if (player.isSneaking())
return ActionResultType.PASS; return ActionResultType.PASS;
@ -87,9 +88,6 @@ public class NixieTubeBlock extends HorizontalBlock implements ITE<NixieTubeTile
} }
} }
} catch (TileEntityException e) {
}
return ActionResultType.PASS; return ActionResultType.PASS;
} }

View File

@ -114,12 +114,8 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE<Red
public int getWeakPower(BlockState state, IBlockReader blockAccess, BlockPos pos, Direction side) { public int getWeakPower(BlockState state, IBlockReader blockAccess, BlockPos pos, Direction side) {
if (!state.get(RECEIVER)) if (!state.get(RECEIVER))
return 0; return 0;
try { return getTileEntityOptional(blockAccess, pos).map(RedstoneLinkTileEntity::getReceivedSignal)
RedstoneLinkTileEntity tileEntity = getTileEntity(blockAccess, pos); .orElse(0);
return tileEntity.getReceivedSignal();
} catch (TileEntityException e) {
}
return 0;
} }
@Override @Override
@ -149,17 +145,15 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE<Red
public ActionResultType toggleMode(BlockState state, World worldIn, BlockPos pos) { public ActionResultType toggleMode(BlockState state, World worldIn, BlockPos pos) {
if (worldIn.isRemote) if (worldIn.isRemote)
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
try {
RedstoneLinkTileEntity te = getTileEntity(worldIn, pos); return onTileEntityUse(worldIn, pos, te -> {
Boolean wasReceiver = state.get(RECEIVER); Boolean wasReceiver = state.get(RECEIVER);
boolean blockPowered = worldIn.isBlockPowered(pos); boolean blockPowered = worldIn.isBlockPowered(pos);
worldIn.setBlockState(pos, state.cycle(RECEIVER) worldIn.setBlockState(pos, state.cycle(RECEIVER)
.with(POWERED, blockPowered), 3); .with(POWERED, blockPowered), 3);
te.transmit(wasReceiver ? 0 : getPower(worldIn, pos)); te.transmit(wasReceiver ? 0 : getPower(worldIn, pos));
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} catch (TileEntityException e) { });
}
return ActionResultType.PASS;
} }
@Override @Override

View File

@ -1,5 +1,7 @@
package com.simibubi.create.content.logistics.block.redstone; package com.simibubi.create.content.logistics.block.redstone;
import java.util.Random;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllShapes; import com.simibubi.create.AllShapes;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
@ -33,8 +35,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import java.util.Random;
public class StockpileSwitchBlock extends HorizontalBlock implements ITE<StockpileSwitchTileEntity>, IWrenchable { public class StockpileSwitchBlock extends HorizontalBlock implements ITE<StockpileSwitchTileEntity>, IWrenchable {
public static final IntegerProperty INDICATOR = IntegerProperty.create("indicator", 0, 6); public static final IntegerProperty INDICATOR = IntegerProperty.create("indicator", 0, 6);
@ -85,19 +85,14 @@ public class StockpileSwitchBlock extends HorizontalBlock implements ITE<Stockpi
public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) {
if (side == blockState.get(HORIZONTAL_FACING).getOpposite()) if (side == blockState.get(HORIZONTAL_FACING).getOpposite())
return 0; return 0;
try { return getTileEntityOptional(blockAccess, pos).filter(StockpileSwitchTileEntity::isPowered)
return getTileEntity(blockAccess, pos).isPowered() ? 15 : 0; .map($ -> 15)
} catch (TileEntityException e) { .orElse(0);
}
return 0;
} }
@Override @Override
public void scheduledTick(BlockState blockState, ServerWorld world, BlockPos pos, Random random) { public void scheduledTick(BlockState blockState, ServerWorld world, BlockPos pos, Random random) {
try { getTileEntityOptional(world, pos).ifPresent(StockpileSwitchTileEntity::updatePowerAfterDelay);
getTileEntity(world, pos).updatePowerAfterDelay();
} catch (TileEntityException e) {
}
} }
@Override @Override

View File

@ -2,102 +2,44 @@ package com.simibubi.create.foundation.block;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function;
import com.simibubi.create.Create; import javax.annotation.Nullable;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.WorldHelper;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
public interface ITE<T extends TileEntity> { public interface ITE<T extends TileEntity> {
Class<T> getTileEntityClass(); Class<T> getTileEntityClass();
default void withTileEntityDo(IBlockReader world, BlockPos pos, Consumer<T> action) { default void withTileEntityDo(IBlockReader world, BlockPos pos, Consumer<T> action) {
try { getTileEntityOptional(world, pos).ifPresent(action);
action.accept(getTileEntity(world, pos));
} catch (TileEntityException e) {
} }
default ActionResultType onTileEntityUse(IBlockReader world, BlockPos pos, Function<T, ActionResultType> action) {
return getTileEntityOptional(world, pos).map(action)
.orElse(ActionResultType.PASS);
} }
default Optional<T> getTileEntityOptional(IBlockReader world, BlockPos pos) { default Optional<T> getTileEntityOptional(IBlockReader world, BlockPos pos) {
try { return Optional.ofNullable(getTileEntity(world, pos));
return Optional.of(getTileEntity(world, pos));
} catch (TileEntityException e) {
}
return Optional.empty();
} }
@Nullable
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
default T getTileEntity(IBlockReader worldIn, BlockPos pos) throws TileEntityException { default T getTileEntity(IBlockReader worldIn, BlockPos pos) {
TileEntity tileEntity = worldIn.getTileEntity(pos); TileEntity tileEntity = worldIn.getTileEntity(pos);
Class<T> expectedClass = getTileEntityClass(); Class<T> expectedClass = getTileEntityClass();
IWorld world = null;
if (worldIn instanceof IWorld)
world = (IWorld) worldIn;
if (tileEntity == null) if (tileEntity == null)
throw new MissingTileEntityException(world, pos, expectedClass); return null;
if (!expectedClass.isInstance(tileEntity)) if (!expectedClass.isInstance(tileEntity))
throw new InvalidTileEntityException(world, pos, expectedClass, tileEntity.getClass()); return null;
return (T) tileEntity; 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);
}
} }

View File

@ -3,7 +3,6 @@ package com.simibubi.create.foundation.config;
public class CCommon extends ConfigBase { public class CCommon extends ConfigBase {
public CWorldGen worldGen = nested(0, CWorldGen::new, Comments.worldGen); public CWorldGen worldGen = nested(0, CWorldGen::new, Comments.worldGen);
public ConfigBool logTeErrors = b(false, "logTeErrors", Comments.logTeErrors);
@Override @Override
public String getName() { public String getName() {
@ -12,7 +11,6 @@ public class CCommon extends ConfigBase {
private static class Comments { private static class Comments {
static String worldGen = "Modify Create's impact on your terrain"; static String worldGen = "Modify Create's impact on your terrain";
static String logTeErrors = "Forward caught TileEntityExceptions to the log at debug level.";
} }
} }