From d4549b4bfdbf30b144ac97f8adbcefb3605bf7ec Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 25 Feb 2019 13:36:05 +0100 Subject: [PATCH] show the creational catalyst's effect so that you know if generators have it --- .../blocks/BlockGeneratorLimitRemover.java | 26 +++++++ .../ellpeck/naturesaura/blocks/ModBlocks.java | 2 +- .../tiles/TileEntityAnimalGenerator.java | 5 ++ .../tiles/TileEntityFireworkGenerator.java | 7 +- .../tiles/TileEntityFlowerGenerator.java | 5 ++ .../TileEntityGeneratorLimitRemover.java | 11 +++ .../blocks/tiles/TileEntityImpl.java | 14 +++- .../blocks/tiles/TileEntityMossGenerator.java | 5 ++ .../blocks/tiles/TileEntityOakGenerator.java | 5 ++ .../tiles/TileEntityPotionGenerator.java | 5 ++ .../render/RenderGeneratorLimitRemover.java | 71 ++++++++++++++++++ .../models/generator_limit_remover_glint.png | Bin 0 -> 435 bytes 12 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java create mode 100644 src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java create mode 100644 src/main/resources/assets/naturesaura/textures/models/generator_limit_remover_glint.png diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java new file mode 100644 index 00000000..a0b75064 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java @@ -0,0 +1,26 @@ +package de.ellpeck.naturesaura.blocks; + +import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover; +import de.ellpeck.naturesaura.blocks.tiles.render.RenderGeneratorLimitRemover; +import de.ellpeck.naturesaura.reg.ITESRProvider; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.util.Tuple; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider { + + public BlockGeneratorLimitRemover() { + super(Material.ROCK, "generator_limit_remover", TileEntityGeneratorLimitRemover.class, "generator_limit_remover"); + this.setSoundType(SoundType.STONE); + this.setHardness(2F); + } + + @Override + @SideOnly(Side.CLIENT) + public Tuple getTESR() { + return new Tuple<>(TileEntityGeneratorLimitRemover.class, new RenderGeneratorLimitRemover()); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 7370421d..0a266864 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -48,7 +48,7 @@ public final class ModBlocks { public static final Block RF_CONVERTER = ModConfig.enabledFeatures.rfConverter ? new BlockRFConverter() : null; public static final Block MOSS_GENERATOR = new BlockMossGenerator(); public static final Block TIME_CHANGER = new BlockTimeChanger(); - public static final Block GENERATOR_LIMIT_REMOVER = new BlockImpl("generator_limit_remover", Material.ROCK).setSoundType(SoundType.STONE).setHardness(2F); + public static final Block GENERATOR_LIMIT_REMOVER = new BlockGeneratorLimitRemover(); public static final Block ENDER_CRATE = new BlockEnderCrate(); public static final Block POWDER_PLACER = new BlockPowderPlacer(); public static final Block FIREWORK_GENERATOR = new BlockFireworkGenerator(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalGenerator.java index 855c7f5e..a80ef603 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalGenerator.java @@ -34,6 +34,11 @@ public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickab } } + @Override + public boolean wantsLimitRemover() { + return true; + } + public boolean isBusy() { return this.timeRemaining > 0; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java index 7dfebeb4..33319324 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java @@ -44,7 +44,7 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick if (this.trackedEntity == null && this.releaseTimer <= 0) { EntityFireworkRocket entity = new EntityFireworkRocket(this.world, item.posX, item.posY, item.posZ, stack); this.trackedEntity = entity; - this.trackedItem = stack; + this.trackedItem = stack.copy(); this.world.spawnEntity(entity); } stack.shrink(1); @@ -128,4 +128,9 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick } } } + + @Override + public boolean wantsLimitRemover() { + return true; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java index ef56d8b5..22d24919 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java @@ -93,6 +93,11 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab } } + @Override + public boolean wantsLimitRemover() { + return true; + } + @Override public void writeNBT(NBTTagCompound compound, SaveType type) { super.writeNBT(compound, type); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java new file mode 100644 index 00000000..0da607b2 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java @@ -0,0 +1,11 @@ +package de.ellpeck.naturesaura.blocks.tiles; + +import net.minecraft.util.math.AxisAlignedBB; + +public class TileEntityGeneratorLimitRemover extends TileEntityImpl { + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return new AxisAlignedBB(this.pos, this.pos.add(1, 2, 1)); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java index db437171..1566b303 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java @@ -62,7 +62,7 @@ public class TileEntityImpl extends TileEntity { } - public void onRedstonePulse(){ + public void onRedstonePulse() { } @@ -172,13 +172,19 @@ public class TileEntityImpl extends TileEntity { } public boolean canGenerateRightNow(int range, int toAdd) { - IBlockState below = this.world.getBlockState(this.pos.down()); - if (below.getBlock() == ModBlocks.GENERATOR_LIMIT_REMOVER) - return true; + if (this.wantsLimitRemover()) { + IBlockState below = this.world.getBlockState(this.pos.down()); + if (below.getBlock() == ModBlocks.GENERATOR_LIMIT_REMOVER) + return true; + } int aura = IAuraChunk.getAuraInArea(this.world, this.pos, range); return aura + toAdd <= IAuraChunk.DEFAULT_AURA * 2; } + public boolean wantsLimitRemover() { + return false; + } + public enum SaveType { TILE, SYNC, diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java index b0bf33cd..1a1acd80 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java @@ -52,4 +52,9 @@ public class TileEntityMossGenerator extends TileEntityImpl implements ITickable this.world.setBlockState(offset, result); } } + + @Override + public boolean wantsLimitRemover() { + return true; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java index 23005d16..afd315fc 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java @@ -34,4 +34,9 @@ public class TileEntityOakGenerator extends TileEntityImpl implements ITickable } } } + + @Override + public boolean wantsLimitRemover() { + return true; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java index d3315a3d..a5d7c2c6 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java @@ -66,4 +66,9 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab } } } + + @Override + public boolean wantsLimitRemover() { + return true; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java new file mode 100644 index 00000000..7ebc6bff --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java @@ -0,0 +1,71 @@ +package de.ellpeck.naturesaura.blocks.tiles.render; + +import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover; +import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class RenderGeneratorLimitRemover extends TileEntitySpecialRenderer { + private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png"); + private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint(); + + @Override + public void render(TileEntityGeneratorLimitRemover te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { + TileEntity above = te.getWorld().getTileEntity(te.getPos().up()); + if (above instanceof TileEntityImpl && ((TileEntityImpl) above).wantsLimitRemover()) { + this.renderGlint(x, y + 1, z); + this.renderGlint(x, y, z); + } + } + + private void renderGlint(double x, double y, double z) { + GlStateManager.pushMatrix(); + RenderHelper.enableStandardItemLighting(); + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + GlStateManager.alphaFunc(516, 0.003921569F); + GlStateManager.depthMask(false); + int brightness = 15 << 20 | 15 << 4; + int j = brightness % 65536; + int k = brightness / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k); + float alpha = ((float) Math.sin(Minecraft.getSystemTime() / 800D) + 1F) / 2F; + GlStateManager.color(alpha, alpha, alpha, alpha); + GlStateManager.translate(x - 0.001F, y + 1 + 0.001F, z + 1 + 0.001F); + GlStateManager.rotate(180F, 1, 0, 0); + GlStateManager.scale(1.002F, 1.002F, 1.002F); + this.bindTexture(RES); + this.model.render(); + GlStateManager.depthMask(true); + GlStateManager.alphaFunc(516, 0.1F); + GlStateManager.disableAlpha(); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + } + + private static class ModelLimitRemoverGlint extends ModelBase { + + private final ModelRenderer box; + + public ModelLimitRemoverGlint() { + this.box = new ModelRenderer(this, 0, 0); + this.box.setTextureSize(64, 64); + this.box.addBox(0, 0, 0, 16, 16, 16); + } + + public void render() { + this.box.render(1 / 16F); + } + } +} diff --git a/src/main/resources/assets/naturesaura/textures/models/generator_limit_remover_glint.png b/src/main/resources/assets/naturesaura/textures/models/generator_limit_remover_glint.png new file mode 100644 index 0000000000000000000000000000000000000000..afcc2394ef43da1141475cb8940c00320a023108 GIT binary patch literal 435 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjGL736~_k^`TL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt3(J<}BT2%yP~hMq2t zAr)~?uQ&=Z8VWcBikGse7c#bQDx0eqJT*jmzk5Vx{m0DwOM$5mH|TU*xdeAC6Yy1> zipW&_4{>udHYKLeLcUX*4AKmF@_iL2z=Qh^X@-;f7!`tnOVR9X7F_Nb6Mw<&;$S; C@v*=F literal 0 HcmV?d00001