improve wireless grids
- add wireless grid plate - add a crafting wireless grid - better recipes - add wireless transmitter
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package storagecraft.item;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -11,12 +13,13 @@ import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import storagecraft.StorageCraft;
|
||||
import storagecraft.tile.TileGrid;
|
||||
import storagecraft.tile.TileWirelessTransmitter;
|
||||
|
||||
public class ItemWirelessGrid extends ItemBase
|
||||
{
|
||||
public static final String NBT_GRID_X = "GridX";
|
||||
public static final String NBT_GRID_Y = "GridY";
|
||||
public static final String NBT_GRID_Z = "GridZ";
|
||||
public static final String NBT_WIRELESS_TRANSMITTER_X = "WirelessTransmitterX";
|
||||
public static final String NBT_WIRELESS_TRANSMITTER_Y = "WirelessTransmitterY";
|
||||
public static final String NBT_WIRELESS_TRANSMITTER_Z = "WirelessTransmitterZ";
|
||||
|
||||
private IIcon iconConnected;
|
||||
private IIcon iconDisconnected;
|
||||
@@ -26,36 +29,26 @@ public class ItemWirelessGrid extends ItemBase
|
||||
super("wirelessGrid");
|
||||
|
||||
setMaxStackSize(1);
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list)
|
||||
{
|
||||
iconConnected = register.registerIcon("storagecraft:wirelessGridConnected");
|
||||
iconDisconnected = register.registerIcon("storagecraft:wirelessGridDisconnected");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileGrid)
|
||||
{
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setInteger(NBT_GRID_X, x);
|
||||
stack.stackTagCompound.setInteger(NBT_GRID_Y, y);
|
||||
stack.stackTagCompound.setInteger(NBT_GRID_Z, z);
|
||||
|
||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("misc.storagecraft:wirelessGrid.set", x, y, z)));
|
||||
|
||||
return true;
|
||||
}
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemUseFirst(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b)
|
||||
{
|
||||
if (isValid(stack))
|
||||
{
|
||||
list.add(StatCollector.translateToLocalFormatted("misc.storagecraft:wirelessGrid.tooltip", getX(stack), getY(stack), getZ(stack)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,9 +66,27 @@ public class ItemWirelessGrid extends ItemBase
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileGrid)
|
||||
if (tile instanceof TileWirelessTransmitter)
|
||||
{
|
||||
player.openGui(StorageCraft.INSTANCE, StorageCraft.GUI.GRID, world, x, y, z);
|
||||
TileWirelessTransmitter wirelessTransmitter = (TileWirelessTransmitter) tile;
|
||||
|
||||
if (wirelessTransmitter.isWorking())
|
||||
{
|
||||
TileGrid grid = wirelessTransmitter.getGrid(stack.getItemDamage());
|
||||
|
||||
if (grid == null)
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("misc.storagecraft:wirelessGrid.noGrid." + stack.getItemDamage())));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.openGui(StorageCraft.INSTANCE, StorageCraft.GUI.GRID, world, grid.xCoord, grid.yCoord, grid.zCoord);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("misc.storagecraft:wirelessGrid.notWorking")));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -89,26 +100,31 @@ public class ItemWirelessGrid extends ItemBase
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("misc.storagecraft:wirelessGrid.notSet")));
|
||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("misc.storagecraft:wirelessGrid.notSet." + stack.getItemDamage())));
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public boolean isCrafting(ItemStack stack)
|
||||
{
|
||||
return stack.getItemDamage() == 1;
|
||||
}
|
||||
|
||||
public int getX(ItemStack stack)
|
||||
{
|
||||
return stack.stackTagCompound.getInteger(NBT_GRID_X);
|
||||
return stack.stackTagCompound.getInteger(NBT_WIRELESS_TRANSMITTER_X);
|
||||
}
|
||||
|
||||
public int getY(ItemStack stack)
|
||||
{
|
||||
return stack.stackTagCompound.getInteger(NBT_GRID_Y);
|
||||
return stack.stackTagCompound.getInteger(NBT_WIRELESS_TRANSMITTER_Y);
|
||||
}
|
||||
|
||||
public int getZ(ItemStack stack)
|
||||
{
|
||||
return stack.stackTagCompound.getInteger(NBT_GRID_Z);
|
||||
return stack.stackTagCompound.getInteger(NBT_WIRELESS_TRANSMITTER_Z);
|
||||
}
|
||||
|
||||
public boolean isInRange(ItemStack stack, EntityPlayer player)
|
||||
@@ -118,7 +134,14 @@ public class ItemWirelessGrid extends ItemBase
|
||||
|
||||
public boolean isValid(ItemStack stack)
|
||||
{
|
||||
return stack.stackTagCompound != null && stack.stackTagCompound.hasKey(NBT_GRID_X) && stack.stackTagCompound.hasKey(NBT_GRID_Y) && stack.stackTagCompound.hasKey(NBT_GRID_Z);
|
||||
return stack.stackTagCompound != null && stack.stackTagCompound.hasKey(NBT_WIRELESS_TRANSMITTER_X) && stack.stackTagCompound.hasKey(NBT_WIRELESS_TRANSMITTER_Y) && stack.stackTagCompound.hasKey(NBT_WIRELESS_TRANSMITTER_Z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register)
|
||||
{
|
||||
iconConnected = register.registerIcon("storagecraft:wirelessGridConnected");
|
||||
iconDisconnected = register.registerIcon("storagecraft:wirelessGridDisconnected");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user