Fixing rotation
This commit is contained in:
@@ -65,7 +65,7 @@ public class Firebox extends CustomContainerFacing implements ITileEntityProvide
|
||||
TileFirebox tile = (TileFirebox) world.getTileEntity(pos);
|
||||
if (tile != null)
|
||||
{
|
||||
System.out.println("Server Slot: " + tile.getStackInSlot(0));
|
||||
//System.out.println("Server Slot: " + tile.getStackInSlot(0));
|
||||
ItemStack playerStack = player.getHeldItemMainhand();
|
||||
Item playerItem;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class Firebox extends CustomContainerFacing implements ITileEntityProvide
|
||||
world.notifyBlockUpdate(pos, state, state, 2);
|
||||
}
|
||||
/*if(world.getBlockState(tempPos).getBlock() instanceof BlockFurnace){
|
||||
System.out.println("Trying to set Block Furnace State active");
|
||||
//System.out.println("Trying to set Block Furnace State active");
|
||||
IBlockState iblockstate = world.getBlockState(tempPos);
|
||||
world.setBlockState(tempPos, Blocks.LIT_FURNACE.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||
TileEntityFurnace tileFurnace = (TileEntityFurnace) world.getTileEntity(tempPos);
|
||||
@@ -122,11 +122,6 @@ public class Firebox extends CustomContainerFacing implements ITileEntityProvide
|
||||
}
|
||||
}
|
||||
}
|
||||
if(world.isRemote){
|
||||
TileFirebox tile = (TileFirebox) world.getTileEntity(pos);
|
||||
System.out.println("Client Slot: " + tile.getStackInSlot(0));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package nmd.primal.forgecraft.renders;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
@@ -17,6 +18,7 @@ import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import nmd.primal.forgecraft.blocks.Firebox;
|
||||
import nmd.primal.forgecraft.tiles.TileFirebox;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -27,7 +29,9 @@ import org.lwjgl.opengl.GL11;
|
||||
public class TileFireboxRender extends TileEntitySpecialRenderer<TileFirebox>
|
||||
{
|
||||
private final RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
|
||||
|
||||
private int rotation;
|
||||
private float translateX, translateZ;
|
||||
private EntityItem entItem = null;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileFirebox tile, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||
@@ -35,7 +39,40 @@ public class TileFireboxRender extends TileEntitySpecialRenderer<TileFirebox>
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y + 0.875D, z + 0.5D);
|
||||
GL11.glScalef(0.25F, 0.25F, 0.25F);
|
||||
//GL11.glRotatef(90.0F * (-tile.rotation + 3), 0.0F, 1.0F, 0.0F);
|
||||
|
||||
World world = tile.getWorld();
|
||||
IBlockState state = world.getBlockState(tile.getPos());
|
||||
|
||||
switch(state.getValue(BlockHorizontal.FACING))
|
||||
{
|
||||
case NORTH:
|
||||
rotation = 0;
|
||||
//Left and Right
|
||||
translateX = 1.5f;
|
||||
//Back and Forth
|
||||
translateZ = 1.05f;
|
||||
break;
|
||||
case EAST:
|
||||
rotation = 3;
|
||||
translateZ = 1.0f;
|
||||
translateX = 1.4f;
|
||||
break;
|
||||
case SOUTH:
|
||||
rotation = 2;
|
||||
//Left and Right
|
||||
translateX = 1.40f;
|
||||
//Back and Forth
|
||||
translateZ = -0.5f;
|
||||
break;
|
||||
case WEST:
|
||||
rotation = 1;
|
||||
//Back and Forth
|
||||
translateX = 2.5f;
|
||||
//Left and Right
|
||||
translateZ = 0.85f;
|
||||
break;
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-1.5F, -0.0F, -1.0F);
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
@@ -43,45 +80,96 @@ public class TileFireboxRender extends TileEntitySpecialRenderer<TileFirebox>
|
||||
float prevLGTY = OpenGlHelper.lastBrightnessY;
|
||||
BlockPos pos = tile.getPos();
|
||||
int bright = tile.getWorld().getCombinedLight(pos.up(), 0);
|
||||
//int bright = (this.getLight(tile.getWorld(), pos) / 2);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, bright % 65536, bright / 65536);
|
||||
|
||||
///
|
||||
// offset height of rendering for worktable slabs
|
||||
// Think about ways to avoid instanceof
|
||||
///
|
||||
//IBlockState state = this.getWorld().getBlockState(pos);
|
||||
//Block block = state.getBlock();
|
||||
|
||||
ItemStack stack = tile.getStackInSlot(0);
|
||||
if (stack != null) {
|
||||
///
|
||||
// rotate 90 degrees for blocks but not items?
|
||||
///
|
||||
boolean is_block = stack.getItem() instanceof ItemBlock;
|
||||
float rotation = is_block ? 180.0F : 90.0F;
|
||||
float height = is_block ? 0.52F : 0.42F;
|
||||
//float scale = is_block ? 0.8F : 1.2F;
|
||||
float scale = is_block ? 0.8F : 1.5F;
|
||||
float height = -0.855f;
|
||||
|
||||
//RenderHelper.glItem(renderItem, stack, shelf_column, 0.0F, row_height, rotation);
|
||||
float scale = is_block ? 0.9F : 1.8F;
|
||||
int stackSize = stack.stackSize;
|
||||
|
||||
if(stackSize < 16){
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * rotation, 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if(stackSize > 15 && stackSize < 32){
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * rotation, 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * (rotation + 1), 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if(stackSize > 31 && stackSize < 48){
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * rotation, 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * (rotation + 1), 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * (rotation + 2), 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if(stackSize > 47){
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * rotation, 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * (rotation + 1), 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * (rotation + 2), 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(translateX, height, translateZ);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(90.0F * (rotation + 3), 0.0F, 1.0F, 0.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
//GL11.glTranslated(rack_column * 0.75F, 0.0D, craft_row * 0.75F);
|
||||
//GL11.glTranslated(rack_column * 1.5F, 0.0D, rack_row);
|
||||
GL11.glTranslated(1.4F, 0.0D, 1.5D);
|
||||
|
||||
//GL11.glTranslatef(0.75F, 0.52F, 0.25F);
|
||||
GL11.glTranslatef(0.75F, height, 0.25F);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
//
|
||||
// item/block rotation
|
||||
//GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(rotation, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
renderItem.renderItem(stack, renderItem.getItemModelMesher().getItemModel(stack));
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevLGTX, prevLGTY);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package nmd.primal.forgecraft.tiles;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.GuiChat;
|
||||
@@ -51,7 +52,7 @@ public class TileFirebox extends BaseTile implements IInventory, ITickable {
|
||||
//System.out.println(iteration);
|
||||
this.iteration = 0;
|
||||
IBlockState state = world.getBlockState(this.pos);
|
||||
BlockPos abovePos = new BlockPos(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
|
||||
BlockPos abovePos = new BlockPos(this.getPos().getX(), this.getPos().getY()+1, this.getPos().getZ());
|
||||
IBlockState aboveState = world.getBlockState(abovePos);
|
||||
if (worldObj.getBlockState(this.getPos()).getValue(Firebox.ACTIVE)) {
|
||||
if (this.getStackInSlot(0) == null) {
|
||||
@@ -66,11 +67,18 @@ public class TileFirebox extends BaseTile implements IInventory, ITickable {
|
||||
world.notifyBlockUpdate(pos, state, state, 2);
|
||||
}
|
||||
if(world.getBlockState(abovePos).getBlock() instanceof BlockFurnace){
|
||||
System.out.println("Trying to set Block Furnace State active");
|
||||
//System.out.println("Trying to set Block Furnace State active");
|
||||
IBlockState iblockstate = world.getBlockState(abovePos);
|
||||
TileEntityFurnace tileFurnace = (TileEntityFurnace) world.getTileEntity(abovePos);
|
||||
world.setBlockState(pos, Blocks.LIT_FURNACE.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||
tileFurnace.setField(0,2000);
|
||||
|
||||
if(world.getBlockState(abovePos).getBlock() == Blocks.LIT_FURNACE){
|
||||
tileFurnace.setField(0,1000);
|
||||
}
|
||||
if(world.getBlockState(abovePos).getBlock() == Blocks.FURNACE){
|
||||
BlockFurnace.setState(true, world, abovePos);
|
||||
//world.setBlockState(abovePos, Blocks.LIT_FURNACE.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||
tileFurnace.setField(0,1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user