diff --git a/src/main/java/me/planetguy/remaininmotion/core/interop/ModInteraction.java b/src/main/java/me/planetguy/remaininmotion/core/interop/ModInteraction.java index 0067c63..fac00a7 100644 --- a/src/main/java/me/planetguy/remaininmotion/core/interop/ModInteraction.java +++ b/src/main/java/me/planetguy/remaininmotion/core/interop/ModInteraction.java @@ -17,6 +17,7 @@ import me.planetguy.remaininmotion.core.interop.mod.ChickenChunks; import me.planetguy.remaininmotion.core.interop.mod.EnderIO; import me.planetguy.remaininmotion.core.interop.mod.ForgeMultipart; +import me.planetguy.remaininmotion.core.interop.mod.ImmersiveEngineering; import me.planetguy.remaininmotion.core.interop.mod.QmunityMultipart; import me.planetguy.remaininmotion.drive.TileEntityCarriageController; import me.planetguy.remaininmotion.util.general.Computers; @@ -61,6 +62,10 @@ public static void Establish() { EventManager.registerEventHandler(new CarpentersBlocks()); } + if(true) { //for debugging - I've had to change IE's modID Loader.isModLoaded("ImmersiveEngineering")) { + EventManager.registerEventHandler(new ImmersiveEngineering()); + } + Wrenches.init(); Computers.setup(); diff --git a/src/main/java/me/planetguy/remaininmotion/core/interop/mod/ImmersiveEngineering.java b/src/main/java/me/planetguy/remaininmotion/core/interop/mod/ImmersiveEngineering.java new file mode 100644 index 0000000..4e9dce9 --- /dev/null +++ b/src/main/java/me/planetguy/remaininmotion/core/interop/mod/ImmersiveEngineering.java @@ -0,0 +1,92 @@ +package me.planetguy.remaininmotion.core.interop.mod; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ChunkCoordinates; +import blusunrize.immersiveengineering.api.energy.IImmersiveConnectable; +import blusunrize.immersiveengineering.api.energy.ImmersiveNetHandler; +import blusunrize.immersiveengineering.api.energy.WireType; +import blusunrize.immersiveengineering.api.energy.ImmersiveNetHandler.Connection; +import blusunrize.immersiveengineering.common.blocks.metal.TileEntityConnectorLV; +import blusunrize.immersiveengineering.common.util.Utils; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import me.planetguy.remaininmotion.api.event.BlockPreMoveEvent; +import me.planetguy.remaininmotion.api.event.TEPostPlaceEvent; +import me.planetguy.remaininmotion.util.position.BlockRecord; + +public class ImmersiveEngineering { + + @SubscribeEvent + public void onBlockPreMoveEvent(BlockPreMoveEvent e) { + if(e.location.entity() instanceof IImmersiveConnectable) { + ChunkCoordinates teLoc=Utils.toCC(e.location.entity()); + NBTTagList ls=new NBTTagList(); + e.location.entityTag().setTag("RemIM_links", ls); + for(Connection c:ImmersiveNetHandler.INSTANCE + .getConnections( + e.location.entity().getWorldObj(), + teLoc)) { + NBTTagCompound t=new NBTTagCompound(); + ls.appendTag(t); + t.setString("wire", c.cableType.getUniqueName()); + t.setDouble("distance", c.length); + if(c.start.equals(teLoc)) { + //relative to TE + if(e.blocks.contains(new BlockRecord(c.end.posX, c.end.posY, c.end.posZ))) { + t.setBoolean("absolute", false); + t.setInteger("x", c.end.posX-teLoc.posX); + t.setInteger("y", c.end.posY-teLoc.posY); + t.setInteger("z", c.end.posZ-teLoc.posZ); + } else { + t.setBoolean("absolute", true); + t.setInteger("x", c.end.posX); + t.setInteger("y", c.end.posY); + t.setInteger("z", c.end.posZ); + } + } else if(c.end.equals(teLoc)) { + if(e.blocks.contains(new BlockRecord(c.start.posX, c.start.posY, c.start.posZ))) { + t.setBoolean("absolute", false); + t.setInteger("x", c.start.posX-teLoc.posX); + t.setInteger("y", c.start.posY-teLoc.posY); + t.setInteger("z", c.start.posZ-teLoc.posZ); + } else { + t.setBoolean("absolute", true); + t.setInteger("x", c.start.posX); + t.setInteger("y", c.start.posY); + t.setInteger("z", c.start.posZ); + } + } + } + } + } + + @SubscribeEvent + public void onTEPostPlaceEvent(TEPostPlaceEvent e) { + if(e.location.entity() instanceof IImmersiveConnectable) { + ChunkCoordinates teLoc=Utils.toCC(e.location.entity()); + NBTTagList tag=e.location.entityTag().getTagList("RemIM_links", 10); + for(int i=0; i