More work on Aludel rendering - still one edge case I can't nab

This commit is contained in:
pahimar 2013-05-13 23:12:03 -04:00
parent fb90f5708c
commit fc58391854
5 changed files with 63 additions and 18 deletions

View file

@ -1,3 +1,3 @@
#Sun, 12 May 2013 20:52:25 -0400
#Mon, 13 May 2013 21:28:00 -0400
build_number=12
build_number=14

View file

@ -14,6 +14,7 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import com.pahimar.ee3.EquivalentExchange3;
import com.pahimar.ee3.lib.GuiIds;
@ -79,7 +80,7 @@ public class BlockGlassBell extends BlockEE {
if (!world.isRemote) {
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y, z);
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y - 1, z);
if ((tileAludel != null) && (tileGlassBell != null)) {
player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y - 1, z);
return true;
@ -101,7 +102,12 @@ public class BlockGlassBell extends BlockEE {
((TileEE) world.getBlockTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
}
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z));
if ((world.getBlockTileEntity(x, y - 1, z) != null) && (world.getBlockTileEntity(x, y - 1, z) instanceof TileAludel)) {
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(ForgeDirection.UP);
}
else {
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z));
}
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
}

View file

@ -14,6 +14,7 @@ import org.lwjgl.opengl.GL11;
import com.pahimar.ee3.client.model.ModelAludel;
import com.pahimar.ee3.lib.Textures;
import com.pahimar.ee3.tileentity.TileAludel;
import com.pahimar.ee3.tileentity.TileGlassBell;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
@ -74,20 +75,24 @@ public class TileEntityAludelRenderer extends TileEntitySpecialRenderer {
*/
GL11.glPushMatrix();
if (tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX) != null) {
float scaleFactor = getGhostItemScaleFactor(tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX));
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
EntityItem ghostEntityItem = new EntityItem(tileAludel.worldObj);
ghostEntityItem.hoverStart = 0.0F;
ghostEntityItem.setEntityItemStack(tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX));
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.2F, (float) z + 0.5F);
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);
customRenderItem.doRenderItem(ghostEntityItem, 0, 0, 0, 0, 0);
TileEntity tileGlassBell = tileAludel.worldObj.getBlockTileEntity(tileAludel.xCoord, tileAludel.yCoord + 1, tileAludel.zCoord);
if ((tileGlassBell != null) && (tileGlassBell instanceof TileGlassBell)) {
if (tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX) != null) {
float scaleFactor = getGhostItemScaleFactor(tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX));
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
EntityItem ghostEntityItem = new EntityItem(tileAludel.worldObj);
ghostEntityItem.hoverStart = 0.0F;
ghostEntityItem.setEntityItemStack(tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX));
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.2F, (float) z + 0.5F);
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);
customRenderItem.doRenderItem(ghostEntityItem, 0, 0, 0, 0, 0);
}
}
GL11.glPopMatrix();

View file

@ -1,5 +1,7 @@
package com.pahimar.ee3.tileentity;
import java.util.logging.Level;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@ -8,6 +10,7 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.packet.Packet;
import com.pahimar.ee3.core.helper.ItemHelper;
import com.pahimar.ee3.core.helper.LogHelper;
import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.network.PacketTypeHandler;
import com.pahimar.ee3.network.packet.PacketTileWithItemUpdate;
@ -184,4 +187,23 @@ public class TileAludel extends TileEE implements IInventory {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2);
}
}
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("TileEE Type: TileAludel\n");
stringBuilder.append(super.toString());
for (int i = 0; i < inventory.length; i++) {
if (inventory[i] != null) {
stringBuilder.append("inventory[" + i + "]: " + inventory[i].toString() + "\n");
}
else {
stringBuilder.append("inventory[" + i + "]: empty\n");
}
}
return stringBuilder.toString();
}
}

View file

@ -113,5 +113,17 @@ public class TileEE extends TileEntity {
return PacketTypeHandler.populatePacket(new PacketTileUpdate(xCoord, yCoord, zCoord, orientation, state, customName));
}
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("x: " + xCoord + ", y: " + yCoord + ", z: " + zCoord + "\n");
stringBuilder.append("customName: " + customName + "\n");
stringBuilder.append("orientation: " + orientation.toString() + "\n");
stringBuilder.append("state: " + state + "\n");
return stringBuilder.toString();
}
}