Conflicts:
	src/minecraft/assemblyline/client/render/RenderArmbot.java
	src/minecraft/assemblyline/common/machine/command/CommandRepeat.java
This commit is contained in:
Brian Ricketts 2013-01-26 18:14:24 -06:00
commit c83ab74fa7
8 changed files with 228 additions and 311 deletions

View file

@ -1 +1 @@
62
63

View file

@ -52,7 +52,8 @@ Minecraft 1.4.5
@ AssemblyLine_v0.2.3.56.jar AssemblyLine_v0.2.3.56_api.zip
* AssemblyLine_v0.2.3.57.jar AssemblyLine_v0.2.3.57_api.zip
x AssemblyLine_v0.2.3.58.jar AssemblyLine_v0.2.3.58_api.zip
* AssemblyLine_v0.2.4.59.jar AssemblyLine_v0.2.4.59_api.zip
@ AssemblyLine_v0.2.4.59.jar AssemblyLine_v0.2.4.59_api.zip
x AssemblyLine_v0.2.4.60.jar AssemblyLine_v0.2.4.60_api.zip
* AssemblyLine_v0.2.4.61.jar AssemblyLine_v0.2.4.61_api.zip
* AssemblyLine_v0.2.4.62.jar AssemblyLine_v0.2.4.62_api.zip
@ AssemblyLine_v0.2.4.61.jar AssemblyLine_v0.2.4.61_api.zip
@ AssemblyLine_v0.2.4.62.jar AssemblyLine_v0.2.4.62_api.zip
* AssemblyLine_v0.2.4.63.jar AssemblyLine_v0.2.4.63_api.zip

View file

@ -11,7 +11,7 @@ import assemblyline.client.gui.GuiImprinter;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.client.render.RenderArmbot;
import assemblyline.client.render.RenderConveyorBelt;
import assemblyline.client.render.RenderCrateOld;
import assemblyline.client.render.RenderCrate;
import assemblyline.client.render.RenderDetector;
import assemblyline.client.render.RenderManipulator;
import assemblyline.client.render.RenderRejector;
@ -49,7 +49,7 @@ public class ClientProxy extends CommonProxy
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, new RenderRejector());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDetector.class, new RenderDetector());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, new RenderManipulator());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, new RenderCrateOld());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, new RenderCrate());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArmbot.class, new RenderArmbot());
}

View file

