Merge branch 'EntityRefactor'
Conflicts: buildcraft_client/net/minecraft/src/buildcraft/core/RenderLaser.java common/net/minecraft/src/BuildCraftCore.java common/net/minecraft/src/buildcraft/builders/TileBuilder.java common/net/minecraft/src/buildcraft/builders/TilePathMarker.java common/net/minecraft/src/buildcraft/core/EntityEnergyLaser.java common/net/minecraft/src/buildcraft/core/EntityLaser.java common/net/minecraft/src/buildcraft/core/EntityRobot.java common/net/minecraft/src/buildcraft/factory/EntityMechanicalArm.java common/net/minecraft/src/buildcraft/factory/TileQuarry.java common/net/minecraft/src/buildcraft/silicon/TileLaser.java
This commit is contained in:
commit
d9a34f0ab1
10 changed files with 287 additions and 154 deletions
|
@ -14,6 +14,7 @@ public class RenderLaser extends Render {
|
|||
private ModelRenderer box;
|
||||
|
||||
public RenderLaser() {
|
||||
|
||||
box = new ModelRenderer(model, 0, 0);
|
||||
box.addBox(0, -0.5F, -0.5F, 16, 1, 1);
|
||||
box.rotationPointX = 0;
|
||||
|
@ -23,14 +24,14 @@ public class RenderLaser extends Render {
|
|||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float f, float f1) {
|
||||
|
||||
doRender((EntityLaser) entity, x, y, z, f, f1);
|
||||
|
||||
entity.setAngles(45, 180);
|
||||
}
|
||||
|
||||
private void doRender(EntityLaser laser, double x, double y, double z, float f, float f1) {
|
||||
|
||||
if (laser.hidden)
|
||||
|
||||
if (!laser.isVisible())
|
||||
return;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.src.buildcraft.core.CoreProxy;
|
|||
import net.minecraft.src.buildcraft.core.DefaultActionProvider;
|
||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.core.DefaultTriggerProvider;
|
||||
import net.minecraft.src.buildcraft.core.EntityEnergyLaser;
|
||||
import net.minecraft.src.buildcraft.core.EntityLaser;
|
||||
import net.minecraft.src.buildcraft.core.EntityRobot;
|
||||
import net.minecraft.src.buildcraft.core.ItemBuildCraft;
|
||||
|
@ -127,11 +128,11 @@ public class BuildCraftCore {
|
|||
public static void load() {
|
||||
|
||||
MinecraftForge.registerConnectionHandler(new ConnectionHandler());
|
||||
|
||||
// MinecraftForge.registerEntity(EntityBlock.class,
|
||||
// mod_BuildCraftCore.instance, EntityIds.BLOCK, 64, 10, true);
|
||||
|
||||
//MinecraftForge.registerEntity(EntityBlock.class, mod_BuildCraftCore.instance, EntityIds.BLOCK, 64, 10, true);
|
||||
MinecraftForge.registerEntity(EntityRobot.class, mod_BuildCraftCore.instance, EntityIds.ROBOT, 64, 3, true);
|
||||
MinecraftForge.registerEntity(EntityLaser.class, mod_BuildCraftCore.instance, EntityIds.LASER, 64, 10, false);
|
||||
MinecraftForge.registerEntity(EntityLaser.class, mod_BuildCraftCore.instance, EntityIds.LASER, 64, 3, false);
|
||||
MinecraftForge.registerEntity(EntityEnergyLaser.class, mod_BuildCraftCore.instance, EntityIds.LASER, 64, 3, false);
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.minecraft.src.buildcraft.api.APIProxy;
|
|||
import net.minecraft.src.buildcraft.api.IPowerReceptor;
|
||||
import net.minecraft.src.buildcraft.api.LaserKind;
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
import net.minecraft.src.buildcraft.api.Position;
|
||||
import net.minecraft.src.buildcraft.api.PowerFramework;
|
||||
import net.minecraft.src.buildcraft.api.PowerProvider;
|
||||
import net.minecraft.src.buildcraft.api.TileNetworkData;
|
||||
|
@ -228,10 +229,12 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
|
||||
for (BlockIndex b : path) {
|
||||
if (previous != null) {
|
||||
EntityLaser laser = new EntityLaser(worldObj);
|
||||
|
||||
laser.setPositions(previous.i + 0.5, previous.j + 0.5, previous.k + 0.5, b.i + 0.5, b.j + 0.5, b.k + 0.5);
|
||||
laser.setTexture(DefaultProps.TEXTURE_PATH_ENTITIES + "/stripes.png");
|
||||
|
||||
EntityLaser laser = new EntityLaser(worldObj,
|
||||
new Position(previous.i + 0.5, previous.j + 0.5, previous.k + 0.5),
|
||||
new Position(b.i + 0.5, b.j + 0.5, b.k + 0.5));
|
||||
|
||||
laser.setTexture("/net/minecraft/src/buildcraft/core/gui/stripes.png");
|
||||
worldObj.spawnEntityInWorld(laser);
|
||||
pathLasers.add(laser);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.util.TreeSet;
|
|||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.buildcraft.api.APIProxy;
|
||||
import net.minecraft.src.buildcraft.api.Position;
|
||||
import net.minecraft.src.buildcraft.core.BlockIndex;
|
||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.core.EntityLaser;
|
||||
|
@ -39,12 +41,18 @@ public class TilePathMarker extends TileMarker {
|
|||
links[1] = marker;
|
||||
}
|
||||
}
|
||||
|
||||
public void createLaserAndConnect(TilePathMarker pathMarker) {
|
||||
EntityLaser laser = new EntityLaser(worldObj);
|
||||
laser.setPositions(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, pathMarker.xCoord + 0.5, pathMarker.yCoord + 0.5,
|
||||
pathMarker.zCoord + 0.5);
|
||||
laser.setTexture(DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_1.png");
|
||||
|
||||
public void createLaserAndConnect (TilePathMarker pathMarker) {
|
||||
|
||||
if (APIProxy.isClient(worldObj))
|
||||
return;
|
||||
|
||||
EntityLaser laser = new EntityLaser(worldObj,
|
||||
new Position(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5),
|
||||
new Position(pathMarker.xCoord + 0.5, pathMarker.yCoord + 0.5, pathMarker.zCoord + 0.5));
|
||||
laser.show();
|
||||
|
||||
laser.setTexture("/net/minecraft/src/buildcraft/core/gui/laser_1.png");
|
||||
worldObj.spawnEntityInWorld(laser);
|
||||
|
||||
connect(pathMarker, laser);
|
||||
|
|
|
@ -10,17 +10,30 @@
|
|||
package net.minecraft.src.buildcraft.core;
|
||||
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.buildcraft.api.Position;
|
||||
|
||||
public class EntityEnergyLaser extends EntityLaser {
|
||||
|
||||
public int displayStage = 0;
|
||||
|
||||
private float power[] = new float[100];
|
||||
private final float power [] = new float [100];
|
||||
private int powerIndex = 0;
|
||||
public float powerAverage = 0;
|
||||
|
||||
public EntityEnergyLaser(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityEnergyLaser(World world, Position head, Position tail) {
|
||||
super(world, head, tail);
|
||||
|
||||
for (int j = 0; j < power.length; ++j)
|
||||
power [j] = 0;
|
||||
}
|
||||
|
||||
public void pushPower(float p) {
|
||||
powerAverage -= power[powerIndex];
|
||||
public void pushPower (float p) {
|
||||
|
||||
powerAverage -= power [powerIndex];
|
||||
powerAverage += p;
|
||||
power[powerIndex] = p;
|
||||
powerIndex++;
|
||||
|
@ -33,17 +46,11 @@ public class EntityEnergyLaser extends EntityLaser {
|
|||
return powerAverage / power.length;
|
||||
}
|
||||
|
||||
public EntityEnergyLaser(World world) {
|
||||
super(world);
|
||||
|
||||
for (int j = 0; j < power.length; ++j)
|
||||
power[j] = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTexture() {
|
||||
if (getPowerAverage() <= 1.0)
|
||||
return DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_1.png";
|
||||
public String getTexture () {
|
||||
|
||||
if (getPowerAverage () <= 1.0)
|
||||
return "/net/minecraft/src/buildcraft/core/gui/laser_1.png";
|
||||
else if (getPowerAverage() <= 2.0)
|
||||
return DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_2.png";
|
||||
else if (getPowerAverage() <= 3.0)
|
||||
|
|
|
@ -9,104 +9,191 @@
|
|||
|
||||
package net.minecraft.src.buildcraft.core;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.buildcraft.api.APIProxy;
|
||||
import net.minecraft.src.buildcraft.api.Position;
|
||||
import net.minecraft.src.forge.ISpawnHandler;
|
||||
|
||||
public class EntityLaser extends Entity {
|
||||
public class EntityLaser extends Entity implements ISpawnHandler {
|
||||
|
||||
protected Position head, tail;
|
||||
|
||||
public double x1, y1, z1, x2, y2, z2;
|
||||
|
||||
boolean hidden = false;
|
||||
|
||||
public String texture;
|
||||
protected double renderSize = 0;
|
||||
protected double angleY = 0;
|
||||
protected double angleZ = 0;
|
||||
protected String texture;
|
||||
|
||||
double lastY;
|
||||
|
||||
public EntityLaser(World world) {
|
||||
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityLaser(World world, Position head, Position tail) {
|
||||
|
||||
super(world);
|
||||
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
|
||||
preventEntitySpawning = false;
|
||||
noClip = true;
|
||||
isImmuneToFire = true;
|
||||
|
||||
setPosition(x1, y1, z1);
|
||||
setPosition(head.x, head.y, head.z);
|
||||
setSize(10, 10);
|
||||
|
||||
dataWatcher.addObject(8 , Integer.valueOf(encodeDouble(head.x)));
|
||||
dataWatcher.addObject(9 , Integer.valueOf(encodeDouble(head.y)));
|
||||
dataWatcher.addObject(10, Integer.valueOf(encodeDouble(head.z)));
|
||||
dataWatcher.addObject(11, Integer.valueOf(encodeDouble(tail.x)));
|
||||
dataWatcher.addObject(12, Integer.valueOf(encodeDouble(tail.y)));
|
||||
dataWatcher.addObject(13, Integer.valueOf(encodeDouble(tail.z)));
|
||||
|
||||
dataWatcher.addObject(14, Byte.valueOf((byte) 0));
|
||||
|
||||
lastY = head.y;
|
||||
}
|
||||
|
||||
public void setPositions(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.z1 = z1;
|
||||
@Override
|
||||
public void writeSpawnData(DataOutputStream data) throws IOException {
|
||||
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
this.z2 = z2;
|
||||
data.writeDouble(head.x);
|
||||
data.writeDouble(head.y);
|
||||
data.writeDouble(head.z);
|
||||
data.writeDouble(tail.x);
|
||||
data.writeDouble(tail.y);
|
||||
data.writeDouble(tail.z);
|
||||
}
|
||||
|
||||
setPosition(x1, y1, z1);
|
||||
@Override
|
||||
public void readSpawnData(DataInputStream data) throws IOException {
|
||||
|
||||
head = new Position(data.readDouble(), data.readDouble(), data.readDouble());
|
||||
tail = new Position(data.readDouble(), data.readDouble(), data.readDouble());
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
|
||||
if (head == null || tail == null)
|
||||
return;
|
||||
|
||||
if (APIProxy.isClient(worldObj)) {
|
||||
updateData();
|
||||
}
|
||||
|
||||
boundingBox.minX = Math.min(head.x, tail.x);
|
||||
boundingBox.minY = Math.min(head.y, tail.y);
|
||||
boundingBox.minZ = Math.min(head.z, tail.z);
|
||||
|
||||
boundingBox.maxX = Math.max(head.x, tail.x);
|
||||
boundingBox.maxY = Math.max(head.y, tail.y);
|
||||
boundingBox.maxZ = Math.max(head.z, tail.z);
|
||||
|
||||
if (!APIProxy.isClient(worldObj)) {
|
||||
|
||||
boundingBox.minX--;
|
||||
boundingBox.minY--;
|
||||
boundingBox.minZ--;
|
||||
|
||||
boundingBox.maxX++;
|
||||
boundingBox.maxY++;
|
||||
boundingBox.maxZ++;
|
||||
}
|
||||
|
||||
double dx = head.x - tail.x;
|
||||
double dy = head.y - tail.y;
|
||||
double dz = head.z - tail.z;
|
||||
|
||||
renderSize = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
angleZ = 360 - (Math.atan2(dz, dx) * 180.0 / Math.PI + 180.0);
|
||||
dx = Math.sqrt(renderSize * renderSize - dy * dy);
|
||||
angleY = -Math.atan2(dy, dx) * 180 / Math.PI;
|
||||
}
|
||||
|
||||
protected void updateData() {
|
||||
|
||||
head.x = decodeDouble(dataWatcher.getWatchableObjectInt(8));
|
||||
head.y = decodeDouble(dataWatcher.getWatchableObjectInt(9));
|
||||
head.z = decodeDouble(dataWatcher.getWatchableObjectInt(10));
|
||||
tail.x = decodeDouble(dataWatcher.getWatchableObjectInt(11));
|
||||
tail.y = decodeDouble(dataWatcher.getWatchableObjectInt(12));
|
||||
tail.z = decodeDouble(dataWatcher.getWatchableObjectInt(13));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double x, double y, double z) {
|
||||
|
||||
posX = x;
|
||||
posY = y;
|
||||
posZ = z;
|
||||
}
|
||||
|
||||
public void setPositions(Position head, Position tail) {
|
||||
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
|
||||
setPosition(head.x, head.y, head.z);
|
||||
|
||||
dataWatcher.updateObject(8 , Integer.valueOf(encodeDouble(head.x)));
|
||||
dataWatcher.updateObject(9 , Integer.valueOf(encodeDouble(head.y)));
|
||||
dataWatcher.updateObject(10, Integer.valueOf(encodeDouble(head.z)));
|
||||
dataWatcher.updateObject(11, Integer.valueOf(encodeDouble(tail.x)));
|
||||
dataWatcher.updateObject(12, Integer.valueOf(encodeDouble(tail.y)));
|
||||
dataWatcher.updateObject(13, Integer.valueOf(encodeDouble(tail.z)));
|
||||
}
|
||||
|
||||
public void show() {
|
||||
dataWatcher.updateObject(14, Byte.valueOf((byte) 1));
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
dataWatcher.updateObject(14, Byte.valueOf((byte) 0));
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return dataWatcher.getWatchableObjectByte(14) == 0 ? false : true;
|
||||
}
|
||||
|
||||
public void setTexture(String texture) {
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double d, double d1, double d2) {
|
||||
|
||||
posX = d;
|
||||
posY = d1;
|
||||
posZ = d2;
|
||||
|
||||
boundingBox.minX = x1 <= x2 ? x1 : x2;
|
||||
boundingBox.minY = y1 <= y2 ? y1 : y2;
|
||||
boundingBox.minZ = z1 <= z2 ? z1 : z2;
|
||||
|
||||
boundingBox.maxX = x1 <= x2 ? x2 : x1;
|
||||
boundingBox.maxY = y1 <= y2 ? y2 : y1;
|
||||
boundingBox.maxZ = z1 <= z2 ? z2 : z1;
|
||||
|
||||
boundingBox.minX--;
|
||||
boundingBox.minY--;
|
||||
boundingBox.minZ--;
|
||||
|
||||
boundingBox.maxX++;
|
||||
boundingBox.maxY++;
|
||||
boundingBox.maxZ++;
|
||||
|
||||
updateGraphicData();
|
||||
}
|
||||
|
||||
double renderSize = 0;
|
||||
double angleY = 0;
|
||||
double angleZ = 0;
|
||||
|
||||
public void updateGraphicData() {
|
||||
|
||||
double dx = x1 - x2;
|
||||
double dy = y1 - y2;
|
||||
double dz = z1 - z2;
|
||||
|
||||
renderSize = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
angleZ = 360 - (Math.atan2(dz, dx) * 180.0 / Math.PI + 180.0);
|
||||
|
||||
dx = Math.sqrt(renderSize * renderSize - dy * dy);
|
||||
|
||||
angleY = -Math.atan2(dy, dx) * 180 / Math.PI;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {}
|
||||
|
||||
public String getTexture() {
|
||||
return texture;
|
||||
}
|
||||
|
||||
public int getBrightnessForRender(float par1) {
|
||||
return 210;
|
||||
|
||||
private int encodeDouble(double d) {
|
||||
return (int) (d * 8000);
|
||||
}
|
||||
|
||||
private double decodeDouble(int i) {
|
||||
return (i / 8000D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package net.minecraft.src.buildcraft.core;
|
|||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -23,6 +24,7 @@ import net.minecraft.src.World;
|
|||
import net.minecraft.src.buildcraft.api.APIProxy;
|
||||
import net.minecraft.src.buildcraft.api.BptSlotInfo;
|
||||
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
|
||||
import net.minecraft.src.buildcraft.api.Position;
|
||||
import net.minecraft.src.buildcraft.core.BptSlot.Mode;
|
||||
import net.minecraft.src.forge.ISpawnHandler;
|
||||
|
||||
|
@ -76,11 +78,12 @@ public class EntityRobot extends Entity implements ISpawnHandler {
|
|||
motionZ = 0;
|
||||
|
||||
setPosition(destX, destY, destZ);
|
||||
laser = new EntityEnergyLaser(worldObj);
|
||||
laser.hidden = true;
|
||||
laser.setPositions(posX, posY, posZ, posX, posY, posZ);
|
||||
|
||||
worldObj.spawnEntityInWorld(laser);
|
||||
if (!APIProxy.isClient(worldObj)) {
|
||||
|
||||
laser = new EntityEnergyLaser(worldObj, new Position(posX, posY, posZ), new Position(posX, posY, posZ));
|
||||
worldObj.spawnEntityInWorld(laser);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,20 +130,19 @@ public class EntityRobot extends Entity implements ISpawnHandler {
|
|||
|
||||
protected void move() {
|
||||
|
||||
if (!reachedDesination()) {
|
||||
|
||||
setPosition(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
|
||||
return;
|
||||
}
|
||||
//System.out.println("move: " + new Position(motionX, motionY, motionZ));
|
||||
setPosition(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
|
||||
if (APIProxy.isClient(worldObj))
|
||||
return;
|
||||
|
||||
BlockIndex newDesination = getNewDesination();
|
||||
if (newDesination != null) {
|
||||
if (reachedDesination()) {
|
||||
|
||||
setDestination(newDesination.i, newDesination.j, newDesination.k);
|
||||
BlockIndex newDesination = getNewDesination();
|
||||
if (newDesination != null) {
|
||||
setDestination(newDesination.i, newDesination.j, newDesination.k);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -178,9 +180,11 @@ public class EntityRobot extends Entity implements ISpawnHandler {
|
|||
destZ = z;
|
||||
|
||||
// TODO: apply power modifier
|
||||
motionX = (destX - posX) / 75 * 1;
|
||||
motionY = (destY - posY) / 75 * 1;
|
||||
motionZ = (destZ - posZ) / 75 * 1;
|
||||
motionX = new BigDecimal((float) (destX - posX) / 75 * 1).setScale(4, BigDecimal.ROUND_HALF_EVEN).doubleValue();
|
||||
motionY = new BigDecimal((float) (destY - posY) / 75 * 1).setScale(4, BigDecimal.ROUND_HALF_EVEN).doubleValue();
|
||||
motionZ = new BigDecimal((float) (destZ - posZ) / 75 * 1).setScale(4, BigDecimal.ROUND_HALF_EVEN).doubleValue();
|
||||
|
||||
//System.out.println("setDest: " + new Position(motionX, motionY, motionZ));
|
||||
}
|
||||
|
||||
protected boolean reachedDesination() {
|
||||
|
@ -195,7 +199,7 @@ public class EntityRobot extends Entity implements ISpawnHandler {
|
|||
|
||||
updateWait();
|
||||
|
||||
// TODO: rewrite
|
||||
// TODO: possible rewrite
|
||||
if (targets.size() > 0) {
|
||||
|
||||
Action a = targets.getFirst();
|
||||
|
@ -212,8 +216,9 @@ public class EntityRobot extends Entity implements ISpawnHandler {
|
|||
} else if (target.stackToUse != null) {
|
||||
|
||||
worldObj.setBlockWithNotify(target.x, target.y, target.z, 0);
|
||||
target.stackToUse.getItem().onItemUse(target.stackToUse, BuildCraftAPI.getBuildCraftPlayer(worldObj),
|
||||
worldObj, target.x, target.y - 1, target.z, 1);
|
||||
target.stackToUse.getItem().onItemUse(target.stackToUse,
|
||||
BuildCraftAPI.getBuildCraftPlayer(worldObj), worldObj, target.x, target.y - 1,
|
||||
target.z, 1);
|
||||
} else {
|
||||
|
||||
try {
|
||||
|
@ -232,8 +237,7 @@ public class EntityRobot extends Entity implements ISpawnHandler {
|
|||
a.builder.postProcessing(worldObj);
|
||||
targets.pop();
|
||||
}
|
||||
} else
|
||||
laser.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateWait() {
|
||||
|
@ -246,19 +250,22 @@ public class EntityRobot extends Entity implements ISpawnHandler {
|
|||
}
|
||||
|
||||
private void updateLaser() {
|
||||
|
||||
BptSlotInfo target = null;
|
||||
|
||||
|
||||
if (APIProxy.isClient(worldObj))
|
||||
return;
|
||||
|
||||
if (targets.size() > 0) {
|
||||
|
||||
Action a = targets.getFirst();
|
||||
target = a.slot;
|
||||
BptSlotInfo target = a.slot;
|
||||
|
||||
laser.setPositions(new Position(posX, posY, posZ), new Position(target.x + 0.5, target.y + 0.5, target.z + 0.5));
|
||||
laser.show();
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
laser.setPositions(posX, posY, posZ, target.x + 0.5, target.y + 0.5, target.z + 0.5);
|
||||
else
|
||||
laser.hidden = true;
|
||||
|
||||
else {
|
||||
laser.hide();
|
||||
}
|
||||
|
||||
laser.pushPower(((float) targets.size()) / ((float) MAX_TARGETS) * 4F);
|
||||
}
|
||||
|
||||
|
@ -266,7 +273,7 @@ public class EntityRobot extends Entity implements ISpawnHandler {
|
|||
|
||||
if (slot != null) {
|
||||
targets.add(new Action(slot, context));
|
||||
laser.hidden = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ package net.minecraft.src.buildcraft.factory;
|
|||
import net.minecraft.src.BuildCraftFactory;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.buildcraft.core.EntityBlock;
|
||||
|
||||
|
@ -31,12 +32,14 @@ public class EntityMechanicalArm extends Entity {
|
|||
public IArmListener listener;
|
||||
boolean inProgressionXZ = false;
|
||||
boolean inProgressionY = false;
|
||||
|
||||
|
||||
protected TileEntity parent;
|
||||
|
||||
public EntityMechanicalArm(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityMechanicalArm(World world, double i, double j, double k, double width, double height) {
|
||||
public EntityMechanicalArm(World world, double i, double j, double k, double width, double height, TileEntity parent) {
|
||||
super(world);
|
||||
|
||||
setPosition(i, j, k);
|
||||
|
@ -78,6 +81,8 @@ public class EntityMechanicalArm extends Entity {
|
|||
head.shadowSize = 1.0F;
|
||||
|
||||
updatePosition();
|
||||
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,6 +189,12 @@ public class EntityMechanicalArm extends Entity {
|
|||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
|
||||
if (parent != null && worldObj.getBlockTileEntity(parent.xCoord, parent.yCoord, parent.zCoord) != parent) {
|
||||
setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
if (speed > 0) {
|
||||
doMove(speed);
|
||||
}
|
||||
|
|
|
@ -115,9 +115,11 @@ public class TileQuarry extends TileMachine implements IArmListener, IMachine, I
|
|||
private boolean loadDefaultBoundaries = false;
|
||||
|
||||
private void createArm() {
|
||||
arm = new EntityMechanicalArm(worldObj, box.xMin + Utils.pipeMaxPos, yCoord + bluePrintBuilder.bluePrint.sizeY - 1
|
||||
+ Utils.pipeMinPos, box.zMin + Utils.pipeMaxPos, bluePrintBuilder.bluePrint.sizeX - 2 + Utils.pipeMinPos * 2,
|
||||
bluePrintBuilder.bluePrint.sizeZ - 2 + Utils.pipeMinPos * 2);
|
||||
arm = new EntityMechanicalArm(worldObj, box.xMin + Utils.pipeMaxPos,
|
||||
yCoord + bluePrintBuilder.bluePrint.sizeY - 1
|
||||
+ Utils.pipeMinPos, box.zMin + Utils.pipeMaxPos,
|
||||
bluePrintBuilder.bluePrint.sizeX - 2 + Utils.pipeMinPos * 2,
|
||||
bluePrintBuilder.bluePrint.sizeZ - 2 + Utils.pipeMinPos * 2, this);
|
||||
|
||||
arm.listener = this;
|
||||
loadArm = true;
|
||||
|
@ -159,11 +161,7 @@ public class TileQuarry extends TileMachine implements IArmListener, IMachine, I
|
|||
return;
|
||||
}
|
||||
|
||||
if (inProcess) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isDigging) {
|
||||
if (inProcess || !isDigging) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -440,8 +438,8 @@ public class TileQuarry extends TileMachine implements IArmListener, IMachine, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
destroy();
|
||||
public void invalidate () {
|
||||
destroy ();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,8 +13,10 @@ import java.util.LinkedList;
|
|||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.buildcraft.api.APIProxy;
|
||||
import net.minecraft.src.buildcraft.api.IPowerReceptor;
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
import net.minecraft.src.buildcraft.api.Position;
|
||||
import net.minecraft.src.buildcraft.api.PowerFramework;
|
||||
import net.minecraft.src.buildcraft.api.PowerProvider;
|
||||
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
|
||||
|
@ -25,10 +27,10 @@ import net.minecraft.src.buildcraft.factory.TileAssemblyTable;
|
|||
public class TileLaser extends TileEntity implements IPowerReceptor {
|
||||
|
||||
private EntityEnergyLaser laser = null;
|
||||
|
||||
private SafeTimeTracker laserTickTracker = new SafeTimeTracker();
|
||||
private SafeTimeTracker searchTracker = new SafeTimeTracker();
|
||||
|
||||
|
||||
private final SafeTimeTracker laserTickTracker = new SafeTimeTracker();
|
||||
private final SafeTimeTracker searchTracker = new SafeTimeTracker();
|
||||
|
||||
private TileAssemblyTable assemblyTable;
|
||||
|
||||
private PowerProvider powerProvider;
|
||||
|
@ -135,10 +137,14 @@ public class TileLaser extends TileEntity implements IPowerReceptor {
|
|||
BlockIndex b = targets.get(worldObj.rand.nextInt(targets.size()));
|
||||
assemblyTable = (TileAssemblyTable) worldObj.getBlockTileEntity(b.i, b.j, b.k);
|
||||
|
||||
if (APIProxy.isClient(worldObj))
|
||||
return;
|
||||
|
||||
if (laser == null) {
|
||||
laser = new EntityEnergyLaser(worldObj);
|
||||
laser = new EntityEnergyLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord, zCoord));
|
||||
setLaserPosition();
|
||||
worldObj.spawnEntityInWorld(laser);
|
||||
laser.show();
|
||||
} else {
|
||||
setLaserPosition();
|
||||
}
|
||||
|
@ -168,10 +174,14 @@ public class TileLaser extends TileEntity implements IPowerReceptor {
|
|||
pz = 0.3;
|
||||
break;
|
||||
}
|
||||
|
||||
laser.setPositions(xCoord + 0.5 + px, yCoord + 0.5 + py, zCoord + 0.5 + pz,
|
||||
assemblyTable.xCoord + 0.475 + (worldObj.rand.nextFloat() - 0.5) / 5F, assemblyTable.yCoord + 9F / 16F,
|
||||
|
||||
Position head = new Position(xCoord + 0.5 + px, yCoord + 0.5 + py, zCoord + 0.5 + pz);
|
||||
Position tail = new Position(
|
||||
assemblyTable.xCoord + 0.475 + (worldObj.rand.nextFloat() - 0.5) / 5F,
|
||||
assemblyTable.yCoord + 9F / 16F,
|
||||
assemblyTable.zCoord + 0.475 + (worldObj.rand.nextFloat() - 0.5) / 5F);
|
||||
|
||||
laser.setPositions(head, tail);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue