diff --git a/src/main/java/makeo/gadomancy/client/ClientProxy.java b/src/main/java/makeo/gadomancy/client/ClientProxy.java index 94882e5..ce21038 100644 --- a/src/main/java/makeo/gadomancy/client/ClientProxy.java +++ b/src/main/java/makeo/gadomancy/client/ClientProxy.java @@ -21,31 +21,9 @@ import makeo.gadomancy.client.renderers.item.ItemRenderRemoteJar; import makeo.gadomancy.client.renderers.item.ItemRenderStoneMachine; import makeo.gadomancy.client.renderers.item.ItemRenderTileEntity; import makeo.gadomancy.client.renderers.item.ItemRenderTileEntityMulti; -import makeo.gadomancy.client.renderers.tile.RenderTileArcaneDropper; -import makeo.gadomancy.client.renderers.tile.RenderTileAuraPylon; -import makeo.gadomancy.client.renderers.tile.RenderTileCapEldritch; -import makeo.gadomancy.client.renderers.tile.RenderTileExtendedNode; -import makeo.gadomancy.client.renderers.tile.RenderTileExtendedNodeJar; -import makeo.gadomancy.client.renderers.tile.RenderTileInfusionClaw; -import makeo.gadomancy.client.renderers.tile.RenderTileManipulationFocus; -import makeo.gadomancy.client.renderers.tile.RenderTileManipulatorPillar; -import makeo.gadomancy.client.renderers.tile.RenderTileNodeManipulator; -import makeo.gadomancy.client.renderers.tile.RenderTileObelisk; -import makeo.gadomancy.client.renderers.tile.RenderTileRemoteJar; -import makeo.gadomancy.client.renderers.tile.RenderTileStickyJar; +import makeo.gadomancy.client.renderers.tile.*; import makeo.gadomancy.common.CommonProxy; -import makeo.gadomancy.common.blocks.tiles.TileAdditionalEldritchPortal; -import makeo.gadomancy.common.blocks.tiles.TileArcaneDropper; -import makeo.gadomancy.common.blocks.tiles.TileAuraPylon; -import makeo.gadomancy.common.blocks.tiles.TileAuraPylonTop; -import makeo.gadomancy.common.blocks.tiles.TileExtendedNode; -import makeo.gadomancy.common.blocks.tiles.TileExtendedNodeJar; -import makeo.gadomancy.common.blocks.tiles.TileInfusionClaw; -import makeo.gadomancy.common.blocks.tiles.TileManipulationFocus; -import makeo.gadomancy.common.blocks.tiles.TileManipulatorPillar; -import makeo.gadomancy.common.blocks.tiles.TileNodeManipulator; -import makeo.gadomancy.common.blocks.tiles.TileRemoteJar; -import makeo.gadomancy.common.blocks.tiles.TileStickyJar; +import makeo.gadomancy.common.blocks.tiles.*; import makeo.gadomancy.common.registration.RegisteredBlocks; import makeo.gadomancy.common.registration.RegisteredItems; import makeo.gadomancy.common.utils.Injector; @@ -126,6 +104,9 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileAuraPylon.class, renderTileAuraPylon); ClientRegistry.bindTileEntitySpecialRenderer(TileAuraPylonTop.class, renderTileAuraPylon); + RenderTileBlockProtector renderTileBlockProtector = new RenderTileBlockProtector(); + ClientRegistry.bindTileEntitySpecialRenderer(TileBlockProtector.class, renderTileBlockProtector); + //Items TileArcaneDropper fakeTile = new TileArcaneDropper(); fakeTile.blockMetadata = 8 | ForgeDirection.SOUTH.ordinal(); @@ -148,6 +129,9 @@ public class ClientProxy extends CommonProxy { TileManipulationFocus tileManipulationFocus = new TileManipulationFocus(); tileManipulationFocus.blockMetadata = 3; itemRenderStoneMachine.registerRenderer(3, tileManipulationFocus, renderTileManipulationFocus); + TileBlockProtector tileBlockProtector = new TileBlockProtector(); + tileBlockProtector.facing = 3; + itemRenderStoneMachine.registerRenderer(2, tileBlockProtector, renderTileBlockProtector); MinecraftForgeClient.registerItemRenderer(RegisteredItems.itemFamiliar, new ItemRenderFamiliar()); MinecraftForgeClient.registerItemRenderer(RegisteredItems.itemCreativeNode, new ItemCreativeNodeRenderer()); diff --git a/src/main/java/makeo/gadomancy/client/models/ModelBlockProtector.java b/src/main/java/makeo/gadomancy/client/models/ModelBlockProtector.java new file mode 100644 index 0000000..baae869 --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/models/ModelBlockProtector.java @@ -0,0 +1,138 @@ +package makeo.gadomancy.client.models; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +/** + * This class is part of the Gadomancy Mod + * Gadomancy is Open Source and distributed under the + * GNU LESSER GENERAL PUBLIC LICENSE + * for more read the LICENSE file + *
+ * Created by makeo @ 11.11.2015 17:15 + */ +public class ModelBlockProtector extends ModelBase { + //fields + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape11; + ModelRenderer Shape12; + ModelRenderer Shape13; + + public ModelBlockProtector() { + textureWidth = 64; + textureHeight = 64; + + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(0F, 0F, 0F, 16, 3, 16); + Shape1.setRotationPoint(-8F, 21F, -8F); + Shape1.setTextureSize(64, 64); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + Shape2 = new ModelRenderer(this, 0, 20); + Shape2.addBox(0F, 0F, 0F, 4, 1, 1); + Shape2.setRotationPoint(-2F, 20F, -8F); + Shape2.setTextureSize(64, 64); + Shape2.mirror = true; + setRotation(Shape2, 0F, 0F, 0F); + Shape3 = new ModelRenderer(this, 11, 20); + Shape3.addBox(0F, 0F, 0F, 4, 1, 3); + Shape3.setRotationPoint(-2F, 20F, -7F); + Shape3.setTextureSize(64, 64); + Shape3.mirror = true; + setRotation(Shape3, -0.3490659F, 0F, 0F); + Shape4 = new ModelRenderer(this, 27, 20); + Shape4.addBox(0F, 0F, 0F, 4, 1, 1); + Shape4.setRotationPoint(-2F, 20F, 7F); + Shape4.setTextureSize(64, 64); + Shape4.mirror = true; + setRotation(Shape4, 0F, 0F, 0F); + Shape5 = new ModelRenderer(this, 38, 20); + Shape5.addBox(0F, 0F, -3F, 4, 1, 3); + Shape5.setRotationPoint(-2F, 20F, 7F); + Shape5.setTextureSize(64, 64); + Shape5.mirror = true; + setRotation(Shape5, 0.3490659F, 0F, 0F); + Shape6 = new ModelRenderer(this, 0, 25); + Shape6.addBox(0F, 0F, 0F, 1, 1, 4); + Shape6.setRotationPoint(-8F, 20F, -2F); + Shape6.setTextureSize(64, 64); + Shape6.mirror = true; + setRotation(Shape6, 0F, 0F, 0F); + Shape7 = new ModelRenderer(this, 11, 25); + Shape7.addBox(0F, 0F, 0F, 3, 1, 4); + Shape7.setRotationPoint(-7F, 20F, -2F); + Shape7.setTextureSize(64, 64); + Shape7.mirror = true; + setRotation(Shape7, 0F, 0F, 0.3490659F); + Shape8 = new ModelRenderer(this, 38, 25); + Shape8.addBox(-3F, 0F, 0F, 3, 1, 4); + Shape8.setRotationPoint(7F, 20F, -2F); + Shape8.setTextureSize(64, 64); + Shape8.mirror = true; + setRotation(Shape8, 0F, 0F, -0.3490659F); + Shape9 = new ModelRenderer(this, 27, 25); + Shape9.addBox(0F, 0F, 0F, 1, 1, 4); + Shape9.setRotationPoint(7F, 20F, -2F); + Shape9.setTextureSize(64, 64); + Shape9.mirror = true; + setRotation(Shape9, 0F, 0F, 0F); + Shape10 = new ModelRenderer(this, 0, 31); + Shape10.addBox(0F, -7F, 0F, 2, 8, 2); + Shape10.setRotationPoint(3F, 22F, 3F); + Shape10.setTextureSize(64, 64); + Shape10.mirror = true; + setRotation(Shape10, 0.3490659F, 0F, -0.3490659F); + Shape11 = new ModelRenderer(this, 10, 31); + Shape11.addBox(-2F, -7F, -2F, 2, 8, 2); + Shape11.setRotationPoint(-3F, 22F, -3F); + Shape11.setTextureSize(64, 64); + Shape11.mirror = true; + setRotation(Shape11, -0.3490659F, 0F, 0.3490659F); + Shape12 = new ModelRenderer(this, 20, 31); + Shape12.addBox(0F, -7F, -2F, 2, 8, 2); + Shape12.setRotationPoint(3F, 22F, -3F); + Shape12.setTextureSize(64, 64); + Shape12.mirror = true; + setRotation(Shape12, -0.3490659F, 0F, -0.3490659F); + Shape13 = new ModelRenderer(this, 30, 31); + Shape13.addBox(-2F, -7F, 0F, 2, 8, 2); + Shape13.setRotationPoint(-3F, 22F, 3F); + Shape13.setTextureSize(64, 64); + Shape13.mirror = true; + setRotation(Shape13, 0.3490659F, 0F, 0.3490659F); + } + + 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, entity); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape6.render(f5); + Shape7.render(f5); + Shape8.render(f5); + Shape9.render(f5); + Shape10.render(f5); + Shape11.render(f5); + Shape12.render(f5); + Shape13.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileBlockProtector.java b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileBlockProtector.java new file mode 100644 index 0000000..dc74077 --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/renderers/tile/RenderTileBlockProtector.java @@ -0,0 +1,71 @@ +package makeo.gadomancy.client.renderers.tile; + +import makeo.gadomancy.client.models.ModelBlockProtector; +import makeo.gadomancy.common.blocks.tiles.TileBlockProtector; +import makeo.gadomancy.common.utils.SimpleResourceLocation; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import thaumcraft.client.renderers.models.ModelJar; +import thaumcraft.client.renderers.tile.TileJarRenderer; + +/** + * This class is part of the Gadomancy Mod + * Gadomancy is Open Source and distributed under the + * GNU LESSER GENERAL PUBLIC LICENSE + * for more read the LICENSE file + * + * Created by makeo @ 11.11.2015 16:28 + */ +public class RenderTileBlockProtector extends TileJarRenderer { + private static final ResourceLocation TEXTURE_OFF = new SimpleResourceLocation("models/block_protector_off.png"); + private static final ResourceLocation TEXTURE_ON = new SimpleResourceLocation("models/block_protector_on.png"); + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) { + renderTileEntityAt((TileBlockProtector)tile, x, y, z, partialTicks); + } + + public void renderTileEntityAt(TileBlockProtector tile, double x, double y, double z, float partialTicks) { + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + + GL11.glTranslatef(0.5f, 0, 0.5f); + GL11.glRotatef(90*tile.facing, 0, 1, 0); + GL11.glTranslatef(-0.5f, 0, -0.5f); + + GL11.glPushMatrix(); + GL11.glTranslatef(0, -2/16f - 0.03f, 0); + GL11.glScalef(0.4f, 0.4f, 0.4f); + GL11.glTranslatef(0.75f, 0.75f, 0.75f); + + int oldFacing = tile.facing; + tile.facing = 0; + super.renderTileEntityAt(tile, 0, 0, 0, partialTicks); + tile.facing = oldFacing; + + GL11.glPopMatrix(); + + + GL11.glPushMatrix(); + GL11.glTranslatef(0.5f, 1.5f, 0.5f); + GL11.glRotatef(180, 1, 0, 0); + + bindTexture(tile.getPowerLevel() > 0 ? TEXTURE_ON : TEXTURE_OFF); + new ModelBlockProtector().render(null, 0, 0, 0, 0, 0, 0.0625f); + GL11.glPopMatrix(); + + + GL11.glTranslatef(0, -2/16f - 0.03f, 0); + GL11.glScalef(0.4f, 0.4f, 0.4f); + GL11.glTranslatef(0.75f, 0.75f, 0.75f); + + GL11.glRotatef(180, 0, 0, 1); + GL11.glTranslatef(-0.5f, 0, 0.5f); + + bindTexture(new ResourceLocation("thaumcraft", "textures/models/jar.png")); + new ModelJar().renderAll(); + + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/makeo/gadomancy/common/blocks/BlockInfusionClaw.java b/src/main/java/makeo/gadomancy/common/blocks/BlockInfusionClaw.java index 7b5f25a..850a78b 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/BlockInfusionClaw.java +++ b/src/main/java/makeo/gadomancy/common/blocks/BlockInfusionClaw.java @@ -16,8 +16,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; -import java.util.Random; - /** * This class is part of the Gadomancy Mod * Gadomancy is Open Source and distributed under the @@ -27,8 +25,6 @@ import java.util.Random; * Created by makeo @ 05.10.2015 21:38 */ public class BlockInfusionClaw extends BlockTransparent { - private static final Random RANDOM = new Random(); - public BlockInfusionClaw() { super(Material.rock); setHardness(3.5f); @@ -90,9 +86,9 @@ public class BlockInfusionClaw extends BlockTransparent { TileInfusionClaw tile = (TileInfusionClaw) world.getTileEntity(x, y, z); ItemStack wandStack = tile.getStackInSlot(0); if(wandStack != null && wandStack.stackSize > 0) { - float f = RANDOM.nextFloat() * 0.8F + 0.1F; - float f1 = RANDOM.nextFloat() * 0.8F + 0.1F; - float f2 = RANDOM.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityItem = new EntityItem(world, x + f, y + f1, z + f2, wandStack.copy()); ItemUtils.applyRandomDropOffset(entityItem, world.rand); diff --git a/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java b/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java index 7eb689a..0ef8b1f 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java +++ b/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java @@ -11,17 +11,20 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import thaumcraft.common.config.ConfigBlocks; import thaumcraft.common.lib.utils.InventoryUtils; +import thaumcraft.common.tiles.TileJarFillable; import thaumcraft.common.tiles.TilePedestal; import java.util.List; @@ -49,6 +52,7 @@ public class BlockStoneMachine extends Block { private IIcon focusIcon; public IIcon pedestalSideIcon; public IIcon pedestalTopIcon; + public IIcon protectorIcon; @Override public void registerBlockIcons(IIconRegister ir) { @@ -56,6 +60,7 @@ public class BlockStoneMachine extends Block { focusIcon = ir.registerIcon("thaumcraft:thaumiumblock"); pedestalTopIcon = ir.registerIcon(Gadomancy.MODID + ":manipulator_bot"); pedestalSideIcon = ir.registerIcon(Gadomancy.MODID + ":ancient_pedestal_side"); + protectorIcon = ir.registerIcon("thaumcraft:pipe_1"); } @Override @@ -70,8 +75,8 @@ public class BlockStoneMachine extends Block { } else { return pedestalTopIcon; } - } else if(metadata == 2) { - return pedestalTopIcon; + } else if (metadata == 2) { + return protectorIcon; } return super.getIcon(side, metadata); @@ -106,11 +111,11 @@ public class BlockStoneMachine extends Block { return new TileManipulatorPillar(); } else if (metadata == 0) { return new TileManipulationFocus(); - } else if(metadata == 1) { + } else if (metadata == 1) { return new TilePedestal(); - } else if(metadata == 2) { + } else if (metadata == 2) { return new TileBlockProtector(); - } else if(metadata == 3) { + } else if (metadata == 3) { return new TileManipulationFocus(); } return null; @@ -130,12 +135,12 @@ public class BlockStoneMachine extends Block { return super.getItemDropped(metadata, random, fortune); } - public void breakBlock(World world, int x, int y, int z, Block block, int metadata) { - if(metadata == 1) { - InventoryUtils.dropItems(world, x, y, z); - } - super.breakBlock(world, x, y, z, block, metadata); - } + public void breakBlock(World world, int x, int y, int z, Block block, int metadata) { + if (metadata == 1) { + InventoryUtils.dropItems(world, x, y, z); + } + super.breakBlock(world, x, y, z, block, metadata); + } @Override public boolean canReplace(World world, int x, int y, int z, int side, ItemStack stack) { @@ -146,6 +151,14 @@ public class BlockStoneMachine extends Block { return super.canReplace(world, x, y, z, side, stack); } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase ent, ItemStack stack) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 2) { + ((TileJarFillable) world.getTileEntity(x, y, z)).facing = MathHelper.floor_double(-ent.rotationYaw * 4.0F / 360.0F + 0.5D) & 0x3; + } + } + @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { int metadata = world.getBlockMetadata(x, y, z); @@ -167,25 +180,30 @@ public class BlockStoneMachine extends Block { } } - /*@Override - public void onPostBlockPlaced(World world, int x, int y, int z, int metadata) { - if(metadata == 0 || metadata == 3) { - TileEntity te = world.getTileEntity(x, y, z); - if(te != null && te instanceof TileManipulationFocus) { - ((TileManipulationFocus) te).setFociId(metadata == 0 ? 0 : 1); - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata == 2) { + TileBlockProtector protector = (TileBlockProtector) world.getTileEntity(x, y, z); + return protector.getCurrentRange(); } - }*/ + return 0; + } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { int metadata = world.getBlockMetadata(x, y, z); - if(metadata == 0 || metadata == 3) { + if (metadata == 0 || metadata == 3) { if (world.getBlock(x, y - 1, z).equals(RegisteredBlocks.blockNodeManipulator) && world.getBlockMetadata(x, y - 1, z) == 5) { return world.getBlock(x, y - 1, z).onBlockActivated(world, x, y - 1, z, player, side, hitX, hitY, hitZ); } - } else if(metadata == 1) { + } else if (metadata == 1) { return ConfigBlocks.blockStoneDevice.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); } @@ -201,8 +219,10 @@ public class BlockStoneMachine extends Block { setBlockBounds(0.0F, -1.0F, 0.0F, 1.0F, -0.5F, 1.0F); } else if (metadata == 0 || metadata == 3) { setBlockBounds(3 / 16f, 0, 3 / 16f, 1 - (3 / 16f), 6 / 16f, 1 - (3 / 16f)); - } else if(metadata == 1) { + } else if (metadata == 1) { setBlockBounds(0.25f, 0, 0.25f, 0.75f, 0.99f, 0.75f); + } else if(metadata == 2) { + setBlockBounds(0, 0, 0, 1, 3/16f, 1); } super.setBlockBoundsBasedOnState(world, x, y, z); } @@ -214,6 +234,10 @@ public class BlockStoneMachine extends Block { setBlockBounds(0, 0, 0, 1, 1, 1); } else if (metadata == 0 || metadata == 3) { setBlockBoundsBasedOnState(world, x, y, z); + } else if(metadata == 2) { + setBlockBounds(3 / 16f, 0, 3 / 16f, 1 - (3 / 16f), 9.5f/16f, 1 - (3 / 16f)); + super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity); + setBlockBoundsBasedOnState(world, x, y, z); } super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity); } diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileBlockProtector.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileBlockProtector.java index ed8087e..7839f68 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileBlockProtector.java +++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileBlockProtector.java @@ -1,6 +1,9 @@ package makeo.gadomancy.common.blocks.tiles; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; @@ -8,6 +11,7 @@ import net.minecraftforge.common.util.ForgeDirection; import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.IEssentiaTransport; +import thaumcraft.common.Thaumcraft; import thaumcraft.common.tiles.TileJarFillable; import java.util.ArrayList; @@ -22,9 +26,8 @@ import java.util.List; * Created by makeo @ 08.11.2015 17:36 */ public class TileBlockProtector extends TileJarFillable { - private static final int UPDATE_TICKS = 20; - private static final int MAX_RANGE = 10; - private static final int SATURATION = 0; + private static final int UPDATE_TICKS = 15; + private static final int MAX_RANGE = 15; private static final Aspect ASPECT = Aspect.ORDER; private int range = 0; @@ -32,17 +35,39 @@ public class TileBlockProtector extends TileJarFillable { private int count = 0; public TileBlockProtector() { - maxAmount = 16; + maxAmount = 8; aspectFilter = ASPECT; } + public int getCurrentRange() { + return range; + } + + public int getPowerLevel() { + return Math.min(worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord), MAX_RANGE); + } + + @Override + public void readCustomNBT(NBTTagCompound compound) { + super.readCustomNBT(compound); + aspectFilter = ASPECT; + range = compound.getInteger("range"); + } + + @Override + public void writeCustomNBT(NBTTagCompound compound) { + super.writeCustomNBT(compound); + compound.removeTag("AspectFilter"); + compound.setInteger("range", range); + } + @Override public void updateEntity() { if (!protectors.contains(this)) { protectors.add(this); } - if(!worldObj.isRemote) { + if (!worldObj.isRemote) { if (++count % 5 == 0 && amount < maxAmount) { fillJar(); } @@ -53,15 +78,55 @@ public class TileBlockProtector extends TileJarFillable { return; } - if(takeFromContainer(ASPECT, 1)) { - if(range < MAX_RANGE) { - range++; + int powerLevel = getPowerLevel(); + boolean executeDecrease = range > powerLevel; + + if(range <= powerLevel) { + executeDecrease = true; + if (takeFromContainer(ASPECT, 1)) { + + if (range < powerLevel) { + range++; + markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + + saturation = 15 - range; + } + executeDecrease = false; } - saturation = SATURATION; - } else if(range > 0) { + } + + if (executeDecrease) { range--; + markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } + } else if(range > 0) { + if (this.worldObj.rand.nextInt(9 - Thaumcraft.proxy.particleCount(2)) == 0) { + Thaumcraft.proxy.wispFX3(this.worldObj, this.xCoord + 0.5F, this.yCoord + 0.68F, this.zCoord + 0.5F, this.xCoord + 0.3F + this.worldObj.rand.nextFloat() * 0.4F, this.yCoord + 0.68F, this.zCoord + 0.3F + this.worldObj.rand.nextFloat() * 0.4F, 0.3F, 6, true, -0.025F); + } + if (this.worldObj.rand.nextInt(15 - Thaumcraft.proxy.particleCount(4)) == 0) { + Thaumcraft.proxy.wispFX3(this.worldObj, this.xCoord + 0.5F, this.yCoord + 0.68F, this.zCoord + 0.5F, this.xCoord + 0.4F + this.worldObj.rand.nextFloat() * 0.2F, this.yCoord + 0.68F, this.zCoord + 0.4F + this.worldObj.rand.nextFloat() * 0.2F, 0.2F, 6, true, -0.02F); + } + } + + if(range > 0) { + for(EntityLivingBase entity : (List