ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderCompost.java

65 lines
2.7 KiB
Java
Raw Normal View History

2016-02-20 15:23:03 +01:00
/*
2016-05-16 22:52:27 +02:00
* This file ("RenderCompost.java") is part of the Actually Additions mod for Minecraft.
2016-02-20 15:23:03 +01:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2016-02-20 15:23:03 +01:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2016-02-20 15:23:03 +01:00
*/
package de.ellpeck.actuallyadditions.mod.blocks.render;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
2016-02-20 15:23:03 +01:00
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
2016-02-20 21:25:18 +01:00
import net.minecraft.client.Minecraft;
2016-02-20 15:23:03 +01:00
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
2016-02-20 15:23:03 +01:00
import net.minecraft.tileentity.TileEntity;
public class RenderCompost extends TileEntitySpecialRenderer{
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage){
2016-02-20 15:23:03 +01:00
if(te instanceof TileEntityCompost){
2016-02-20 16:16:41 +01:00
TileEntityCompost compost = (TileEntityCompost)te;
ItemStack slot = compost.getStackInSlot(0);
if(StackUtil.isValid(slot)){
Block display = null;
int maxAmount = 0;
for(CompostRecipe aRecipe : ActuallyAdditionsAPI.COMPOST_RECIPES){
if(slot.isItemEqual(aRecipe.input)){
display = aRecipe.inputDisplay;
maxAmount = StackUtil.getStackSize(aRecipe.input);
break;
}
else if(slot.isItemEqual(aRecipe.output)){
display = aRecipe.outputDisplay;
maxAmount = StackUtil.getStackSize(aRecipe.output);
break;
}
}
if(display != null){
float i = (float)StackUtil.getStackSize(slot)/(float)maxAmount;
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y+(i/3F)+0.01F, (float)z+0.5F);
//Hehe
if("ShadowfactsDev".equals(Minecraft.getMinecraft().thePlayer.getName())){
GlStateManager.translate(0F, 1F, 0F);
}
GlStateManager.scale(1.5F, i, 1.5F);
AssetUtil.renderBlockInWorld(display, 0);
GlStateManager.popMatrix();
2016-02-20 21:25:18 +01:00
}
2016-02-20 15:23:03 +01:00
}
}
}
}