Double-click inserting on Bins
This commit is contained in:
parent
52d42e99f2
commit
2594918bee
13 changed files with 403 additions and 404 deletions
|
@ -27,6 +27,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.EnumCreatureType;
|
import net.minecraft.entity.EnumCreatureType;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -260,10 +261,36 @@ public class BlockBasic extends Block
|
||||||
{
|
{
|
||||||
TileEntityBin bin = (TileEntityBin)world.getBlockTileEntity(x, y, z);
|
TileEntityBin bin = (TileEntityBin)world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(bin.itemCount < bin.MAX_STORAGE)
|
||||||
|
{
|
||||||
|
if(bin.addTicks == 0)
|
||||||
|
{
|
||||||
if(entityplayer.getCurrentEquippedItem() != null)
|
if(entityplayer.getCurrentEquippedItem() != null)
|
||||||
{
|
{
|
||||||
ItemStack remain = bin.add(entityplayer.getCurrentEquippedItem());
|
ItemStack remain = bin.add(entityplayer.getCurrentEquippedItem());
|
||||||
entityplayer.setCurrentItemOrArmor(0, remain);
|
entityplayer.setCurrentItemOrArmor(0, remain);
|
||||||
|
bin.addTicks = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ItemStack[] inv = entityplayer.inventory.mainInventory;
|
||||||
|
|
||||||
|
for(int i = 0; i < inv.length; i++)
|
||||||
|
{
|
||||||
|
if(bin.itemCount == bin.MAX_STORAGE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(inv[i] != null)
|
||||||
|
{
|
||||||
|
ItemStack remain = bin.add(inv[i]);
|
||||||
|
inv[i] = remain;
|
||||||
|
}
|
||||||
|
|
||||||
|
((EntityPlayerMP)entityplayer).sendContainerAndContentsToPlayer(entityplayer.openContainer, entityplayer.openContainer.getInventory());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
|
||||||
|
|
||||||
public final int MAX_DELAY = 10;
|
public final int MAX_DELAY = 10;
|
||||||
|
|
||||||
|
public int addTicks = 0;
|
||||||
|
|
||||||
public int delayTicks;
|
public int delayTicks;
|
||||||
|
|
||||||
public int itemCount;
|
public int itemCount;
|
||||||
|
@ -156,6 +158,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
|
||||||
{
|
{
|
||||||
if(!worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
|
addTicks = Math.max(0, addTicks-1);
|
||||||
delayTicks = Math.max(0, delayTicks-1);
|
delayTicks = Math.max(0, delayTicks-1);
|
||||||
|
|
||||||
if(getStack() != null && isActive && delayTicks == 0)
|
if(getStack() != null && isActive && delayTicks == 0)
|
||||||
|
|
|
@ -64,22 +64,22 @@ public class FXElectricBolt extends EntityFX
|
||||||
{
|
{
|
||||||
super(world, startVec.x, startVec.y, startVec.z);
|
super(world, startVec.x, startVec.y, startVec.z);
|
||||||
|
|
||||||
this.rand = new Random();
|
rand = new Random();
|
||||||
this.start = new BoltPoint(startVec);
|
start = new BoltPoint(startVec);
|
||||||
this.end = new BoltPoint(targetVec);
|
end = new BoltPoint(targetVec);
|
||||||
|
|
||||||
if (this.end.y == Double.POSITIVE_INFINITY)
|
if(end.y == Double.POSITIVE_INFINITY)
|
||||||
{
|
{
|
||||||
this.end.y = Minecraft.getMinecraft().thePlayer.posY + 30;
|
end.y = Minecraft.getMinecraft().thePlayer.posY + 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** By default, we do an electrical color */
|
/** By default, we do an electrical color */
|
||||||
this.segmentCount = 1;
|
segmentCount = 1;
|
||||||
this.particleMaxAge = (3 + this.rand.nextInt(3) - 1);
|
particleMaxAge = (3 + rand.nextInt(3) - 1);
|
||||||
this.complexity = 2f;
|
complexity = 2f;
|
||||||
this.boltWidth = 0.05f;
|
boltWidth = 0.05f;
|
||||||
this.boltLength = this.start.distance(this.end);
|
boltLength = start.distance(end);
|
||||||
this.setUp(doSplits);
|
setUp(doSplits);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FXElectricBolt(World world, Vector3 startVec, Vector3 targetVec)
|
public FXElectricBolt(World world, Vector3 startVec, Vector3 targetVec)
|
||||||
|
@ -92,21 +92,21 @@ public class FXElectricBolt extends EntityFX
|
||||||
*/
|
*/
|
||||||
private void setUp(boolean doSplits)
|
private void setUp(boolean doSplits)
|
||||||
{
|
{
|
||||||
this.segments.add(new BoltSegment(this.start, this.end));
|
segments.add(new BoltSegment(start, end));
|
||||||
this.recalculate();
|
recalculate();
|
||||||
|
|
||||||
if (doSplits)
|
if(doSplits)
|
||||||
{
|
{
|
||||||
double offsetRatio = this.boltLength * this.complexity;
|
double offsetRatio = boltLength * complexity;
|
||||||
this.split(2, offsetRatio / 10, 0.7f, 0.1f, 20 / 2);
|
split(2, offsetRatio / 10, 0.7f, 0.1f, 20 / 2);
|
||||||
this.split(2, offsetRatio / 15, 0.5f, 0.1f, 25 / 2);
|
split(2, offsetRatio / 15, 0.5f, 0.1f, 25 / 2);
|
||||||
this.split(2, offsetRatio / 25, 0.5f, 0.1f, 28 / 2);
|
split(2, offsetRatio / 25, 0.5f, 0.1f, 28 / 2);
|
||||||
this.split(2, offsetRatio / 38, 0.5f, 0.1f, 30 / 2);
|
split(2, offsetRatio / 38, 0.5f, 0.1f, 30 / 2);
|
||||||
this.split(2, offsetRatio / 55, 0, 0, 0);
|
split(2, offsetRatio / 55, 0, 0, 0);
|
||||||
this.split(2, offsetRatio / 70, 0, 0, 0);
|
split(2, offsetRatio / 70, 0, 0, 0);
|
||||||
this.recalculate();
|
recalculate();
|
||||||
|
|
||||||
Collections.sort(this.segments, new Comparator()
|
Collections.sort(segments, new Comparator()
|
||||||
{
|
{
|
||||||
public int compare(BoltSegment bolt1, BoltSegment bolt2)
|
public int compare(BoltSegment bolt1, BoltSegment bolt2)
|
||||||
{
|
{
|
||||||
|
@ -124,9 +124,9 @@ public class FXElectricBolt extends EntityFX
|
||||||
|
|
||||||
public FXElectricBolt setColor(float r, float g, float b)
|
public FXElectricBolt setColor(float r, float g, float b)
|
||||||
{
|
{
|
||||||
this.particleRed = r + (this.rand.nextFloat() * 0.1f) - 0.1f;
|
particleRed = r + (rand.nextFloat() * 0.1f) - 0.1f;
|
||||||
this.particleGreen = g + (this.rand.nextFloat() * 0.1f) - 0.1f;
|
particleGreen = g + (rand.nextFloat() * 0.1f) - 0.1f;
|
||||||
this.particleBlue = b + (this.rand.nextFloat() * 0.1f) - 0.1f;
|
particleBlue = b + (rand.nextFloat() * 0.1f) - 0.1f;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,12 +142,12 @@ public class FXElectricBolt extends EntityFX
|
||||||
public void split(int splitAmount, double offset, float splitChance, float splitLength, float splitAngle)
|
public void split(int splitAmount, double offset, float splitChance, float splitLength, float splitAngle)
|
||||||
{
|
{
|
||||||
/** Temporarily store old segments in a new array */
|
/** Temporarily store old segments in a new array */
|
||||||
List<BoltSegment> oldSegments = this.segments;
|
List<BoltSegment> oldSegments = segments;
|
||||||
this.segments = new ArrayList();
|
segments = new ArrayList();
|
||||||
/** Previous segment */
|
/** Previous segment */
|
||||||
BoltSegment prev = null;
|
BoltSegment prev = null;
|
||||||
|
|
||||||
for (BoltSegment segment : oldSegments)
|
for(BoltSegment segment : oldSegments)
|
||||||
{
|
{
|
||||||
prev = segment.prev;
|
prev = segment.prev;
|
||||||
/** Length of each subsegment */
|
/** Length of each subsegment */
|
||||||
|
@ -165,46 +165,46 @@ public class FXElectricBolt extends EntityFX
|
||||||
/**
|
/**
|
||||||
* Create bolt points.
|
* Create bolt points.
|
||||||
*/
|
*/
|
||||||
for (int i = 1; i < splitAmount; i++)
|
for(int i = 1; i < splitAmount; i++)
|
||||||
{
|
{
|
||||||
Vector3 newOffset = segment.difference.getPerpendicular().rotate(this.rand.nextFloat() * 360, segment.difference).scale((this.rand.nextFloat() - 0.5F) * offset);
|
Vector3 newOffset = segment.difference.getPerpendicular().rotate(rand.nextFloat() * 360, segment.difference).scale((rand.nextFloat() - 0.5F) * offset);
|
||||||
Vector3 basePoint = startPoint.clone().translate(subSegment.clone().scale(i));
|
Vector3 basePoint = startPoint.clone().translate(subSegment.clone().scale(i));
|
||||||
|
|
||||||
newPoints[i] = new BoltPoint(basePoint, newOffset);
|
newPoints[i] = new BoltPoint(basePoint, newOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < splitAmount; i++)
|
for(int i = 0; i < splitAmount; i++)
|
||||||
{
|
{
|
||||||
BoltSegment next = new BoltSegment(newPoints[i], newPoints[(i + 1)], segment.alpha, segment.id * splitAmount + i, segment.splitID);
|
BoltSegment next = new BoltSegment(newPoints[i], newPoints[(i + 1)], segment.alpha, segment.id * splitAmount + i, segment.splitID);
|
||||||
next.prev = prev;
|
next.prev = prev;
|
||||||
|
|
||||||
if (prev != null)
|
if(prev != null)
|
||||||
{
|
{
|
||||||
prev.next = next;
|
prev.next = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i != 0) && (this.rand.nextFloat() < splitChance))
|
if((i != 0) && (rand.nextFloat() < splitChance))
|
||||||
{
|
{
|
||||||
Vector3 splitrot = next.difference.xCrossProduct().rotate(this.rand.nextFloat() * 360, next.difference);
|
Vector3 splitrot = next.difference.xCrossProduct().rotate(rand.nextFloat() * 360, next.difference);
|
||||||
Vector3 diff = next.difference.clone().rotate((this.rand.nextFloat() * 0.66F + 0.33F) * splitAngle, splitrot).scale(splitLength);
|
Vector3 diff = next.difference.clone().rotate((rand.nextFloat() * 0.66F + 0.33F) * splitAngle, splitrot).scale(splitLength);
|
||||||
this.maxSplitID += 1;
|
maxSplitID += 1;
|
||||||
this.parentIDMap.put(this.maxSplitID, next.splitID);
|
parentIDMap.put(maxSplitID, next.splitID);
|
||||||
BoltSegment split = new BoltSegment(newPoints[i], new BoltPoint(newPoints[(i + 1)].base, newPoints[(i + 1)].offset.clone().translate(diff)), segment.alpha / 2f, next.id, this.maxSplitID);
|
BoltSegment split = new BoltSegment(newPoints[i], new BoltPoint(newPoints[(i + 1)].base, newPoints[(i + 1)].offset.clone().translate(diff)), segment.alpha / 2f, next.id, maxSplitID);
|
||||||
split.prev = prev;
|
split.prev = prev;
|
||||||
this.segments.add(split);
|
segments.add(split);
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = next;
|
prev = next;
|
||||||
this.segments.add(next);
|
segments.add(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segment.next != null)
|
if(segment.next != null)
|
||||||
{
|
{
|
||||||
segment.next.prev = prev;
|
segment.next.prev = prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.segmentCount *= splitAmount;
|
segmentCount *= splitAmount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,15 +212,17 @@ public class FXElectricBolt extends EntityFX
|
||||||
{
|
{
|
||||||
HashMap<Integer, Integer> lastActiveSegment = new HashMap<Integer, Integer>();
|
HashMap<Integer, Integer> lastActiveSegment = new HashMap<Integer, Integer>();
|
||||||
|
|
||||||
Collections.sort(this.segments, new Comparator()
|
Collections.sort(segments, new Comparator()
|
||||||
{
|
{
|
||||||
public int compare(BoltSegment o1, BoltSegment o2)
|
public int compare(BoltSegment o1, BoltSegment o2)
|
||||||
{
|
{
|
||||||
int comp = Integer.valueOf(o1.splitID).compareTo(Integer.valueOf(o2.splitID));
|
int comp = Integer.valueOf(o1.splitID).compareTo(Integer.valueOf(o2.splitID));
|
||||||
if (comp == 0)
|
|
||||||
|
if(comp == 0)
|
||||||
{
|
{
|
||||||
return Integer.valueOf(o1.id).compareTo(Integer.valueOf(o2.id));
|
return Integer.valueOf(o1.id).compareTo(Integer.valueOf(o2.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,13 +236,13 @@ public class FXElectricBolt extends EntityFX
|
||||||
int lastSplitCalc = 0;
|
int lastSplitCalc = 0;
|
||||||
int lastActiveSeg = 0;
|
int lastActiveSeg = 0;
|
||||||
|
|
||||||
for (BoltSegment segment : this.segments)
|
for(BoltSegment segment : segments)
|
||||||
{
|
{
|
||||||
if (segment.splitID > lastSplitCalc)
|
if(segment.splitID > lastSplitCalc)
|
||||||
{
|
{
|
||||||
lastActiveSegment.put(lastSplitCalc, lastActiveSeg);
|
lastActiveSegment.put(lastSplitCalc, lastActiveSeg);
|
||||||
lastSplitCalc = segment.splitID;
|
lastSplitCalc = segment.splitID;
|
||||||
lastActiveSeg = lastActiveSegment.get(this.parentIDMap.get(segment.splitID)).intValue();
|
lastActiveSeg = lastActiveSegment.get(parentIDMap.get(segment.splitID)).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
lastActiveSeg = segment.id;
|
lastActiveSeg = segment.id;
|
||||||
|
@ -251,17 +253,17 @@ public class FXElectricBolt extends EntityFX
|
||||||
lastActiveSeg = lastActiveSegment.get(0).intValue();
|
lastActiveSeg = lastActiveSegment.get(0).intValue();
|
||||||
BoltSegment segment;
|
BoltSegment segment;
|
||||||
|
|
||||||
for (Iterator<BoltSegment> iterator = this.segments.iterator(); iterator.hasNext(); segment.recalculate())
|
for(Iterator<BoltSegment> iterator = segments.iterator(); iterator.hasNext(); segment.recalculate())
|
||||||
{
|
{
|
||||||
segment = iterator.next();
|
segment = iterator.next();
|
||||||
|
|
||||||
if (lastSplitCalc != segment.splitID)
|
if(lastSplitCalc != segment.splitID)
|
||||||
{
|
{
|
||||||
lastSplitCalc = segment.splitID;
|
lastSplitCalc = segment.splitID;
|
||||||
lastActiveSeg = lastActiveSegment.get(segment.splitID);
|
lastActiveSeg = lastActiveSegment.get(segment.splitID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segment.id > lastActiveSeg)
|
if(segment.id > lastActiveSeg)
|
||||||
{
|
{
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
|
@ -271,13 +273,13 @@ public class FXElectricBolt extends EntityFX
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate()
|
public void onUpdate()
|
||||||
{
|
{
|
||||||
this.prevPosX = this.posX;
|
prevPosX = posX;
|
||||||
this.prevPosY = this.posY;
|
prevPosY = posY;
|
||||||
this.prevPosZ = this.posZ;
|
prevPosZ = posZ;
|
||||||
|
|
||||||
if (this.particleAge++ >= this.particleMaxAge)
|
if(particleAge++ >= particleMaxAge)
|
||||||
{
|
{
|
||||||
this.setDead();
|
setDead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,29 +306,29 @@ public class FXElectricBolt extends EntityFX
|
||||||
tessellator.setBrightness(15728880);
|
tessellator.setBrightness(15728880);
|
||||||
Vector3 playerVector = new Vector3(sinYaw * -cosPitch, -cosSinPitch / cosYaw, cosYaw * cosPitch);
|
Vector3 playerVector = new Vector3(sinYaw * -cosPitch, -cosSinPitch / cosYaw, cosYaw * cosPitch);
|
||||||
|
|
||||||
int renderlength = (int) ((this.particleAge + partialframe + (int) (this.boltLength * 3.0F)) / (int) (this.boltLength * 3.0F) * this.segmentCount);
|
int renderlength = (int)((particleAge + partialframe + (int)(boltLength * 3.0F)) / (int)(boltLength * 3.0F) * segmentCount);
|
||||||
|
|
||||||
for (BoltSegment segment : this.segments)
|
for(BoltSegment segment : segments)
|
||||||
{
|
{
|
||||||
if (segment != null && segment.id <= renderlength)
|
if(segment != null && segment.id <= renderlength)
|
||||||
{
|
{
|
||||||
double renderWidth = this.boltWidth * ((new Vector3(player).distance(segment.start) / 5f + 1f) * (1 + segment.alpha) * 0.5f);
|
double renderWidth = boltWidth * ((new Vector3(player).distance(segment.start) / 5f + 1f) * (1 + segment.alpha) * 0.5f);
|
||||||
renderWidth = Math.min(this.boltWidth, Math.max(renderWidth, 0));
|
renderWidth = Math.min(boltWidth, Math.max(renderWidth, 0));
|
||||||
|
|
||||||
if (segment.difference.getMagnitude() > 0 && segment.difference.getMagnitude() != Double.NaN && segment.difference.getMagnitude() != Double.POSITIVE_INFINITY && renderWidth > 0 && renderWidth != Double.NaN && renderWidth != Double.POSITIVE_INFINITY)
|
if(segment.difference.getMagnitude() > 0 && segment.difference.getMagnitude() != Double.NaN && segment.difference.getMagnitude() != Double.POSITIVE_INFINITY && renderWidth > 0 && renderWidth != Double.NaN && renderWidth != Double.POSITIVE_INFINITY)
|
||||||
{
|
{
|
||||||
Vector3 diffPrev = playerVector.crossProduct(segment.prevDiff).scale(renderWidth / segment.sinPrev);
|
Vector3 diffPrev = playerVector.crossProduct(segment.prevDiff).scale(renderWidth / segment.sinPrev);
|
||||||
Vector3 diffNext = playerVector.crossProduct(segment.nextDiff).scale(renderWidth / segment.sinNext);
|
Vector3 diffNext = playerVector.crossProduct(segment.nextDiff).scale(renderWidth / segment.sinNext);
|
||||||
Vector3 startVec = segment.start;
|
Vector3 startVec = segment.start;
|
||||||
Vector3 endVec = segment.end;
|
Vector3 endVec = segment.end;
|
||||||
float rx1 = (float) (startVec.x - interpPosX);
|
float rx1 = (float)(startVec.x - interpPosX);
|
||||||
float ry1 = (float) (startVec.y - interpPosY);
|
float ry1 = (float)(startVec.y - interpPosY);
|
||||||
float rz1 = (float) (startVec.z - interpPosZ);
|
float rz1 = (float)(startVec.z - interpPosZ);
|
||||||
float rx2 = (float) (endVec.x - interpPosX);
|
float rx2 = (float)(endVec.x - interpPosX);
|
||||||
float ry2 = (float) (endVec.y - interpPosY);
|
float ry2 = (float)(endVec.y - interpPosY);
|
||||||
float rz2 = (float) (endVec.z - interpPosZ);
|
float rz2 = (float)(endVec.z - interpPosZ);
|
||||||
|
|
||||||
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, (1.0F - (this.particleAge >= 0 ? ((float) this.particleAge / (float) this.particleMaxAge) : 0.0F) * 0.6f) * segment.alpha);
|
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, (1.0F - (particleAge >= 0 ? ((float)particleAge / (float)particleMaxAge) : 0.0F) * 0.6f) * segment.alpha);
|
||||||
tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D);
|
tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D);
|
||||||
tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D);
|
tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D);
|
||||||
tessellator.addVertexWithUV(rx1 + diffPrev.x, ry1 + diffPrev.y, rz1 + diffPrev.z, 0.5D, 1.0D);
|
tessellator.addVertexWithUV(rx1 + diffPrev.x, ry1 + diffPrev.y, rz1 + diffPrev.z, 0.5D, 1.0D);
|
||||||
|
@ -336,24 +338,24 @@ public class FXElectricBolt extends EntityFX
|
||||||
* Render the bolts balls.
|
* Render the bolts balls.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (segment.next == null)
|
if(segment.next == null)
|
||||||
{
|
{
|
||||||
Vector3 roundEnd = segment.end.clone().translate(segment.difference.clone().normalize().scale(renderWidth));
|
Vector3 roundEnd = segment.end.clone().translate(segment.difference.clone().normalize().scale(renderWidth));
|
||||||
float rx3 = (float) (roundEnd.x - interpPosX);
|
float rx3 = (float)(roundEnd.x - interpPosX);
|
||||||
float ry3 = (float) (roundEnd.y - interpPosY);
|
float ry3 = (float)(roundEnd.y - interpPosY);
|
||||||
float rz3 = (float) (roundEnd.z - interpPosZ);
|
float rz3 = (float)(roundEnd.z - interpPosZ);
|
||||||
tessellator.addVertexWithUV(rx3 - diffNext.x, ry3 - diffNext.y, rz3 - diffNext.z, 0.0D, 0.0D);
|
tessellator.addVertexWithUV(rx3 - diffNext.x, ry3 - diffNext.y, rz3 - diffNext.z, 0.0D, 0.0D);
|
||||||
tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D);
|
tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D);
|
||||||
tessellator.addVertexWithUV(rx2 + diffNext.x, ry2 + diffNext.y, rz2 + diffNext.z, 0.5D, 1.0D);
|
tessellator.addVertexWithUV(rx2 + diffNext.x, ry2 + diffNext.y, rz2 + diffNext.z, 0.5D, 1.0D);
|
||||||
tessellator.addVertexWithUV(rx3 + diffNext.x, ry3 + diffNext.y, rz3 + diffNext.z, 0.0D, 1.0D);
|
tessellator.addVertexWithUV(rx3 + diffNext.x, ry3 + diffNext.y, rz3 + diffNext.z, 0.0D, 1.0D);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segment.prev == null)
|
if(segment.prev == null)
|
||||||
{
|
{
|
||||||
Vector3 roundEnd = segment.start.clone().difference(segment.difference.clone().normalize().scale(renderWidth));
|
Vector3 roundEnd = segment.start.clone().difference(segment.difference.clone().normalize().scale(renderWidth));
|
||||||
float rx3 = (float) (roundEnd.x - interpPosX);
|
float rx3 = (float)(roundEnd.x - interpPosX);
|
||||||
float ry3 = (float) (roundEnd.y - interpPosY);
|
float ry3 = (float)(roundEnd.y - interpPosY);
|
||||||
float rz3 = (float) (roundEnd.z - interpPosZ);
|
float rz3 = (float)(roundEnd.z - interpPosZ);
|
||||||
tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D);
|
tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D);
|
||||||
tessellator.addVertexWithUV(rx3 - diffPrev.x, ry3 - diffPrev.y, rz3 - diffPrev.z, 0.0D, 0.0D);
|
tessellator.addVertexWithUV(rx3 - diffPrev.x, ry3 - diffPrev.y, rz3 - diffPrev.z, 0.0D, 0.0D);
|
||||||
tessellator.addVertexWithUV(rx3 + diffPrev.x, ry3 + diffPrev.y, rz3 + diffPrev.z, 0.0D, 1.0D);
|
tessellator.addVertexWithUV(rx3 + diffPrev.x, ry3 + diffPrev.y, rz3 + diffPrev.z, 0.0D, 1.0D);
|
||||||
|
@ -379,11 +381,11 @@ public class FXElectricBolt extends EntityFX
|
||||||
public Vector3 base;
|
public Vector3 base;
|
||||||
public Vector3 offset;
|
public Vector3 offset;
|
||||||
|
|
||||||
public BoltPoint(Vector3 base, Vector3 offset)
|
public BoltPoint(Vector3 b, Vector3 o)
|
||||||
{
|
{
|
||||||
super(base.clone().translate(offset));
|
super(b.clone().translate(o));
|
||||||
this.base = base;
|
base = b;
|
||||||
this.offset = offset;
|
offset = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoltPoint(Vector3 base)
|
public BoltPoint(Vector3 base)
|
||||||
|
@ -416,42 +418,40 @@ public class FXElectricBolt extends EntityFX
|
||||||
this(start, end, 1, 0, 0);
|
this(start, end, 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoltSegment(BoltPoint start, BoltPoint end, float alpha, int id, int splitID)
|
public BoltSegment(BoltPoint s, BoltPoint e, float a, int i, int id)
|
||||||
{
|
{
|
||||||
this.start = start;
|
start = s;
|
||||||
this.end = end;
|
end = e;
|
||||||
this.alpha = alpha;
|
alpha = a;
|
||||||
this.id = id;
|
id = i;
|
||||||
this.splitID = splitID;
|
splitID = id;
|
||||||
this.difference = this.end.clone().difference(this.start);
|
difference = end.clone().difference(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recalculate()
|
public void recalculate()
|
||||||
{
|
{
|
||||||
if (this.prev != null)
|
if(prev != null)
|
||||||
{
|
{
|
||||||
Vector3 prevDiffNorm = this.prev.difference.clone().normalize();
|
Vector3 prevDiffNorm = prev.difference.clone().normalize();
|
||||||
Vector3 diffNorm = this.difference.clone().normalize();
|
Vector3 diffNorm = difference.clone().normalize();
|
||||||
this.prevDiff = diffNorm.clone().translate(prevDiffNorm).normalize();
|
prevDiff = diffNorm.clone().translate(prevDiffNorm).normalize();
|
||||||
this.sinPrev = Math.sin(diffNorm.anglePreNorm(prevDiffNorm.clone().scale(-1)) / 2);
|
sinPrev = Math.sin(diffNorm.anglePreNorm(prevDiffNorm.clone().scale(-1)) / 2);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
prevDiff = difference.clone().normalize();
|
||||||
this.prevDiff = this.difference.clone().normalize();
|
sinPrev = 1;
|
||||||
this.sinPrev = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.next != null)
|
if(next != null)
|
||||||
{
|
{
|
||||||
Vector3 nextDiffNorm = this.next.difference.clone().normalize();
|
Vector3 nextDiffNorm = next.difference.clone().normalize();
|
||||||
Vector3 diffNorm = this.difference.clone().normalize();
|
Vector3 diffNorm = difference.clone().normalize();
|
||||||
this.nextDiff = diffNorm.clone().translate(nextDiffNorm).normalize();
|
nextDiff = diffNorm.clone().translate(nextDiffNorm).normalize();
|
||||||
this.sinNext = Math.sin(diffNorm.anglePreNorm(nextDiffNorm.clone().scale(-1)) / 2);
|
sinNext = Math.sin(diffNorm.anglePreNorm(nextDiffNorm.clone().scale(-1)) / 2);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
nextDiff = difference.clone().normalize();
|
||||||
this.nextDiff = this.difference.clone().normalize();
|
sinNext = 1;
|
||||||
this.sinNext = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class GuiBattery extends GuiContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY)
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||||
{
|
{
|
||||||
mc.renderEngine.bindTexture(TEXTURE);
|
mc.renderEngine.bindTexture(TEXTURE);
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
|
@ -39,75 +39,69 @@ public class GuiMultimeter extends GuiContainer
|
||||||
private int containerHeight;
|
private int containerHeight;
|
||||||
private GuiTextField textFieldLimit;
|
private GuiTextField textFieldLimit;
|
||||||
|
|
||||||
public GuiMultimeter(InventoryPlayer inventoryPlayer, TileEntityMultimeter tileEntity)
|
public GuiMultimeter(InventoryPlayer inventoryPlayer, TileEntityMultimeter tile)
|
||||||
{
|
{
|
||||||
super(new ContainerMultimeter(inventoryPlayer, tileEntity));
|
super(new ContainerMultimeter(inventoryPlayer, tile));
|
||||||
this.tileEntity = tileEntity;
|
tileEntity = tile;
|
||||||
this.ySize = 217;
|
ySize = 217;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui()
|
public void initGui()
|
||||||
{
|
{
|
||||||
super.initGui();
|
super.initGui();
|
||||||
this.buttonList.add(new GuiButton(0, this.width / 2 + 20, this.height / 2 - 30, 50, 20, "Toggle"));
|
buttonList.add(new GuiButton(0, width / 2 + 20, height / 2 - 30, 50, 20, "Toggle"));
|
||||||
this.textFieldLimit = new GuiTextField(fontRenderer, 35, 82, 65, 12);
|
textFieldLimit = new GuiTextField(fontRenderer, 35, 82, 65, 12);
|
||||||
this.textFieldLimit.setMaxStringLength(8);
|
textFieldLimit.setMaxStringLength(8);
|
||||||
this.textFieldLimit.setText("" + this.tileEntity.getLimit());
|
textFieldLimit.setText("" + tileEntity.getLimit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void keyTyped(char par1, int par2)
|
protected void keyTyped(char par1, int par2)
|
||||||
{
|
{
|
||||||
super.keyTyped(par1, par2);
|
super.keyTyped(par1, par2);
|
||||||
this.textFieldLimit.textboxKeyTyped(par1, par2);
|
textFieldLimit.textboxKeyTyped(par1, par2);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ArrayList data = new ArrayList();
|
ArrayList data = new ArrayList();
|
||||||
data.add((byte)3);
|
data.add((byte)3);
|
||||||
data.add(Float.parseFloat(textFieldLimit.getText()));
|
data.add(Float.parseFloat(textFieldLimit.getText()));
|
||||||
|
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity)), data);
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity)), data);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int par1, int par2, int par3)
|
protected void mouseClicked(int par1, int par2, int par3)
|
||||||
{
|
{
|
||||||
super.mouseClicked(par1, par2, par3);
|
super.mouseClicked(par1, par2, par3);
|
||||||
this.textFieldLimit.mouseClicked(par1 - this.containerWidth, par2 - this.containerHeight, par3);
|
textFieldLimit.mouseClicked(par1 - containerWidth, par2 - containerHeight, par3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||||
{
|
{
|
||||||
String s = this.tileEntity.getBlockType().getLocalizedName();
|
String s = tileEntity.getBlockType().getLocalizedName();
|
||||||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 15, 4210752);
|
fontRenderer.drawString(s, xSize / 2 - fontRenderer.getStringWidth(s) / 2, 15, 4210752);
|
||||||
this.fontRenderer.drawString("Average Energy: " + Math.round(this.tileEntity.getAverageDetectedEnergy()) + " J", 35, 25, 4210752);
|
fontRenderer.drawString("Average Energy: " + Math.round(tileEntity.getAverageDetectedEnergy()) + " J", 35, 25, 4210752);
|
||||||
this.fontRenderer.drawString("Energy: " + Math.round(this.tileEntity.getDetectedEnergy()) + " J", 35, 35, 4210752);
|
fontRenderer.drawString("Energy: " + Math.round(tileEntity.getDetectedEnergy()) + " J", 35, 35, 4210752);
|
||||||
this.fontRenderer.drawString("Output Redstone If... ", 35, 54, 4210752);
|
fontRenderer.drawString("Output Redstone If... ", 35, 54, 4210752);
|
||||||
this.fontRenderer.drawString(this.tileEntity.getMode().display, 35, 65, 4210752);
|
fontRenderer.drawString(tileEntity.getMode().display, 35, 65, 4210752);
|
||||||
this.fontRenderer.drawString("KiloJoules", 35, 100, 4210752);
|
fontRenderer.drawString("KiloJoules", 35, 100, 4210752);
|
||||||
|
|
||||||
this.textFieldLimit.drawTextBox();
|
textFieldLimit.drawTextBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
|
protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
|
||||||
{
|
{
|
||||||
this.containerWidth = (this.width - this.xSize) / 2;
|
containerWidth = (width - xSize) / 2;
|
||||||
this.containerHeight = (this.height - this.ySize) / 2;
|
containerHeight = (height - ySize) / 2;
|
||||||
|
|
||||||
this.mc.renderEngine.bindTexture(TEXTURE);
|
mc.renderEngine.bindTexture(TEXTURE);
|
||||||
GL11.glColor4f(1, 1, 1, 1);
|
GL11.glColor4f(1, 1, 1, 1);
|
||||||
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0, this.xSize, this.ySize);
|
drawTexturedModalRect(containerWidth, containerHeight, 0, 0, xSize, ySize);
|
||||||
|
|
||||||
int length = Math.min((int) (this.tileEntity.getDetectedEnergy() / this.tileEntity.getPeak()) * 115, 115);
|
int length = Math.min((int) (tileEntity.getDetectedEnergy() / tileEntity.getPeak()) * 115, 115);
|
||||||
this.drawTexturedModalRect(this.containerWidth + 14, this.containerHeight + 126 - length, 176, 115 - length, 6, length);
|
drawTexturedModalRect(containerWidth + 14, containerHeight + 126 - length, 176, 115 - length, 6, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,5 +112,4 @@ public class GuiMultimeter extends GuiContainer
|
||||||
|
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TeslaGrid
|
public class TeslaGrid
|
||||||
{
|
{
|
||||||
private static final TeslaGrid INSTANCE_CLIENT = new TeslaGrid();
|
private static final TeslaGrid INSTANCE_CLIENT = new TeslaGrid();
|
||||||
|
@ -25,15 +21,15 @@ public class TeslaGrid
|
||||||
|
|
||||||
public void register(ITesla iTesla)
|
public void register(ITesla iTesla)
|
||||||
{
|
{
|
||||||
Iterator<ITesla> it = this.tileEntities.iterator();
|
Iterator<ITesla> it = tileEntities.iterator();
|
||||||
|
|
||||||
while (it.hasNext())
|
while(it.hasNext())
|
||||||
{
|
{
|
||||||
ITesla tesla = it.next();
|
ITesla tesla = it.next();
|
||||||
|
|
||||||
if (tesla instanceof TileEntity)
|
if(tesla instanceof TileEntity)
|
||||||
{
|
{
|
||||||
if (!((TileEntity) tesla).isInvalid())
|
if(!((TileEntity) tesla).isInvalid())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -43,22 +39,22 @@ public class TeslaGrid
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tileEntities.add(iTesla);
|
tileEntities.add(iTesla);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregister(ITesla iTesla)
|
public void unregister(ITesla iTesla)
|
||||||
{
|
{
|
||||||
this.tileEntities.remove(iTesla);
|
tileEntities.remove(iTesla);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<ITesla> get()
|
public Set<ITesla> get()
|
||||||
{
|
{
|
||||||
return this.tileEntities;
|
return tileEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TeslaGrid instance()
|
public static TeslaGrid instance()
|
||||||
{
|
{
|
||||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||||
{
|
{
|
||||||
return INSTANCE_SERVER;
|
return INSTANCE_SERVER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
package mekanism.induction.common.block;
|
package mekanism.induction.common.block;
|
||||||
|
|
||||||
|
import mekanism.api.Object3D;
|
||||||
import mekanism.common.Mekanism;
|
import mekanism.common.Mekanism;
|
||||||
import mekanism.induction.client.render.BlockRenderingHandler;
|
import mekanism.induction.client.render.BlockRenderingHandler;
|
||||||
import mekanism.induction.common.MekanismInduction;
|
|
||||||
import mekanism.induction.common.item.ItemCoordLink;
|
import mekanism.induction.common.item.ItemCoordLink;
|
||||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.core.vector.Vector3;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -24,8 +22,8 @@ public class BlockEMContractor extends Block implements ITileEntityProvider
|
||||||
public BlockEMContractor(int id)
|
public BlockEMContractor(int id)
|
||||||
{
|
{
|
||||||
super(id, Material.piston);
|
super(id, Material.piston);
|
||||||
this.setCreativeTab(Mekanism.tabMekanism);
|
setCreativeTab(Mekanism.tabMekanism);
|
||||||
this.setTextureName("mekanism:machine");
|
setTextureName("mekanism:machine");
|
||||||
setHardness(5F);
|
setHardness(5F);
|
||||||
setResistance(10F);
|
setResistance(10F);
|
||||||
}
|
}
|
||||||
|
@ -42,32 +40,33 @@ public class BlockEMContractor extends Block implements ITileEntityProvider
|
||||||
{
|
{
|
||||||
TileEntityEMContractor contractor = (TileEntityEMContractor) world.getBlockTileEntity(par2, par3, par4);
|
TileEntityEMContractor contractor = (TileEntityEMContractor) world.getBlockTileEntity(par2, par3, par4);
|
||||||
|
|
||||||
if (entityPlayer.getCurrentEquippedItem() != null)
|
if(entityPlayer.getCurrentEquippedItem() != null)
|
||||||
{
|
{
|
||||||
if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
if(entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
||||||
{
|
{
|
||||||
contractor.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage());
|
contractor.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage());
|
||||||
|
|
||||||
if (!entityPlayer.capabilities.isCreativeMode)
|
if(!entityPlayer.capabilities.isCreativeMode)
|
||||||
{
|
{
|
||||||
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink)
|
else if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink)
|
||||||
{
|
{
|
||||||
ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem());
|
ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem());
|
||||||
Vector3 linkVec = link.getLink(entityPlayer.getCurrentEquippedItem());
|
Object3D linkVec = link.getLink(entityPlayer.getCurrentEquippedItem());
|
||||||
|
|
||||||
if (linkVec != null)
|
if(linkVec != null)
|
||||||
{
|
{
|
||||||
if (linkVec.getTileEntity(world) instanceof TileEntityEMContractor)
|
if(linkVec.getTileEntity(world) instanceof TileEntityEMContractor)
|
||||||
{
|
{
|
||||||
contractor.setLink((TileEntityEMContractor) linkVec.getTileEntity(world), true);
|
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 " + getLocalizedName() + " with " + " [" + (int) linkVec.xCoord + ", " + (int) linkVec.yCoord + ", " + (int) linkVec.zCoord + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
link.clearLink(entityPlayer.getCurrentEquippedItem());
|
link.clearLink(entityPlayer.getCurrentEquippedItem());
|
||||||
|
@ -80,12 +79,11 @@ public class BlockEMContractor extends Block implements ITileEntityProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entityPlayer.isSneaking())
|
if(!entityPlayer.isSneaking())
|
||||||
{
|
{
|
||||||
contractor.incrementFacing();
|
contractor.incrementFacing();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
contractor.suck = !contractor.suck;
|
contractor.suck = !contractor.suck;
|
||||||
contractor.updatePath();
|
contractor.updatePath();
|
||||||
}
|
}
|
||||||
|
@ -98,13 +96,13 @@ public class BlockEMContractor extends Block implements ITileEntityProvider
|
||||||
{
|
{
|
||||||
TileEntityEMContractor tileContractor = (TileEntityEMContractor) world.getBlockTileEntity(x, y, z);
|
TileEntityEMContractor tileContractor = (TileEntityEMContractor) world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
if (!world.isRemote && !tileContractor.isLatched())
|
if(!world.isRemote && !tileContractor.isLatched())
|
||||||
{
|
{
|
||||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ);
|
TileEntity tileEntity = world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ);
|
||||||
|
|
||||||
if (tileEntity instanceof IInventory)
|
if(tileEntity instanceof IInventory)
|
||||||
{
|
{
|
||||||
tileContractor.setFacing(side.getOpposite());
|
tileContractor.setFacing(side.getOpposite());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package mekanism.induction.common.block;
|
package mekanism.induction.common.block;
|
||||||
|
|
||||||
|
import mekanism.api.Object3D;
|
||||||
import mekanism.common.Mekanism;
|
import mekanism.common.Mekanism;
|
||||||
import mekanism.induction.client.render.BlockRenderingHandler;
|
import mekanism.induction.client.render.BlockRenderingHandler;
|
||||||
import mekanism.induction.common.item.ItemCoordLink;
|
import mekanism.induction.common.item.ItemCoordLink;
|
||||||
|
@ -48,54 +49,54 @@ public class BlockTesla extends Block implements ITileEntityProvider
|
||||||
TileEntity t = world.getBlockTileEntity(x, y, z);
|
TileEntity t = world.getBlockTileEntity(x, y, z);
|
||||||
TileEntityTesla tileEntity = ((TileEntityTesla) t).getControllingTelsa();
|
TileEntityTesla tileEntity = ((TileEntityTesla) t).getControllingTelsa();
|
||||||
|
|
||||||
if (entityPlayer.getCurrentEquippedItem() != null)
|
if(entityPlayer.getCurrentEquippedItem() != null)
|
||||||
{
|
{
|
||||||
if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
if(entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
||||||
{
|
{
|
||||||
tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage());
|
tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage());
|
||||||
|
|
||||||
if (!entityPlayer.capabilities.isCreativeMode)
|
if(!entityPlayer.capabilities.isCreativeMode)
|
||||||
{
|
{
|
||||||
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (entityPlayer.getCurrentEquippedItem().itemID == Item.redstone.itemID)
|
else if(entityPlayer.getCurrentEquippedItem().itemID == Item.redstone.itemID)
|
||||||
{
|
{
|
||||||
boolean status = tileEntity.toggleEntityAttack();
|
boolean status = tileEntity.toggleEntityAttack();
|
||||||
|
|
||||||
if (!entityPlayer.capabilities.isCreativeMode)
|
if(!entityPlayer.capabilities.isCreativeMode)
|
||||||
{
|
{
|
||||||
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!world.isRemote)
|
if(!world.isRemote)
|
||||||
{
|
{
|
||||||
entityPlayer.addChatMessage("Toggled entity attack to: " + status);
|
entityPlayer.addChatMessage("Toggled entity attack to: " + status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink)
|
else if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink)
|
||||||
{
|
{
|
||||||
if (tileEntity.linked == null)
|
if(tileEntity.linked == null)
|
||||||
{
|
{
|
||||||
ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem());
|
ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem());
|
||||||
Vector3 linkVec = link.getLink(entityPlayer.getCurrentEquippedItem());
|
Object3D linkObj = link.getLink(entityPlayer.getCurrentEquippedItem());
|
||||||
|
|
||||||
if (linkVec != null)
|
if(linkObj != null)
|
||||||
{
|
{
|
||||||
if (!world.isRemote)
|
if(!world.isRemote)
|
||||||
{
|
{
|
||||||
int dimID = link.getLinkDim(entityPlayer.getCurrentEquippedItem());
|
int dimID = link.getLinkDim(entityPlayer.getCurrentEquippedItem());
|
||||||
World otherWorld = MinecraftServer.getServer().worldServerForDimension(dimID);
|
World otherWorld = MinecraftServer.getServer().worldServerForDimension(dimID);
|
||||||
|
|
||||||
if (linkVec.getTileEntity(otherWorld) instanceof TileEntityTesla)
|
if(linkObj.getTileEntity(otherWorld) instanceof TileEntityTesla)
|
||||||
{
|
{
|
||||||
tileEntity.setLink(new Vector3(((TileEntityTesla) linkVec.getTileEntity(otherWorld)).getTopTelsa()), dimID, true);
|
tileEntity.setLink(Object3D.get(((TileEntityTesla) linkObj.getTileEntity(otherWorld)).getTopTelsa()), dimID, true);
|
||||||
|
|
||||||
entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkVec.x + ", " + (int) linkVec.y + ", " + (int) linkVec.z + "]");
|
entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkObj.xCoord + ", " + (int) linkObj.yCoord + ", " + (int) linkObj.zCoord + "]");
|
||||||
|
|
||||||
link.clearLink(entityPlayer.getCurrentEquippedItem());
|
link.clearLink(entityPlayer.getCurrentEquippedItem());
|
||||||
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "ambient.weather.thunder", 5, 1);
|
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "ambient.weather.thunder", 5, 1);
|
||||||
|
@ -105,11 +106,10 @@ public class BlockTesla extends Block implements ITileEntityProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
tileEntity.setLink(null, world.provider.dimensionId, true);
|
tileEntity.setLink(null, world.provider.dimensionId, true);
|
||||||
|
|
||||||
if (!world.isRemote)
|
if(!world.isRemote)
|
||||||
{
|
{
|
||||||
entityPlayer.addChatMessage("Unlinked Tesla.");
|
entityPlayer.addChatMessage("Unlinked Tesla.");
|
||||||
}
|
}
|
||||||
|
@ -118,11 +118,10 @@ public class BlockTesla extends Block implements ITileEntityProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
boolean receiveMode = tileEntity.toggleReceive();
|
boolean receiveMode = tileEntity.toggleReceive();
|
||||||
|
|
||||||
if (world.isRemote)
|
if(world.isRemote)
|
||||||
{
|
{
|
||||||
entityPlayer.addChatMessage("Tesla receive mode is now " + receiveMode);
|
entityPlayer.addChatMessage("Tesla receive mode is now " + receiveMode);
|
||||||
}
|
}
|
||||||
|
@ -146,8 +145,8 @@ public class BlockTesla extends Block implements ITileEntityProvider
|
||||||
return new TileEntityTesla();
|
return new TileEntityTesla();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public int getRenderType()
|
public int getRenderType()
|
||||||
{
|
{
|
||||||
return BlockRenderingHandler.INSTANCE.getRenderId();
|
return BlockRenderingHandler.INSTANCE.getRenderId();
|
||||||
|
@ -164,5 +163,4 @@ public class BlockTesla extends Block implements ITileEntityProvider
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,11 @@ package mekanism.induction.common.item;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import mekanism.common.Mekanism;
|
import mekanism.api.Object3D;
|
||||||
import mekanism.common.item.ItemMekanism;
|
import mekanism.common.item.ItemMekanism;
|
||||||
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 universalelectricity.core.vector.Vector3;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -34,10 +33,10 @@ public abstract class ItemCoordLink extends ItemMekanism
|
||||||
|
|
||||||
if (hasLink(itemstack))
|
if (hasLink(itemstack))
|
||||||
{
|
{
|
||||||
Vector3 vec = getLink(itemstack);
|
Object3D obj = getLink(itemstack);
|
||||||
int dimID = getLinkDim(itemstack);
|
int dimID = getLinkDim(itemstack);
|
||||||
|
|
||||||
list.add("Bound to [" + (int) vec.x + ", " + (int) vec.y + ", " + (int) vec.z + "], dimension '" + dimID + "'");
|
list.add("Bound to [" + (int) obj.xCoord + ", " + (int) obj.yCoord + ", " + (int) obj.zCoord + "], dimension '" + dimID + "'");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -50,23 +49,23 @@ public abstract class ItemCoordLink extends ItemMekanism
|
||||||
return getLink(itemStack) != null;
|
return getLink(itemStack) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 getLink(ItemStack itemStack)
|
public Object3D getLink(ItemStack itemStack)
|
||||||
{
|
{
|
||||||
if (itemStack.stackTagCompound == null || !itemStack.getTagCompound().hasKey("position"))
|
if (itemStack.stackTagCompound == null || !itemStack.getTagCompound().hasKey("position"))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Vector3(itemStack.getTagCompound().getCompoundTag("position"));
|
return Object3D.read(itemStack.getTagCompound().getCompoundTag("position"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLink(ItemStack itemStack, Vector3 vec, int dimID)
|
public void setLink(ItemStack itemStack, Object3D obj, int dimID)
|
||||||
{
|
{
|
||||||
if (itemStack.getTagCompound() == null)
|
if (itemStack.getTagCompound() == null)
|
||||||
{
|
{
|
||||||
itemStack.setTagCompound(new NBTTagCompound());
|
itemStack.setTagCompound(new NBTTagCompound());
|
||||||
}
|
}
|
||||||
|
|
||||||
itemStack.getTagCompound().setCompoundTag("position", vec.writeToNBT(new NBTTagCompound()));
|
itemStack.getTagCompound().setCompoundTag("position", obj.write(new NBTTagCompound()));
|
||||||
|
|
||||||
itemStack.stackTagCompound.setInteger("dimID", dimID);
|
itemStack.stackTagCompound.setInteger("dimID", dimID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
*/
|
*/
|
||||||
package mekanism.induction.common.item;
|
package mekanism.induction.common.item;
|
||||||
|
|
||||||
|
import mekanism.api.Object3D;
|
||||||
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.world.World;
|
import net.minecraft.world.World;
|
||||||
import universalelectricity.core.vector.Vector3;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
|
@ -26,7 +26,7 @@ public class ItemLinker extends ItemCoordLink
|
||||||
{
|
{
|
||||||
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 Object3D(x, y, z), dimID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -594,9 +594,6 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param itemDamage
|
|
||||||
*/
|
|
||||||
public void setDye(int dye)
|
public void setDye(int dye)
|
||||||
{
|
{
|
||||||
dyeID = dye;
|
dyeID = dye;
|
||||||
|
|
|
@ -52,9 +52,9 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet
|
||||||
|
|
||||||
public String display;
|
public String display;
|
||||||
|
|
||||||
private DetectMode(String display)
|
private DetectMode(String s)
|
||||||
{
|
{
|
||||||
this.display = display;
|
display = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +70,12 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet
|
||||||
{
|
{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if (!this.worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
if (this.ticks % 20 == 0)
|
if(ticks % 20 == 0)
|
||||||
{
|
{
|
||||||
float prevDetectedEnergy = this.detectedEnergy;
|
float prevDetectedEnergy = detectedEnergy;
|
||||||
this.updateDetection(this.doGetDetectedEnergy());
|
updateDetection(doGetDetectedEnergy());
|
||||||
|
|
||||||
boolean outputRedstone = false;
|
boolean outputRedstone = false;
|
||||||
|
|
||||||
|
@ -84,38 +84,38 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case EQUAL:
|
case EQUAL:
|
||||||
outputRedstone = this.detectedEnergy == this.energyLimit;
|
outputRedstone = detectedEnergy == energyLimit;
|
||||||
break;
|
break;
|
||||||
case GREATER_THAN:
|
case GREATER_THAN:
|
||||||
outputRedstone = this.detectedEnergy > this.energyLimit;
|
outputRedstone = detectedEnergy > energyLimit;
|
||||||
break;
|
break;
|
||||||
case GREATER_THAN_EQUAL:
|
case GREATER_THAN_EQUAL:
|
||||||
outputRedstone = this.detectedEnergy >= this.energyLimit;
|
outputRedstone = detectedEnergy >= energyLimit;
|
||||||
break;
|
break;
|
||||||
case LESS_THAN:
|
case LESS_THAN:
|
||||||
outputRedstone = this.detectedEnergy < this.energyLimit;
|
outputRedstone = detectedEnergy < energyLimit;
|
||||||
break;
|
break;
|
||||||
case LESS_THAN_EQUAL:
|
case LESS_THAN_EQUAL:
|
||||||
outputRedstone = this.detectedEnergy <= this.energyLimit;
|
outputRedstone = detectedEnergy <= energyLimit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputRedstone != this.redstoneOn)
|
if(outputRedstone != redstoneOn)
|
||||||
{
|
{
|
||||||
this.redstoneOn = outputRedstone;
|
redstoneOn = outputRedstone;
|
||||||
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, MekanismInduction.Multimeter.blockID);
|
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, MekanismInduction.Multimeter.blockID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevDetectedEnergy != this.detectedEnergy)
|
if(prevDetectedEnergy != detectedEnergy)
|
||||||
{
|
{
|
||||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
for (EntityPlayer player : this.playersUsing)
|
for(EntityPlayer player : playersUsing)
|
||||||
{
|
{
|
||||||
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), player);
|
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), player);
|
||||||
}
|
}
|
||||||
|
@ -128,15 +128,15 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet
|
||||||
switch (input.readByte())
|
switch (input.readByte())
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
this.detectMode = DetectMode.values()[input.readByte()];
|
detectMode = DetectMode.values()[input.readByte()];
|
||||||
this.detectedEnergy = input.readFloat();
|
detectedEnergy = input.readFloat();
|
||||||
this.energyLimit = input.readFloat();
|
energyLimit = input.readFloat();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
this.toggleMode();
|
toggleMode();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
this.energyLimit = input.readFloat();
|
energyLimit = input.readFloat();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,41 +165,41 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet
|
||||||
|
|
||||||
public float doGetDetectedEnergy()
|
public float doGetDetectedEnergy()
|
||||||
{
|
{
|
||||||
ForgeDirection direction = this.getDirection();
|
ForgeDirection direction = getDirection();
|
||||||
TileEntity tileEntity = this.worldObj.getBlockTileEntity(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ);
|
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
||||||
return getDetectedEnergy(direction.getOpposite(), tileEntity);
|
return getDetectedEnergy(direction.getOpposite(), tileEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getDetectedEnergy(ForgeDirection side, TileEntity tileEntity)
|
public static float getDetectedEnergy(ForgeDirection side, TileEntity tileEntity)
|
||||||
{
|
{
|
||||||
if (tileEntity instanceof TileEntityElectrical)
|
if(tileEntity instanceof TileEntityElectrical)
|
||||||
{
|
{
|
||||||
return ((TileEntityElectrical) tileEntity).getEnergyStored();
|
return ((TileEntityElectrical) tileEntity).getEnergyStored();
|
||||||
}
|
}
|
||||||
else if (tileEntity instanceof IElectricalStorage)
|
else if(tileEntity instanceof IElectricalStorage)
|
||||||
{
|
{
|
||||||
return ((IElectricalStorage) tileEntity).getEnergyStored();
|
return ((IElectricalStorage) tileEntity).getEnergyStored();
|
||||||
}
|
}
|
||||||
else if (tileEntity instanceof IConductor)
|
else if(tileEntity instanceof IConductor)
|
||||||
{
|
{
|
||||||
IElectricityNetwork network = ((IConductor) tileEntity).getNetwork();
|
IElectricityNetwork network = ((IConductor) tileEntity).getNetwork();
|
||||||
|
|
||||||
if (MultimeterEventHandler.getCache(tileEntity.worldObj).containsKey(network) && MultimeterEventHandler.getCache(tileEntity.worldObj).get(network) instanceof Float)
|
if(MultimeterEventHandler.getCache(tileEntity.worldObj).containsKey(network) && MultimeterEventHandler.getCache(tileEntity.worldObj).get(network) instanceof Float)
|
||||||
{
|
{
|
||||||
return MultimeterEventHandler.getCache(tileEntity.worldObj).get(network);
|
return MultimeterEventHandler.getCache(tileEntity.worldObj).get(network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tileEntity instanceof IEnergyStorage)
|
else if(tileEntity instanceof IEnergyStorage)
|
||||||
{
|
{
|
||||||
return ((IEnergyStorage) tileEntity).getStored();
|
return ((IEnergyStorage) tileEntity).getStored();
|
||||||
}
|
}
|
||||||
else if (tileEntity instanceof IEnergyStorage)
|
else if(tileEntity instanceof IEnergyStorage)
|
||||||
{
|
{
|
||||||
return ((IEnergyStorage) tileEntity).getStored();
|
return ((IEnergyStorage) tileEntity).getStored();
|
||||||
}
|
}
|
||||||
else if (tileEntity instanceof IPowerReceptor)
|
else if(tileEntity instanceof IPowerReceptor)
|
||||||
{
|
{
|
||||||
if (((IPowerReceptor) tileEntity).getPowerReceiver(side) != null)
|
if(((IPowerReceptor) tileEntity).getPowerReceiver(side) != null)
|
||||||
{
|
{
|
||||||
return ((IPowerReceptor) tileEntity).getPowerReceiver(side).getEnergyStored();
|
return ((IPowerReceptor) tileEntity).getPowerReceiver(side).getEnergyStored();
|
||||||
}
|
}
|
||||||
|
@ -210,82 +210,72 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet
|
||||||
|
|
||||||
public void updateDetection(float detected)
|
public void updateDetection(float detected)
|
||||||
{
|
{
|
||||||
this.detectedEnergy = detected;
|
detectedEnergy = detected;
|
||||||
this.detectedAverageEnergy = (detectedAverageEnergy + this.detectedEnergy) / 2;
|
detectedAverageEnergy = (detectedAverageEnergy + detectedEnergy) / 2;
|
||||||
this.peakDetection = Math.max(peakDetection, this.detectedEnergy);
|
peakDetection = Math.max(peakDetection, detectedEnergy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getDetectedEnergy()
|
public float getDetectedEnergy()
|
||||||
{
|
{
|
||||||
return this.detectedEnergy;
|
return detectedEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAverageDetectedEnergy()
|
public float getAverageDetectedEnergy()
|
||||||
{
|
{
|
||||||
return this.detectedAverageEnergy;
|
return detectedAverageEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleMode()
|
public void toggleMode()
|
||||||
{
|
{
|
||||||
this.detectMode = DetectMode.values()[(this.detectMode.ordinal() + 1) % DetectMode.values().length];
|
detectMode = DetectMode.values()[(detectMode.ordinal() + 1) % DetectMode.values().length];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads a tile entity from NBT.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
this.detectMode = DetectMode.values()[nbt.getInteger("detectMode")];
|
detectMode = DetectMode.values()[nbt.getInteger("detectMode")];
|
||||||
this.energyLimit = nbt.getFloat("energyLimit");
|
energyLimit = nbt.getFloat("energyLimit");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a tile entity to NBT.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setInteger("detectMode", this.detectMode.ordinal());
|
nbt.setInteger("detectMode", detectMode.ordinal());
|
||||||
nbt.setFloat("energyLimit", this.energyLimit);
|
nbt.setFloat("energyLimit", energyLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DetectMode getMode()
|
public DetectMode getMode()
|
||||||
{
|
{
|
||||||
return this.detectMode;
|
return detectMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getLimit()
|
public float getLimit()
|
||||||
{
|
{
|
||||||
return this.energyLimit;
|
return energyLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public float getPeak()
|
public float getPeak()
|
||||||
{
|
{
|
||||||
return this.peakDetection;
|
return peakDetection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection direction)
|
public boolean canConnect(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
return direction == this.getDirection();
|
return direction == getDirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForgeDirection getDirection()
|
public ForgeDirection getDirection()
|
||||||
{
|
{
|
||||||
return ForgeDirection.getOrientation(this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
|
return ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDirection(ForgeDirection direction)
|
public void setDirection(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, direction.ordinal(), 3);
|
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
/**
|
/**
|
||||||
* Quantum Tesla
|
* Quantum Tesla
|
||||||
*/
|
*/
|
||||||
public Vector3 linked;
|
public Object3D linked;
|
||||||
public int linkDim;
|
public int linkDim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,47 +90,47 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
{
|
{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
boolean doPacketUpdate = this.getEnergyStored() > 0;
|
boolean doPacketUpdate = getEnergyStored() > 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only transfer if it is the bottom controlling Tesla tower.
|
* Only transfer if it is the bottom controlling Tesla tower.
|
||||||
*/
|
*/
|
||||||
if (this.isController())
|
if(isController())
|
||||||
{
|
{
|
||||||
this.produce();
|
produce();
|
||||||
|
|
||||||
if (this.ticks % (5 + this.worldObj.rand.nextInt(2)) == 0 && ((this.worldObj.isRemote && this.doTransfer) || (this.getEnergyStored() > 0 && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))))
|
if(ticks % (5 + worldObj.rand.nextInt(2)) == 0 && ((worldObj.isRemote && doTransfer) || (getEnergyStored() > 0 && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))))
|
||||||
{
|
{
|
||||||
final TileEntityTesla topTesla = this.getTopTelsa();
|
final TileEntityTesla topTesla = getTopTelsa();
|
||||||
final Vector3 topTeslaVector = new Vector3(topTesla);
|
final Vector3 topTeslaVector = new Vector3(topTesla);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quantum transportation.
|
* Quantum transportation.
|
||||||
*/
|
*/
|
||||||
if (this.linked != null || this.isLinkedClient)
|
if(linked != null || isLinkedClient)
|
||||||
{
|
{
|
||||||
if (!this.worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
World dimWorld = MinecraftServer.getServer().worldServerForDimension(this.linkDim);
|
World dimWorld = MinecraftServer.getServer().worldServerForDimension(linkDim);
|
||||||
|
|
||||||
if (dimWorld != null)
|
if(dimWorld != null)
|
||||||
{
|
{
|
||||||
TileEntity transferTile = this.linked.getTileEntity(dimWorld);
|
TileEntity transferTile = linked.getTileEntity(dimWorld);
|
||||||
|
|
||||||
if (transferTile instanceof TileEntityTesla && !transferTile.isInvalid())
|
if(transferTile instanceof TileEntityTesla && !transferTile.isInvalid())
|
||||||
{
|
{
|
||||||
this.transfer(((TileEntityTesla) transferTile), Math.min(this.getProvide(ForgeDirection.UNKNOWN), TRANSFER_CAP));
|
transfer(((TileEntityTesla) transferTile), Math.min(getProvide(ForgeDirection.UNKNOWN), TRANSFER_CAP));
|
||||||
|
|
||||||
if (this.zapCounter % 5 == 0 && MekanismInduction.SOUND_FXS)
|
if(zapCounter % 5 == 0 && MekanismInduction.SOUND_FXS)
|
||||||
{
|
{
|
||||||
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, MekanismInduction.PREFIX + "electricshock", this.getEnergyStored() / 25, 1.3f - 0.5f * (this.dyeID / 16f));
|
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, MekanismInduction.PREFIX + "electricshock", getEnergyStored() / 25, 1.3f - 0.5f * (dyeID / 16f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MekanismInduction.proxy.renderElectricShock(this.worldObj, topTeslaVector.clone().translate(0.5), topTeslaVector.clone().translate(new Vector3(0.5, Double.POSITIVE_INFINITY, 0.5)), false);
|
MekanismInduction.proxy.renderElectricShock(worldObj, topTeslaVector.clone().translate(0.5), topTeslaVector.clone().translate(new Vector3(0.5, Double.POSITIVE_INFINITY, 0.5)), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -138,18 +138,18 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
|
|
||||||
List<ITesla> transferTeslaCoils = new ArrayList<ITesla>();
|
List<ITesla> transferTeslaCoils = new ArrayList<ITesla>();
|
||||||
|
|
||||||
for (ITesla tesla : TeslaGrid.instance().get())
|
for(ITesla tesla : TeslaGrid.instance().get())
|
||||||
{
|
{
|
||||||
if (new Vector3((TileEntity) tesla).distance(new Vector3(this)) < this.getRange())
|
if(new Vector3((TileEntity) tesla).distance(new Vector3(this)) < getRange())
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Make sure Tesla is not part of this tower.
|
* Make sure Tesla is not part of this tower.
|
||||||
*/
|
*/
|
||||||
if (!this.connectedTeslas.contains(tesla) && tesla.canReceive(this))
|
if(!connectedTeslas.contains(tesla) && tesla.canReceive(this))
|
||||||
{
|
{
|
||||||
if (tesla instanceof TileEntityTesla)
|
if(tesla instanceof TileEntityTesla)
|
||||||
{
|
{
|
||||||
if (((TileEntityTesla) tesla).getHeight() <= 1)
|
if(((TileEntityTesla) tesla).getHeight() <= 1)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -172,11 +172,11 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
double distance1 = new Vector3(topTesla).distance(new Vector3((TileEntity) o1));
|
double distance1 = new Vector3(topTesla).distance(new Vector3((TileEntity) o1));
|
||||||
double distance2 = new Vector3(topTesla).distance(new Vector3((TileEntity) o2));
|
double distance2 = new Vector3(topTesla).distance(new Vector3((TileEntity) o2));
|
||||||
|
|
||||||
if (distance1 < distance2)
|
if(distance1 < distance2)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (distance1 > distance2)
|
else if(distance1 > distance2)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -191,51 +191,51 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (transferTeslaCoils.size() > 0)
|
if(transferTeslaCoils.size() > 0)
|
||||||
{
|
{
|
||||||
float transferEnergy = this.getEnergyStored() / transferTeslaCoils.size();
|
float transferEnergy = getEnergyStored() / transferTeslaCoils.size();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
boolean sentPacket = false;
|
boolean sentPacket = false;
|
||||||
for (ITesla tesla : transferTeslaCoils)
|
for(ITesla tesla : transferTeslaCoils)
|
||||||
{
|
{
|
||||||
if (this.zapCounter % 5 == 0 && MekanismInduction.SOUND_FXS)
|
if(zapCounter % 5 == 0 && MekanismInduction.SOUND_FXS)
|
||||||
{
|
{
|
||||||
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, MekanismInduction.PREFIX + "electricshock", this.getEnergyStored() / 25, 1.3f - 0.5f * (this.dyeID / 16f));
|
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, MekanismInduction.PREFIX + "electricshock", getEnergyStored() / 25, 1.3f - 0.5f * (dyeID / 16f));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 targetVector = new Vector3((TileEntity) tesla);
|
Vector3 targetVector = new Vector3((TileEntity) tesla);
|
||||||
|
|
||||||
if (tesla instanceof TileEntityTesla)
|
if(tesla instanceof TileEntityTesla)
|
||||||
{
|
{
|
||||||
((TileEntityTesla) tesla).getControllingTelsa().outputBlacklist.add(this);
|
((TileEntityTesla) tesla).getControllingTelsa().outputBlacklist.add(this);
|
||||||
targetVector = new Vector3(((TileEntityTesla) tesla).getTopTelsa());
|
targetVector = new Vector3(((TileEntityTesla) tesla).getTopTelsa());
|
||||||
}
|
}
|
||||||
|
|
||||||
double distance = topTeslaVector.distance(targetVector);
|
double distance = topTeslaVector.distance(targetVector);
|
||||||
MekanismInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) MekanismInduction.DYE_COLORS[this.dyeID].x, (float) MekanismInduction.DYE_COLORS[this.dyeID].y, (float) MekanismInduction.DYE_COLORS[this.dyeID].z);
|
MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) MekanismInduction.DYE_COLORS[dyeID].x, (float) MekanismInduction.DYE_COLORS[dyeID].y, (float) MekanismInduction.DYE_COLORS[dyeID].z);
|
||||||
|
|
||||||
this.transfer(tesla, Math.min(transferEnergy, TRANSFER_CAP));
|
transfer(tesla, Math.min(transferEnergy, TRANSFER_CAP));
|
||||||
|
|
||||||
if (!sentPacket && transferEnergy > 0)
|
if(!sentPacket && transferEnergy > 0)
|
||||||
{
|
{
|
||||||
this.sendPacket(3);
|
sendPacket(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.attackEntities && this.zapCounter % 5 == 0)
|
if(attackEntities && zapCounter % 5 == 0)
|
||||||
{
|
{
|
||||||
MovingObjectPosition mop = topTeslaVector.clone().translate(0.5).rayTraceEntities(this.worldObj, targetVector.clone().translate(0.5));
|
MovingObjectPosition mop = topTeslaVector.clone().translate(0.5).rayTraceEntities(worldObj, targetVector.clone().translate(0.5));
|
||||||
|
|
||||||
if (mop != null && mop.entityHit != null)
|
if(mop != null && mop.entityHit != null)
|
||||||
{
|
{
|
||||||
if (mop.entityHit instanceof EntityLivingBase)
|
if(mop.entityHit instanceof EntityLivingBase)
|
||||||
{
|
{
|
||||||
mop.entityHit.attackEntityFrom(DamageSource.magic, 4);
|
mop.entityHit.attackEntityFrom(DamageSource.magic, 4);
|
||||||
MekanismInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).clone().translate(0.5), new Vector3(mop.entityHit));
|
MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(topTesla).clone().translate(0.5), new Vector3(mop.entityHit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count++ > 1)
|
if(count++ > 1)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -243,27 +243,27 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.zapCounter++;
|
zapCounter++;
|
||||||
this.outputBlacklist.clear();
|
outputBlacklist.clear();
|
||||||
|
|
||||||
this.doTransfer = false;
|
doTransfer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.worldObj.isRemote && this.getEnergyStored() > 0 != doPacketUpdate)
|
if(!worldObj.isRemote && getEnergyStored() > 0 != doPacketUpdate)
|
||||||
{
|
{
|
||||||
this.sendPacket(2);
|
sendPacket(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clearCache();
|
clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transfer(ITesla tesla, float transferEnergy)
|
private void transfer(ITesla tesla, float transferEnergy)
|
||||||
{
|
{
|
||||||
if (transferEnergy > 0)
|
if(transferEnergy > 0)
|
||||||
{
|
{
|
||||||
tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)), true);
|
tesla.transfer(transferEnergy * (1 - (worldObj.rand.nextFloat() * 0.1f)), true);
|
||||||
this.transfer(-transferEnergy, true);
|
transfer(-transferEnergy, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,13 +276,13 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
@Override
|
@Override
|
||||||
public boolean canReceive(TileEntity tileEntity)
|
public boolean canReceive(TileEntity tileEntity)
|
||||||
{
|
{
|
||||||
return this.canReceive && !this.outputBlacklist.contains(tileEntity) && this.getRequest(ForgeDirection.UNKNOWN) > 0;
|
return canReceive && !outputBlacklist.contains(tileEntity) && getRequest(ForgeDirection.UNKNOWN) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection direction)
|
public boolean canConnect(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
return this.isController();
|
return isController();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -320,7 +320,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
|
|
||||||
public void sendPacket(int id)
|
public void sendPacket(int id)
|
||||||
{
|
{
|
||||||
switch (id)
|
switch(id)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||||
|
@ -337,80 +337,80 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
@Override
|
@Override
|
||||||
public void handlePacketData(ByteArrayDataInput input)
|
public void handlePacketData(ByteArrayDataInput input)
|
||||||
{
|
{
|
||||||
switch (input.readByte())
|
switch(input.readByte())
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
this.setEnergyStored(input.readFloat());
|
setEnergyStored(input.readFloat());
|
||||||
this.dyeID = input.readInt();
|
dyeID = input.readInt();
|
||||||
this.canReceive = input.readBoolean();
|
canReceive = input.readBoolean();
|
||||||
this.attackEntities = input.readBoolean();
|
attackEntities = input.readBoolean();
|
||||||
this.isLinkedClient = input.readBoolean();
|
isLinkedClient = input.readBoolean();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
this.setEnergyStored(input.readFloat());
|
setEnergyStored(input.readFloat());
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
this.doTransfer = true;
|
doTransfer = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isController()
|
private boolean isController()
|
||||||
{
|
{
|
||||||
return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord) == 0;
|
return worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearCache()
|
private void clearCache()
|
||||||
{
|
{
|
||||||
this.topCache = null;
|
topCache = null;
|
||||||
this.controlCache = null;
|
controlCache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float transfer(float transferEnergy, boolean doTransfer)
|
public float transfer(float transferEnergy, boolean doTransfer)
|
||||||
{
|
{
|
||||||
if (isController() || this.getControllingTelsa() == this)
|
if(isController() || getControllingTelsa() == this)
|
||||||
{
|
{
|
||||||
if (doTransfer)
|
if(doTransfer)
|
||||||
{
|
{
|
||||||
this.receiveElectricity(transferEnergy, true);
|
receiveElectricity(transferEnergy, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sendPacket(2);
|
sendPacket(2);
|
||||||
return transferEnergy;
|
return transferEnergy;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (this.getEnergyStored() > 0)
|
if(getEnergyStored() > 0)
|
||||||
{
|
{
|
||||||
transferEnergy += this.getEnergyStored();
|
transferEnergy += getEnergyStored();
|
||||||
this.setEnergyStored(0);
|
setEnergyStored(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getControllingTelsa().transfer(transferEnergy, doTransfer);
|
return getControllingTelsa().transfer(transferEnergy, doTransfer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRange()
|
public int getRange()
|
||||||
{
|
{
|
||||||
return Math.min(4 * (this.getHeight() - 1), 50);
|
return Math.min(4 * (getHeight() - 1), 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePositionStatus()
|
public void updatePositionStatus()
|
||||||
{
|
{
|
||||||
boolean isTop = new Vector3(this).translate(new Vector3(0, 1, 0)).getTileEntity(this.worldObj) instanceof TileEntityTesla;
|
boolean isTop = new Vector3(this).translate(new Vector3(0, 1, 0)).getTileEntity(worldObj) instanceof TileEntityTesla;
|
||||||
boolean isBottom = new Vector3(this).translate(new Vector3(0, -1, 0)).getTileEntity(this.worldObj) instanceof TileEntityTesla;
|
boolean isBottom = new Vector3(this).translate(new Vector3(0, -1, 0)).getTileEntity(worldObj) instanceof TileEntityTesla;
|
||||||
|
|
||||||
if (isTop && isBottom)
|
if(isTop && isBottom)
|
||||||
{
|
{
|
||||||
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, 1, 3);
|
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 3);
|
||||||
}
|
}
|
||||||
else if (isBottom)
|
else if(isBottom)
|
||||||
{
|
{
|
||||||
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, 2, 3);
|
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 2, 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, 0, 3);
|
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,22 +421,22 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
*/
|
*/
|
||||||
public TileEntityTesla getTopTelsa()
|
public TileEntityTesla getTopTelsa()
|
||||||
{
|
{
|
||||||
if (this.topCache != null)
|
if(topCache != null)
|
||||||
{
|
{
|
||||||
return this.topCache;
|
return topCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connectedTeslas.clear();
|
connectedTeslas.clear();
|
||||||
Vector3 checkPosition = new Vector3(this);
|
Vector3 checkPosition = new Vector3(this);
|
||||||
TileEntityTesla returnTile = this;
|
TileEntityTesla returnTile = this;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
TileEntity t = checkPosition.getTileEntity(this.worldObj);
|
TileEntity t = checkPosition.getTileEntity(worldObj);
|
||||||
|
|
||||||
if (t instanceof TileEntityTesla)
|
if(t instanceof TileEntityTesla)
|
||||||
{
|
{
|
||||||
this.connectedTeslas.add((TileEntityTesla) t);
|
connectedTeslas.add((TileEntityTesla) t);
|
||||||
returnTile = (TileEntityTesla) t;
|
returnTile = (TileEntityTesla) t;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -447,7 +447,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
checkPosition.y++;
|
checkPosition.y++;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.topCache = returnTile;
|
topCache = returnTile;
|
||||||
return returnTile;
|
return returnTile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,9 +458,9 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
*/
|
*/
|
||||||
public TileEntityTesla getControllingTelsa()
|
public TileEntityTesla getControllingTelsa()
|
||||||
{
|
{
|
||||||
if (this.controlCache != null)
|
if(controlCache != null)
|
||||||
{
|
{
|
||||||
return this.controlCache;
|
return controlCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 checkPosition = new Vector3(this);
|
Vector3 checkPosition = new Vector3(this);
|
||||||
|
@ -468,9 +468,9 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
TileEntity t = checkPosition.getTileEntity(this.worldObj);
|
TileEntity t = checkPosition.getTileEntity(worldObj);
|
||||||
|
|
||||||
if (t instanceof TileEntityTesla)
|
if(t instanceof TileEntityTesla)
|
||||||
{
|
{
|
||||||
returnTile = (TileEntityTesla) t;
|
returnTile = (TileEntityTesla) t;
|
||||||
}
|
}
|
||||||
|
@ -482,7 +482,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
checkPosition.y--;
|
checkPosition.y--;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.controlCache = returnTile;
|
controlCache = returnTile;
|
||||||
return returnTile;
|
return returnTile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,16 +493,16 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
*/
|
*/
|
||||||
public int getHeight()
|
public int getHeight()
|
||||||
{
|
{
|
||||||
this.connectedTeslas.clear();
|
connectedTeslas.clear();
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
TileEntity t = new Vector3(this).translate(new Vector3(0, y, 0)).getTileEntity(this.worldObj);
|
TileEntity t = new Vector3(this).translate(new Vector3(0, y, 0)).getTileEntity(worldObj);
|
||||||
|
|
||||||
if (t instanceof TileEntityTesla)
|
if(t instanceof TileEntityTesla)
|
||||||
{
|
{
|
||||||
this.connectedTeslas.add((TileEntityTesla) t);
|
connectedTeslas.add((TileEntityTesla) t);
|
||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -535,19 +535,19 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
|
|
||||||
public void setDye(int id)
|
public void setDye(int id)
|
||||||
{
|
{
|
||||||
this.dyeID = id;
|
dyeID = id;
|
||||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean toggleReceive()
|
public boolean toggleReceive()
|
||||||
{
|
{
|
||||||
return this.canReceive = !this.canReceive;
|
return canReceive = !canReceive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean toggleEntityAttack()
|
public boolean toggleEntityAttack()
|
||||||
{
|
{
|
||||||
boolean returnBool = this.attackEntities = !this.attackEntities;
|
boolean returnBool = attackEntities = !attackEntities;
|
||||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
return returnBool;
|
return returnBool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,14 +558,14 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
this.dyeID = nbt.getInteger("dyeID");
|
dyeID = nbt.getInteger("dyeID");
|
||||||
this.canReceive = nbt.getBoolean("canReceive");
|
canReceive = nbt.getBoolean("canReceive");
|
||||||
this.attackEntities = nbt.getBoolean("attackEntities");
|
attackEntities = nbt.getBoolean("attackEntities");
|
||||||
|
|
||||||
if (nbt.hasKey("link_x") && nbt.hasKey("link_y") && nbt.hasKey("link_z"))
|
if(nbt.hasKey("linked"))
|
||||||
{
|
{
|
||||||
this.linked = new Vector3(nbt.getInteger("link_x"), nbt.getInteger("link_y"), nbt.getInteger("link_z"));
|
linked = Object3D.read(nbt.getCompoundTag("linked"));
|
||||||
this.linkDim = nbt.getInteger("linkDim");
|
linkDim = nbt.getInteger("linkDim");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,48 +576,46 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setInteger("dyeID", this.dyeID);
|
nbt.setInteger("dyeID", dyeID);
|
||||||
nbt.setBoolean("canReceive", this.canReceive);
|
nbt.setBoolean("canReceive", canReceive);
|
||||||
nbt.setBoolean("attackEntities", this.attackEntities);
|
nbt.setBoolean("attackEntities", attackEntities);
|
||||||
|
|
||||||
if (this.linked != null)
|
if(linked != null)
|
||||||
{
|
{
|
||||||
nbt.setInteger("link_x", (int) this.linked.x);
|
nbt.setCompoundTag("linked", linked.write(new NBTTagCompound()));
|
||||||
nbt.setInteger("link_y", (int) this.linked.y);
|
nbt.setInteger("linkDim", linkDim);
|
||||||
nbt.setInteger("link_z", (int) this.linked.z);
|
|
||||||
nbt.setInteger("linkDim", this.linkDim);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLink(Vector3 vector3, int dimID, boolean setOpponent)
|
public void setLink(Object3D obj, int dimID, boolean setOpponent)
|
||||||
{
|
{
|
||||||
if (!this.worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
World otherWorld = MinecraftServer.getServer().worldServerForDimension(this.linkDim);
|
World otherWorld = MinecraftServer.getServer().worldServerForDimension(linkDim);
|
||||||
|
|
||||||
if (setOpponent && this.linked != null && otherWorld != null)
|
if(setOpponent && linked != null && otherWorld != null)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = this.linked.getTileEntity(otherWorld);
|
TileEntity tileEntity = linked.getTileEntity(otherWorld);
|
||||||
|
|
||||||
if (tileEntity instanceof TileEntityTesla)
|
if(tileEntity instanceof TileEntityTesla)
|
||||||
{
|
{
|
||||||
((TileEntityTesla) tileEntity).setLink(null, this.linkDim, false);
|
((TileEntityTesla) tileEntity).setLink(null, linkDim, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.linked = vector3;
|
linked = obj;
|
||||||
this.linkDim = dimID;
|
linkDim = dimID;
|
||||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
|
|
||||||
World newOtherWorld = MinecraftServer.getServer().worldServerForDimension(this.linkDim);
|
World newOtherWorld = MinecraftServer.getServer().worldServerForDimension(linkDim);
|
||||||
|
|
||||||
if (setOpponent && newOtherWorld != null && this.linked != null)
|
if(setOpponent && newOtherWorld != null && linked != null)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = this.linked.getTileEntity(newOtherWorld);
|
TileEntity tileEntity = linked.getTileEntity(newOtherWorld);
|
||||||
|
|
||||||
if (tileEntity instanceof TileEntityTesla)
|
if(tileEntity instanceof TileEntityTesla)
|
||||||
{
|
{
|
||||||
((TileEntityTesla) tileEntity).setLink(new Vector3(this), this.worldObj.provider.dimensionId, false);
|
((TileEntityTesla) tileEntity).setLink(Object3D.get(this), worldObj.provider.dimensionId, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,9 +624,9 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
@Override
|
@Override
|
||||||
public float getRequest(ForgeDirection direction)
|
public float getRequest(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
if (direction != ForgeDirection.DOWN)
|
if(direction != ForgeDirection.DOWN)
|
||||||
{
|
{
|
||||||
return this.getMaxEnergyStored() - this.getEnergyStored();
|
return getMaxEnergyStored() - getEnergyStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -637,9 +635,9 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
||||||
@Override
|
@Override
|
||||||
public float getProvide(ForgeDirection direction)
|
public float getProvide(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
if (this.isController() && direction == ForgeDirection.DOWN)
|
if(isController() && direction == ForgeDirection.DOWN)
|
||||||
{
|
{
|
||||||
return this.getEnergyStored();
|
return getEnergyStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue