mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
parent
e745ebdc28
commit
ded8ceb529
6 changed files with 20 additions and 11 deletions
|
@ -56,7 +56,7 @@ public class BlockCanolaPress extends BlockContainerBase{
|
|||
if(!world.isRemote){
|
||||
TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(pos);
|
||||
if(press != null){
|
||||
if(this.checkFailUseItemOnTank(player, player.getHeldItem(hand), press.tank)){
|
||||
if(!this.tryUseItemOnTank(player, hand, press.tank)){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class BlockCoffeeMachine extends BlockContainerBase{
|
|||
if(!world.isRemote){
|
||||
TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine)world.getTileEntity(pos);
|
||||
if(machine != null){
|
||||
if(this.checkFailUseItemOnTank(player, player.getHeldItem(hand), machine.tank)){
|
||||
if(!this.tryUseItemOnTank(player, hand, machine.tank)){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,11 +59,10 @@ public class BlockFermentingBarrel extends BlockContainerBase{
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
if(!world.isRemote){
|
||||
TileEntityFermentingBarrel press = (TileEntityFermentingBarrel)world.getTileEntity(pos);
|
||||
if(press != null){
|
||||
if(this.checkFailUseItemOnTank(player, heldItem, press.canolaTank) && this.checkFailUseItemOnTank(player, heldItem, press.oilTank)){
|
||||
if(!this.tryUseItemOnTank(player, hand, press.canolaTank) && !this.tryUseItemOnTank(player, hand, press.oilTank)){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FERMENTING_BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,14 +56,13 @@ public class BlockFluidCollector extends BlockContainerBase{
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if(this.tryToggleRedstone(world, pos, player)){
|
||||
return true;
|
||||
}
|
||||
if(!world.isRemote){
|
||||
TileEntityFluidCollector collector = (TileEntityFluidCollector)world.getTileEntity(pos);
|
||||
if(collector != null){
|
||||
if(this.checkFailUseItemOnTank(player, stack, collector.tank)){
|
||||
if(!this.tryUseItemOnTank(player, hand, collector.tank)){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FLUID_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,12 +77,11 @@ public class BlockOilGenerator extends BlockContainerBase{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ItemStack stack = player.getHeldItem(hand);
|
||||
if(!world.isRemote){
|
||||
TileEntityOilGenerator generator = (TileEntityOilGenerator)world.getTileEntity(pos);
|
||||
if(generator != null){
|
||||
if(this.checkFailUseItemOnTank(player, stack, generator.tank)){
|
||||
if(!this.tryUseItemOnTank(player, hand, generator.tank)){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.OIL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -191,8 +193,18 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean checkFailUseItemOnTank(EntityPlayer player, ItemStack heldItem, FluidTank tank){
|
||||
return !StackUtil.isValid(heldItem) || !FluidUtil.interactWithFluidHandler(heldItem, tank, player).isSuccess();
|
||||
protected boolean tryUseItemOnTank(EntityPlayer player, EnumHand hand, FluidTank tank){
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
|
||||
if(StackUtil.isValid(heldItem)){
|
||||
FluidActionResult result = FluidUtil.interactWithFluidHandler(heldItem, tank, player);
|
||||
if(result.isSuccess()){
|
||||
player.setHeldItem(hand, result.getResult());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue