diff --git a/Calclavia-Core b/Calclavia-Core index 0f31f415..051bbef2 160000 --- a/Calclavia-Core +++ b/Calclavia-Core @@ -1 +1 @@ -Subproject commit 0f31f415f1203883a1e4bed6570646b51ff5143d +Subproject commit 051bbef264186f28303b43eb7f71e523e56d72cc diff --git a/Universal-Electricity b/Universal-Electricity index a33b93b4..c0d32e25 160000 --- a/Universal-Electricity +++ b/Universal-Electricity @@ -1 +1 @@ -Subproject commit a33b93b4b5aa5a7049b3f4daa4a9c9650298d00b +Subproject commit c0d32e2507b3e5efc74dfede53e6c15743fa286e diff --git a/src/main/java/resonantinduction/levitator/BlockEMContractor.java b/src/main/java/resonantinduction/levitator/BlockEMContractor.java index 1cccc145..b8235b73 100644 --- a/src/main/java/resonantinduction/levitator/BlockEMContractor.java +++ b/src/main/java/resonantinduction/levitator/BlockEMContractor.java @@ -1,5 +1,6 @@ package resonantinduction.levitator; +import calclavia.lib.prefab.item.ItemCoordLink; import net.minecraft.block.ITileEntityProvider; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; diff --git a/src/main/java/resonantinduction/levitator/ItemCoordLink.java b/src/main/java/resonantinduction/levitator/ItemCoordLink.java deleted file mode 100644 index 60a9288d..00000000 --- a/src/main/java/resonantinduction/levitator/ItemCoordLink.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * - */ -package resonantinduction.levitator; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import resonantinduction.base.ItemBase; -import universalelectricity.api.vector.Vector3; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * @author Calclavia - * - */ -public abstract class ItemCoordLink extends ItemBase -{ - public ItemCoordLink(String name, int id) - { - super(name, id); - this.setMaxStackSize(1); - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - super.addInformation(itemstack, entityplayer, list, flag); - - if (hasLink(itemstack)) - { - Vector3 vec = getLink(itemstack); - int dimID = getLinkDim(itemstack); - - list.add("Bound to [" + (int) vec.x + ", " + (int) vec.y + ", " + (int) vec.z + "], dimension '" + dimID + "'"); - } - else - { - list.add("No block bound"); - } - } - - public boolean hasLink(ItemStack itemStack) - { - return getLink(itemStack) != null; - } - - public Vector3 getLink(ItemStack itemStack) - { - if (itemStack.stackTagCompound == null || !itemStack.getTagCompound().hasKey("position")) - { - return null; - } - return new Vector3(itemStack.getTagCompound().getCompoundTag("position")); - } - - public void setLink(ItemStack itemStack, Vector3 vec, int dimID) - { - if (itemStack.getTagCompound() == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } - - itemStack.getTagCompound().setCompoundTag("position", vec.writeToNBT(new NBTTagCompound())); - - itemStack.stackTagCompound.setInteger("dimID", dimID); - } - - public int getLinkDim(ItemStack itemStack) - { - if (itemStack.stackTagCompound == null) - { - return 0; - } - - return itemStack.stackTagCompound.getInteger("dimID"); - } - - public void clearLink(ItemStack itemStack) - { - itemStack.getTagCompound().removeTag("position"); - itemStack.getTagCompound().removeTag("dimID"); - } -} diff --git a/src/main/java/resonantinduction/levitator/ItemLinker.java b/src/main/java/resonantinduction/levitator/ItemLinker.java index b8851464..edf3e00a 100644 --- a/src/main/java/resonantinduction/levitator/ItemLinker.java +++ b/src/main/java/resonantinduction/levitator/ItemLinker.java @@ -6,7 +6,10 @@ package resonantinduction.levitator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import universalelectricity.api.vector.Vector3; +import resonantinduction.ResonantInduction; +import resonantinduction.TabRI; +import universalelectricity.api.vector.VectorWorld; +import calclavia.lib.prefab.item.ItemCoordLink; /** * @author Calclavia @@ -16,7 +19,7 @@ public class ItemLinker extends ItemCoordLink { public ItemLinker(int id) { - super("linker", id); + super(id, "linker", ResonantInduction.CONFIGURATION, ResonantInduction.PREFIX, TabRI.INSTANCE); } @Override @@ -24,9 +27,8 @@ public class ItemLinker extends ItemCoordLink { if (!world.isRemote) { - int dimID = world.provider.dimensionId; - player.addChatMessage("Set link to block [" + x + ", " + y + ", " + z + "], dimension '" + dimID + "'"); - this.setLink(stack, new Vector3(x, y, z), dimID); + player.addChatMessage("Set link to block [" + x + ", " + y + ", " + z + "], Dimension: '" + world.getWorldInfo().getWorldName() + "'"); + this.setLink(stack, new VectorWorld(world, x, y, z)); } return true; diff --git a/src/main/java/resonantinduction/tesla/BlockTesla.java b/src/main/java/resonantinduction/tesla/BlockTesla.java index 056d5e93..169d33e7 100644 --- a/src/main/java/resonantinduction/tesla/BlockTesla.java +++ b/src/main/java/resonantinduction/tesla/BlockTesla.java @@ -3,6 +3,7 @@ */ package resonantinduction.tesla; +import calclavia.lib.prefab.item.ItemCoordLink; import net.minecraft.block.ITileEntityProvider; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -11,9 +12,9 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import resonantinduction.ResonantInduction; import resonantinduction.base.BlockBase; -import resonantinduction.levitator.ItemCoordLink; import resonantinduction.render.BlockRenderingHandler; import universalelectricity.api.vector.Vector3; +import universalelectricity.api.vector.VectorWorld; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -77,18 +78,17 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider if (tileEntity.linked == null) { ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem()); - Vector3 linkVec = link.getLink(entityPlayer.getCurrentEquippedItem()); + VectorWorld linkVec = link.getLink(entityPlayer.getCurrentEquippedItem()); if (linkVec != null) { if (!world.isRemote) { - int dimID = link.getLinkDim(entityPlayer.getCurrentEquippedItem()); - World otherWorld = MinecraftServer.getServer().worldServerForDimension(dimID); + World otherWorld = linkVec.world; if (linkVec.getTileEntity(otherWorld) instanceof TileTesla) { - tileEntity.setLink(new Vector3(((TileTesla) linkVec.getTileEntity(otherWorld)).getTopTelsa()), dimID, true); + tileEntity.setLink(new Vector3(((TileTesla) linkVec.getTileEntity(otherWorld)).getTopTelsa()), linkVec.world.provider.dimensionId, true); entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkVec.x + ", " + (int) linkVec.y + ", " + (int) linkVec.z + "]");