Merge branch 'master' of https://github.com/calclavia/Resonant-Induction
This commit is contained in:
commit
c95031de2e
6 changed files with 86 additions and 19 deletions
|
@ -54,6 +54,11 @@ public class Vector3
|
||||||
this(entity.posX, entity.posY, entity.posZ);
|
this(entity.posX, entity.posY, entity.posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3(ForgeDirection direction)
|
||||||
|
{
|
||||||
|
this(direction.offsetX, direction.offsetY, direction.offsetZ);
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3 scale(double amount)
|
public Vector3 scale(double amount)
|
||||||
{
|
{
|
||||||
return this.scale(new Vector3(amount));
|
return this.scale(new Vector3(amount));
|
||||||
|
|
|
@ -57,12 +57,15 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider
|
||||||
{
|
{
|
||||||
if (linkVec.getTileEntity(world) instanceof TileEntityEMContractor)
|
if (linkVec.getTileEntity(world) instanceof TileEntityEMContractor)
|
||||||
{
|
{
|
||||||
contractor.setLink((TileEntityEMContractor) linkVec.getTileEntity(world));
|
contractor.setLink((TileEntityEMContractor) linkVec.getTileEntity(world), true);
|
||||||
|
|
||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
{
|
{
|
||||||
entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkVec.x + ", " + (int) linkVec.y + ", " + (int) linkVec.z + "]");
|
entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkVec.x + ", " + (int) linkVec.y + ", " + (int) linkVec.z + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
link.clearLink(entityPlayer.getCurrentEquippedItem());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,12 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
|
|
||||||
private ForgeDirection facing = ForgeDirection.UP;
|
private ForgeDirection facing = ForgeDirection.UP;
|
||||||
|
|
||||||
public int pushDelay;
|
private int pushDelay;
|
||||||
|
|
||||||
public float energyStored;
|
private float energyStored;
|
||||||
|
|
||||||
public AxisAlignedBB operationBounds;
|
private AxisAlignedBB operationBounds;
|
||||||
public AxisAlignedBB suckBounds;
|
private AxisAlignedBB suckBounds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* true = suck, false = push
|
* true = suck, false = push
|
||||||
|
@ -53,10 +53,11 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
|
|
||||||
private PathfinderEMContractor pathfinder;
|
private PathfinderEMContractor pathfinder;
|
||||||
private Set<EntityItem> pathfindingTrackers = new HashSet<EntityItem>();
|
private Set<EntityItem> pathfindingTrackers = new HashSet<EntityItem>();
|
||||||
public TileEntityEMContractor linked;
|
private TileEntityEMContractor linked;
|
||||||
|
|
||||||
/** Color of beam */
|
/** Color of beam */
|
||||||
private int dyeID = 13;
|
private int dyeID = 13;
|
||||||
|
private Vector3 tempLinkVector;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
|
@ -65,6 +66,17 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
|
|
||||||
this.pushDelay = Math.max(0, this.pushDelay - 1);
|
this.pushDelay = Math.max(0, this.pushDelay - 1);
|
||||||
|
|
||||||
|
if (this.tempLinkVector != null)
|
||||||
|
{
|
||||||
|
if (this.tempLinkVector.getTileEntity(this.worldObj) instanceof TileEntityEMContractor)
|
||||||
|
{
|
||||||
|
this.setLink((TileEntityEMContractor) this.tempLinkVector.getTileEntity(this.worldObj), true);
|
||||||
|
System.out.println("TEST" + this.linked);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tempLinkVector = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (canFunction())
|
if (canFunction())
|
||||||
{
|
{
|
||||||
TileEntity inventoryTile = getLatched();
|
TileEntity inventoryTile = getLatched();
|
||||||
|
@ -156,7 +168,7 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem), TileEntityTesla.dyeColors[dyeID]);
|
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem), TileEntityTesla.dyeColors[dyeID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.moveEntity(entityItem, this.getFacing(), new Vector3(this));
|
this.moveEntity(entityItem, this.getDirection(), new Vector3(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -376,7 +388,7 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
setFacing(ForgeDirection.getOrientation(newOrdinal));
|
setFacing(ForgeDirection.getOrientation(newOrdinal));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForgeDirection getFacing()
|
public ForgeDirection getDirection()
|
||||||
{
|
{
|
||||||
return facing;
|
return facing;
|
||||||
}
|
}
|
||||||
|
@ -407,7 +419,7 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
this.suck = nbt.getBoolean("suck");
|
this.suck = nbt.getBoolean("suck");
|
||||||
this.energyStored = nbt.getFloat("energyStored");
|
this.energyStored = nbt.getFloat("energyStored");
|
||||||
this.dyeID = nbt.getInteger("dyeID");
|
this.dyeID = nbt.getInteger("dyeID");
|
||||||
|
this.tempLinkVector = new Vector3(nbt.getInteger("link_x"), nbt.getInteger("link_y"), nbt.getInteger("link_z"));
|
||||||
updateBounds();
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,6 +432,13 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
nbt.setBoolean("suck", suck);
|
nbt.setBoolean("suck", suck);
|
||||||
nbt.setFloat("energyStored", energyStored);
|
nbt.setFloat("energyStored", energyStored);
|
||||||
nbt.setInteger("dyeID", this.dyeID);
|
nbt.setInteger("dyeID", this.dyeID);
|
||||||
|
|
||||||
|
if (this.linked != null)
|
||||||
|
{
|
||||||
|
nbt.setInteger("link_x", this.linked.xCoord);
|
||||||
|
nbt.setInteger("link_y", this.linked.yCoord);
|
||||||
|
nbt.setInteger("link_z", this.linked.zCoord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -432,7 +451,12 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
energyStored = input.readFloat();
|
energyStored = input.readFloat();
|
||||||
this.dyeID = input.readInt();
|
this.dyeID = input.readInt();
|
||||||
|
|
||||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
if (input.readBoolean())
|
||||||
|
{
|
||||||
|
this.tempLinkVector = new Vector3(input.readInt(), input.readInt(), input.readInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||||
updateBounds();
|
updateBounds();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -448,6 +472,18 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
data.add(energyStored);
|
data.add(energyStored);
|
||||||
data.add(this.dyeID);
|
data.add(this.dyeID);
|
||||||
|
|
||||||
|
if (this.linked != null)
|
||||||
|
{
|
||||||
|
data.add(true);
|
||||||
|
data.add(this.linked.xCoord);
|
||||||
|
data.add(this.linked.yCoord);
|
||||||
|
data.add(this.linked.zCoord);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.add(false);
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,10 +509,20 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
/**
|
/**
|
||||||
* Link between two TileEntities, do pathfinding operation.
|
* Link between two TileEntities, do pathfinding operation.
|
||||||
*/
|
*/
|
||||||
public void setLink(TileEntityEMContractor tileEntity)
|
public void setLink(TileEntityEMContractor tileEntity, boolean setOpponent)
|
||||||
{
|
{
|
||||||
|
if (this.linked != null && setOpponent)
|
||||||
|
{
|
||||||
|
this.linked.setLink(null, false);
|
||||||
|
}
|
||||||
|
|
||||||
this.linked = tileEntity;
|
this.linked = tileEntity;
|
||||||
this.linked.linked = this;
|
|
||||||
|
if (setOpponent)
|
||||||
|
{
|
||||||
|
this.linked.setLink(this, false);
|
||||||
|
}
|
||||||
|
|
||||||
this.updatePath();
|
this.updatePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,8 +532,14 @@ public class TileEntityEMContractor extends TileEntityBase implements IPacketRec
|
||||||
|
|
||||||
if (this.linked != null)
|
if (this.linked != null)
|
||||||
{
|
{
|
||||||
this.pathfinder = new PathfinderEMContractor(this.worldObj, new Vector3(this.linked));
|
Vector3 start = new Vector3(this).translate(new Vector3(this.getDirection()));
|
||||||
this.pathfinder.find(new Vector3(this));
|
Vector3 target = new Vector3(this.linked).translate(new Vector3(this.linked.getDirection()));
|
||||||
|
|
||||||
|
if (TileEntityEMContractor.canBePath(this.worldObj, start) && TileEntityEMContractor.canBePath(this.worldObj, target))
|
||||||
|
{
|
||||||
|
this.pathfinder = new PathfinderEMContractor(this.worldObj, target);
|
||||||
|
this.pathfinder.find(start);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@ package resonantinduction.entangler;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
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.nbt.NBTTagCompound;
|
||||||
import resonantinduction.base.ItemBase;
|
import resonantinduction.base.ItemBase;
|
||||||
import resonantinduction.base.Vector3;
|
import resonantinduction.base.Vector3;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
|
@ -50,7 +50,7 @@ public abstract class ItemCoordLink extends ItemBase
|
||||||
|
|
||||||
public Vector3 getLink(ItemStack itemStack)
|
public Vector3 getLink(ItemStack itemStack)
|
||||||
{
|
{
|
||||||
if (itemStack.stackTagCompound == null)
|
if (itemStack.stackTagCompound == null || !(itemStack.getTagCompound().hasKey("bindX") && itemStack.getTagCompound().hasKey("bindY") && itemStack.getTagCompound().hasKey("bindZ")))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -85,4 +85,12 @@ public abstract class ItemCoordLink extends ItemBase
|
||||||
|
|
||||||
return itemStack.stackTagCompound.getInteger("dimID");
|
return itemStack.stackTagCompound.getInteger("dimID");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearLink(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
itemStack.getTagCompound().removeTag("bindX");
|
||||||
|
itemStack.getTagCompound().removeTag("bindY");
|
||||||
|
itemStack.getTagCompound().removeTag("bindZ");
|
||||||
|
itemStack.getTagCompound().removeTag("dimID");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ public class ItemLinker extends ItemCoordLink
|
||||||
{
|
{
|
||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
{
|
{
|
||||||
System.out.println("TEST");
|
|
||||||
int dimID = world.provider.dimensionId;
|
int dimID = world.provider.dimensionId;
|
||||||
player.addChatMessage("Set link to block [" + x + ", " + y + ", " + z + "], dimension '" + dimID + "'");
|
player.addChatMessage("Set link to block [" + x + ", " + y + ", " + z + "], dimension '" + dimID + "'");
|
||||||
this.setLink(stack, new Vector3(x, y, z), dimID);
|
this.setLink(stack, new Vector3(x, y, z), dimID);
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
|
||||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||||
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
||||||
|
|
||||||
switch (((TileEntityEMContractor) t).getFacing())
|
switch (((TileEntityEMContractor) t).getDirection())
|
||||||
{
|
{
|
||||||
case DOWN:
|
case DOWN:
|
||||||
GL11.glRotatef(180, 0, 0, 1);
|
GL11.glRotatef(180, 0, 0, 1);
|
||||||
|
|
Loading…
Reference in a new issue