WTF Metadata
This commit is contained in:
@@ -19,6 +19,8 @@ import com.kitsu.medievalcraft.packethandle.curedLeather.MsgHandleCuredLeatherZ;
|
||||
import com.kitsu.medievalcraft.packethandle.curedLeather.MsgPacketCuredLeatherX;
|
||||
import com.kitsu.medievalcraft.packethandle.curedLeather.MsgPacketCuredLeatherY;
|
||||
import com.kitsu.medievalcraft.packethandle.curedLeather.MsgPacketCuredLeatherZ;
|
||||
import com.kitsu.medievalcraft.packethandle.forge.MsgHandleForge;
|
||||
import com.kitsu.medievalcraft.packethandle.forge.MsgPacketForge;
|
||||
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgHandle;
|
||||
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgHandleLocY;
|
||||
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgHandleLocZ;
|
||||
@@ -82,6 +84,7 @@ public class Main {
|
||||
sNet.registerMessage(MsgHandleCuredLeatherY.class, MsgPacketCuredLeatherY.class, 7, Side.SERVER);
|
||||
sNet.registerMessage(MsgHandleCuredLeatherZ.class, MsgPacketCuredLeatherZ.class, 8, Side.SERVER);
|
||||
sNet.registerMessage(MsgHandleShelfCase.class, MsgPacketShelfCase.class, 9, Side.SERVER);
|
||||
sNet.registerMessage(MsgHandleForge.class, MsgPacketForge.class, 10, Side.SERVER);
|
||||
CustomTab.MedievalTab();
|
||||
ModBlocks.init();
|
||||
ModItems.init();
|
||||
|
||||
@@ -28,6 +28,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import com.kitsu.medievalcraft.Main;
|
||||
import com.kitsu.medievalcraft.block.ModBlocks;
|
||||
import com.kitsu.medievalcraft.item.ModItems;
|
||||
import com.kitsu.medievalcraft.packethandle.forge.MsgPacketForge;
|
||||
import com.kitsu.medievalcraft.packethandle.shelf.MsgPacketShelfCase;
|
||||
import com.kitsu.medievalcraft.renderer.RenderId;
|
||||
import com.kitsu.medievalcraft.tileents.machine.TileForge;
|
||||
import com.kitsu.medievalcraft.util.CustomTab;
|
||||
@@ -40,14 +42,14 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class Forge extends BlockContainer implements TileForgePlaceables{
|
||||
|
||||
private final Random random = new Random();
|
||||
private float mopX, mopY, mopZ, mopBlockX, mopBlockY, mopBlockZ;
|
||||
private int sideMeta, c;
|
||||
private int sideMeta;
|
||||
public static int c;
|
||||
|
||||
public Forge(String unlocalizedName, Material material) {
|
||||
super(material.rock);
|
||||
this.setBlockName(unlocalizedName);
|
||||
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
|
||||
//this.setCreativeTab(CustomTab.MedievalCraftTab);
|
||||
this.setCreativeTab(CustomTab.MedievalCraftTab);
|
||||
this.setHardness(3.0F);
|
||||
this.setResistance(5.0F);
|
||||
this.setHarvestLevel("pickaxe", 1, 0);
|
||||
@@ -76,6 +78,7 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
|
||||
if(!world.isRemote){
|
||||
world.setBlockMetadataWithNotify(x, y, z, (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3), 2);
|
||||
System.out.println(world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
@@ -94,13 +97,18 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
|
||||
|
||||
if(world.isRemote){
|
||||
MovingObjectPosition mop = Minecraft.getMinecraft().renderViewEntity.rayTrace(5, 1.0F);
|
||||
sideMeta = mop.sideHit;
|
||||
//c = sideMeta;
|
||||
c = (int)mop.sideHit;
|
||||
|
||||
Main.sNet.sendToServer(new MsgPacketForge((int) c));
|
||||
System.out.println("Client");
|
||||
System.out.println(c);
|
||||
System.out.println(world.getBlockMetadata(x, y, z));
|
||||
|
||||
}
|
||||
if(!world.isRemote){
|
||||
System.out.println("Server");
|
||||
System.out.println(c);
|
||||
System.out.println(world.getBlockMetadata(x, y, z));
|
||||
if(player.inventory.getCurrentItem()!=null){
|
||||
if((player.inventory.getCurrentItem().getItem()==Item.getItemFromBlock(Blocks.torch))||
|
||||
(player.inventory.getCurrentItem().getItem()==Items.flint_and_steel)||
|
||||
@@ -109,30 +117,25 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
|
||||
tileEnt.isOn=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(c==1){
|
||||
if(player.inventory.getCurrentItem()!=null){
|
||||
if(tileEnt.getStackInSlot(1)==null){
|
||||
if(player.inventory.getCurrentItem()!=null){
|
||||
if(player.inventory.getCurrentItem().getItem()==Items.coal){
|
||||
if(player.inventory.getCurrentItem().getItem()==Items.coal){
|
||||
if(tileEnt.getStackInSlot(1)==null){
|
||||
if(player.inventory.getCurrentItem()!=null){
|
||||
tileEnt.setInventorySlotContents(1, player.inventory.getCurrentItem());
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(tileEnt.getStackInSlot(0)!=null){
|
||||
if(player.inventory.getCurrentItem()!=null){
|
||||
if(player.inventory.getCurrentItem()!=null){
|
||||
if(player.inventory.getCurrentItem().getItem()==Items.coal){
|
||||
ItemStack pStack = player.inventory.getCurrentItem().copy();
|
||||
ItemStack sStack = tileEnt.getStackInSlot(1).copy();
|
||||
ItemStack sStackTemp = tileEnt.getStackInSlot(1).copy();
|
||||
if(tileEnt.getStackInSlot(0).stackSize < 64){
|
||||
sStackTemp.stackSize++;
|
||||
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
|
||||
tileEnt.setInventorySlotContents(1, sStackTemp);
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
}
|
||||
}
|
||||
if(tileEnt.getStackInSlot(1)!=null){
|
||||
ItemStack pStack = player.inventory.getCurrentItem().copy();
|
||||
ItemStack sStack = tileEnt.getStackInSlot(1).copy();
|
||||
ItemStack sStackTemp = tileEnt.getStackInSlot(1).copy();
|
||||
if(tileEnt.getStackInSlot(1).stackSize < 64){
|
||||
sStackTemp.stackSize++;
|
||||
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
|
||||
tileEnt.setInventorySlotContents(1, sStackTemp);
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,6 +164,7 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
|
||||
if(c!=0 && c!=1){
|
||||
if(player.inventory.getCurrentItem()!=null){
|
||||
if(tileEnt.getStackInSlot(0)==null){
|
||||
System.out.println();
|
||||
if(isItemFuel(player.inventory.getCurrentItem())==true){
|
||||
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
@@ -184,14 +188,14 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
|
||||
if(player.isSneaking() && player.inventory.getCurrentItem()==null) {
|
||||
if(tileEnt.getStackInSlot(0)!=null){
|
||||
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, tileEnt.getStackInSlot(0)));
|
||||
tileEnt.setInventorySlotContents(0, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!player.isSneaking()) {
|
||||
if(!player.isSneaking()) {
|
||||
if((player.inventory.getCurrentItem()==null)){
|
||||
if(tileEnt.getStackInSlot(0)!=null){
|
||||
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
|
||||
@@ -206,7 +210,6 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
|
||||
}
|
||||
tileEnt.markForUpdate();
|
||||
tileEnt.markDirty();
|
||||
//System.out.println(player.inventory.getCurrentItem());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ContainerForge extends Container {
|
||||
}
|
||||
}*/
|
||||
addSlotToContainer(new Slot(tileEnt, 0, 80, 34));
|
||||
addSlotToContainer(new Slot(tileEnt, 1, 81, 34));
|
||||
addSlotToContainer(new Slot(tileEnt, 0, 81, 34));
|
||||
//commonly used vanilla code that adds the player's inventory
|
||||
bindPlayerInventory(inventoryPlayer);
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.kitsu.medievalcraft.packethandle.firebox;
|
||||
|
||||
public class MsgHandleFirebox {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.kitsu.medievalcraft.packethandle.firebox;
|
||||
|
||||
public class MsgPacketFirebox {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.kitsu.medievalcraft.packethandle.forge;
|
||||
|
||||
import com.kitsu.medievalcraft.block.machines.Forge;
|
||||
import com.kitsu.medievalcraft.block.wood.ShelfFour;
|
||||
import com.kitsu.medievalcraft.packethandle.shelf.MsgPacketShelfCase;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class MsgHandleForge implements IMessageHandler<MsgPacketForge, IMessage>{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MsgPacketForge message, MessageContext ctx) {
|
||||
Forge.c = message.caseType;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.kitsu.medievalcraft.packethandle.forge;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class MsgPacketForge implements IMessage {
|
||||
|
||||
public int caseType;
|
||||
|
||||
public MsgPacketForge() {}
|
||||
|
||||
public MsgPacketForge(int x){
|
||||
this.caseType = x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.caseType = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(this.caseType);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,15 +12,7 @@ public class MsgHandleShelfCase implements IMessageHandler<MsgPacketShelfCase, I
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MsgPacketShelfCase message, MessageContext ctx) {
|
||||
|
||||
//HotIronBlock.locX = message.locx;
|
||||
//HotIronPlate.locX = message.locx;
|
||||
ShelfFour.caseType = message.caseType;
|
||||
//ItemRendererLongbow.tick = message.lTick;
|
||||
|
||||
//System.out.println(message.lTick);
|
||||
//ctx.getClientHandler().addToSendQueue(new MsgPacket(message.useme));
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,9 @@ public class MsgPacketShelfCase implements IMessage {
|
||||
public MsgPacketShelfCase(int x){
|
||||
this.caseType = x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
||||
this.caseType = buf.readInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,8 @@ public class ForgeRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
private final Random rand = new Random();
|
||||
private double r = rand.nextDouble();
|
||||
//public ModelFirebox model;
|
||||
EntityItem entItem = null;
|
||||
EntityItem entCoal = null;
|
||||
//boolean slotStatus;
|
||||
public static final ResourceLocation MODEL = new ResourceLocation("kitsumedievalcraft:models/SingleForge.obj");
|
||||
public static final ResourceLocation TEXTURE = new ResourceLocation("kitsumedievalcraft:models/SingleForge.png");
|
||||
|
||||
@@ -46,9 +44,6 @@ public class ForgeRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
renderBlock(tileEntity, tile.getWorldObj(), tile.xCoord,tile.yCoord, tile.zCoord, ModBlocks.forge);
|
||||
|
||||
|
||||
//}
|
||||
|
||||
if(tileEntity.getStackInSlot(0) != null){
|
||||
entItem = new EntityItem(tileEntity.getWorldObj(), x, y, z, tileEntity.getStackInSlot(0));
|
||||
GL11.glPushMatrix();
|
||||
@@ -70,28 +65,21 @@ public class ForgeRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
public void renderBlock(TileForge tl, World world, int i, int j,int k, Block block) {
|
||||
GL11.glPushMatrix();
|
||||
//GL11.glRotatef(15F, 0F, 1F, 0F);
|
||||
float scale = 0.50f;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glTranslatef(1.0F, 1.0F, 1.0F);
|
||||
int dir = world.getBlockMetadata(i, j, k);
|
||||
if(dir == 0){
|
||||
//GL11.glTranslatef(-1F, 0F, 1F);
|
||||
GL11.glRotated(90F, 0.0, 1.0F, 0.0F);
|
||||
}
|
||||
if(dir == 1){
|
||||
//GL11.glTranslatef(-1F, 0F, 1F);
|
||||
//GL11.glRotated(90F, 0.0, 1.0F, 0.0F);
|
||||
}
|
||||
if(dir == 2){
|
||||
//GL11.glTranslatef(-2F, 0F, 0F);
|
||||
GL11.glRotated(-90F, 0.0, 1.0F, 0.0F);
|
||||
}
|
||||
if(dir == 3){
|
||||
//GL11.glTranslatef(-1F, 0F, -1F);
|
||||
GL11.glRotated(180F, 0.0, 1.0F, 0.0F);
|
||||
}
|
||||
//
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
||||
|
||||
this.model.renderAll();
|
||||
|
||||
@@ -20,6 +20,7 @@ public class TileForge extends TileEntity implements IInventory{
|
||||
private NBTTagCompound tag = new NBTTagCompound();
|
||||
public int heat;
|
||||
public boolean isOn;
|
||||
public boolean grate;
|
||||
|
||||
public TileForge(){
|
||||
this.inv = new ItemStack[2];
|
||||
@@ -146,8 +147,9 @@ public class TileForge extends TileEntity implements IInventory{
|
||||
this.tileForgeName = tagCompound.getString("CustomName");
|
||||
}
|
||||
//this.stack0 = tagCompound.getString("stack0");
|
||||
this.heat = tag.getInteger("HEAT");
|
||||
this.isOn = tag.getBoolean("ISCOAL");
|
||||
this.heat = tag.getInteger("HEAT");
|
||||
this.isOn = tag.getBoolean("ISCOAL");
|
||||
this.grate = tag.getBoolean("GRATE");
|
||||
|
||||
}
|
||||
|
||||
@@ -168,6 +170,8 @@ public class TileForge extends TileEntity implements IInventory{
|
||||
tagCompound.setTag("Inventory", itemList);
|
||||
tag.setInteger("HEAT", this.heat);
|
||||
tag.setBoolean("ISCOAL", this.isOn);
|
||||
tag.setBoolean("GRATE", this.grate);
|
||||
|
||||
}
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
|
||||
Reference in New Issue
Block a user