diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java index 489e77ca..61b7073c 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java @@ -2,6 +2,7 @@ package WayofTime.bloodmagic.block; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.item.ItemDemonCrystal; import WayofTime.bloodmagic.item.block.ItemBlockDemonCrystal; import WayofTime.bloodmagic.soul.EnumDemonWillType; import WayofTime.bloodmagic.soul.PlayerDemonWillHandler; @@ -28,7 +29,6 @@ import net.minecraft.world.World; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.Random; public class BlockDemonCrystal extends Block implements IBMBlock, IVariantProvider { public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 6); @@ -48,17 +48,29 @@ public class BlockDemonCrystal extends Block implements IBMBlock, IVariantProvid @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - if (world.isRemote) - return true; + if (!world.isRemote) { + TileEntity tile = world.getTileEntity(pos); + if (tile instanceof TileDemonCrystal) { + TileDemonCrystal crystal = (TileDemonCrystal) tile; + boolean isCreative = player.capabilities.isCreativeMode; + boolean holdsCrystal = player.getHeldItem(hand).getItem() instanceof ItemDemonCrystal; - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileDemonCrystal) { - TileDemonCrystal crystal = (TileDemonCrystal) tile; + if (PlayerDemonWillHandler.getTotalDemonWill(EnumDemonWillType.DEFAULT, player) > 1024 && !(holdsCrystal && isCreative)) { + crystal.dropSingleCrystal(); - if (PlayerDemonWillHandler.getTotalDemonWill(EnumDemonWillType.DEFAULT, player) > 1024) - crystal.dropSingleCrystal(); + } + if (!crystal.getWorld().isRemote && isCreative && holdsCrystal) { + if (crystal.crystalCount < 7) { + crystal.internalCounter = 0; + if(crystal.progressToNextCrystal > 0) + crystal.progressToNextCrystal--; + crystal.crystalCount++; + crystal.markDirty(); + crystal.notifyUpdate(); + } + } + } } - return true; } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java index 392b3ebf..d856cc42 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java @@ -1,17 +1,16 @@ package WayofTime.bloodmagic.tile; -import net.minecraft.block.state.IBlockState; -import net.minecraft.inventory.InventoryHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import WayofTime.bloodmagic.block.BlockDemonCrystal; import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import WayofTime.bloodmagic.soul.DemonWillHolder; import WayofTime.bloodmagic.soul.EnumDemonWillType; import WayofTime.bloodmagic.tile.base.TileTicking; +import net.minecraft.block.state.IBlockState; +import net.minecraft.inventory.InventoryHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.MathHelper; public class TileDemonCrystal extends TileTicking { @@ -36,6 +35,8 @@ public class TileDemonCrystal extends TileTicking { if (getWorld().isRemote) { + if(internalCounter % 20 == 0) + getWorld().markBlockRangeForRenderUpdate(pos, pos); return; }