Implemented ISneakWrench on tanks as first event driven wrenched block
This commit is contained in:
parent
b62a9ce93a
commit
4f8e7a2124
2 changed files with 37 additions and 28 deletions
|
@ -52,31 +52,6 @@ public class ItemBlockTank extends ItemBlock implements IFluidContainerItem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getWrenchedItem(World world, Vector3 vec)
|
|
||||||
{
|
|
||||||
TileEntity entity = vec.getTileEntity(world);
|
|
||||||
|
|
||||||
if (entity instanceof TileTank && ((TileTank) entity).getInternalTank() != null && ((TileTank) entity).getInternalTank().getFluid() != null)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = new ItemStack(Archaic.blockTank);
|
|
||||||
|
|
||||||
FluidStack stack = ((TileTank) entity).getInternalTank().getFluid();
|
|
||||||
|
|
||||||
if (stack != null)
|
|
||||||
{
|
|
||||||
if (itemStack.getTagCompound() == null)
|
|
||||||
{
|
|
||||||
itemStack.setTagCompound(new NBTTagCompound());
|
|
||||||
}
|
|
||||||
((TileTank) entity).drain(ForgeDirection.UNKNOWN, stack.amount, true);
|
|
||||||
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound()));
|
|
||||||
}
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemStackLimit(ItemStack stack)
|
public int getItemStackLimit(ItemStack stack)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package resonantinduction.archaic.fluid.tank;
|
package resonantinduction.archaic.fluid.tank;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
@ -14,6 +17,7 @@ import net.minecraftforge.fluids.FluidTank;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import resonant.api.IRemovable.ISneakPickup;
|
||||||
import resonant.lib.content.module.TileBlock.IComparatorInputOverride;
|
import resonant.lib.content.module.TileBlock.IComparatorInputOverride;
|
||||||
import resonant.lib.content.module.TileRender;
|
import resonant.lib.content.module.TileRender;
|
||||||
import resonant.lib.render.FluidRenderUtility;
|
import resonant.lib.render.FluidRenderUtility;
|
||||||
|
@ -32,7 +36,10 @@ import universalelectricity.api.vector.Vector3;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class TileTank extends TileFluidDistribution implements IComparatorInputOverride
|
/** Tile/Block class for basic Dynamic tanks
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
|
public class TileTank extends TileFluidDistribution implements IComparatorInputOverride, ISneakPickup
|
||||||
{
|
{
|
||||||
public static final int VOLUME = 16;
|
public static final int VOLUME = 16;
|
||||||
|
|
||||||
|
@ -55,7 +62,7 @@ public class TileTank extends TileFluidDistribution implements IComparatorInputO
|
||||||
protected boolean use(EntityPlayer player, int side, Vector3 vector3)
|
protected boolean use(EntityPlayer player, int side, Vector3 vector3)
|
||||||
{
|
{
|
||||||
if (!world().isRemote)
|
if (!world().isRemote)
|
||||||
{
|
{ /*
|
||||||
if (player.isSneaking())
|
if (player.isSneaking())
|
||||||
{
|
{
|
||||||
ItemStack dropStack = ItemBlockTank.getWrenchedItem(world(), position());
|
ItemStack dropStack = ItemBlockTank.getWrenchedItem(world(), position());
|
||||||
|
@ -72,7 +79,7 @@ public class TileTank extends TileFluidDistribution implements IComparatorInputO
|
||||||
|
|
||||||
position().setBlock(world(), 0);
|
position().setBlock(world(), 0);
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
return FluidUtility.playerActivatedFluidItem(world(), x(), y(), z(), player, side);
|
return FluidUtility.playerActivatedFluidItem(world(), x(), y(), z(), player, side);
|
||||||
}
|
}
|
||||||
|
@ -234,4 +241,31 @@ public class TileTank extends TileFluidDistribution implements IComparatorInputO
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getRemovedItems(EntityPlayer entity)
|
||||||
|
{
|
||||||
|
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
|
ItemStack itemStack = new ItemStack(Archaic.blockTank);
|
||||||
|
if (itemStack != null)
|
||||||
|
{
|
||||||
|
if (getInternalTank() != null && getInternalTank().getFluid() != null)
|
||||||
|
{
|
||||||
|
FluidStack stack = getInternalTank().getFluid();
|
||||||
|
|
||||||
|
if (stack != null)
|
||||||
|
{
|
||||||
|
if (itemStack.getTagCompound() == null)
|
||||||
|
{
|
||||||
|
itemStack.setTagCompound(new NBTTagCompound());
|
||||||
|
}
|
||||||
|
drain(ForgeDirection.UNKNOWN, stack.amount, true);
|
||||||
|
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drops.add(itemStack);
|
||||||
|
}
|
||||||
|
return drops;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue