Added to tools set
This commit is contained in:
parent
cec261a273
commit
794600d71f
2 changed files with 116 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
package dark.api;
|
||||
|
||||
import dark.api.IToolReadOut.EnumTools;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
|
@ -17,5 +18,14 @@ public interface IToolReadOut
|
|||
{
|
||||
PIPE_GUAGE(),
|
||||
MULTI_METER();
|
||||
|
||||
public static EnumTools get(int meta)
|
||||
{
|
||||
if (meta < EnumTools.values().length)
|
||||
{
|
||||
return EnumTools.values()[meta];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
105
src/dark/core/items/ItemTools.java
Normal file
105
src/dark/core/items/ItemTools.java
Normal file
|
@ -0,0 +1,105 @@
|
|||
package dark.core.items;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import dark.api.IToolReadOut;
|
||||
import dark.api.IToolReadOut.EnumTools;
|
||||
import dark.core.helpers.FluidHelper;
|
||||
|
||||
public class ItemTools extends ItemBasic
|
||||
{
|
||||
public ItemTools(int id, Configuration config)
|
||||
{
|
||||
super(id, "lmTool", config);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
this.setCreativeTab(CreativeTabs.tabTools);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
int meta = itemStack.getItemDamage();
|
||||
if (meta == 0)
|
||||
{
|
||||
return "item." + "PipeGauge";
|
||||
}
|
||||
else if (meta == 1)
|
||||
{
|
||||
return "item." + "MultiMeter";
|
||||
}
|
||||
return "item." + this.getUnlocalizedName() + "." + meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(this, 1, 0));
|
||||
par3List.add(new ItemStack(this, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
EnumTools tool = EnumTools.get(itemStack.getItemDamage());
|
||||
|
||||
if (tool != null)
|
||||
{
|
||||
if (tileEntity instanceof IToolReadOut)
|
||||
{
|
||||
String output = ((IToolReadOut) tileEntity).getMeterReading(player, ForgeDirection.getOrientation(side), EnumTools.PIPE_GUAGE);
|
||||
if (output != null && !output.isEmpty())
|
||||
{
|
||||
if (output.length() > 100)
|
||||
{
|
||||
output = output.substring(0, 100);
|
||||
}
|
||||
output.trim();
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d("ReadOut> " + output));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (tool == EnumTools.PIPE_GUAGE)
|
||||
{
|
||||
if (tileEntity instanceof IFluidHandler)
|
||||
{
|
||||
FluidTankInfo[] tanks = ((IFluidHandler) tileEntity).getTankInfo(ForgeDirection.getOrientation(side));
|
||||
if (tanks != null)
|
||||
{
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d("FluidHandler> Side:"+ForgeDirection.getOrientation(side).toString()+" Tanks:" + tanks.length));
|
||||
for (FluidStack stack : FluidHelper.getFluidList(tanks))
|
||||
{
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d("Fluid>" + stack.amount + "mb of " + stack.getFluid().getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tool == EnumTools.MULTI_METER)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue