Tanks can be picked up with fluid inside
This commit is contained in:
parent
f6a42dd58a
commit
1394b4fccf
3 changed files with 96 additions and 1 deletions
|
@ -11,7 +11,7 @@ tile.ReleaseValve.0.name=Release Valve
|
|||
tile.FluidTank.name = Tank
|
||||
tile.FluidSink.name = Sink
|
||||
|
||||
# Fluid pipes now have more than 32 sub types, currently there are only 160 sub types of pipe
|
||||
# Fluid pipes
|
||||
tile.FluidPipe.0.name =Wood Trough
|
||||
tile.FluidPipe.1.name =Black Wood Trough
|
||||
tile.FluidPipe.2.name =Red Wood Trough
|
||||
|
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -17,10 +19,13 @@ import com.builtbroken.common.Pair;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.helpers.ItemWorldHelper;
|
||||
import dark.core.prefab.fluids.FluidHelper;
|
||||
import dark.fluid.client.render.BlockRenderHelper;
|
||||
import dark.fluid.common.FluidPartsMaterial;
|
||||
import dark.fluid.common.pipes.ItemBlockPipe;
|
||||
import dark.fluid.common.pipes.TileEntityPipe;
|
||||
import dark.machines.machines.ItemBlockEnergyStorage;
|
||||
|
||||
public class BlockTank extends BlockFM
|
||||
{
|
||||
|
@ -110,6 +115,28 @@ public class BlockTank extends BlockFM
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
ItemStack dropStack = ItemBlockPipe.getWrenchedItem(world, new Vector3(x, y, z));
|
||||
if (dropStack != null)
|
||||
{
|
||||
if (entityPlayer.getHeldItem() == null)
|
||||
{
|
||||
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, dropStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemWorldHelper.dropItemStack(world, new Vector3(x, y, z), dropStack, false);
|
||||
}
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtraConfigs(Configuration config)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,23 @@
|
|||
package dark.fluid.common.pipes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import dark.fluid.common.FMRecipeLoader;
|
||||
import dark.fluid.common.FluidPartsMaterial;
|
||||
import dark.fluid.common.machines.TileEntityTank;
|
||||
import dark.fluid.common.prefab.TileEntityFluidNetworkTile;
|
||||
|
||||
public class ItemBlockPipe extends ItemBlock
|
||||
|
@ -25,6 +36,63 @@ public class ItemBlockPipe extends ItemBlock
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
|
||||
{
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("fluid"));
|
||||
if (fluid != null)
|
||||
{
|
||||
list.add("Fluid: " + fluid.getFluid().getName());
|
||||
list.add("Vol: " + fluid.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getWrenchedItem(World world, Vector3 vec)
|
||||
{
|
||||
TileEntity entity = vec.getTileEntity(world);
|
||||
if (entity instanceof TileEntityTank)
|
||||
{
|
||||
ItemStack itemStack = new ItemStack(FMRecipeLoader.blockTank);
|
||||
FluidStack stack = ((TileEntityTank) entity).drain(ForgeDirection.UNKNOWN, Integer.MAX_VALUE, false);
|
||||
if (itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
if (stack != null)
|
||||
{
|
||||
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack itemStack, World par2World, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
|
||||
if (itemStack.getTagCompound() != null && !player.capabilities.isCreativeMode && itemStack.getTagCompound().hasKey("fluid"))
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemStackLimit(ItemStack stack)
|
||||
{
|
||||
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return this.getItemStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue