diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-17 23:52:19 +0200 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-17 23:52:19 +0200 |
| commit | 38ac6454b2c88432f1da9474fcceafb9d8ab5e3b (patch) | |
| tree | c3aabab0d8d375b7b497df171445e6eef611db7d | |
| parent | 84dd93f4aac7d3abf1abcec335cd7c3761dd186c (diff) | |
Sync stuff :)
9 files changed, 100 insertions, 47 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java index b24f69d..d151808 100644 --- a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java +++ b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -5,13 +5,18 @@ import java.util.Random; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemRing; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; public class BlockJewelrsCraftingTable extends BlockContainer @@ -19,31 +24,31 @@ public class BlockJewelrsCraftingTable extends BlockContainer Random rand = new Random(); int modifiers[] = new int[] { Item.blazePowder.itemID }; int effects[] = new int[] { 12 }; - + protected BlockJewelrsCraftingTable(int par1, Material par2Material) { super(par1, par2Material); this.setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F); } - + @Override public TileEntity createNewTileEntity(World world) { return new TileEntityJewelrsCraftingTable(); } - + @Override public boolean renderAsNormalBlock() { return false; } - + @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getBlockTileEntity(i, j, k); ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null) + if (te != null && !world.isRemote) { if (!te.hasJewel && item != null && item.getItem().itemID == ItemList.ring.itemID) { @@ -57,7 +62,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.hasModifier = true; --item.stackSize; } - + if (te.hasModifier && entityPlayer.isSneaking()) { entityPlayer.inventory.addItemStackToInventory(new ItemStack(te.modifier.itemID, 1, te.modifier.getItemDamage())); @@ -70,25 +75,33 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.jewel = new ItemStack(0, 0, 0); te.hasJewel = false; } + te.isDirty = true; world.setBlockTileEntity(i, j, k, te); } return true; } - + public void giveJewelToPlayer(TileEntityJewelrsCraftingTable cf, EntityPlayer player, ItemStack item, ItemStack modifier) { if (item != null) { - // ItemRing.addEffect(item, new PotionEffect(Potion.fireResistance.id, 120)); + ItemRing.addEffect(item, Potion.fireResistance.id); player.inventory.addItemStackToInventory(item); } } - + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) + { + int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + @Override public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) { TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getBlockTileEntity(i, j, k); - if (te != null) + if (te != null && !world.isRemote) { if (te.hasEndItem) { @@ -103,27 +116,28 @@ public class BlockJewelrsCraftingTable extends BlockContainer else if (!te.hasModifier && !world.isRemote) player.addChatMessage("You need a modifier"); te.timer = 5; + te.isDirty = true; } } - + @Override public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) { return false; } - + @Override public boolean isOpaqueCube() { return false; } - + @Override public int getRenderType() { return -1; } - + @Override public void registerIcons(IconRegister icon) { diff --git a/common/darkknight/jewelrycraft/block/BlockMolder.java b/common/darkknight/jewelrycraft/block/BlockMolder.java index 5d1f30d..a3df95f 100644 --- a/common/darkknight/jewelrycraft/block/BlockMolder.java +++ b/common/darkknight/jewelrycraft/block/BlockMolder.java @@ -45,19 +45,21 @@ public class BlockMolder extends BlockContainer { TileEntityMolder te = (TileEntityMolder) world.getBlockTileEntity(i, j, k); ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null && item != null && !te.hasMold && item.itemID == ItemList.molds.itemID) + if (te != null && item != null && !te.hasMold && item.itemID == ItemList.molds.itemID && !world.isRemote) { te.mold = item; te.hasMold = true; --item.stackSize; if (world.isRemote) entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.molder.addedmold", te.mold.getDisplayName())); + te.isDirty = true; } - if (te.hasMold && entityPlayer.isSneaking()) + if (te.hasMold && entityPlayer.isSneaking() && !world.isRemote) { entityPlayer.inventory.addItemStackToInventory(new ItemStack(te.mold.itemID, 1, te.mold.getItemDamage())); te.mold = new ItemStack(0, 0, 0); te.hasMold = false; + te.isDirty = true; } return true; } @@ -140,6 +142,7 @@ public class BlockMolder extends BlockContainer player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.molder.moldisempty")); else if (me.mold.itemID != ItemList.molds.itemID) player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.molder.moldismissing")); + me.isDirty = true; } } diff --git a/common/darkknight/jewelrycraft/block/BlockSmelter.java b/common/darkknight/jewelrycraft/block/BlockSmelter.java index 9764ac5..9702917 100644 --- a/common/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/common/darkknight/jewelrycraft/block/BlockSmelter.java @@ -101,6 +101,7 @@ public class BlockSmelter extends BlockContainer te.hasMetal = false; } world.setBlockTileEntity(i, j, k, te); + te.isDirty = true; } return true; } @@ -137,6 +138,7 @@ public class BlockSmelter extends BlockContainer player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.modlerhasitem")); else player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.molderismissing")); + te.isDirty = true; } } diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index aa23da3..ea75aa2 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -17,7 +17,7 @@ public class ItemRing extends ItemBase super(par1); this.setMaxStackSize(1); } - + public static void addMetal(ItemStack item, ItemStack metal) { NBTTagCompound itemStackData; @@ -32,8 +32,8 @@ public class ItemRing extends ItemBase metal.writeToNBT(ingotNBT); itemStackData.setTag("ingot", ingotNBT); } - - public static void addEffect(ItemStack item, PotionEffect effect) + + public static void addEffect(ItemStack item, int potion) { NBTTagCompound itemStackData; if (item.hasTagCompound()) @@ -43,16 +43,15 @@ public class ItemRing extends ItemBase itemStackData = new NBTTagCompound(); item.setTagCompound(itemStackData); } - NBTTagCompound effectNBT = new NBTTagCompound(); - effect.writeCustomPotionEffectToNBT(effectNBT); - itemStackData.setTag("effect", effectNBT); + NBTTagCompound potionNBT = new NBTTagCompound(); + potionNBT.setInteger("potion", potion); } - + /** * allows items to add custom lines of information to the mouseover description */ @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({ "rawtypes", "unchecked", "static-access" }) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { if (stack.hasTagCompound()) @@ -64,27 +63,33 @@ public class ItemRing extends ItemBase ingotStack.readFromNBT(ingotNBT); list.add(EnumChatFormatting.GRAY + ingotStack.getDisplayName()); } - - if (stack.getTagCompound().hasKey("effect")) + + if (stack.getTagCompound().hasKey("potion")) { - NBTTagCompound effectNBT = (NBTTagCompound) stack.getTagCompound().getTag("effect"); - PotionEffect effect = new PotionEffect(0, 0); - effect.readCustomPotionEffectFromNBT(effectNBT); - list.add(EnumChatFormatting.GREEN + effect.getEffectName()); + NBTTagCompound potionNBT = new NBTTagCompound();; + int potion = 0; + potion = potionNBT.getInteger("potion"); + list.add(EnumChatFormatting.GREEN + Integer.toString(potion)); } } } - + @Override public void onUpdate(ItemStack stack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (stack.hasTagCompound() && stack.getTagCompound().hasKey("effect") && !par2World.isRemote) + if (stack.hasTagCompound()) { - // NBTTagCompound effectNBT = (NBTTagCompound) stack.getTagCompound().getTag("effect"); - // PotionEffect effect = new PotionEffect(0, 0); - // effect.readCustomPotionEffectFromNBT(effectNBT); - // ((EntityPlayer) par3Entity).addPotionEffect(effect); - + if(stack.getTagCompound().hasKey("effect")) + { + if (par3Entity instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)par3Entity; + NBTTagCompound potionNBT = new NBTTagCompound(); + int potion = 0; + potion = potionNBT.getInteger("potion"); + if(potion != 0 && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(potion, 4)); + } + } } } } diff --git a/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java b/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java index 51db2da..6d674ef 100644 --- a/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java +++ b/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java @@ -26,10 +26,22 @@ public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRende ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + int block = te.getBlockMetadata(); GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - modelTable.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + if (block == 0) + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + else if (block == 1){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + } + else if (block == 2) + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + else if (block == 3) + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + + modelTable.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); GL11.glPopMatrix(); } diff --git a/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java b/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java index 616919d..2c00726 100644 --- a/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java +++ b/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java @@ -35,8 +35,10 @@ public class TileEntitySmelterRender extends TileEntitySpecialRenderer GL11.glPushMatrix(); if (block == 0) GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - else if (block == 1) - GL11.glRotatef(180F, 1F, 0.0F, 1F); + else if (block == 1){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + } else if (block == 2) GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); else if (block == 3) diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java index 633c4fd..74e681b 100644 --- a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java +++ b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -9,7 +9,7 @@ import net.minecraft.tileentity.TileEntity; public class TileEntityJewelrsCraftingTable extends TileEntity { - public boolean hasJewel, hasModifier, hasEndItem; + public boolean hasJewel, hasModifier, hasEndItem, isDirty; public ItemStack jewel, modifier, endItem; public int timer; @@ -22,6 +22,7 @@ public class TileEntityJewelrsCraftingTable extends TileEntity this.hasModifier = false; this.hasEndItem = false; this.timer = 0; + this.isDirty = false; } @Override @@ -63,6 +64,10 @@ public class TileEntityJewelrsCraftingTable extends TileEntity public void updateEntity() { super.updateEntity(); + if(isDirty){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = true; + } if (this.hasJewel && this.hasModifier && !this.hasEndItem) { if (timer > 0) diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java index 1e36225..8bf1724 100644 --- a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java +++ b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java @@ -11,7 +11,7 @@ import darkknight.jewelrycraft.item.ItemList; public class TileEntityMolder extends TileEntity { public int cooling; - public boolean hasMoltenMetal, hasJewelBase, hasMold; + public boolean hasMoltenMetal, hasJewelBase, hasMold, isDirty; public ItemStack mold, jewelBase, moltenMetal, ringMetal; public TileEntityMolder() @@ -24,6 +24,7 @@ public class TileEntityMolder extends TileEntity this.hasJewelBase = false; this.hasMoltenMetal = false; this.hasMold = false; + this.isDirty = false; } @Override @@ -70,9 +71,13 @@ public class TileEntityMolder extends TileEntity public void updateEntity() { super.updateEntity(); + if(isDirty){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = true; + } if (moltenMetal.itemID != 0) { - this.worldObj.playSoundEffect(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F, "random.fizz", 0.5F, 2.6F + 0.2F * 0.8F); + this.worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.fizz", 0.5F, 1F); for (int l = 0; l < 2; ++l) { //EntityFX entityfx = new EntityReddustFX(this.worldObj, (double)xCoord + Math.random(), (double)yCoord + 0.2D, (double)zCoord + Math.random(), 0.0F, 0.0F, 0.0F); diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java index 06e97ac..e656bed 100644 --- a/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java +++ b/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java @@ -11,7 +11,7 @@ import net.minecraft.tileentity.TileEntity; public class TileEntitySmelter extends TileEntity { public int melting, flow, n = 0, p = 0; - public boolean hasMetal, hasMoltenMetal; + public boolean hasMetal, hasMoltenMetal, isDirty; public ItemStack metal, moltenMetal; public TileEntitySmelter() @@ -22,6 +22,7 @@ public class TileEntitySmelter extends TileEntity this.hasMoltenMetal = false; this.metal = new ItemStack(0, 0, 0); this.moltenMetal = new ItemStack(0, 0, 0); + this.isDirty = false; } @Override @@ -57,6 +58,10 @@ public class TileEntitySmelter extends TileEntity { super.updateEntity(); Random rand = new Random(); + if(isDirty){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = true; + } if (p > 0) --p; else @@ -73,12 +78,12 @@ public class TileEntitySmelter extends TileEntity if (flow <= 0) n = 0; } - if (this.melting > 0) + if (metal.itemID != 0) { for (int l = 0; l < 5; ++l) { //EntityFX entityfx = new EntityReddustFX(this.worldObj, (double)xCoord + Math.random(), (double)yCoord + 0.2D, (double)zCoord + Math.random(), 0.0F, 0.0F, 0.0F); - this.worldObj.spawnParticle("flame", xCoord, yCoord + 1.1D, zCoord, 0.0D, 0.5D, 0.0D); + this.worldObj.spawnParticle("flame", xCoord, (double) yCoord + 0.6F, zCoord, 0.0D, 0.0D, 0.0D); } } if (rand.nextInt(65) == 0) |
