diff --git a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java index 19cb3f84..466a3c3b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java @@ -254,6 +254,7 @@ import WayofTime.alchemicalWizardry.common.tileEntity.TEAlchemicCalcinator; import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar; import WayofTime.alchemicalWizardry.common.tileEntity.TEBellJar; import WayofTime.alchemicalWizardry.common.tileEntity.TEConduit; +import WayofTime.alchemicalWizardry.common.tileEntity.TECrucible; import WayofTime.alchemicalWizardry.common.tileEntity.TEHomHeart; import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone; import WayofTime.alchemicalWizardry.common.tileEntity.TEMimicBlock; @@ -276,10 +277,10 @@ import WayofTime.alchemicalWizardry.common.tweaker.MineTweakerIntegration; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; @@ -769,6 +770,7 @@ public class AlchemicalWizardry GameRegistry.registerTileEntity(TEAlchemicCalcinator.class, "containerAlchemicCalcinator"); GameRegistry.registerTileEntity(TEDemonChest.class, "containerDemonChest"); GameRegistry.registerTileEntity(TEMimicBlock.class, "containerMimic"); + GameRegistry.registerTileEntity(TECrucible.class, "containerCrucible"); ModBlocks.bloodRune.setHarvestLevel("pickaxe", 2); ModBlocks.speedRune.setHarvestLevel("pickaxe", 2); ModBlocks.efficiencyRune.setHarvestLevel("pickaxe", 2); diff --git a/src/main/java/WayofTime/alchemicalWizardry/ModBlocks.java b/src/main/java/WayofTime/alchemicalWizardry/ModBlocks.java index bf90abce..97aa9cba 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/ModBlocks.java +++ b/src/main/java/WayofTime/alchemicalWizardry/ModBlocks.java @@ -99,7 +99,7 @@ public class ModBlocks public static Block blockMimic; public static Block blockEnchantmentGlyph; public static Block blockStabilityGlyph; - public static Block blockIncence; + public static Block blockCrucible; public static void init() { @@ -142,7 +142,7 @@ public class ModBlocks blockLifeEssence = new LifeEssenceBlock(); blockEnchantmentGlyph = new BlockEnchantmentGlyph(); blockStabilityGlyph = new BlockStabilityGlyph(); - blockIncence = new BlockCrucible(); + blockCrucible = new BlockCrucible(); } public static void registerBlocksInPre() @@ -189,7 +189,7 @@ public class ModBlocks GameRegistry.registerBlock(ModBlocks.blockEnchantmentGlyph, ItemEnchantmentGlyphBlock.class, "blockEnchantmentGlyph"); GameRegistry.registerBlock(ModBlocks.blockStabilityGlyph, ItemStabilityGlyphBlock.class, "blockStabilityGlyph"); -// GameRegistry.registerBlock(ModBlocks.blockIncence, "blockIncence"); + GameRegistry.registerBlock(ModBlocks.blockCrucible, "blockCrucible"); } public static void registerBlocksInInit() diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/sacrifice/IIncense.java b/src/main/java/WayofTime/alchemicalWizardry/api/sacrifice/IIncense.java new file mode 100644 index 00000000..5e6f62ca --- /dev/null +++ b/src/main/java/WayofTime/alchemicalWizardry/api/sacrifice/IIncense.java @@ -0,0 +1,20 @@ +package WayofTime.alchemicalWizardry.api.sacrifice; + +import net.minecraft.item.ItemStack; + +public interface IIncense +{ + public int getMinLevel(ItemStack stack); + + public int getMaxLevel(ItemStack stack); + + public int getIncenseDuration(ItemStack stack); + + /** + * @param stack + * @return a float from 0 to 1 + */ + public float getRedColour(ItemStack stack); + public float getGreenColour(ItemStack stack); + public float getBlueColour(ItemStack stack); +} diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/sacrifice/PlayerSacrificeHandler.java b/src/main/java/WayofTime/alchemicalWizardry/api/sacrifice/PlayerSacrificeHandler.java new file mode 100644 index 00000000..2f3de3bf --- /dev/null +++ b/src/main/java/WayofTime/alchemicalWizardry/api/sacrifice/PlayerSacrificeHandler.java @@ -0,0 +1,36 @@ +package WayofTime.alchemicalWizardry.api.sacrifice; + +import WayofTime.alchemicalWizardry.api.spell.APISpellHelper; +import net.minecraft.entity.player.EntityPlayer; + +public class PlayerSacrificeHandler +{ + public int getPlayerIncense(EntityPlayer player) + { + return APISpellHelper.getCurrentIncense(player); + } + + public void setPlayerIncense(EntityPlayer player, int amount) + { + APISpellHelper.setCurrentIncense(player, amount); + } + + public boolean incrementIncense(EntityPlayer player, int min, int max) + { + int amount = this.getPlayerIncense(player); + if(amount < min || amount >= max) + { + return false; + } + + amount++; + + return true; + } + + public boolean sacrificePlayerHealth(EntityPlayer player) + { + + return false; + } +} diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java index 8bac8bd5..78a94eea 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java @@ -42,6 +42,23 @@ public class APISpellHelper return beaconData; } + public static int getCurrentIncense(EntityPlayer player) + { + NBTTagCompound data = player.getEntityData(); + if(data.hasKey("BM:CurrentIncense")) + { + return data.getInteger("BM:CurrentIncense"); + } + + return 0; + } + + public static void setCurrentIncense(EntityPlayer player, int amount) + { + NBTTagCompound data = player.getEntityData(); + data.setInteger("BM:CurrentIncense", amount); + } + public static int getPlayerLPTag(EntityPlayer player) { NBTTagCompound data = APISpellHelper.getPersistentDataTag(player); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrucible.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrucible.java index b9b778e0..c17fa34a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrucible.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrucible.java @@ -1,19 +1,23 @@ package WayofTime.alchemicalWizardry.common.block; -import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import net.minecraft.block.Block; +import java.util.Random; + +import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.tileEntity.TECrucible; -public class BlockCrucible extends Block +public class BlockCrucible extends BlockContainer { public BlockCrucible() { super(Material.anvil); this.setCreativeTab(AlchemicalWizardry.tabBloodMagic); - this.setBlockName("blockIncence"); + this.setBlockName("blockCrucible"); } @Override @@ -39,4 +43,20 @@ public class BlockCrucible extends Block { return false; } + + @Override + public TileEntity createNewTileEntity(World world, int meta) + { + return new TECrucible(); + } + + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random rand) + { + if (rand.nextInt(3) != 0) + { + TECrucible tile = (TECrucible)world.getTileEntity(x, y, z); + tile.spawnClientParticle(world, x, y, z, rand); + } + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TECrucible.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TECrucible.java new file mode 100644 index 00000000..fac7ebf2 --- /dev/null +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TECrucible.java @@ -0,0 +1,118 @@ +package WayofTime.alchemicalWizardry.common.tileEntity; + +import java.util.Random; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.api.sacrifice.IIncense; + +public class TECrucible extends TEInventory +{ + public float rColour; + public float gColour; + public float bColour; + + public int ticksRemaining = 0; + + public TECrucible() + { + super(1); + float f = (float) 1.0F; + float f1 = f * 0.6F + 0.4F; + float f2 = f * f * 0.7F - 0.5F; + float f3 = f * f * 0.6F - 0.7F; + rColour = f1; + gColour = f2; + bColour = f3; + } + + @Override + public void updateEntity() + { + if(ticksRemaining <= 0) + { + ItemStack stack = this.getStackInSlot(0); + if(stack != null && stack.getItem() instanceof IIncense) + { + IIncense incense = (IIncense)stack.getItem(); + + rColour = incense.getRedColour(stack); + gColour = incense.getGreenColour(stack); + bColour = incense.getBlueColour(stack); + ticksRemaining = incense.getIncenseDuration(stack); + + stack.stackSize--; + if(stack.stackSize <= 0) + { + this.setInventorySlotContents(0, null); + } + } + }else + { + ticksRemaining--; + } + + } + + public void spawnClientParticle(World world, int x, int y, int z, Random rand) + { + world.spawnParticle("reddust", x + 0.5D + rand.nextGaussian() / 8, y + 0.5D, z + 0.5D + rand.nextGaussian() / 8, rColour, gColour, bColour); + } + + @Override + public void writeToNBT(NBTTagCompound tag) + { + super.writeToNBT(tag); + this.writeClientNBT(tag); + } + + @Override + public void readFromNBT(NBTTagCompound tag) + { + super.readFromNBT(tag); + this.readClientNBT(tag); + } + + public void readClientNBT(NBTTagCompound tag) + { + rColour = tag.getFloat("rColour"); + gColour = tag.getFloat("gColour"); + bColour = tag.getFloat("bColour"); + + ticksRemaining = tag.getInteger("ticksRemaining"); + } + + public void writeClientNBT(NBTTagCompound tag) + { + tag.setFloat("rColour", rColour); + tag.setFloat("gColour", gColour); + tag.setFloat("bColour", bColour); + + tag.setInteger("ticksRemaining", ticksRemaining); + } + + @Override + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeClientNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 90210, nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) + { + super.onDataPacket(net, packet); + readClientNBT(packet.func_148857_g()); + } + + @Override + public String getInventoryName() + { + return "TECrucible"; + } +}