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
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2016-02-20 15:23:03 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
|
|
|
|
2016-05-20 17:55:33 +02:00
|
|
|
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;
|
2017-03-07 20:41:27 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
2016-11-16 16:59:00 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
2016-05-20 17:55:33 +02:00
|
|
|
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;
|
2016-05-20 17:55:33 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-02-20 15:23:03 +01:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-12-18 17:28:29 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2016-02-20 15:23:03 +01:00
|
|
|
|
2016-12-18 17:28:29 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2016-02-20 15:23:03 +01:00
|
|
|
public class RenderCompost extends TileEntitySpecialRenderer{
|
|
|
|
|
|
|
|
@Override
|
2016-05-29 23:49:35 +02:00
|
|
|
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;
|
2016-12-04 00:10:52 +01:00
|
|
|
ItemStack slot = compost.slots.getStackInSlot(0);
|
2016-05-20 17:55:33 +02:00
|
|
|
|
2016-11-16 16:59:00 +01:00
|
|
|
if(StackUtil.isValid(slot)){
|
2016-05-20 17:55:33 +02:00
|
|
|
Block display = null;
|
|
|
|
int maxAmount = 0;
|
|
|
|
for(CompostRecipe aRecipe : ActuallyAdditionsAPI.COMPOST_RECIPES){
|
2017-03-07 20:41:27 +01:00
|
|
|
if(ItemUtil.areItemsEqual(slot, aRecipe.input, true)){
|
2016-05-20 17:55:33 +02:00
|
|
|
display = aRecipe.inputDisplay;
|
2016-12-04 00:10:52 +01:00
|
|
|
maxAmount = aRecipe.input.getMaxStackSize();
|
2016-05-20 17:55:33 +02:00
|
|
|
break;
|
|
|
|
}
|
2017-03-07 20:41:27 +01:00
|
|
|
else if(ItemUtil.areItemsEqual(slot, aRecipe.output, true)){
|
2016-05-20 17:55:33 +02:00
|
|
|
display = aRecipe.outputDisplay;
|
2016-12-04 00:10:52 +01:00
|
|
|
maxAmount = aRecipe.output.getMaxStackSize();
|
2016-05-20 17:55:33 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(display != null){
|
2016-11-16 16:59:00 +01:00
|
|
|
float i = (float)StackUtil.getStackSize(slot)/(float)maxAmount;
|
2016-05-20 17:55:33 +02:00
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
GlStateManager.translate((float)x+0.5F, (float)y+(i/3F)+0.01F, (float)z+0.5F);
|
|
|
|
//Hehe
|
2016-11-26 21:32:27 +01:00
|
|
|
if("ShadowfactsDev".equals(Minecraft.getMinecraft().player.getName())){
|
2016-05-20 17:55:33 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|