diff options
| author | bspkrs <bspkrs@gmail.com> | 2013-12-16 17:14:37 -0500 |
|---|---|---|
| committer | bspkrs <bspkrs@gmail.com> | 2013-12-16 17:14:37 -0500 |
| commit | a10f28bdcf0a94044a7e780cf12f412d6ab6f9b3 (patch) | |
| tree | 3f105ec3bc52c1920e573bfaf4ec3f26314a01b1 | |
| parent | cd382ad8aca86022db99c4d3c472e433cce3d653 (diff) | |
| parent | 0f327ea5c4ca4a621266a7226b4072b332ead6f3 (diff) | |
Merge branch 'master' of https://github.com/sor1n/Modjam-Mod
9 files changed, 415 insertions, 1 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java new file mode 100644 index 0000000..95ebdf5 --- /dev/null +++ b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -0,0 +1,142 @@ +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.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.StatCollector; +import net.minecraft.world.Explosion; +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; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; + +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 && !world.isRemote) + { + if (!te.hasJewel && item != null && item.getItem().itemID == ItemList.ring.itemID) + { + te.jewel = item; + te.hasJewel = true; + --item.stackSize; + } + if (!te.hasModifier && item != null && item.getItem().itemID == modifiers[0]) + { + te.modifier = item; + te.hasModifier = true; + --item.stackSize; + } + + if (te.hasModifier && entityPlayer.isSneaking()) + { + entityPlayer.dropPlayerItem(te.modifier); + te.hasModifier = false; + } + if (te.hasJewel && entityPlayer.isSneaking()) + { + entityPlayer.dropPlayerItem(te.jewel); + te.hasJewel = false; + } + world.setBlockTileEntity(i, j, k, te); + } + return true; + } + + @Override + public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int par5) + { + } + + @Override + public void onBlockDestroyedByExplosion(World world, int i, int j, int k, Explosion par5Explosion) + { + onBlockDestroyedByPlayer(world, i, j, k, 0); + } + + public void giveJewelToPlayer(TileEntityJewelrsCraftingTable cf, EntityPlayer player, ItemStack item) + { + if (item != null) + { + if (cf.modifier.itemID == Item.blazePowder.itemID) + { + ItemRing.addEffect(item, new PotionEffect(12, 12)); + } + player.inventory.addItemStackToInventory(item); + } + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) + { + TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getBlockTileEntity(i, j, k); + if(te.hasJewel && te.hasModifier) + { + giveJewelToPlayer(te, player, te.jewel); + te.jewel = new ItemStack(0, 0, 0); + te.hasJewel = false; + te.modifier = new ItemStack(0, 0, 0); + te.hasModifier = 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 void registerIcons(IconRegister icon) + { + this.blockIcon = icon.registerIcon("jewelrycraft:jewelrsCraftingTable"); + } +} diff --git a/common/darkknight/jewelrycraft/block/BlockList.java b/common/darkknight/jewelrycraft/block/BlockList.java index 368b97f..f094811 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.TileEntityJewelrsCraftingTable; import darkknight.jewelrycraft.tileentity.TileEntityMolder; import darkknight.jewelrycraft.tileentity.TileEntitySmelter; @@ -25,7 +26,7 @@ public class BlockList shadowOre = new BlockBase(ConfigHandler.idShadowOre, Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep).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); - jewelCraftingTable = new BlockBase(ConfigHandler.idJewelCraftingTable, Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("jewelrycraft.jewelCraftingTable").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"); @@ -34,6 +35,7 @@ public class BlockList GameRegistry.registerTileEntity(TileEntitySmelter.class, "30"); GameRegistry.registerTileEntity(TileEntityMolder.class, "31"); + GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, "32"); isInitialized = true; } diff --git a/common/darkknight/jewelrycraft/client/ClientProxy.java b/common/darkknight/jewelrycraft/client/ClientProxy.java index fc19fff..35fec97 100644 --- a/common/darkknight/jewelrycraft/client/ClientProxy.java +++ b/common/darkknight/jewelrycraft/client/ClientProxy.java @@ -2,8 +2,10 @@ package darkknight.jewelrycraft.client; import cpw.mods.fml.client.registry.ClientRegistry; import darkknight.jewelrycraft.CommonProxy; +import darkknight.jewelrycraft.renders.TileEntityJewelrsCraftingTableRender; import darkknight.jewelrycraft.renders.TileEntityMolderRender; import darkknight.jewelrycraft.renders.TileEntitySmelterRender; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; import darkknight.jewelrycraft.tileentity.TileEntityMolder; import darkknight.jewelrycraft.tileentity.TileEntitySmelter; @@ -14,5 +16,6 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmelter.class, new TileEntitySmelterRender()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMolder.class, new TileEntityMolderRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJewelrsCraftingTable.class, new TileEntityJewelrsCraftingTableRender()); } } diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index ba16dd5..8d6b83d 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -2,11 +2,13 @@ package darkknight.jewelrycraft.item; import java.util.List; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; public class ItemRing extends ItemBase { @@ -72,4 +74,16 @@ public class ItemRing extends ItemBase } } } + + public void onUpdate(ItemStack stack, World par2World, Entity par3Entity, int par4, boolean par5) + { + if(stack.getTagCompound().hasKey("effect")) + { + NBTTagCompound effectNBT = (NBTTagCompound) stack.getTagCompound().getTag("effect"); + PotionEffect effect = new PotionEffect(0, 0); + effect.readCustomPotionEffectFromNBT(effectNBT); + ((EntityPlayer)par3Entity).addPotionEffect(effect); + + } + } } diff --git a/common/darkknight/jewelrycraft/model/ModelJewlersCraftingBench.java b/common/darkknight/jewelrycraft/model/ModelJewlersCraftingBench.java new file mode 100644 index 0000000..1cc3f72 --- /dev/null +++ b/common/darkknight/jewelrycraft/model/ModelJewlersCraftingBench.java @@ -0,0 +1,140 @@ +package darkknight.jewelrycraft.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelJewlersCraftingBench extends ModelBase +{ + //fields + ModelRenderer Leg1; + ModelRenderer Leg2; + ModelRenderer Leg3; + ModelRenderer Leg4; + ModelRenderer Top; + ModelRenderer Support1; + ModelRenderer Support2; + ModelRenderer Support3; + ModelRenderer Support4; + ModelRenderer Support5; + ModelRenderer Support6; + ModelRenderer Support7; + ModelRenderer Support8; + + public ModelJewlersCraftingBench() + { + textureWidth = 64; + textureHeight = 32; + + Leg1 = new ModelRenderer(this, 0, 0); + Leg1.addBox(0F, 0F, 0F, 2, 10, 2); + Leg1.setRotationPoint(-6F, 14F, 4F); + Leg1.setTextureSize(64, 32); + Leg1.mirror = true; + setRotation(Leg1, 0F, 0F, 0F); + Leg2 = new ModelRenderer(this, 0, 0); + Leg2.addBox(0F, 0F, 0F, 2, 10, 2); + Leg2.setRotationPoint(-6F, 14F, -6F); + Leg2.setTextureSize(64, 32); + Leg2.mirror = true; + setRotation(Leg2, 0F, 0F, 0F); + Leg3 = new ModelRenderer(this, 0, 0); + Leg3.addBox(0F, 0F, 0F, 2, 10, 2); + Leg3.setRotationPoint(4F, 14F, -6F); + Leg3.setTextureSize(64, 32); + Leg3.mirror = true; + setRotation(Leg3, 0F, 0F, 0F); + Leg4 = new ModelRenderer(this, 0, 0); + Leg4.addBox(0F, 0F, 0F, 2, 10, 2); + Leg4.setRotationPoint(4F, 14F, 4F); + Leg4.setTextureSize(64, 32); + Leg4.mirror = true; + setRotation(Leg4, 0F, 0F, 0F); + Top = new ModelRenderer(this, 0, 13); + Top.addBox(0F, 0F, 0F, 16, 1, 16); + Top.setRotationPoint(-8F, 13F, -8F); + Top.setTextureSize(64, 32); + Top.mirror = true; + setRotation(Top, 0F, 0F, 0F); + Support1 = new ModelRenderer(this, 0, 0); + Support1.addBox(0F, 0F, 0F, 3, 1, 1); + Support1.setRotationPoint(3F, 12F, 5F); + Support1.setTextureSize(64, 32); + Support1.mirror = true; + setRotation(Support1, 0F, 0F, 0F); + Support2 = new ModelRenderer(this, 0, 0); + Support2.addBox(0F, 0F, 0F, 1, 1, 3); + Support2.setRotationPoint(2F, 12F, 2F); + Support2.setTextureSize(64, 32); + Support2.mirror = true; + setRotation(Support2, 0F, 0F, 0F); + Support3 = new ModelRenderer(this, 0, 0); + Support3.addBox(0F, 0F, 0F, 1, 1, 3); + Support3.setRotationPoint(6F, 12F, 2F); + Support3.setTextureSize(64, 32); + Support3.mirror = true; + setRotation(Support3, 0F, 0F, 0F); + Support4 = new ModelRenderer(this, 0, 0); + Support4.addBox(0F, 0F, 0F, 3, 1, 1); + Support4.setRotationPoint(3F, 12F, 1F); + Support4.setTextureSize(64, 32); + Support4.mirror = true; + setRotation(Support4, 0F, 0F, 0F); + Support5 = new ModelRenderer(this, 0, 0); + Support5.addBox(0F, 0F, 0F, 1, 1, 3); + Support5.setRotationPoint(-3F, 12F, 2F); + Support5.setTextureSize(64, 32); + Support5.mirror = true; + setRotation(Support5, 0F, 0F, 0F); + Support6 = new ModelRenderer(this, 0, 0); + Support6.addBox(0F, 0F, 0F, 3, 1, 1); + Support6.setRotationPoint(-6F, 12F, 5F); + Support6.setTextureSize(64, 32); + Support6.mirror = true; + setRotation(Support6, 0F, 0F, 0F); + Support7 = new ModelRenderer(this, 0, 0); + Support7.addBox(0F, 0F, 0F, 1, 1, 3); + Support7.setRotationPoint(-7F, 12F, 2F); + Support7.setTextureSize(64, 32); + Support7.mirror = true; + setRotation(Support7, 0F, 0F, 0F); + Support8 = new ModelRenderer(this, 0, 0); + Support8.addBox(0F, 0F, 0F, 3, 1, 1); + Support8.setRotationPoint(-6F, 12F, 1F); + Support8.setTextureSize(64, 32); + Support8.mirror = true; + setRotation(Support8, 0F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5); + Leg1.render(f5); + Leg2.render(f5); + Leg3.render(f5); + Leg4.render(f5); + Top.render(f5); + Support1.render(f5); + Support2.render(f5); + Support3.render(f5); + Support4.render(f5); + Support5.render(f5); + Support6.render(f5); + Support7.render(f5); + Support8.render(f5); + } + + 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/renders/TileEntityJewelrsCraftingTableRender.java b/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java new file mode 100644 index 0000000..51db2da --- /dev/null +++ b/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java @@ -0,0 +1,48 @@ +package darkknight.jewelrycraft.renders; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.model.ModelJewlersCraftingBench; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRenderer +{ + ModelJewlersCraftingBench modelTable = new ModelJewlersCraftingBench(); + String texture = "textures/tileentities/JewelrsCraftingBench.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); + + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + + 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); + 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); + } + +} diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java new file mode 100644 index 0000000..5cce837 --- /dev/null +++ b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -0,0 +1,65 @@ +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 TileEntityJewelrsCraftingTable extends TileEntity +{ + public boolean hasJewel, hasModifier; + public ItemStack jewel, modifier; + + public TileEntityJewelrsCraftingTable() + { + this.jewel = new ItemStack(0, 0, 0); + this.modifier = new ItemStack(0, 0, 0); + this.hasJewel = false; + this.hasModifier = false; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setBoolean("hasJewel", hasJewel); + nbt.setBoolean("hasModifier", hasModifier); + NBTTagCompound tag = new NBTTagCompound(); + NBTTagCompound tag1 = new NBTTagCompound(); + this.jewel.writeToNBT(tag); + nbt.setCompoundTag("jewel", tag); + this.modifier.writeToNBT(tag1); + nbt.setCompoundTag("modifier", tag1); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + this.hasJewel = nbt.getBoolean("hasJewel"); + this.hasModifier = nbt.getBoolean("hasModifier"); + this.jewel = new ItemStack(0, 0, 0); + this.jewel.readFromNBT(nbt.getCompoundTag("jewel")); + this.modifier = new ItemStack(0, 0, 0); + this.modifier.readFromNBT(nbt.getCompoundTag("modifier")); + } + + public void updateEntity() + { + super.updateEntity(); + } + + public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) + { + readFromNBT(pkt.data); + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbtTag = new NBTTagCompound(); + this.writeToNBT(nbtTag); + return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); + } +} diff --git a/resources/assets/jewelrycraft/textures/blocks/jewelrsCraftingTable.png b/resources/assets/jewelrycraft/textures/blocks/jewelrsCraftingTable.png Binary files differnew file mode 100644 index 0000000..e826bbe --- /dev/null +++ b/resources/assets/jewelrycraft/textures/blocks/jewelrsCraftingTable.png diff --git a/resources/assets/jewelrycraft/textures/tileentities/JewelrsCraftingBench.png b/resources/assets/jewelrycraft/textures/tileentities/JewelrsCraftingBench.png Binary files differnew file mode 100644 index 0000000..1ee75d0 --- /dev/null +++ b/resources/assets/jewelrycraft/textures/tileentities/JewelrsCraftingBench.png |
