mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
show the creational catalyst's effect so that you know if generators have it
This commit is contained in:
parent
7e6f6450e4
commit
d4549b4bfd
12 changed files with 150 additions and 6 deletions
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,7 +48,7 @@ public final class ModBlocks {
|
||||||
public static final Block RF_CONVERTER = ModConfig.enabledFeatures.rfConverter ? new BlockRFConverter() : null;
|
public static final Block RF_CONVERTER = ModConfig.enabledFeatures.rfConverter ? new BlockRFConverter() : null;
|
||||||
public static final Block MOSS_GENERATOR = new BlockMossGenerator();
|
public static final Block MOSS_GENERATOR = new BlockMossGenerator();
|
||||||
public static final Block TIME_CHANGER = new BlockTimeChanger();
|
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 ENDER_CRATE = new BlockEnderCrate();
|
||||||
public static final Block POWDER_PLACER = new BlockPowderPlacer();
|
public static final Block POWDER_PLACER = new BlockPowderPlacer();
|
||||||
public static final Block FIREWORK_GENERATOR = new BlockFireworkGenerator();
|
public static final Block FIREWORK_GENERATOR = new BlockFireworkGenerator();
|
||||||
|
|
|
@ -34,6 +34,11 @@ public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean wantsLimitRemover() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isBusy() {
|
public boolean isBusy() {
|
||||||
return this.timeRemaining > 0;
|
return this.timeRemaining > 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
|
||||||
if (this.trackedEntity == null && this.releaseTimer <= 0) {
|
if (this.trackedEntity == null && this.releaseTimer <= 0) {
|
||||||
EntityFireworkRocket entity = new EntityFireworkRocket(this.world, item.posX, item.posY, item.posZ, stack);
|
EntityFireworkRocket entity = new EntityFireworkRocket(this.world, item.posX, item.posY, item.posZ, stack);
|
||||||
this.trackedEntity = entity;
|
this.trackedEntity = entity;
|
||||||
this.trackedItem = stack;
|
this.trackedItem = stack.copy();
|
||||||
this.world.spawnEntity(entity);
|
this.world.spawnEntity(entity);
|
||||||
}
|
}
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
|
@ -128,4 +128,9 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean wantsLimitRemover() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,11 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean wantsLimitRemover() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(NBTTagCompound compound, SaveType type) {
|
public void writeNBT(NBTTagCompound compound, SaveType type) {
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -172,13 +172,19 @@ public class TileEntityImpl extends TileEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGenerateRightNow(int range, int toAdd) {
|
public boolean canGenerateRightNow(int range, int toAdd) {
|
||||||
|
if (this.wantsLimitRemover()) {
|
||||||
IBlockState below = this.world.getBlockState(this.pos.down());
|
IBlockState below = this.world.getBlockState(this.pos.down());
|
||||||
if (below.getBlock() == ModBlocks.GENERATOR_LIMIT_REMOVER)
|
if (below.getBlock() == ModBlocks.GENERATOR_LIMIT_REMOVER)
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
int aura = IAuraChunk.getAuraInArea(this.world, this.pos, range);
|
int aura = IAuraChunk.getAuraInArea(this.world, this.pos, range);
|
||||||
return aura + toAdd <= IAuraChunk.DEFAULT_AURA * 2;
|
return aura + toAdd <= IAuraChunk.DEFAULT_AURA * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean wantsLimitRemover() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public enum SaveType {
|
public enum SaveType {
|
||||||
TILE,
|
TILE,
|
||||||
SYNC,
|
SYNC,
|
||||||
|
|
|
@ -52,4 +52,9 @@ public class TileEntityMossGenerator extends TileEntityImpl implements ITickable
|
||||||
this.world.setBlockState(offset, result);
|
this.world.setBlockState(offset, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean wantsLimitRemover() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,4 +34,9 @@ public class TileEntityOakGenerator extends TileEntityImpl implements ITickable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean wantsLimitRemover() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,4 +66,9 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean wantsLimitRemover() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 |
Loading…
Reference in a new issue