show the creational catalyst's effect so that you know if generators have it

This commit is contained in:
Ellpeck 2019-02-25 13:36:05 +01:00
parent 7e6f6450e4
commit d4549b4bfd
12 changed files with 150 additions and 6 deletions

View file

@ -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<Class, TileEntitySpecialRenderer> getTESR() {
return new Tuple<>(TileEntityGeneratorLimitRemover.class, new RenderGeneratorLimitRemover());
}
}

View file

@ -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();

View file

@ -34,6 +34,11 @@ public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickab
}
}
@Override
public boolean wantsLimitRemover() {
return true;
}
public boolean isBusy() {
return this.timeRemaining > 0;
}

View file

@ -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;
}
}

View file

@ -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);

View file

@ -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));
}
}

View file

@ -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,

View file

@ -52,4 +52,9 @@ public class TileEntityMossGenerator extends TileEntityImpl implements ITickable
this.world.setBlockState(offset, result);
}
}
@Override
public boolean wantsLimitRemover() {
return true;
}
}

View file

@ -34,4 +34,9 @@ public class TileEntityOakGenerator extends TileEntityImpl implements ITickable
}
}
}
@Override
public boolean wantsLimitRemover() {
return true;
}
}

View file

@ -66,4 +66,9 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab
}
}
}
@Override
public boolean wantsLimitRemover() {
return true;
}
}

View file

@ -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<TileEntityGeneratorLimitRemover> {
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);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 B