-
Notifications
You must be signed in to change notification settings - Fork 25
/
ReactorItemRenderer.java
68 lines (57 loc) · 2.05 KB
/
ReactorItemRenderer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*******************************************************************************
* @author Reika Kalseki
*
* Copyright 2017
*
* All rights reserved.
* Distribution of the software in any form is only allowed with
* explicit, prior permission from the owner.
******************************************************************************/
package Reika.ReactorCraft;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import Reika.DragonAPI.Libraries.IO.ReikaTextureHelper;
import Reika.ReactorCraft.Registry.ReactorBlocks;
import Reika.ReactorCraft.Registry.ReactorTiles;
public class ReactorItemRenderer implements IItemRenderer {
public ReactorItemRenderer() {
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
float a = 0; float b = 0;
RenderBlocks rb = (RenderBlocks)data[0];
if (type == type.ENTITY) {
a = -0.5F;
b = -0.5F;
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
if (item.getItemDamage() >= ReactorTiles.TEList.length)
return;
ReactorTiles machine = ReactorTiles.TEList[item.getItemDamage()];
if (machine.isPipe()) {
ReikaTextureHelper.bindTerrainTexture();
rb.renderBlockAsItem(ReactorBlocks.DUCT.getBlockInstance(), machine.getBlockMetadata(), 1);
}
else if (machine.hasRender())
TileEntityRendererDispatcher.instance.renderTileEntityAt(machine.createTEInstanceForRender(), a, -0.1D, b, 0.0F);
else {
ReikaTextureHelper.bindTerrainTexture();
if (type == type.EQUIPPED || type == type.EQUIPPED_FIRST_PERSON) {
double d = 0.5;
GL11.glTranslated(d, d, d);
}
rb.renderBlockAsItem(machine.getBlockInstance(), machine.getBlockMetadata(), 1);
}
}
}