diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-26 22:52:08 +0200 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-26 22:52:08 +0200 |
| commit | cd56b1630738397247f9299ca524dfc58990b3c8 (patch) | |
| tree | 585d096cc2106038527c9ec9f7c516269543c732 | |
| parent | f55ff6d1f790f6ac80f5c0c96187dae2e27fb096 (diff) | |
Invisibility and jump boost ring, that nullifies fall damage and a cool new block!
14 files changed, 677 insertions, 3 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockDisplayer.java b/common/darkknight/jewelrycraft/block/BlockDisplayer.java new file mode 100644 index 0000000..02de477 --- /dev/null +++ b/common/darkknight/jewelrycraft/block/BlockDisplayer.java @@ -0,0 +1,168 @@ +package darkknight.jewelrycraft.block; + +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.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; + +public class BlockDisplayer extends BlockContainer +{ + Random rand = new Random(); + + protected BlockDisplayer(int par1, Material par2Material) + { + super(par1, par2Material); + } + + @Override + public TileEntity createNewTileEntity(World world) + { + return new TileEntityDisplayer(); + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @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 boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) + { + TileEntityDisplayer te = (TileEntityDisplayer) world.getBlockTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && item != null && !world.isRemote) + { + if(!te.hasObject) + { + te.object = item.copy(); + te.object.stackSize = 1; + te.quantity += item.stackSize; + te.hasObject = true; + if (!entityPlayer.capabilities.isCreativeMode) item.stackSize = 0; + te.isDirty = true; + } + else if(te.object.itemID == item.itemID && te.object.getItemDamage() == item.getItemDamage() && te.object.getTooltip(entityPlayer, false).equals(item.getTooltip(entityPlayer, false))) + { + te.quantity += item.stackSize; + te.object.stackSize = 1; + if (!entityPlayer.capabilities.isCreativeMode) item.stackSize = 0; + te.isDirty = true; + } + } + return true; + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) + { + TileEntityDisplayer te = (TileEntityDisplayer) world.getBlockTileEntity(i, j, k); + if (te != null && !world.isRemote) + { + if (te.hasObject && player.inventory.addItemStackToInventory(te.object)) + { + if(player.isSneaking()) + { + if(te.quantity > 64) + { + te.object.stackSize = 63; + player.inventory.addItemStackToInventory(te.object); + te.object.stackSize = 1; + te.quantity -= 64; + } + else + { + te.object.stackSize = te.quantity - 1; + player.inventory.addItemStackToInventory(te.object); + te.hasObject = false; + te.object = new ItemStack(0, 0, 0); + te.quantity = 0; + } + te.isDirty = true; + } + else + { + if(te.quantity >= 2) + { + player.inventory.addItemStackToInventory(te.object); + te.object.stackSize = 1; + --te.quantity; + } + else + { + player.inventory.addItemStackToInventory(te.object); + te.object.stackSize = 1; + te.hasObject = false; + te.object = new ItemStack(0, 0, 0); + te.quantity = 0; + } + te.isDirty = true; + } + } + } + } + + public void dropItem(World world, double x, double y, double z, ItemStack stack) + { + EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.5D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + public void breakBlock(World world, int i, int j, int k, int par5, int par6) + { + TileEntityDisplayer te = (TileEntityDisplayer) world.getBlockTileEntity(i, j, k); + + if (te != null && te.hasObject) + { + te.object.stackSize = te.quantity; + dropItem(te.worldObj, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.object); + world.markTileEntityForDespawn(te); + } + + super.breakBlock(world, i, j, k, par5, par6); + } + + @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 registerIcons(IconRegister icon) + { + this.blockIcon = icon.registerIcon("jewelrycraft:displayer"); + } +} diff --git a/common/darkknight/jewelrycraft/block/BlockList.java b/common/darkknight/jewelrycraft/block/BlockList.java index 10e1cdc..3a17d9a 100644 --- a/common/darkknight/jewelrycraft/block/BlockList.java +++ b/common/darkknight/jewelrycraft/block/BlockList.java @@ -6,6 +6,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; import darkknight.jewelrycraft.tileentity.TileEntityMolder; import darkknight.jewelrycraft.tileentity.TileEntitySmelter; @@ -15,6 +16,7 @@ public class BlockList public static Block shadowOre; public static Block smelter; public static Block molder; + public static Block displayer; public static Block jewelCraftingTable; private static boolean isInitialized = false; @@ -24,18 +26,21 @@ public class BlockList if (!isInitialized) { shadowOre = new Block(ConfigHandler.idShadowOre, Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep).setTextureName("jewelrycraft:oreShadow").setUnlocalizedName("Jewelrycraft.oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); - smelter = new BlockSmelter(ConfigHandler.idSmelter, Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundMetalFootstep).setUnlocalizedName("Jewelrycraft.smelter").setCreativeTab(JewelrycraftMod.jewelrycraft); - molder = new BlockMolder(ConfigHandler.idMolder, Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundMetalFootstep).setUnlocalizedName("Jewelrycraft.molder").setCreativeTab(JewelrycraftMod.jewelrycraft); + smelter = new BlockSmelter(ConfigHandler.idSmelter, Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("Jewelrycraft.smelter").setCreativeTab(JewelrycraftMod.jewelrycraft); + molder = new BlockMolder(ConfigHandler.idMolder, Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("Jewelrycraft.molder").setCreativeTab(JewelrycraftMod.jewelrycraft); + displayer = new BlockDisplayer(ConfigHandler.idDisplayer, Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundMetalFootstep).setUnlocalizedName("Jewelrycraft.displayer").setCreativeTab(JewelrycraftMod.jewelrycraft); jewelCraftingTable = new BlockJewelrsCraftingTable(ConfigHandler.idJewelCraftingTable, Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("Jewelrycraft.jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft); GameRegistry.registerBlock(shadowOre, "shadowOre"); GameRegistry.registerBlock(smelter, "Smelter"); GameRegistry.registerBlock(molder, "Molder"); GameRegistry.registerBlock(jewelCraftingTable, "jewelCraftingTable"); + GameRegistry.registerBlock(displayer, "Displayer"); GameRegistry.registerTileEntity(TileEntitySmelter.class, "30"); GameRegistry.registerTileEntity(TileEntityMolder.class, "31"); GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, "32"); + GameRegistry.registerTileEntity(TileEntityDisplayer.class, "33"); isInitialized = true; } diff --git a/common/darkknight/jewelrycraft/client/ClientProxy.java b/common/darkknight/jewelrycraft/client/ClientProxy.java index 35fec97..3362dd3 100644 --- a/common/darkknight/jewelrycraft/client/ClientProxy.java +++ b/common/darkknight/jewelrycraft/client/ClientProxy.java @@ -2,9 +2,11 @@ package darkknight.jewelrycraft.client; import cpw.mods.fml.client.registry.ClientRegistry; import darkknight.jewelrycraft.CommonProxy; +import darkknight.jewelrycraft.renders.TileEntityDisplayerRender; import darkknight.jewelrycraft.renders.TileEntityJewelrsCraftingTableRender; import darkknight.jewelrycraft.renders.TileEntityMolderRender; import darkknight.jewelrycraft.renders.TileEntitySmelterRender; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; import darkknight.jewelrycraft.tileentity.TileEntityMolder; import darkknight.jewelrycraft.tileentity.TileEntitySmelter; @@ -17,5 +19,6 @@ public class ClientProxy extends CommonProxy ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmelter.class, new TileEntitySmelterRender()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMolder.class, new TileEntityMolderRender()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJewelrsCraftingTable.class, new TileEntityJewelrsCraftingTableRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDisplayer.class, new TileEntityDisplayerRender()); } } diff --git a/common/darkknight/jewelrycraft/config/ConfigHandler.java b/common/darkknight/jewelrycraft/config/ConfigHandler.java index 5a9120a..d23d358 100644 --- a/common/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/common/darkknight/jewelrycraft/config/ConfigHandler.java @@ -14,8 +14,9 @@ public class ConfigHandler public static int idShadowOre = 1750; public static int idSmelter = 1751; - public static int idMolder = 1754; + public static int idDisplayer = 1752; public static int idJewelCraftingTable = 1753; + public static int idMolder = 1754; public static int ingotCoolingTime = 200; public static int ingotMeltingTime = 1500; @@ -40,6 +41,7 @@ public class ConfigHandler idShadowOre = config.getBlock("Shadow Ore", idShadowOre).getInt(); idSmelter = config.getBlock("Smelter", idSmelter).getInt(); idMolder = config.getBlock("Molder", idMolder).getInt(); + idDisplayer = config.getBlock("Displayer", idDisplayer).getInt(); idJewelCraftingTable = config.getBlock("Jeweler's Crafting Table", idJewelCraftingTable).getInt(); ingotCoolingTime = config.get("timers", "Molder Ingot Cooling Time", ingotCoolingTime).getInt(); diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index 92e16cf..52fb376 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -243,6 +243,12 @@ public class ItemRing extends Item if (JewelryNBT.isModifierX(stack, new ItemStack(Item.blazePowder)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 4, amplifier)); else if (JewelryNBT.isModifierX(stack, new ItemStack(Item.sugar)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 4, amplifier)); else if (JewelryNBT.isModifierX(stack, new ItemStack(Item.pickaxeIron)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 4, amplifier)); + else if (JewelryNBT.isModifierX(stack, new ItemStack(Item.feather)) && entityplayer != null) + { + entityplayer.addPotionEffect(new PotionEffect(Potion.jump.id, 4, amplifier)); + entityplayer.fallDistance=0; + } + else if (JewelryNBT.isModifierX(stack, new ItemStack(Item.potion, 1, 8270)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.invisibility.id, 4, amplifier)); } } } diff --git a/common/darkknight/jewelrycraft/model/ModelDisplayer.java b/common/darkknight/jewelrycraft/model/ModelDisplayer.java new file mode 100644 index 0000000..9764ca0 --- /dev/null +++ b/common/darkknight/jewelrycraft/model/ModelDisplayer.java @@ -0,0 +1,241 @@ +package darkknight.jewelrycraft.model; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelDisplayer extends ModelBase +{ + //fields + ModelRenderer Base; + ModelRenderer Ring11; + ModelRenderer Ring12; + ModelRenderer Ring13; + ModelRenderer Ring14; + ModelRenderer Ring31; + ModelRenderer Ring21; + ModelRenderer Ring32; + ModelRenderer Ring22; + ModelRenderer Ring33; + ModelRenderer Ring23; + ModelRenderer Ring34; + ModelRenderer Ring24; + ModelRenderer Ring25; + ModelRenderer Ring26; + ModelRenderer Ring27; + ModelRenderer Ring28; + ModelRenderer Ring35; + ModelRenderer Ring36; + ModelRenderer Ring37; + ModelRenderer Ring38; + ModelRenderer Ring39; + ModelRenderer Ring310; + ModelRenderer Ring311; + ModelRenderer Ring312; + + public ModelDisplayer() + { + textureWidth = 64; + textureHeight = 32; + + Base = new ModelRenderer(this, 0, 0); + Base.addBox(0F, 0F, 0F, 16, 3, 16); + Base.setRotationPoint(-8F, 21F, -8F); + Base.setTextureSize(64, 32); + Base.mirror = true; + setRotation(Base, 0F, 0F, 0F); + Ring11 = new ModelRenderer(this, 0, 26); + Ring11.addBox(-2F, 0F, 2F, 4, 1, 1); + Ring11.setRotationPoint(0F, 19F, 0F); + Ring11.setTextureSize(64, 32); + Ring11.mirror = true; + setRotation(Ring11, 0F, 0F, 0F); + Ring12 = new ModelRenderer(this, 0, 20); + Ring12.addBox(-3F, 0F, -2F, 1, 1, 4); + Ring12.setRotationPoint(0F, 19F, 0F); + Ring12.setTextureSize(64, 32); + Ring12.mirror = true; + setRotation(Ring12, 0F, 0F, 0F); + Ring13 = new ModelRenderer(this, 0, 20); + Ring13.addBox(2F, 0F, -2F, 1, 1, 4); + Ring13.setRotationPoint(0F, 19F, 0F); + Ring13.setTextureSize(64, 32); + Ring13.mirror = true; + setRotation(Ring13, 0F, 0F, 0F); + Ring14 = new ModelRenderer(this, 0, 26); + Ring14.addBox(-2F, 0F, -3F, 4, 1, 1); + Ring14.setRotationPoint(0F, 19F, 0F); + Ring14.setTextureSize(64, 32); + Ring14.mirror = true; + setRotation(Ring14, 0F, 0F, 0F); + Ring21 = new ModelRenderer(this, 0, 29); + Ring21.addBox(-4F, 0F, 3F, 1, 1, 1); + Ring21.setRotationPoint(0F, 19F, 0F); + Ring21.setTextureSize(64, 32); + Ring21.mirror = true; + setRotation(Ring21, 0F, 0F, 0F); + Ring22 = new ModelRenderer(this, 0, 29); + Ring22.addBox(-4F, 0F, -4F, 1, 1, 1); + Ring22.setRotationPoint(0F, 19F, 0F); + Ring22.setTextureSize(64, 32); + Ring22.mirror = true; + setRotation(Ring22, 0F, 0F, 0F); + Ring23 = new ModelRenderer(this, 0, 29); + Ring23.addBox(3F, 0F, -4F, 1, 1, 1); + Ring23.setRotationPoint(0F, 19F, 0F); + Ring23.setTextureSize(64, 32); + Ring23.mirror = true; + setRotation(Ring23, 0F, 0F, 0F); + Ring34 = new ModelRenderer(this, 26, 20); + Ring34.addBox(6F, 0F, -4F, 1, 1, 8); + Ring34.setRotationPoint(0F, 19F, 0F); + Ring34.setTextureSize(64, 32); + Ring34.mirror = true; + setRotation(Ring34, 0F, 0F, 0F); + Ring24 = new ModelRenderer(this, 0, 29); + Ring24.addBox(3F, 0F, 3F, 1, 1, 1); + Ring24.setRotationPoint(0F, 19F, 0F); + Ring24.setTextureSize(64, 32); + Ring24.mirror = true; + setRotation(Ring24, 0F, 0F, 0F); + Ring25 = new ModelRenderer(this, 11, 20); + Ring25.addBox(4F, 0F, -3F, 1, 1, 6); + Ring25.setRotationPoint(0F, 19F, 0F); + Ring25.setTextureSize(64, 32); + Ring25.mirror = true; + setRotation(Ring25, 0F, 0F, 0F); + Ring26 = new ModelRenderer(this, 11, 28); + Ring26.addBox(-3F, 0F, -5F, 6, 1, 1); + Ring26.setRotationPoint(0F, 19F, 0F); + Ring26.setTextureSize(64, 32); + Ring26.mirror = true; + setRotation(Ring26, 0F, 0F, 0F); + Ring27 = new ModelRenderer(this, 11, 20); + Ring27.addBox(-5F, 0F, -3F, 1, 1, 6); + Ring27.setRotationPoint(0F, 19F, 0F); + Ring27.setTextureSize(64, 32); + Ring27.mirror = true; + setRotation(Ring27, 0F, 0F, 0F); + Ring28 = new ModelRenderer(this, 11, 28); + Ring28.addBox(-3F, 0F, 4F, 6, 1, 1); + Ring28.setRotationPoint(0F, 19F, 0F); + Ring28.setTextureSize(64, 32); + Ring28.mirror = true; + setRotation(Ring28, 0F, 0F, 0F); + Ring31 = new ModelRenderer(this, 0, 29); + Ring31.addBox(-6F, 0F, 4F, 1, 1, 1); + Ring31.setRotationPoint(0F, 19F, 0F); + Ring31.setTextureSize(64, 32); + Ring31.mirror = true; + setRotation(Ring31, 0F, 0F, 0F); + Ring32 = new ModelRenderer(this, 26, 20); + Ring32.addBox(-7F, 0F, -4F, 1, 1, 8); + Ring32.setRotationPoint(0F, 19F, 0F); + Ring32.setTextureSize(64, 32); + Ring32.mirror = true; + setRotation(Ring32, 0F, 0F, 0F); + Ring33 = new ModelRenderer(this, 26, 30); + Ring33.addBox(-4F, 0F, -7F, 8, 1, 1); + Ring33.setRotationPoint(0F, 19F, 0F); + Ring33.setTextureSize(64, 32); + Ring33.mirror = true; + setRotation(Ring33, 0F, 0F, 0F); + Ring35 = new ModelRenderer(this, 26, 30); + Ring35.addBox(-4F, 0F, 6F, 8, 1, 1); + Ring35.setRotationPoint(0F, 19F, 0F); + Ring35.setTextureSize(64, 32); + Ring35.mirror = true; + setRotation(Ring35, 0F, 0F, 0F); + Ring36 = new ModelRenderer(this, 0, 29); + Ring36.addBox(-5F, 0F, 5F, 1, 1, 1); + Ring36.setRotationPoint(0F, 19F, 0F); + Ring36.setTextureSize(64, 32); + Ring36.mirror = true; + setRotation(Ring36, 0F, 0F, 0F); + Ring37 = new ModelRenderer(this, 0, 29); + Ring37.addBox(5F, 0F, 4F, 1, 1, 1); + Ring37.setRotationPoint(0F, 19F, 0F); + Ring37.setTextureSize(64, 32); + Ring37.mirror = true; + setRotation(Ring37, 0F, 0F, 0F); + Ring38 = new ModelRenderer(this, 0, 29); + Ring38.addBox(4F, 0F, 5F, 1, 1, 1); + Ring38.setRotationPoint(0F, 19F, 0F); + Ring38.setTextureSize(64, 32); + Ring38.mirror = true; + setRotation(Ring38, 0F, 0F, 0F); + Ring39 = new ModelRenderer(this, 0, 29); + Ring39.addBox(4F, 0F, -6F, 1, 1, 1); + Ring39.setRotationPoint(0F, 19F, 0F); + Ring39.setTextureSize(64, 32); + Ring39.mirror = true; + setRotation(Ring39, 0F, 0F, 0F); + Ring310 = new ModelRenderer(this, 0, 29); + Ring310.addBox(5F, 0F, -5F, 1, 1, 1); + Ring310.setRotationPoint(0F, 19F, 0F); + Ring310.setTextureSize(64, 32); + Ring310.mirror = true; + setRotation(Ring310, 0F, 0F, 0F); + Ring311 = new ModelRenderer(this, 0, 29); + Ring311.addBox(-6F, 0F, -5F, 1, 1, 1); + Ring311.setRotationPoint(0F, 19F, 0F); + Ring311.setTextureSize(64, 32); + Ring311.mirror = true; + setRotation(Ring311, 0F, 0F, 0F); + Ring312 = new ModelRenderer(this, 0, 29); + Ring312.addBox(-5F, 0F, -6F, 1, 1, 1); + Ring312.setRotationPoint(0F, 19F, 0F); + Ring312.setTextureSize(64, 32); + Ring312.mirror = true; + setRotation(Ring312, 0F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + GL11.glPushMatrix(); + Base.render(f5); + GL11.glTranslatef(0.0F, 0F - f, 0.0F); + Ring11.render(f5); + Ring12.render(f5); + Ring13.render(f5); + Ring14.render(f5); + GL11.glTranslatef(0.0F, 0F + f - f1, 0.0F); + Ring21.render(f5); + Ring22.render(f5); + Ring23.render(f5); + Ring24.render(f5); + Ring25.render(f5); + Ring26.render(f5); + Ring27.render(f5); + Ring28.render(f5); + GL11.glTranslatef(0.0F, 0F + f1 - f2, 0.0F); + Ring31.render(f5); + Ring32.render(f5); + Ring33.render(f5); + Ring34.render(f5); + Ring35.render(f5); + Ring36.render(f5); + Ring37.render(f5); + Ring38.render(f5); + Ring39.render(f5); + Ring310.render(f5); + Ring311.render(f5); + Ring312.render(f5); + GL11.glPopMatrix(); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, null); + } + +} diff --git a/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java b/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java index b222d83..3f4587f 100644 --- a/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java +++ b/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java @@ -23,6 +23,7 @@ public class CraftingRecipes GameRegistry.addRecipe(new ItemStack(BlockList.molder), "x x", "xxx", 'x', Block.cobblestone); GameRegistry.addRecipe(new ItemStack(BlockList.smelter), "xyx", "x x", "xzx", 'x', Block.cobblestone, 'y', Item.bucketEmpty, 'z', Item.bucketLava); GameRegistry.addRecipe(new ItemStack(BlockList.jewelCraftingTable), "xxx", "y y", "y y", 'x', Block.planks, 'y', Block.cobblestone); + GameRegistry.addRecipe(new ItemStack(BlockList.displayer, 2), " x ", "xxx", "yyy", 'x', Item.ingotIron, 'y', Block.blockEmerald); GameRegistry.addSmelting(BlockList.shadowOre.blockID, new ItemStack(ItemList.shadowIngot), 1.5f); FurnaceRecipes.smelting().addSmelting(ItemList.clayMolds.itemID, 0, new ItemStack(ItemList.molds, 1, 0), 0.85F); FurnaceRecipes.smelting().addSmelting(ItemList.clayMolds.itemID, 1, new ItemStack(ItemList.molds, 1, 1), 0.85F); diff --git a/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java b/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java new file mode 100644 index 0000000..a354a11 --- /dev/null +++ b/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java @@ -0,0 +1,135 @@ +package darkknight.jewelrycraft.renders; + +import org.lwjgl.opengl.GL11; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +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.item.Item; +import darkknight.jewelrycraft.model.ModelDisplayer; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class TileEntityDisplayerRender extends TileEntitySpecialRenderer +{ + ModelDisplayer displayer = new ModelDisplayer(); + String texture = "textures/tileentities/Displayer.png"; + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + TileEntityDisplayer disp = (TileEntityDisplayer)te; + int block = disp.getBlockMetadata(); + + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + displayer.render((Entity) null, disp.ringTranslation1, disp.ringTranslation2, disp.ringTranslation3, 0.0F, 0.0F, 0.0625F); + if(disp != null && disp.hasObject) + { + int ind = -3; + GL11.glPushMatrix(); + renderLabel(EnumChatFormatting.YELLOW + disp.object.getDisplayName(), 0F, (-0.16F)*ind, 0, block); + GL11.glPopMatrix(); + ind++; + GL11.glPushMatrix(); + renderLabel(Integer.toString(disp.quantity), 0F, (-0.16F)*ind, 0, block); + GL11.glPopMatrix(); + ind++; + if(disp.object.itemID != Item.map.itemID && disp.object.getTooltip(null, true) != null) + { + for(int i = 1; i < disp.object.getTooltip(null, true).size(); i++) + { + if(disp.object.getTooltip(null, true).get(i).toString() != "") + { + GL11.glPushMatrix(); + renderLabel(disp.object.getTooltip(null, true).get(i).toString(), 0F, (-0.16F)*ind, 0, block); + GL11.glPopMatrix(); + ind++; + } + } + } + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.worldObj, 0.0D, 0.0D, 0.0D, disp.object); + entityitem.hoverStart = 0.0F; + disp.object.stackSize = 1; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(0.0F, -0.6F + disp.ringTranslation1/5, 0F); + GL11.glRotatef(disp.rotAngle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public void adjustLightFixture(World world, int i, int j, int k, Block block) + { + Tessellator tess = Tessellator.instance; + float brightness = block.getBlockBrightness(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); + } + + protected void renderLabel(String par2Str, double x, double y, double z, int metadata) + { + FontRenderer fontrenderer = RenderManager.instance.getFontRenderer(); + float var14 = 0.01266667F * 1.5F; + float var17 = 0.015F; + GL11.glRotatef(180F, 0F, 0F, 1F); + if(metadata == 0) GL11.glRotatef(0F, 0F, 1F, 0F); + else if(metadata == 1) GL11.glRotatef(270F, 0F, 1F, 0F); + else if(metadata == 2) GL11.glRotatef(180F, 0F, 1F, 0F); + else if(metadata == 3) GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef((float)x, (float)y, (float)z + 0.45F); + GL11.glScalef(-0.015F, -var14, 0.015F); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + int j = fontrenderer.getStringWidth(par2Str) / 2; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(0.2F, 0.2F, 0.2F, 0.8F); + tessellator.addVertex((double)(-33.333 - 0), -1D, 0.1D); + tessellator.addVertex((double)(-33.333 - 0), 8D, 0.1D); + tessellator.addVertex((double)(33.333 + 0), 8D, 0.1D); + tessellator.addVertex((double)(33.333 + 0), -1D, 0.1D); + tessellator.draw(); + if ((fontrenderer.getStringWidth(par2Str)/2) > 30) var17 = 0.9F / fontrenderer.getStringWidth(par2Str); + else var17 = var14; + GL11.glScalef(var17*70F, 1F, 0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + fontrenderer.drawString(par2Str, -j, 0, -1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } +} diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java b/common/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java new file mode 100644 index 0000000..c3eba49 --- /dev/null +++ b/common/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java @@ -0,0 +1,110 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityDisplayer extends TileEntity +{ + public float ringTranslation1, ringTranslation2, ringTranslation3, rotAngle; + public boolean isDescending1, isDescending2, isDescending3, isDirty, hasObject; + public ItemStack object; + public int quantity; + + public TileEntityDisplayer() + { + this.ringTranslation1 = 0; + this.ringTranslation2 = 0; + this.ringTranslation3 = 0; + this.rotAngle = 0; + this.quantity = 0; + this.isDescending1 = false; + this.isDescending2 = false; + this.isDescending3 = false; + this.isDirty = false; + this.hasObject = false; + this.object = new ItemStack(0, 0, 0); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setFloat("translation1", ringTranslation1); + nbt.setFloat("translation2", ringTranslation2); + nbt.setFloat("translation3", ringTranslation3); + nbt.setFloat("angle", rotAngle); + nbt.setInteger("quantity", quantity); + nbt.setBoolean("descending1", isDescending1); + nbt.setBoolean("descending2", isDescending2); + nbt.setBoolean("descending3", isDescending3); + nbt.setBoolean("hasObject", hasObject); + NBTTagCompound tag = new NBTTagCompound(); + this.object.writeToNBT(tag); + nbt.setCompoundTag("object", tag); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + this.ringTranslation1 = nbt.getFloat("translation1"); + this.ringTranslation2 = nbt.getFloat("translation2"); + this.ringTranslation3 = nbt.getFloat("translation3"); + this.rotAngle = nbt.getFloat("angle"); + this.quantity = nbt.getInteger("quantity"); + this.isDescending1 = nbt.getBoolean("descending1"); + this.isDescending2 = nbt.getBoolean("descending2"); + this.isDescending3 = nbt.getBoolean("descending3"); + this.hasObject = nbt.getBoolean("hasObject"); + this.object = new ItemStack(0, 0, 0); + this.object.readFromNBT(nbt.getCompoundTag("object")); + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(isDirty) + { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = true; + } + if(ringTranslation1 >= 0.6) isDescending1 = true; + if(ringTranslation1 <= 0) isDescending1 = false; + if(!isDescending1) ringTranslation1 += 0.05; + if(isDescending1) ringTranslation1 -= 0.05; + + if(ringTranslation2 >= 0.6) isDescending2 = true; + if(ringTranslation2 <= 0) isDescending2 = false; + if(!isDescending2) ringTranslation2 += 0.04; + if(isDescending2) ringTranslation2 -= 0.04; + + if(ringTranslation3 >= 0.6) isDescending3 = true; + if(ringTranslation3 <= 0) isDescending3 = false; + if(!isDescending3) ringTranslation3 += 0.03; + if(isDescending3) ringTranslation3 -= 0.03; + if(rotAngle < 360F) rotAngle += 6F; + if(rotAngle>=360F) rotAngle = 0F; + } + + @Override + public Packet getDescriptionPacket() + { + Packet132TileEntityData packet = (Packet132TileEntityData) super.getDescriptionPacket(); + NBTTagCompound dataTag = packet != null ? packet.data : new NBTTagCompound(); + writeToNBT(dataTag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, dataTag); + } + + @Override + public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) + { + super.onDataPacket(net, pkt); + NBTTagCompound tag = pkt != null ? pkt.data : new NBTTagCompound(); + readFromNBT(tag); + } +} diff --git a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java index 255d4f5..0821565 100644 --- a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java +++ b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -26,6 +26,8 @@ public class JewelrycraftUtil modifiers.add(new ItemStack(Item.pickaxeIron)); modifiers.add(new ItemStack(Item.bed)); modifiers.add(new ItemStack(Item.eyeOfEnder)); + modifiers.add(new ItemStack(Item.feather)); + modifiers.add(new ItemStack(Item.potion, 1, 8270)); //Jewels jewel.add(new ItemStack(Item.enderPearl)); diff --git a/resources/assets/jewelrycraft/Displayer.tcn b/resources/assets/jewelrycraft/Displayer.tcn Binary files differnew file mode 100644 index 0000000..06113a0 --- /dev/null +++ b/resources/assets/jewelrycraft/Displayer.tcn diff --git a/resources/assets/jewelrycraft/lang/en_US.lang b/resources/assets/jewelrycraft/lang/en_US.lang index 116ed64..667264f 100644 --- a/resources/assets/jewelrycraft/lang/en_US.lang +++ b/resources/assets/jewelrycraft/lang/en_US.lang @@ -10,6 +10,7 @@ item.Jewelrycraft.ring.name=Ring tile.Jewelrycraft.oreShadow.name=Shadow Ore tile.Jewelrycraft.smelter.name=Smelter tile.Jewelrycraft.molder.name=Molder +tile.Jewelrycraft.displayer.name=Displayer tile.Jewelrycraft.jewelCraftingTable.name=Jeweler's Crafting Table itemGroup.JewelryCraft=Jewelrycraft chatmessage.Jewelrycraft.molder.addedmold=Added %s to molder. diff --git a/resources/assets/jewelrycraft/textures/blocks/displayer.png b/resources/assets/jewelrycraft/textures/blocks/displayer.png Binary files differnew file mode 100644 index 0000000..155fa53 --- /dev/null +++ b/resources/assets/jewelrycraft/textures/blocks/displayer.png diff --git a/resources/assets/jewelrycraft/textures/tileentities/Displayer.png b/resources/assets/jewelrycraft/textures/tileentities/Displayer.png Binary files differnew file mode 100644 index 0000000..200637b --- /dev/null +++ b/resources/assets/jewelrycraft/textures/tileentities/Displayer.png |
