Attempt to fix armbot item render

This commit is contained in:
Henry Mao 2013-02-03 12:51:10 +08:00
parent 934f7cca17
commit 4056ce587f
5 changed files with 42 additions and 23 deletions

View file

@ -3,6 +3,7 @@ package assemblyline.api;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
/**
* An interface applied to Armbots.
@ -21,6 +22,8 @@ public interface IArmbot
*/
public void dropEntity(Entity entity);
public void dropItem(ItemStack itemStack);
/**
* Drops all entities in the Armbot's hand.
*/
@ -30,4 +33,6 @@ public interface IArmbot
* @return Returns all entities being grabbed by the Armbot.
*/
public List<Entity> getGrabbedEntities();
public List<ItemStack> getGrabbedItems();
}

View file

@ -1,14 +1,16 @@
package assemblyline.client.render;
import net.minecraft.client.Minecraft;
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.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.client.ForgeHooksClient;
import org.lwjgl.opengl.GL11;
@ -62,18 +64,15 @@ public class RenderArmbot extends TileEntitySpecialRenderer
GL11.glPushMatrix();
GL11.glRotatef(180, 0, 0, 1);
for (Entity entity : ((TileEntityArmbot) tileEntity).getGrabbedEntities())
for (ItemStack itemStack : ((TileEntityArmbot) tileEntity).getGrabbedItems())
{
// Items don't move right, so we render them manually
if (entity != null && entity instanceof EntityItem)
if (itemStack != null)
{
EntityItem entityItem = (EntityItem) entity;
RenderItem render = (RenderItem) RenderManager.instance.getEntityRenderObject(entity);
RenderItem renderItem = ((RenderItem) RenderManager.instance.getEntityClassRenderObject(EntityItem.class));
RenderEngine renderEngine = Minecraft.getMinecraft().renderEngine;
renderItem.renderItemIntoGUI(this.getFontRenderer(), renderEngine, itemStack, 0, 0);
if (render != null)
{
render.doRender(entityItem, -handPos.x + 0.5f, handPos.y - 1.5f, -handPos.z + 0.5f, 0, 0);
}
}
}
GL11.glPopMatrix();

View file

@ -93,7 +93,7 @@ public class AssemblyLine
@PreInit
public void preInit(FMLPreInitializationEvent event)
{
UniversalElectricity.register(this, 1, 2, 4, false);
UniversalElectricity.register(this, 1, 2, 5, false);
instance = this;
CONFIGURATION.load();

View file

@ -78,9 +78,10 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
private String displayText = "";
/**
* An entity that the armbot is grabbed onto.
* An entity that the Armbot is grabbed onto. Entity Items are held separately.
*/
private final List<Entity> grabbedEntities = new ArrayList<Entity>();
private final List<ItemStack> grabbedItems = new ArrayList<ItemStack>();
@Override
public void initiate()
@ -874,18 +875,24 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
return this.grabbedEntities;
}
@Override
public List<ItemStack> getGrabbedItems()
{
return this.grabbedItems;
}
@Override
public void grabEntity(Entity entity)
{
this.grabbedEntities.add(entity);
if (entity instanceof EntityItem)
{
// Items don't move right, so we render them manually
this.worldObj.removeEntity(entity);
this.grabbedItems.add(((EntityItem) entity).getEntityItem());
entity.setDead();
}
else
{
this.grabbedEntities.add(entity);
}
entity.isDead = false;
}
@Override
@ -894,14 +901,21 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
this.grabbedEntities.remove(entity);
}
@Override
public void dropItem(ItemStack itemStack)
{
this.grabbedItems.remove(itemStack);
}
@Override
public void dropAll()
{
for (Entity entity : this.grabbedEntities)
for (ItemStack itemStack : this.grabbedItems)
{
this.dropEntity(entity);
this.dropItem(itemStack);
}
this.grabbedEntities.clear();
this.grabbedItems.clear();
}
}

View file

@ -33,7 +33,7 @@ public class CommandBreak extends Command
if (block != null && BREAK_TIME <= this.ticks)
{
ArrayList<ItemStack> items = block.getBlockDropped(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), serachPosition.getBlockMetadata(world), 0);
if (!this.keep || items.size() > 1)
{
this.dropBlockAsItem(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ());
@ -42,14 +42,15 @@ public class CommandBreak extends Command
{
this.tileEntity.grabEntity(new EntityItem(this.world, (double) serachPosition.intX() + 0.5D, (double) serachPosition.intY() + 0.5D, (double) serachPosition.intZ() + 0.5D, items.get(0)));
}
serachPosition.setBlockWithNotify(this.world, 0);
return true;
return false;
}
/**
* Notes on break command Beds Break Wrong Multi blocks don't work
*/
return false;
return true;
}
protected void dropBlockAsItem_do(World world, int x, int y, int z, ItemStack stack)