@ -1,35 +1,190 @@
package assemblyline.client.render;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.client.renderer.RenderEngine;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.common.ForgeDirection;
public class RenderCrate implements ISimpleBlockRenderingHandler
import org.lwjgl.opengl.GL11;
import assemblyline.common.block.TileEntityCrate;
public class RenderCrate extends TileEntitySpecialRenderer
{
private final RenderBlocks renderBlocks = new RenderBlocks();
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
public void renderTileEntityAt(TileEntity var1, double x, double y, double z, float var8)
{
if (var1 instanceof TileEntityCrate)
{
TileEntityCrate tileEntity = (TileEntityCrate) var1;
RenderItem renderItem = ((RenderItem) RenderManager.instance.getEntityClassRenderObject(EntityItem.class));
String itemName = "Empty";
String amount = "";
ItemStack itemStack = tileEntity.getStackInSlot(0);
if (itemStack != null)
{
itemName = itemStack.getDisplayName();
amount = Integer.toString(itemStack.stackSize);
}
for (int side = 2; side < 6; side++)
{
ForgeDirection direction = ForgeDirection.getOrientation(side);
this.setupLight(tileEntity, direction.offsetX, direction.offsetZ);
if (itemStack != null)
{
GL11.glPushMatrix();
switch (side)
{
case 2:
GL11.glTranslated(x + 0.65, y + 0.9, z - 0.01);
break;
case 3:
GL11.glTranslated(x + 0.35, y + 0.9, z + 1.01);
GL11.glRotatef(180, 0, 1, 0);
break;
case 4:
GL11.glTranslated(x - 0.01, y + 0.9, z + 0.35);
GL11.glRotatef(90, 0, 1, 0);
break;
case 5:
GL11.glTranslated(x + 1.01, y + 0.9, z + 0.65);
GL11.glRotatef(-90, 0, 1, 0);
break;
}
float scale = 0.03125F;
GL11.glScalef(0.6f * scale, 0.6f * scale, 0);
GL11.glRotatef(180, 0, 0, 1);
RenderEngine renderEngine = Minecraft.getMinecraft().renderEngine;
EntityItem ei = new EntityItem(tileEntity.worldObj, 0.0, 0.0, 0.0, itemStack);
GL11.glDisable(2896);
if (!ForgeHooksClient.renderInventoryItem(this.renderBlocks, renderEngine, itemStack, true, 0.0F, 0.0F, 0.0F))
{
renderItem.renderItemIntoGUI(this.getFontRenderer(), renderEngine, itemStack, 0, 0);
}
GL11.glEnable(2896);
GL11.glPopMatrix();
}
this.renderText(itemName, side, 0.02f, x, y - 0.35f, z);
if (amount != "")
{
this.renderText(amount, side, 0.02f, x, y - 0.15f, z);
}
}
}
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
private void setupLight(TileEntity tileEntity, int xDifference, int zDifference)
{
return false;
World world = tileEntity.worldObj;
if (world.isBlockOpaqueCube(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference)) { return; }
int br = world.getLightBrightnessForSkyBlocks(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference, 0);
int var11 = br % 65536;
int var12 = br / 65536;
float scale = 0.6F;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * scale, var12 * scale);
}
@Override
public boolean shouldRender3DInInventory()
private void renderText(String text, int side, float maxScale, double x, double y, double z)
{
return false;
}
GL11.glPushMatrix();
@Override
public int getRenderId()
{
return 0;
}
GL11.glPolygonOffset(-10, -10);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
float displayX = 1 / 16;
float displayY = 1 / 16;
float displayWidth = 1 - (2 / 16);
float displayHeight = 1 - (2 / 16);
GL11.glTranslated(x, y, z);
switch (side)
{
case 3:
GL11.glTranslatef(0, 1, 0);
GL11.glRotatef(0, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 2:
GL11.glTranslatef(1, 1, 1);
GL11.glRotatef(180, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 5:
GL11.glTranslatef(0, 1, 1);
GL11.glRotatef(90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 4:
GL11.glTranslatef(1, 1, 0);
GL11.glRotatef(-90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
}
// Find Center
GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2);
GL11.glRotatef(-90, 1, 0, 0);
FontRenderer fontRenderer = this.getFontRenderer();
int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1);
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
int requiredHeight = lineHeight * 1;
float scaler = 0.8f;
float scaleX = (displayWidth / requiredWidth);
float scaleY = (displayHeight / requiredHeight);
float scale = (float) scaleX * scaler;
if (maxScale > 0)
{
scale = Math.min(scale, maxScale);
}
GL11.glScalef(scale, -scale, scale);
GL11.glDepthMask(false);
int offsetX;
int offsetY;
int realHeight = (int) Math.floor(displayHeight / scale);
int realWidth = (int) Math.floor(displayWidth / scale);
offsetX = (realWidth - requiredWidth) / 2;
offsetY = (realHeight - requiredHeight) / 2;
GL11.glDisable(GL11.GL_LIGHTING);
fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPopMatrix();
}
}

View file

@ -1,187 +0,0 @@
package assemblyline.client.render;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderEngine;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import assemblyline.common.block.TileEntityCrate;
public class RenderCrateOld extends TileEntitySpecialRenderer
{
private final RenderBlocks renderBlocks = new RenderBlocks();
@Override
public void renderTileEntityAt(TileEntity var1, double x, double y, double z, float var8)
{
if (var1 instanceof TileEntityCrate)
{
TileEntityCrate tileEntity = (TileEntityCrate) var1;
RenderItem renderItem = ((RenderItem) RenderManager.instance.getEntityClassRenderObject(EntityItem.class));
String itemName = "Empty";
String amount = "";
ItemStack itemStack = tileEntity.getStackInSlot(0);
if (itemStack != null)
{
itemName = itemStack.getDisplayName();
amount = Integer.toString(itemStack.stackSize);
}
for (int side = 2; side < 6; side++)
{
ForgeDirection direction = ForgeDirection.getOrientation(side);
this.setupLight(tileEntity, direction.offsetX, direction.offsetZ);
if (itemStack != null)
{
GL11.glPushMatrix();
switch (side)
{
case 2:
GL11.glTranslated(x + 0.65, y + 0.9, z - 0.01);
break;
case 3:
GL11.glTranslated(x + 0.35, y + 0.9, z + 1.01);
GL11.glRotatef(180, 0, 1, 0);
break;
case 4:
GL11.glTranslated(x - 0.01, y + 0.9, z + 0.35);
GL11.glRotatef(90, 0, 1, 0);
break;
case 5:
GL11.glTranslated(x + 1.01, y + 0.9, z + 0.65);
GL11.glRotatef(-90, 0, 1, 0);
break;
}
float scale = 0.03125F;
GL11.glScalef(0.6f * scale, 0.6f * scale, 0);
GL11.glRotatef(180, 0, 0, 1);
RenderEngine renderEngine = Minecraft.getMinecraft().renderEngine;
EntityItem ei = new EntityItem(tileEntity.worldObj, 0.0, 0.0, 0.0, itemStack);
if (!ForgeHooksClient.renderInventoryItem(this.renderBlocks, renderEngine, itemStack, true, 0.0F, 0.0F, 0.0F))
{
renderItem.renderItemIntoGUI(this.getFontRenderer(), renderEngine, itemStack, 0, 0);
}
GL11.glPopMatrix();
}
this.renderText(itemName, side, 0.02f, x, y - 0.35f, z);
if (amount != "")
{
this.renderText(amount, side, 0.02f, x, y - 0.15f, z);
}
}
}
}
private void setupLight(TileEntity tileEntity, int xDifference, int zDifference)
{
World world = tileEntity.worldObj;
if (world.isBlockOpaqueCube(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference)) { return; }
int br = world.getLightBrightnessForSkyBlocks(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference, 0);
int var11 = br % 65536;
int var12 = br / 65536;
float scale = 0.6F;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * scale, var12 * scale);
}
private void renderText(String text, int side, float maxScale, double x, double y, double z)
{
GL11.glPushMatrix();
GL11.glPolygonOffset(-10, -10);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
float displayX = 1 / 16;
float displayY = 1 / 16;
float displayWidth = 1 - (2 / 16);
float displayHeight = 1 - (2 / 16);
GL11.glTranslated(x, y, z);
switch (side)
{
case 3:
GL11.glTranslatef(0, 1, 0);
GL11.glRotatef(0, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 2:
GL11.glTranslatef(1, 1, 1);
GL11.glRotatef(180, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 5:
GL11.glTranslatef(0, 1, 1);
GL11.glRotatef(90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 4:
GL11.glTranslatef(1, 1, 0);
GL11.glRotatef(-90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
}
// Find Center
GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2);
GL11.glRotatef(-90, 1, 0, 0);
FontRenderer fontRenderer = this.getFontRenderer();
int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1);
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
int requiredHeight = lineHeight * 1;
float scaler = 0.8f;
float scaleX = (displayWidth / requiredWidth);
float scaleY = (displayHeight / requiredHeight);
float scale = (float) scaleX * scaler;
if (maxScale > 0)
{
scale = Math.min(scale, maxScale);
}
GL11.glScalef(scale, -scale, scale);
GL11.glDepthMask(false);
int offsetX;
int offsetY;
int realHeight = (int) Math.floor(displayHeight / scale);
int realWidth = (int) Math.floor(displayWidth / scale);
offsetX = (realWidth - requiredWidth) / 2;
offsetY = (realHeight - requiredHeight) / 2;
GL11.glDisable(GL11.GL_LIGHTING);
fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPopMatrix();
}
}

View file

@ -5,13 +5,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.BlockMachine;
import assemblyline.api.IFilterable;
import assemblyline.common.AssemblyLine;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.machine.imprinter.ItemImprinter;
/**
* A block that allows the placement of mass amount of a specific item within it. It will be allowed
@ -36,59 +33,48 @@ public class BlockCrate extends BlockMachine
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (world.getBlockTileEntity(x, y, z) instanceof TileEntityCrate)
{
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
if (side == ForgeDirection.UP.ordinal())
/**
* Make double clicking input all stacks.
*/
boolean allMode = false;
if (world.getWorldTime() - tileEntity.prevClickTime < 10)
{
if (tileEntity != null)
allMode = true;
}
tileEntity.prevClickTime = world.getWorldTime();
if (side == 1 || (side > 1 && hitY > 0.5))
{
if (allMode)
{
if (tileEntity instanceof IFilterable)
{
ItemStack containingStack = ((IFilterable) tileEntity).getFilter();
if (containingStack != null)
{
if (!world.isRemote)
{
EntityItem dropStack = new EntityItem(world, player.posX, player.posY, player.posZ, containingStack);
dropStack.delayBeforeCanPickup = 0;
world.spawnEntityInWorld(dropStack);
}
((IFilterable) tileEntity).setFilter(null);
return true;
}
else
{
if (player.getCurrentEquippedItem() != null)
{
if (player.getCurrentEquippedItem().getItem() instanceof ItemImprinter)
{
((IFilterable) tileEntity).setFilter(player.getCurrentEquippedItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
return true;
}
}
}
}
this.insertAllItems(tileEntity, player);
}
else
{
this.insertCurrentItem(tileEntity, player);
}
}
if (side > 1 && hitY > 0.7)
else if (side == 0 || (side > 1 && hitY <= 0.5))
{
return this.insertAllItems(tileEntity, player);
if (allMode)
{
this.ejectItems(tileEntity, player, TileEntityCrate.MAX_LIMIT);
}
else
{
this.ejectItems(tileEntity, player, 64);
}
}
else
{
return this.insertCurrentItem(tileEntity, player);
}
}
return false;
return true;
}
@Override
@ -125,6 +111,11 @@ public class BlockCrate extends BlockMachine
{
ItemStack requestStack = player.getCurrentEquippedItem();
if (requestStack == null && tileEntity.getStackInSlot(0) != null)
{
requestStack = tileEntity.getStackInSlot(0).copy();
}
if (requestStack != null)
{
if (requestStack.isStackable())
@ -238,32 +229,6 @@ public class BlockCrate extends BlockMachine
return itemStack;
}
/**
* Drops the crate as a block that stores items within it.
*/
@Override
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (world.getBlockTileEntity(x, y, z) != null)
{
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
if (player.getCurrentEquippedItem() == null)
{
/**
* Eject all items if clicked on the top 30% of the block.
*/
if (side > 1 && hitY > 0.7)
{
return this.ejectItems(tileEntity, player, TileEntityCrate.MAX_LIMIT);
}
else if (side != ForgeDirection.UP.ordinal()) { return this.ejectItems(tileEntity, player, 64); }
}
}
return false;
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{

View file

@ -1,14 +1,13 @@
package assemblyline.common.block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import universalelectricity.prefab.tile.TileEntityAdvanced;
@ -19,10 +18,11 @@ import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
public class TileEntityCrate extends TileEntityAdvanced implements ISidedInventory, IPacketReceiver
public class TileEntityCrate extends TileEntityAdvanced implements IInventory, IPacketReceiver
{
public static final int MAX_LIMIT = 2048;
public static final int MAX_LIMIT = 2880;
private ItemStack[] containingItems = new ItemStack[1];
public long prevClickTime = -1000;
@Override
public boolean canUpdate()
@ -244,16 +244,4 @@ public class TileEntityCrate extends TileEntityAdvanced implements ISidedInvento
{
return "Crate";
}
@Override
public int getStartInventorySide(ForgeDirection side)
{
return 0;
}
@Override
public int getSizeInventorySide(ForgeDirection side)
{
return 1;
}
}

View file

@ -2,10 +2,10 @@ package assemblyline.common.machine.command;
public class CommandReturn extends Command
{
public static final float IDLE_ROTATION_PITCH = 0;
public static final float IDLE_ROTATION_YAW = 0;
public static final float IDLE_ROTATION_PITCH = 0;
public static final float IDLE_ROTATION_YAW = 0;
private CommandRotateTo rotateToCommand;
private CommandRotateTo rotateToCommand;
@Override
public void onTaskStart()
@ -13,29 +13,24 @@ public class CommandReturn extends Command
this.rotateToCommand = (CommandRotateTo) this.commandManager.getNewCommand(this.tileEntity, CommandRotateTo.class, new String[] { "0", "0" });
this.rotateToCommand.onTaskStart();
}
@Override
protected boolean doTask()
{
if (this.rotateToCommand == null)
{
this.onTaskStart();
}
return this.rotateToCommand.doTask();
}
@Override
public void onTaskEnd()
{
this.rotateToCommand.onTaskEnd();
}
/*
* @Override protected boolean doTask() { /** Move the arm rotation to idle position if the machine is not idling
*
* if (Math.abs(this.tileEntity.rotationPitch - IDLE_ROTATION_PITCH) > 0.01 || Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) > 0.01) { if (Math.abs(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) > 0.125) this.tileEntity.rotationPitch += (IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * 0.05; else this.tileEntity.rotationPitch += Math.signum(IDLE_ROTATION_PITCH - this.tileEntity.rotationPitch) * (0.125 * 0.05); if (Math.abs(this.tileEntity.rotationPitch - IDLE_ROTATION_PITCH) < 0.0125) this.tileEntity.rotationPitch = IDLE_ROTATION_PITCH;
*
* if (Math.abs(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) > 0.125) this.tileEntity.rotationYaw += (IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * 0.05; else this.tileEntity.rotationYaw += Math.signum(IDLE_ROTATION_YAW - this.tileEntity.rotationYaw) * (0.125 * 0.05); if (Math.abs(this.tileEntity.rotationYaw - IDLE_ROTATION_YAW) < 0.0125) this.tileEntity.rotationYaw = IDLE_ROTATION_YAW; return true; }
*
* return false; }
*/
@Override
public String toString()
{