mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
parent
91dc0f4ce1
commit
91170ea432
2 changed files with 15 additions and 10 deletions
|
@ -65,11 +65,12 @@ public class TileEntityDropper extends TileEntityInventoryBase{
|
|||
}
|
||||
|
||||
private void doWork(){
|
||||
if(StackUtil.isValid(this.removeFromInventory(false))){
|
||||
ItemStack stack = this.removeFromInventory(true);
|
||||
stack = StackUtil.setStackSize(stack, 1);
|
||||
ItemStack theoreticalRemove = this.removeFromInventory(false);
|
||||
if(StackUtil.isValid(theoreticalRemove)){
|
||||
IBlockState state = this.world.getBlockState(this.pos);
|
||||
WorldUtil.dropItemAtSide(WorldUtil.getDirectionByPistonRotation(state.getBlock().getMetaFromState(state)), this.world, this.pos, stack);
|
||||
if(WorldUtil.dropItemAtSide(WorldUtil.getDirectionByPistonRotation(state.getBlock().getMetaFromState(state)), this.world, this.pos, StackUtil.setStackSize(theoreticalRemove.copy(), 1))){
|
||||
this.removeFromInventory(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -181,13 +181,17 @@ public final class WorldUtil{
|
|||
return stack;
|
||||
}
|
||||
|
||||
public static void dropItemAtSide(EnumFacing side, World world, BlockPos pos, ItemStack stack){
|
||||
public static boolean dropItemAtSide(EnumFacing side, World world, BlockPos pos, ItemStack stack){
|
||||
BlockPos coords = pos.offset(side);
|
||||
if(world.isBlockLoaded(coords)){
|
||||
EntityItem item = new EntityItem(world, coords.getX()+0.5, coords.getY()+0.5, coords.getZ()+0.5, stack);
|
||||
item.motionX = 0;
|
||||
item.motionY = 0;
|
||||
item.motionZ = 0;
|
||||
world.spawnEntity(item);
|
||||
|
||||
return world.spawnEntity(item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static EnumFacing getDirectionBySidesInOrder(int side){
|
||||
|
|
Loading…
Reference in a new issue