More generic chest detection

- Possibly enabled the use of modded chest blocks for portable inventories
- More safety checks
This commit is contained in:
simibubi 2020-03-28 19:03:18 +01:00
parent e891aeb8c1
commit 1da43f8ffc
3 changed files with 15 additions and 5 deletions

View file

@ -298,8 +298,11 @@ public class RotationPropagator {
BlockState neighbourState = worldIn.getBlockState(neighbourPos);
if (!(neighbourState.getBlock() instanceof IRotate))
continue;
final KineticTileEntity neighbourTE = (KineticTileEntity) worldIn.getTileEntity(neighbourPos);
TileEntity tileEntity = worldIn.getTileEntity(neighbourPos);
if (!(tileEntity instanceof KineticTileEntity))
continue;
final KineticTileEntity neighbourTE = (KineticTileEntity) tileEntity;
if (!neighbourTE.hasSource() || !neighbourTE.source.equals(pos))
continue;

View file

@ -7,6 +7,8 @@ import net.minecraft.block.ChestBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.ChestType;
import net.minecraft.tileentity.BarrelTileEntity;
import net.minecraft.tileentity.ChestTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.items.CapabilityItemHandler;
@ -105,9 +107,9 @@ public class MountedStorage {
TileEntityType<?> type = te.getType();
if (type == AllTileEntities.FLEXCRATE.type)
return true;
if (type == TileEntityType.BARREL)
if (te instanceof ChestTileEntity)
return true;
if (type == TileEntityType.CHEST || type == TileEntityType.TRAPPED_CHEST)
if (te instanceof BarrelTileEntity)
return true;
return false;
}

View file

@ -97,7 +97,12 @@ public class SawBlock extends DirectionalAxisKineticBlock implements IWithTileEn
super.onLanded(worldIn, entityIn);
if (!(entityIn instanceof ItemEntity))
return;
withTileEntityDo(entityIn.world, entityIn.getPosition(), te -> {
BlockPos pos = entityIn.getPosition();
if (!(worldIn.getTileEntity(pos) instanceof SawTileEntity))
return;
if (entityIn.world.isRemote)
return;
withTileEntityDo(entityIn.world, pos, te -> {
te.insertItem((ItemEntity) entityIn);
});
}