2019-03-31 23:53:53 +02:00
|
|
|
package de.ellpeck.naturesaura.blocks.tiles.render;
|
|
|
|
|
2020-01-23 19:20:47 +01:00
|
|
|
import com.mojang.blaze3d.platform.GlStateManager;
|
2019-03-31 23:53:53 +02:00
|
|
|
import de.ellpeck.naturesaura.NaturesAura;
|
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
|
2020-01-23 19:20:47 +01:00
|
|
|
import net.minecraft.client.renderer.entity.model.RendererModel;
|
|
|
|
import net.minecraft.client.renderer.model.Model;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
|
|
|
import net.minecraft.util.Direction;
|
2019-03-31 23:53:53 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2019-03-31 23:53:53 +02:00
|
|
|
|
2019-10-20 22:30:49 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
public class RenderProjectileGenerator extends TileEntityRenderer<TileEntityProjectileGenerator> {
|
2019-03-31 23:53:53 +02:00
|
|
|
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
|
|
|
|
private final ModelOverlay model = new ModelOverlay();
|
|
|
|
|
|
|
|
@Override
|
2020-01-23 19:20:47 +01:00
|
|
|
public void render(TileEntityProjectileGenerator te, double x, double y, double z, float partialTicks, int destroyStage) {
|
2019-03-31 23:53:53 +02:00
|
|
|
GlStateManager.pushMatrix();
|
2020-01-23 19:20:47 +01:00
|
|
|
GlStateManager.translated(x, y, z);
|
2019-10-20 22:30:49 +02:00
|
|
|
if (te.nextSide == Direction.NORTH) {
|
2020-01-23 19:20:47 +01:00
|
|
|
GlStateManager.rotatef(270, 0, 1, 0);
|
|
|
|
GlStateManager.translatef(-0.001F, 0, -1);
|
2019-10-20 22:30:49 +02:00
|
|
|
} else if (te.nextSide == Direction.EAST) {
|
2020-01-23 19:20:47 +01:00
|
|
|
GlStateManager.rotatef(180, 0, 1, 0);
|
|
|
|
GlStateManager.translatef(-1.001F, 0, -1);
|
2019-10-20 22:30:49 +02:00
|
|
|
} else if (te.nextSide == Direction.SOUTH) {
|
2020-01-23 19:20:47 +01:00
|
|
|
GlStateManager.rotatef(90, 0, 1, 0);
|
|
|
|
GlStateManager.translatef(-1.001F, 0, 0);
|
2019-03-31 23:53:53 +02:00
|
|
|
} else {
|
2020-01-23 19:20:47 +01:00
|
|
|
GlStateManager.translatef(-0.001F, 0, 0);
|
2019-03-31 23:53:53 +02:00
|
|
|
}
|
|
|
|
this.bindTexture(RES);
|
|
|
|
this.model.render();
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
|
|
|
|
2020-01-23 19:20:47 +01:00
|
|
|
private static class ModelOverlay extends Model {
|
2019-03-31 23:53:53 +02:00
|
|
|
|
2020-01-23 19:20:47 +01:00
|
|
|
private final RendererModel box;
|
2019-03-31 23:53:53 +02:00
|
|
|
|
|
|
|
public ModelOverlay() {
|
2020-01-23 19:20:47 +01:00
|
|
|
this.box = new RendererModel(this, 0, 0);
|
2019-03-31 23:53:53 +02:00
|
|
|
this.box.setTextureSize(64, 64);
|
|
|
|
this.box.addBox(0, 0, 0, 16, 16, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void render() {
|
|
|
|
this.box.render(1 / 16F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|