mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-25 22:46:26 +01:00
More generic chest detection
- Possibly enabled the use of modded chest blocks for portable inventories - More safety checks
This commit is contained in:
parent
e891aeb8c1
commit
1da43f8ffc
3 changed files with 15 additions and 5 deletions
|
@ -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);
|
||||||
final KineticTileEntity neighbourTE = (KineticTileEntity) worldIn.getTileEntity(neighbourPos);
|
if (!(tileEntity instanceof KineticTileEntity))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
final KineticTileEntity neighbourTE = (KineticTileEntity) tileEntity;
|
||||||
if (!neighbourTE.hasSource() || !neighbourTE.source.equals(pos))
|
if (!neighbourTE.hasSource() || !neighbourTE.source.equals(pos))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue