diff --git a/Changelog.txt b/Changelog.txt index 0999ec5..729cb47 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4,6 +4,7 @@ Fixed portal orientations. Added a sanguimancy folder to the world save. Improved the Quarry ritual a lot. It is instant, but it works a lot better and costs a lot more. By default you don't get the items mined. Fixed the Chunkloading log not getting generated if the sanguimancy folder already existed. +Modifications to the Blood Amulet. Can now be filled in machines. Version 1.1.8-Pre9: Fixed a world crashing bug with portals. diff --git a/src/main/java/tombenpotter/sanguimancy/blocks/BlockLumpCleaner.java b/src/main/java/tombenpotter/sanguimancy/blocks/BlockLumpCleaner.java index 93b6d91..ce7efa9 100644 --- a/src/main/java/tombenpotter/sanguimancy/blocks/BlockLumpCleaner.java +++ b/src/main/java/tombenpotter/sanguimancy/blocks/BlockLumpCleaner.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidContainerRegistry; import tombenpotter.sanguimancy.Sanguimancy; -import tombenpotter.sanguimancy.tile.TileLumpCleaner; +import tombenpotter.sanguimancy.tile.TileBloodCleaner; import tombenpotter.sanguimancy.util.RandomUtils; public class BlockLumpCleaner extends BlockContainer { @@ -41,7 +41,7 @@ public void registerBlockIcons(IIconRegister ir) { @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileLumpCleaner(); + return new TileBloodCleaner(); } @Override @@ -53,7 +53,7 @@ public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - TileLumpCleaner fluidHandler = (TileLumpCleaner) world.getTileEntity(x, y, z); + TileBloodCleaner fluidHandler = (TileBloodCleaner) world.getTileEntity(x, y, z); if (RandomUtils.fillHandlerWithContainer(world, fluidHandler, player)) { world.markBlockForUpdate(x, y, z); return true; @@ -89,8 +89,8 @@ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase e @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) { int meta = access.getBlockMetadata(x, y, z); - if (access.getTileEntity(x, y, z) != null && access.getTileEntity(x, y, z) instanceof TileLumpCleaner) { - TileLumpCleaner tile = (TileLumpCleaner) access.getTileEntity(x, y, z); + if (access.getTileEntity(x, y, z) != null && access.getTileEntity(x, y, z) instanceof TileBloodCleaner) { + TileBloodCleaner tile = (TileBloodCleaner) access.getTileEntity(x, y, z); if (tile.isActive) { return side == 1 ? this.topIcon : (side == 0 ? this.bottomIcon : (side != meta ? this.blockIcon : this.frontOnIcon)); } else { diff --git a/src/main/java/tombenpotter/sanguimancy/container/ContainerLumpCleaner.java b/src/main/java/tombenpotter/sanguimancy/container/ContainerLumpCleaner.java index 9603ceb..f45e50e 100644 --- a/src/main/java/tombenpotter/sanguimancy/container/ContainerLumpCleaner.java +++ b/src/main/java/tombenpotter/sanguimancy/container/ContainerLumpCleaner.java @@ -7,13 +7,13 @@ import net.minecraft.inventory.SlotFurnace; import net.minecraft.item.ItemStack; import tombenpotter.sanguimancy.registry.ItemsRegistry; -import tombenpotter.sanguimancy.tile.TileLumpCleaner; +import tombenpotter.sanguimancy.tile.TileBloodCleaner; public class ContainerLumpCleaner extends Container { - TileLumpCleaner tile; + TileBloodCleaner tile; - public ContainerLumpCleaner(EntityPlayer player, TileLumpCleaner entity) { + public ContainerLumpCleaner(EntityPlayer player, TileBloodCleaner entity) { this.tile = entity; createSlots(entity, player); bindPlayerInventory(player.inventory); @@ -30,7 +30,7 @@ public void bindPlayerInventory(InventoryPlayer inv) { } } - public void createSlots(TileLumpCleaner tile, EntityPlayer player) { + public void createSlots(TileBloodCleaner tile, EntityPlayer player) { addSlotToContainer(new Slot(tile, 0, 52, 16)); addSlotToContainer(new SlotFurnace(player, tile, 1, 129, 34)); } diff --git a/src/main/java/tombenpotter/sanguimancy/gui/GuiLumpCleaner.java b/src/main/java/tombenpotter/sanguimancy/gui/GuiLumpCleaner.java index ece57ed..2b2d593 100644 --- a/src/main/java/tombenpotter/sanguimancy/gui/GuiLumpCleaner.java +++ b/src/main/java/tombenpotter/sanguimancy/gui/GuiLumpCleaner.java @@ -8,7 +8,7 @@ import org.lwjgl.opengl.GL11; import tombenpotter.sanguimancy.Sanguimancy; import tombenpotter.sanguimancy.container.ContainerLumpCleaner; -import tombenpotter.sanguimancy.tile.TileLumpCleaner; +import tombenpotter.sanguimancy.tile.TileBloodCleaner; import java.util.ArrayList; @@ -17,10 +17,10 @@ public class GuiLumpCleaner extends GuiContainer { public static final ResourceLocation gui = new ResourceLocation(Sanguimancy.texturePath, "textures/gui/LumpCleaner.png"); @SuppressWarnings("unused") public ContainerLumpCleaner container; - public TileLumpCleaner te; + public TileBloodCleaner te; String containerName = "Ore Lump Cleaner"; - public GuiLumpCleaner(EntityPlayer player, TileLumpCleaner tile) { + public GuiLumpCleaner(EntityPlayer player, TileBloodCleaner tile) { super(new ContainerLumpCleaner(player, tile)); this.container = (ContainerLumpCleaner) this.inventorySlots; this.te = tile; diff --git a/src/main/java/tombenpotter/sanguimancy/items/ItemBloodAmulet.java b/src/main/java/tombenpotter/sanguimancy/items/ItemBloodAmulet.java index 967cd80..5d40457 100644 --- a/src/main/java/tombenpotter/sanguimancy/items/ItemBloodAmulet.java +++ b/src/main/java/tombenpotter/sanguimancy/items/ItemBloodAmulet.java @@ -1,5 +1,6 @@ package tombenpotter.sanguimancy.items; +import WayofTime.alchemicalWizardry.AlchemicalWizardry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.GuiScreen; @@ -9,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.StatCollector; @@ -16,13 +18,15 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; import tombenpotter.sanguimancy.Sanguimancy; import tombenpotter.sanguimancy.tile.TileBloodTank; import tombenpotter.sanguimancy.util.RandomUtils; import java.util.List; -public class ItemBloodAmulet extends Item { +public class ItemBloodAmulet extends Item implements IFluidContainerItem { public int bloodLoss = 1200; @@ -50,28 +54,20 @@ public void onUpdate(ItemStack stack, World world, Entity entity, int par4, bool livingBase.motionY = 0; livingBase.motionZ = 0; livingBase.addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 1)); - stack.stackTagCompound.setInteger("blood", stack.stackTagCompound.getInteger("blood") - bloodLoss); + if (drain(stack, bloodLoss, false) != null) { + drain(stack, bloodLoss, true); + } } } } } - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { - if (!world.isRemote && addBloodAndDrainTank(stack, world, x, y, z)) { - return true; - } - return super.onItemUse(stack, player, world, x, y, z, par7, par8, par9, par10); - } - - public boolean addBloodAndDrainTank(ItemStack stack, World world, int x, int y, int z) { - RandomUtils.checkAndSetCompound(stack); + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileBloodTank) { TileBloodTank tile = (TileBloodTank) world.getTileEntity(x, y, z); - if (tile.tank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME) { + if (tile.tank.getFluid() != null && tile.tank.getFluid().fluidID == AlchemicalWizardry.lifeEssenceFluid.getID()) { tile.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.BUCKET_VOLUME, true); - RandomUtils.checkAndSetCompound(stack); - stack.stackTagCompound.setInteger("blood", stack.stackTagCompound.getInteger("blood") + FluidContainerRegistry.BUCKET_VOLUME); - world.markBlockForUpdate(x, y, z); + fill(stack, new FluidStack(AlchemicalWizardry.lifeEssenceFluid, FluidContainerRegistry.BUCKET_VOLUME), true); return true; } } @@ -81,14 +77,80 @@ public boolean addBloodAndDrainTank(ItemStack stack, World world, int x, int y, @SideOnly(Side.CLIENT) @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) { - if (!GuiScreen.isShiftKeyDown()) { - list.add(StatCollector.translateToLocal("info.Sanguimancy.tooltip.shift.info")); + if (stack.hasTagCompound()) { + if (!GuiScreen.isShiftKeyDown()) + list.add(StatCollector.translateToLocal("info.Sanguimancy.tooltip.shift.info")); + else { + NBTTagCompound tag = stack.stackTagCompound.getCompoundTag("tank"); + if (stack.hasTagCompound() && tag.getString("FluidName") != "") { + list.add(StatCollector.translateToLocal("info.Sanguimancy.tooltip.fluid") + ": " + RandomUtils.capitalizeFirstLetter(tag.getString("FluidName"))); + list.add(StatCollector.translateToLocal("info.Sanguimancy.tooltip.amount") + ": " + tag.getInteger("Amount") + "/" + getCapacity(stack) + "mB"); + } + } } - if (GuiScreen.isShiftKeyDown()) { - if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("blood")) { - list.add(StatCollector.translateToLocal("info.Sanguimancy.tooltip.amount") + ": " + stack.stackTagCompound.getInteger("blood") + " mB"); - list.add(bloodLoss + " mB " + StatCollector.translateToLocal("info.Sanguimancy.toolitp.per.point")); + } + + @Override + public FluidStack getFluid(ItemStack stack) { + if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("tank") && stack.stackTagCompound.getCompoundTag("tank").getString("FluidName") != "") { + NBTTagCompound tag = stack.stackTagCompound.getCompoundTag("tank"); + return FluidStack.loadFluidStackFromNBT(tag); + } + return null; + } + + @Override + public int getCapacity(ItemStack container) { + return Integer.MAX_VALUE; + } + + @Override + public int fill(ItemStack stack, FluidStack resource, boolean doFill) { + if (resource == null || stack.stackSize != 1) return 0; + if (resource.fluidID != AlchemicalWizardry.lifeEssenceFluid.getID()) { + return 0; + } + int fillAmount = 0, capacity = getCapacity(stack); + NBTTagCompound tag = stack.stackTagCompound, fluidTag = null; + FluidStack fluid = null; + if (tag == null || !tag.hasKey("tank") || (fluidTag = tag.getCompoundTag("tank")) == null || (fluid = FluidStack.loadFluidStackFromNBT(fluidTag)) == null) + fillAmount = Math.min(capacity, resource.amount); + if (fluid == null) { + if (doFill) { + fluid = resource.copy(); + fluid.amount = 0; } + } else if (!fluid.isFluidEqual(resource)) + return 0; + else + fillAmount = Math.min(capacity - fluid.amount, resource.amount); + fillAmount = Math.max(fillAmount, 0); + if (doFill) { + if (tag == null) + tag = stack.stackTagCompound = new NBTTagCompound(); + fluid.amount += fillAmount; + tag.setTag("tank", fluid.writeToNBT(fluidTag == null ? new NBTTagCompound() : fluidTag)); + } + return fillAmount; + } + + @Override + public FluidStack drain(ItemStack stack, int maxDrain, boolean doDrain) { + NBTTagCompound tag = stack.stackTagCompound, fluidTag = null; + FluidStack fluid = null; + if (tag == null || !tag.hasKey("tank") || (fluidTag = tag.getCompoundTag("tank")) == null || (fluid = FluidStack.loadFluidStackFromNBT(fluidTag)) == null) { + if (fluidTag != null) + tag.removeTag("tank"); + return null; + } + int drainAmount = Math.min(maxDrain, fluid.amount); + if (doDrain) { + tag.removeTag("tank"); + fluid.amount -= drainAmount; + if (fluid.amount > 0) + fill(stack, fluid, true); } + fluid.amount = drainAmount; + return fluid; } } diff --git a/src/main/java/tombenpotter/sanguimancy/proxies/CommonProxy.java b/src/main/java/tombenpotter/sanguimancy/proxies/CommonProxy.java index 5e8171d..7fcf0d0 100644 --- a/src/main/java/tombenpotter/sanguimancy/proxies/CommonProxy.java +++ b/src/main/java/tombenpotter/sanguimancy/proxies/CommonProxy.java @@ -6,7 +6,7 @@ import net.minecraft.world.World; import tombenpotter.sanguimancy.container.ContainerLumpCleaner; import tombenpotter.sanguimancy.gui.GuiLumpCleaner; -import tombenpotter.sanguimancy.tile.TileLumpCleaner; +import tombenpotter.sanguimancy.tile.TileBloodCleaner; public class CommonProxy implements IGuiHandler { @@ -22,8 +22,8 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int TileEntity tile = world.getTileEntity(x, y, z); switch (ID) { case 0: - if (tile != null && tile instanceof TileLumpCleaner) { - return new ContainerLumpCleaner(player, (TileLumpCleaner) tile); + if (tile != null && tile instanceof TileBloodCleaner) { + return new ContainerLumpCleaner(player, (TileBloodCleaner) tile); } default: return null; @@ -35,8 +35,8 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int TileEntity tile = world.getTileEntity(x, y, z); switch (ID) { case 0: - if (tile != null && tile instanceof TileLumpCleaner) { - return new GuiLumpCleaner(player, (TileLumpCleaner) tile); + if (tile != null && tile instanceof TileBloodCleaner) { + return new GuiLumpCleaner(player, (TileBloodCleaner) tile); } default: return null; diff --git a/src/main/java/tombenpotter/sanguimancy/registry/RecipesRegistry.java b/src/main/java/tombenpotter/sanguimancy/registry/RecipesRegistry.java index fadd303..2da631a 100644 --- a/src/main/java/tombenpotter/sanguimancy/registry/RecipesRegistry.java +++ b/src/main/java/tombenpotter/sanguimancy/registry/RecipesRegistry.java @@ -18,7 +18,7 @@ public class RecipesRegistry { - public static IRecipe altarEmitter, sacrificeTransferrer, corruptionReader, unattunedPlayerSacrificer, corruptionCrystallizer, bloodTank, lumpCleaner; + public static IRecipe altarEmitter, sacrificeTransferrer, corruptionReader, unattunedPlayerSacrificer, corruptionCrystallizer, bloodTank, lumpCleaner, bloodAmulet; public static AltarRecipe altarDiviner, attunedPlayerSacrificer, corruptionCatalyst; public static RecipeCorruptedInfusion poisonousPotato, rottenFlesh, crackedStoneBricks, bonemeal, soulSand, corruptedDemonShard, cobblestone, gravel, sand, dirt; @@ -46,6 +46,8 @@ public static void registerOrbRecipes() { bloodTank = RecipeRegistry.getLatestCraftingRecipe(); GameRegistry.addRecipe(new ShapedBloodOrbRecipe(RandomUtils.SanguimancyItemStacks.lumpCleaner, "XXX", "YZY", "ABA", 'X', RandomUtils.SanguimancyItemStacks.oreLump, 'Y', RandomUtils.SanguimancyItemStacks.bloodTank, 'Z', new ItemStack(ModItems.masterBloodOrb), 'A', new ItemStack(Blocks.iron_block), 'B', new ItemStack(Blocks.diamond_block))); lumpCleaner = RecipeRegistry.getLatestCraftingRecipe(); + GameRegistry.addRecipe(new ShapedBloodOrbRecipe(RandomUtils.SanguimancyItemStacks.bloodAmulet, "XYX", "ZAZ", "BCB", 'X', new ItemStack(Items.string), 'Y', new ItemStack(Items.bucket), 'Z', new ItemStack(ModItems.demonicSlate), 'A', new ItemStack(Items.clock), 'B', RandomUtils.SanguimancyItemStacks.bloodTank, 'C', new ItemStack(ModItems.magicianBloodOrb))); + bloodAmulet = RecipeRegistry.getLatestCraftingRecipe(); } public static void registerCustomModRecipes() { diff --git a/src/main/java/tombenpotter/sanguimancy/registry/TileRegistry.java b/src/main/java/tombenpotter/sanguimancy/registry/TileRegistry.java index 1d47c88..e8836e7 100644 --- a/src/main/java/tombenpotter/sanguimancy/registry/TileRegistry.java +++ b/src/main/java/tombenpotter/sanguimancy/registry/TileRegistry.java @@ -11,7 +11,7 @@ public static void registerTEs() { GameRegistry.registerTileEntity(TileSacrificeTransfer.class, "TileSacrificeTransfer"); GameRegistry.registerTileEntity(TileIllusion.class, "TileIllusion"); GameRegistry.registerTileEntity(TileCorruptionCrystallizer.class, "TileCorruptionCrystallizer"); - GameRegistry.registerTileEntity(TileLumpCleaner.class, "TileLumpCleaner"); + GameRegistry.registerTileEntity(TileBloodCleaner.class, "TileBloodCleaner"); GameRegistry.registerTileEntity(TileBloodTank.class, "TileBloodTank"); GameRegistry.registerTileEntity(TileDimensionalPortal.class, "TileDimensionalPortal"); } diff --git a/src/main/java/tombenpotter/sanguimancy/tile/TileLumpCleaner.java b/src/main/java/tombenpotter/sanguimancy/tile/TileBloodCleaner.java similarity index 98% rename from src/main/java/tombenpotter/sanguimancy/tile/TileLumpCleaner.java rename to src/main/java/tombenpotter/sanguimancy/tile/TileBloodCleaner.java index 0cf9798..75ee9b7 100644 --- a/src/main/java/tombenpotter/sanguimancy/tile/TileLumpCleaner.java +++ b/src/main/java/tombenpotter/sanguimancy/tile/TileBloodCleaner.java @@ -14,7 +14,7 @@ import net.minecraftforge.fluids.*; import tombenpotter.sanguimancy.recipes.RecipeBloodCleanser; -public class TileLumpCleaner extends TileEntity implements ISidedInventory, IFluidHandler { +public class TileBloodCleaner extends TileEntity implements ISidedInventory, IFluidHandler { public ItemStack[] inventory; public int capacity; @@ -23,7 +23,7 @@ public class TileLumpCleaner extends TileEntity implements ISidedInventory, IFlu public FluidTank tank; public boolean isActive; - public TileLumpCleaner() { + public TileBloodCleaner() { inventory = new ItemStack[2]; capacity = FluidContainerRegistry.BUCKET_VOLUME * 16; maxTicks = 150; diff --git a/src/main/java/tombenpotter/sanguimancy/util/RandomUtils.java b/src/main/java/tombenpotter/sanguimancy/util/RandomUtils.java index 2cd80b9..ece7c3f 100644 --- a/src/main/java/tombenpotter/sanguimancy/util/RandomUtils.java +++ b/src/main/java/tombenpotter/sanguimancy/util/RandomUtils.java @@ -233,6 +233,7 @@ public static class SanguimancyItemStacks { public static ItemStack corruptedDemonShard = new ItemStack(ItemsRegistry.corruptedDemonShard); public static ItemStack corruptionCatalist = new ItemStack(ItemsRegistry.corruptionCatalyst); public static ItemStack oreLump = new ItemStack(ItemsRegistry.oreLump); + public static ItemStack bloodAmulet = new ItemStack(ItemsRegistry.bloodAmulet); // Blocks public static ItemStack altarEmitter = new ItemStack(BlocksRegistry.altarEmitter); diff --git a/src/main/resources/assets/sanguimancy/textures/blocks/LumpCleaner_Inactive.png b/src/main/resources/assets/sanguimancy/textures/blocks/LumpCleaner_Inactive.png index 249ae70..fee8949 100644 Binary files a/src/main/resources/assets/sanguimancy/textures/blocks/LumpCleaner_Inactive.png and b/src/main/resources/assets/sanguimancy/textures/blocks/LumpCleaner_Inactive.png differ