Merge branch '6.5.x' of github.com:BuildCraft/BuildCraft into 6.5.x
This commit is contained in:
commit
64879212fe
6 changed files with 124 additions and 32 deletions
|
@ -14,9 +14,11 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import cofh.api.energy.IEnergyStorage;
|
||||
|
||||
import buildcraft.api.boards.RedstoneBoardRobot;
|
||||
import buildcraft.api.core.IZone;
|
||||
|
||||
|
@ -41,8 +43,14 @@ public abstract class EntityRobotBase extends EntityLiving implements IInventory
|
|||
|
||||
public abstract RedstoneBoardRobot getBoard();
|
||||
|
||||
public abstract void aimItemAt(float yaw, float pitch);
|
||||
|
||||
public abstract void aimItemAt(int x, int y, int z);
|
||||
|
||||
public abstract float getAimYaw();
|
||||
|
||||
public abstract float getAimPitch();
|
||||
|
||||
public abstract int getEnergy();
|
||||
|
||||
public abstract IEnergyStorage getBattery();
|
||||
|
|
|
@ -200,7 +200,7 @@ public class ItemList extends ItemBuildCraft implements IList {
|
|||
return oreMatch(stacks[0], item);
|
||||
} else {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack != null && StackHelper.isMatchingItem(stacks[0], item, true, false)) {
|
||||
if (stack != null && StackHelper.isMatchingItem(stack, item, true, false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,13 +30,16 @@ import net.minecraft.util.AxisAlignedBB;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
@ -98,6 +101,7 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
|
||||
public ItemStack itemInUse;
|
||||
public float itemAngle1 = 0;
|
||||
public float renderItemAngle1 = 0;
|
||||
public float itemAngle2 = 0;
|
||||
public boolean itemActive = false;
|
||||
public float itemActiveStage = 0;
|
||||
|
@ -290,6 +294,7 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
|
||||
if (worldObj.isRemote) {
|
||||
updateDataClient();
|
||||
updateRotationYaw(60.0f);
|
||||
updateEnergyFX();
|
||||
}
|
||||
|
||||
|
@ -343,6 +348,10 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
this.worldObj.theProfiler.endSection();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateEntityActionState() {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateEnergyFX() {
|
||||
energyFX += energySpendPerCycle;
|
||||
|
@ -830,35 +839,78 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void aimItemAt(int x, int y, int z) {
|
||||
itemAngle1 = (float) Math.atan2(z - Math.floor(posZ),
|
||||
x - Math.floor(posX));
|
||||
public float getAimYaw() {
|
||||
return itemAngle1;
|
||||
}
|
||||
|
||||
itemAngle2 = 0;
|
||||
@Override
|
||||
public float getAimPitch() {
|
||||
return itemAngle2;
|
||||
}
|
||||
|
||||
if (Math.floor(posY) < y) {
|
||||
itemAngle2 = (float) -Math.PI / 4;
|
||||
|
||||
if (Math.floor(posX) == x && Math.floor(posZ) == z) {
|
||||
itemAngle2 -= (float) Math.PI / 4;
|
||||
}
|
||||
} else if (Math.floor(posY) > y) {
|
||||
itemAngle2 = (float) Math.PI / 2;
|
||||
|
||||
if (Math.floor(posX) == x && Math.floor(posZ) == z) {
|
||||
itemAngle2 += (float) Math.PI / 4;
|
||||
}
|
||||
}
|
||||
|
||||
int xComp = (int) Math.floor(posX);
|
||||
int yComp = (int) Math.floor(posY);
|
||||
int zComp = (int) Math.floor(posZ);
|
||||
|
||||
setSteamDirection(xComp - x, yComp - y, zComp - z);
|
||||
@Override
|
||||
public void aimItemAt(float yaw, float pitch) {
|
||||
itemAngle1 = yaw;
|
||||
itemAngle2 = pitch;
|
||||
|
||||
updateDataServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void aimItemAt(int x, int y, int z) {
|
||||
int deltaX = x - (int) Math.floor(posX);
|
||||
int deltaY = y - (int) Math.floor(posY);
|
||||
int deltaZ = z - (int) Math.floor(posZ);
|
||||
|
||||
if (deltaX != 0 || deltaZ != 0) {
|
||||
itemAngle1 = (float) (Math.atan2(deltaZ, deltaX) * 180f / Math.PI) + 180f;
|
||||
}
|
||||
double d3 = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ);
|
||||
itemAngle2 = (float) (-(Math.atan2(deltaY, d3) * 180.0D / Math.PI));
|
||||
|
||||
setSteamDirection(deltaX, deltaY, deltaZ);
|
||||
|
||||
updateDataServer();
|
||||
}
|
||||
|
||||
private void updateRotationYaw(float maxStep) {
|
||||
float step = MathHelper.wrapAngleTo180_float(itemAngle1 - rotationYaw);
|
||||
|
||||
if (step > maxStep) {
|
||||
step = maxStep;
|
||||
}
|
||||
|
||||
if (step < -maxStep) {
|
||||
step = -maxStep;
|
||||
}
|
||||
|
||||
rotationYaw = rotationYaw + step;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float func_110146_f(float targetYaw, float dist) {
|
||||
if (worldObj.isRemote) {
|
||||
float f2 = MathHelper.wrapAngleTo180_float(this.rotationYaw - this.renderYawOffset);
|
||||
this.renderYawOffset += f2 * 0.5F;
|
||||
float f3 = MathHelper.wrapAngleTo180_float(this.rotationYaw - this.renderYawOffset);
|
||||
boolean flag = f3 < -90.0F || f3 >= 90.0F;
|
||||
|
||||
this.renderYawOffset = this.rotationYaw - f3;
|
||||
|
||||
if (f3 * f3 > 2500.0F) {
|
||||
this.renderYawOffset += f3 * 0.2F;
|
||||
}
|
||||
|
||||
float newDist = dist;
|
||||
if (flag) {
|
||||
newDist *= -1.0F;
|
||||
}
|
||||
|
||||
return newDist;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemActive(final boolean isActive) {
|
||||
if (isActive != itemActive) {
|
||||
|
|
|
@ -38,7 +38,6 @@ public class AIRobotGotoBlock extends AIRobotGoto {
|
|||
finalX = x;
|
||||
finalY = y;
|
||||
finalZ = z;
|
||||
robot.aimItemAt((int) Math.floor(finalX), (int) Math.floor(finalY), (int) Math.floor(finalZ));
|
||||
}
|
||||
|
||||
public AIRobotGotoBlock(EntityRobotBase robot, int x, int y, int z, double iMaxDistance) {
|
||||
|
@ -53,7 +52,6 @@ public class AIRobotGotoBlock extends AIRobotGoto {
|
|||
finalX = path.getLast().x;
|
||||
finalY = path.getLast().y;
|
||||
finalZ = path.getLast().z;
|
||||
robot.aimItemAt((int) Math.floor(finalX), (int) Math.floor(finalY), (int) Math.floor(finalZ));
|
||||
setNextInPath();
|
||||
}
|
||||
|
||||
|
@ -118,6 +116,7 @@ public class AIRobotGotoBlock extends AIRobotGoto {
|
|||
BlockIndex next = path.getFirst();
|
||||
setDestination(robot, next.x + 0.5F, next.y + 0.5F, next.z + 0.5F);
|
||||
prevDistance = Double.MAX_VALUE;
|
||||
robot.aimItemAt(next.x, next.y, next.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
package buildcraft.robotics.ai;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.core.BlockIndex;
|
||||
|
@ -69,6 +71,12 @@ public class AIRobotGotoStation extends AIRobot {
|
|||
stationIndex.z + 0.5F + stationSide.offsetZ * 0.5F));
|
||||
} else {
|
||||
setSuccess(true);
|
||||
if (stationSide.offsetY == 0) {
|
||||
robot.aimItemAt(stationIndex.x + 2 * stationSide.offsetX, stationIndex.y,
|
||||
stationIndex.z + 2 * stationSide.offsetZ);
|
||||
} else {
|
||||
robot.aimItemAt(MathHelper.floor_float(robot.getAimYaw() / 90f) * 90f + 180f, robot.getAimPitch());
|
||||
}
|
||||
robot.dock(station);
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Date;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
|
@ -25,6 +26,8 @@ import net.minecraft.entity.item.EntityItem;
|
|||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import buildcraft.BuildCraftRobotics;
|
||||
|
@ -75,13 +78,16 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float f, float f1) {
|
||||
doRender((EntityRobot) entity, x, y, z);
|
||||
doRender((EntityRobot) entity, x, y, z, f1);
|
||||
}
|
||||
|
||||
private void doRender(EntityRobot robot, double x, double y, double z) {
|
||||
private void doRender(EntityRobot robot, double x, double y, double z, float partialTicks) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
float robotYaw = this.interpolateRotation(robot.prevRenderYawOffset, robot.renderYawOffset, partialTicks);
|
||||
GL11.glRotatef(-robotYaw, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
if (robot.getStackInSlot(0) != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(-0.125F, 0, -0.125F);
|
||||
|
@ -117,8 +123,7 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
if (robot.itemInUse != null) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glRotatef((float) (-robot.itemAngle1 / (2 * Math.PI) * 360) + 180, 0, 1, 0);
|
||||
GL11.glRotatef((float) (robot.itemAngle2 / (2 * Math.PI) * 360), 0, 0, 1);
|
||||
GL11.glRotatef(robot.itemAngle2, 0, 0, 1);
|
||||
|
||||
if (robot.itemActive) {
|
||||
long newDate = new Date().getTime();
|
||||
|
@ -225,10 +230,16 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
((IRobotOverlayItem) wearable.getItem()).renderRobotOverlay(wearable, textureManager);
|
||||
} else if (wearable.getItem() instanceof ItemArmor) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(1.125F, 1.125F, 1.125F);
|
||||
GL11.glScalef(1.0125F, 1.0125F, 1.0125F);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
GL11.glRotatef(180F, 0, 0, 1);
|
||||
textureManager.bindTexture(RenderBiped.getArmorResource(entity, wearable, 0, null));
|
||||
helmetBox.render(1 / 16F);
|
||||
ModelBiped armorModel = ForgeHooksClient.getArmorModel(entity, wearable, 0, null);
|
||||
if (armorModel != null) {
|
||||
armorModel.render(entity, 0, 0, 0, -90f, 0, 1 / 16F);
|
||||
} else {
|
||||
helmetBox.render(1 / 16F);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -262,5 +273,19 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private float interpolateRotation(float prevRot, float rot, float partialTicks) {
|
||||
float angle;
|
||||
|
||||
for (angle = rot - prevRot; angle < -180.0F; angle += 360.0F) {
|
||||
}
|
||||
|
||||
while (angle >= 180.0F) {
|
||||
angle -= 360.0F;
|
||||
}
|
||||
|
||||
return prevRot + partialTicks * angle;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue