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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
* Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions: The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package bartworks.client.renderer;
import static gregtech.common.render.GTRendererBlock.renderNegativeXFacing;
import static gregtech.common.render.GTRendererBlock.renderNegativeYFacing;
import static gregtech.common.render.GTRendererBlock.renderNegativeZFacing;
import static gregtech.common.render.GTRendererBlock.renderPositiveXFacing;
import static gregtech.common.render.GTRendererBlock.renderPositiveYFacing;
import static gregtech.common.render.GTRendererBlock.renderPositiveZFacing;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import bartworks.system.material.BWMetaGeneratedBlocks;
import bartworks.system.material.TileEntityMetaGeneratedBlock;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import gregtech.GTMod;
@ThreadSafeISBRH(perThread = true)
public class BWBlockOreRenderer implements ISimpleBlockRenderingHandler {
public static BWBlockOreRenderer INSTANCE;
public static int renderID;
public static final float blockMin = 0.0F;
public static final float blockMax = 1.0F;
public static void register() {
renderID = RenderingRegistry.getNextAvailableRenderId();
INSTANCE = new BWBlockOreRenderer();
RenderingRegistry.registerBlockHandler(INSTANCE);
}
@Override
public void renderInventoryBlock(Block aBlock, int aMeta, int modelId, RenderBlocks aRenderer) {
TileEntityMetaGeneratedBlock tTileEntity = ((BWMetaGeneratedBlocks) aBlock).getProperTileEntityForRendering();
tTileEntity.mMetaData = (short) aMeta;
aRenderer.enableAO = false;
aRenderer.useInventoryTint = true;
aBlock.setBlockBoundsForItemRender();
aRenderer.setRenderBoundsFromBlock(aBlock);
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
renderNegativeYFacing(
null,
aRenderer,
aBlock,
0,
0,
0,
tTileEntity.getTexture(aBlock, ForgeDirection.DOWN),
true);
renderPositiveYFacing(
null,
aRenderer,
aBlock,
0,
0,
0,
tTileEntity.getTexture(aBlock, ForgeDirection.UP),
true);
renderNegativeZFacing(
null,
aRenderer,
aBlock,
0,
0,
0,
tTileEntity.getTexture(aBlock, ForgeDirection.NORTH),
true);
renderPositiveZFacing(
null,
aRenderer,
aBlock,
0,
0,
0,
tTileEntity.getTexture(aBlock, ForgeDirection.SOUTH),
true);
renderNegativeXFacing(
null,
aRenderer,
aBlock,
0,
0,
0,
tTileEntity.getTexture(aBlock, ForgeDirection.WEST),
true);
renderPositiveXFacing(
null,
aRenderer,
aBlock,
0,
0,
0,
tTileEntity.getTexture(aBlock, ForgeDirection.EAST),
true);
aRenderer.setRenderBoundsFromBlock(aBlock);
aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
aRenderer.useInventoryTint = false;
}
// spotless:off
@Override
public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int modelId, RenderBlocks aRenderer) {
BWMetaGeneratedBlocks tBlock = (BWMetaGeneratedBlocks) aBlock;
if(tBlock == null) return false;
TileEntityMetaGeneratedBlock fakeTileEntity = tBlock.getProperTileEntityForRendering(); // meh
if(fakeTileEntity == null) return false;
TileEntityMetaGeneratedBlock actualTileEntity = (TileEntityMetaGeneratedBlock) aWorld.getTileEntity(aX, aY, aZ);
if(actualTileEntity == null) return false;
fakeTileEntity.mMetaData = actualTileEntity.mMetaData;
aRenderer.useInventoryTint = false;
aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax);
aRenderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GTMod.gregtechproxy.mRenderTileAmbientOcclusion;
aRenderer.setRenderBoundsFromBlock(aBlock);
renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.DOWN), true);
renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.UP), true);
renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.NORTH), true);
renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), true);
renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.WEST), true);
renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.EAST), true);
return true;
}
// spotless:on
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId() {
return renderID;
}
}
|