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); BlockState neighbourState = worldIn.getBlockState(neighbourPos);
if (!(neighbourState.getBlock() instanceof IRotate)) if (!(neighbourState.getBlock() instanceof IRotate))
continue; continue;
TileEntity tileEntity = worldIn.getTileEntity(neighbourPos);
if (!(tileEntity instanceof KineticTileEntity))
continue;
final KineticTileEntity neighbourTE = (KineticTileEntity) worldIn.getTileEntity(neighbourPos); final KineticTileEntity neighbourTE = (KineticTileEntity) tileEntity;
if (!neighbourTE.hasSource() || !neighbourTE.source.equals(pos)) if (!neighbourTE.hasSource() || !neighbourTE.source.equals(pos))
continue; continue;

View File

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

View File

@ -97,7 +97,12 @@ public class SawBlock extends DirectionalAxisKineticBlock implements IWithTileEn
super.onLanded(worldIn, entityIn); super.onLanded(worldIn, entityIn);
if (!(entityIn instanceof ItemEntity)) if (!(entityIn instanceof ItemEntity))
return; 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); te.insertItem((ItemEntity) entityIn);
}); });
} }