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(){
|
private void doWork(){
|
||||||
if(StackUtil.isValid(this.removeFromInventory(false))){
|
ItemStack theoreticalRemove = this.removeFromInventory(false);
|
||||||
ItemStack stack = this.removeFromInventory(true);
|
if(StackUtil.isValid(theoreticalRemove)){
|
||||||
stack = StackUtil.setStackSize(stack, 1);
|
|
||||||
IBlockState state = this.world.getBlockState(this.pos);
|
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;
|
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);
|
BlockPos coords = pos.offset(side);
|
||||||
EntityItem item = new EntityItem(world, coords.getX()+0.5, coords.getY()+0.5, coords.getZ()+0.5, stack);
|
if(world.isBlockLoaded(coords)){
|
||||||
item.motionX = 0;
|
EntityItem item = new EntityItem(world, coords.getX()+0.5, coords.getY()+0.5, coords.getZ()+0.5, stack);
|
||||||
item.motionY = 0;
|
item.motionX = 0;
|
||||||
item.motionZ = 0;
|
item.motionY = 0;
|
||||||
world.spawnEntity(item);
|
item.motionZ = 0;
|
||||||
|
|
||||||
|
return world.spawnEntity(item);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnumFacing getDirectionBySidesInOrder(int side){
|
public static EnumFacing getDirectionBySidesInOrder(int side){
|
||||||
|
|
Loading…
Reference in a new issue