mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
The Great Reformat; moving to google-java-style w/ 4 space indent and 120 column line wrap
This commit is contained in:
1 parent
c632cc6af9
commit
e0b7ea62a4
933 files changed
+95734
-108818
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package mekanism.client.render.tileentity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.MekanismRenderer.DisplayInteger;
|
||||
@@ -24,179 +23,161 @@ import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderConfigurableMachine<S extends TileEntity & ISideConfiguration> extends TileEntitySpecialRenderer<S>
|
||||
{
|
||||
private Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
public class RenderConfigurableMachine<S extends TileEntity & ISideConfiguration> extends TileEntitySpecialRenderer<S> {
|
||||
|
||||
private HashMap<EnumFacing, HashMap<TransmissionType, DisplayInteger>> cachedOverlays = new HashMap<>();
|
||||
private Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
|
||||
public RenderConfigurableMachine()
|
||||
{
|
||||
rendererDispatcher = TileEntityRendererDispatcher.instance;
|
||||
}
|
||||
private HashMap<EnumFacing, HashMap<TransmissionType, DisplayInteger>> cachedOverlays = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void render(S configurable, double x, double y, double z, float partialTick, int destroyStage, float alpha)
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
public RenderConfigurableMachine() {
|
||||
rendererDispatcher = TileEntityRendererDispatcher.instance;
|
||||
}
|
||||
|
||||
EntityPlayer player = mc.player;
|
||||
ItemStack itemStack = player.inventory.getCurrentItem();
|
||||
RayTraceResult pos = player.rayTrace(8.0D, 1.0F);
|
||||
@Override
|
||||
public void render(S configurable, double x, double y, double z, float partialTick, int destroyStage, float alpha) {
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
if(pos != null && !itemStack.isEmpty() && itemStack.getItem() instanceof ItemConfigurator && ((ItemConfigurator)itemStack.getItem()).getState(itemStack).isConfigurating())
|
||||
{
|
||||
BlockPos bp = pos.getBlockPos();
|
||||
EntityPlayer player = mc.player;
|
||||
ItemStack itemStack = player.inventory.getCurrentItem();
|
||||
RayTraceResult pos = player.rayTrace(8.0D, 1.0F);
|
||||
|
||||
TransmissionType type = ((ItemConfigurator)itemStack.getItem()).getState(itemStack).getTransmission();
|
||||
if (pos != null && !itemStack.isEmpty() && itemStack.getItem() instanceof ItemConfigurator
|
||||
&& ((ItemConfigurator) itemStack.getItem()).getState(itemStack).isConfigurating()) {
|
||||
BlockPos bp = pos.getBlockPos();
|
||||
|
||||
if(configurable.getConfig().supports(type))
|
||||
{
|
||||
if(bp.equals(configurable.getPos()))
|
||||
{
|
||||
SideData data = configurable.getConfig().getOutput(type, pos.sideHit, configurable.getOrientation());
|
||||
|
||||
if(data != TileComponentConfig.EMPTY)
|
||||
{
|
||||
push();
|
||||
|
||||
MekanismRenderer.color(data.color, 0.6F);
|
||||
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
GlStateManager.translate((float)x, (float)y, (float)z);
|
||||
|
||||
int display = getOverlayDisplay(pos.sideHit, type).display;
|
||||
GL11.glCallList(display);
|
||||
|
||||
MekanismRenderer.resetColor();
|
||||
|
||||
pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TransmissionType type = ((ItemConfigurator) itemStack.getItem()).getState(itemStack).getTransmission();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
if (configurable.getConfig().supports(type)) {
|
||||
if (bp.equals(configurable.getPos())) {
|
||||
SideData data = configurable.getConfig()
|
||||
.getOutput(type, pos.sideHit, configurable.getOrientation());
|
||||
|
||||
private void pop()
|
||||
{
|
||||
GL11.glPopAttrib();
|
||||
MekanismRenderer.glowOff();
|
||||
MekanismRenderer.blendOff();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
if (data != TileComponentConfig.EMPTY) {
|
||||
push();
|
||||
|
||||
private void push()
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
MekanismRenderer.glowOn();
|
||||
MekanismRenderer.blendOn();
|
||||
}
|
||||
MekanismRenderer.color(data.color, 0.6F);
|
||||
|
||||
private DisplayInteger getOverlayDisplay(EnumFacing side, TransmissionType type)
|
||||
{
|
||||
if(cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(type))
|
||||
{
|
||||
return cachedOverlays.get(side).get(type);
|
||||
}
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
GlStateManager.translate((float) x, (float) y, (float) z);
|
||||
|
||||
Model3D toReturn = new Model3D();
|
||||
toReturn.baseBlock = Blocks.STONE;
|
||||
toReturn.setTexture(MekanismRenderer.overlays.get(type));
|
||||
int display = getOverlayDisplay(pos.sideHit, type).display;
|
||||
GL11.glCallList(display);
|
||||
|
||||
DisplayInteger display = DisplayInteger.createAndStart();
|
||||
MekanismRenderer.resetColor();
|
||||
|
||||
if(cachedOverlays.containsKey(side))
|
||||
{
|
||||
cachedOverlays.get(side).put(type, display);
|
||||
}
|
||||
else {
|
||||
HashMap<TransmissionType, DisplayInteger> map = new HashMap<>();
|
||||
map.put(type, display);
|
||||
cachedOverlays.put(side, map);
|
||||
}
|
||||
pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch(side)
|
||||
{
|
||||
case DOWN:
|
||||
{
|
||||
toReturn.minY = -.01;
|
||||
toReturn.maxY = -.001;
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
toReturn.minX = 0;
|
||||
toReturn.minZ = 0;
|
||||
toReturn.maxX = 1;
|
||||
toReturn.maxZ = 1;
|
||||
break;
|
||||
}
|
||||
case UP:
|
||||
{
|
||||
toReturn.minY = 1.001;
|
||||
toReturn.maxY = 1.01;
|
||||
private void pop() {
|
||||
GL11.glPopAttrib();
|
||||
MekanismRenderer.glowOff();
|
||||
MekanismRenderer.blendOff();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
toReturn.minX = 0;
|
||||
toReturn.minZ = 0;
|
||||
toReturn.maxX = 1;
|
||||
toReturn.maxZ = 1;
|
||||
break;
|
||||
}
|
||||
case NORTH:
|
||||
{
|
||||
toReturn.minZ = -.01;
|
||||
toReturn.maxZ = -.001;
|
||||
private void push() {
|
||||
GlStateManager.pushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
MekanismRenderer.glowOn();
|
||||
MekanismRenderer.blendOn();
|
||||
}
|
||||
|
||||
toReturn.minX = 0;
|
||||
toReturn.minY = 0;
|
||||
toReturn.maxX = 1;
|
||||
toReturn.maxY = 1;
|
||||
break;
|
||||
}
|
||||
case SOUTH:
|
||||
{
|
||||
toReturn.minZ = 1.001;
|
||||
toReturn.maxZ = 1.01;
|
||||
private DisplayInteger getOverlayDisplay(EnumFacing side, TransmissionType type) {
|
||||
if (cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(type)) {
|
||||
return cachedOverlays.get(side).get(type);
|
||||
}
|
||||
|
||||
toReturn.minX = 0;
|
||||
toReturn.minY = 0;
|
||||
toReturn.maxX = 1;
|
||||
toReturn.maxY = 1;
|
||||
break;
|
||||
}
|
||||
case WEST:
|
||||
{
|
||||
toReturn.minX = -.01;
|
||||
toReturn.maxX = -.001;
|
||||
Model3D toReturn = new Model3D();
|
||||
toReturn.baseBlock = Blocks.STONE;
|
||||
toReturn.setTexture(MekanismRenderer.overlays.get(type));
|
||||
|
||||
toReturn.minY = 0;
|
||||
toReturn.minZ = 0;
|
||||
toReturn.maxY = 1;
|
||||
toReturn.maxZ = 1;
|
||||
break;
|
||||
}
|
||||
case EAST:
|
||||
{
|
||||
toReturn.minX = 1.001;
|
||||
toReturn.maxX = 1.01;
|
||||
DisplayInteger display = DisplayInteger.createAndStart();
|
||||
|
||||
toReturn.minY = 0;
|
||||
toReturn.minZ = 0;
|
||||
toReturn.maxY = 1;
|
||||
toReturn.maxZ = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cachedOverlays.containsKey(side)) {
|
||||
cachedOverlays.get(side).put(type, display);
|
||||
} else {
|
||||
HashMap<TransmissionType, DisplayInteger> map = new HashMap<>();
|
||||
map.put(type, display);
|
||||
cachedOverlays.put(side, map);
|
||||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
DisplayInteger.endList();
|
||||
switch (side) {
|
||||
case DOWN: {
|
||||
toReturn.minY = -.01;
|
||||
toReturn.maxY = -.001;
|
||||
|
||||
return display;
|
||||
}
|
||||
toReturn.minX = 0;
|
||||
toReturn.minZ = 0;
|
||||
toReturn.maxX = 1;
|
||||
toReturn.maxZ = 1;
|
||||
break;
|
||||
}
|
||||
case UP: {
|
||||
toReturn.minY = 1.001;
|
||||
toReturn.maxY = 1.01;
|
||||
|
||||
toReturn.minX = 0;
|
||||
toReturn.minZ = 0;
|
||||
toReturn.maxX = 1;
|
||||
toReturn.maxZ = 1;
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
toReturn.minZ = -.01;
|
||||
toReturn.maxZ = -.001;
|
||||
|
||||
toReturn.minX = 0;
|
||||
toReturn.minY = 0;
|
||||
toReturn.maxX = 1;
|
||||
toReturn.maxY = 1;
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
toReturn.minZ = 1.001;
|
||||
toReturn.maxZ = 1.01;
|
||||
|
||||
toReturn.minX = 0;
|
||||
toReturn.minY = 0;
|
||||
toReturn.maxX = 1;
|
||||
toReturn.maxY = 1;
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
toReturn.minX = -.01;
|
||||
toReturn.maxX = -.001;
|
||||
|
||||
toReturn.minY = 0;
|
||||
toReturn.minZ = 0;
|
||||
toReturn.maxY = 1;
|
||||
toReturn.maxZ = 1;
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
toReturn.minX = 1.001;
|
||||
toReturn.maxX = 1.01;
|
||||
|
||||
toReturn.minY = 0;
|
||||
toReturn.minZ = 0;
|
||||
toReturn.maxY = 1;
|
||||
toReturn.maxZ = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
DisplayInteger.endList();
|
||||
|
||||
return display;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user