mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 04:09:43 +00:00
Implement combustion gen model and add system for rotatable ISBRH models
This commit is contained in:
1 parent
fca2a2fbfc
commit
c989340b02
28 files changed
+296
-412
No files matched your search
@@ -13,17 +13,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
import net.minecraftforge.client.model.techne.TechneModel;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.lwjgl.util.vector.Matrix4f;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
@@ -85,7 +77,6 @@ import crazypants.enderio.machine.farm.FarmingStationRenderer;
|
||||
import crazypants.enderio.machine.farm.FarmingStationSpecialRenderer;
|
||||
import crazypants.enderio.machine.farm.TileFarmStation;
|
||||
import crazypants.enderio.machine.generator.combustion.BlockCombustionGenerator;
|
||||
import crazypants.enderio.machine.generator.combustion.CombustionGeneratorModelRenderer;
|
||||
import crazypants.enderio.machine.generator.combustion.CombustionGeneratorRenderer;
|
||||
import crazypants.enderio.machine.generator.combustion.TileCombustionGenerator;
|
||||
import crazypants.enderio.machine.generator.zombie.TileZombieGenerator;
|
||||
@@ -140,15 +131,19 @@ import crazypants.enderio.teleport.anchor.TileTravelAnchor;
|
||||
import crazypants.enderio.teleport.anchor.TravelEntitySpecialRenderer;
|
||||
import crazypants.enderio.teleport.telepad.TeleportEntityRenderHandler;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.render.TechneUtil;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
// @formatter:off
|
||||
public static int[][] sideAndFacingToSpriteOffset = new int[][] {
|
||||
|
||||
{ 3, 2, 0, 0, 0, 0 }, { 2, 3, 1, 1, 1, 1 }, { 1, 1, 3, 2, 5, 4 }, { 0, 0, 2, 3, 4, 5 }, { 4, 5, 4, 5, 3, 2 }, { 5, 4, 5, 4, 2, 3 } };
|
||||
{ 3, 2, 0, 0, 0, 0 },
|
||||
{ 2, 3, 1, 1, 1, 1 },
|
||||
{ 1, 1, 3, 2, 5, 4 },
|
||||
{ 0, 0, 2, 3, 4, 5 },
|
||||
{ 4, 5, 4, 5, 3, 2 },
|
||||
{ 5, 4, 5, 4, 2, 3 }
|
||||
};
|
||||
// @formatter:on
|
||||
|
||||
static {
|
||||
@@ -268,18 +263,9 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileWeatherObelisk.class, twr);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockWeatherObelisk), twr);
|
||||
|
||||
if(Config.useCombustionGenModel) {
|
||||
CombustionGeneratorModelRenderer cgmr = new CombustionGeneratorModelRenderer();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCombustionGenerator.class, cgmr);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockCombustionGenerator), cgmr);
|
||||
} else {
|
||||
BlockCombustionGenerator.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
CombustionGeneratorRenderer cr = new CombustionGeneratorRenderer();
|
||||
RenderingRegistry.registerBlockHandler(cr);
|
||||
if(!Config.combustionGeneratorUseOpaqueModel) {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCombustionGenerator.class, cr);
|
||||
}
|
||||
}
|
||||
BlockCombustionGenerator.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
CombustionGeneratorRenderer cr = new CombustionGeneratorRenderer();
|
||||
RenderingRegistry.registerBlockHandler(cr);
|
||||
|
||||
ZombieGeneratorRenderer zgr = new ZombieGeneratorRenderer();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileZombieGenerator.class, zgr);
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -131,9 +132,9 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
overlayIconNone = iIconRegister.registerIcon("enderio:machineOverlayNone");
|
||||
selectedFaceIcon = iIconRegister.registerIcon("enderio:machineOverlaySelectedFace");
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getOverlayIconForMode(IoMode mode) {
|
||||
public IIcon getOverlayIconForMode(ForgeDirection face, IoMode mode) {
|
||||
if(mode == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import crazypants.enderio.TileEntityEio;
|
||||
import crazypants.enderio.api.redstone.IRedstoneConnectable;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.IProgressTile;
|
||||
import crazypants.util.InventoryWrapper;
|
||||
import crazypants.util.ItemUtil;
|
||||
import crazypants.util.Lang;
|
||||
@@ -192,6 +191,10 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
public short getFacing() {
|
||||
return facing;
|
||||
}
|
||||
|
||||
public ForgeDirection getFacingDir() {
|
||||
return ForgeDirection.getOrientation(facing);
|
||||
}
|
||||
|
||||
public void setFacing(short facing) {
|
||||
this.facing = facing;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -19,24 +16,19 @@ import crazypants.enderio.machine.painter.PainterUtil;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.CustomCubeRenderer;
|
||||
import crazypants.render.CustomRenderBlocks;
|
||||
import crazypants.render.IRenderFace;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.vecmath.Vertex;
|
||||
|
||||
public class AbstractMachineRenderer implements ISimpleBlockRenderingHandler, IItemRenderer {
|
||||
|
||||
private OverlayRenderer overlayRenderer = new OverlayRenderer();
|
||||
|
||||
private AbstractMachineEntity curEnt;
|
||||
|
||||
private CustomCubeRenderer ccr = new CustomCubeRenderer();
|
||||
|
||||
|
||||
private PaintedBlockRenderer paintedRenderer = new PaintedBlockRenderer(this.getRenderId(), null); // passthrough renderer for paintable machines
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -48,10 +40,10 @@ public class AbstractMachineRenderer implements ISimpleBlockRenderingHandler, II
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
Block block;
|
||||
if ((block = PainterUtil.getSourceBlock(item)) != null) {
|
||||
paintedRenderer.renderInventoryBlock(block, PainterUtil.getSourceBlockMetadata(item), 0, (RenderBlocks)data[0]);
|
||||
if((block = PainterUtil.getSourceBlock(item)) != null) {
|
||||
paintedRenderer.renderInventoryBlock(block, PainterUtil.getSourceBlockMetadata(item), 0, (RenderBlocks) data[0]);
|
||||
} else {
|
||||
renderInventoryBlock(Block.getBlockFromItem(item.getItem()), item.getItemDamage(), 0, (RenderBlocks)data[0]);
|
||||
renderInventoryBlock(Block.getBlockFromItem(item.getItem()), item.getItemDamage(), 0, (RenderBlocks) data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,13 +68,13 @@ public class AbstractMachineRenderer implements ISimpleBlockRenderingHandler, II
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
AbstractMachineEntity machine = null;
|
||||
if(te instanceof AbstractMachineEntity) {
|
||||
curEnt = (AbstractMachineEntity)te;
|
||||
} else {
|
||||
curEnt = null;
|
||||
machine = (AbstractMachineEntity) te;
|
||||
}
|
||||
|
||||
if (te instanceof IPaintableTileEntity && ((IPaintableTileEntity) te).getSourceBlock() != null) {
|
||||
|
||||
overlayRenderer.setTile(machine);
|
||||
if(te instanceof IPaintableTileEntity && ((IPaintableTileEntity) te).getSourceBlock() != null) {
|
||||
ccr.setOverrideTexture(IconUtil.blankTexture);
|
||||
ccr.renderBlock(world, block, x, y, z, overlayRenderer);
|
||||
ccr.setOverrideTexture(renderer.overrideBlockTexture);
|
||||
@@ -105,25 +97,4 @@ public class AbstractMachineRenderer implements ISimpleBlockRenderingHandler, II
|
||||
public int getRenderId() {
|
||||
return AbstractMachineBlock.renderId;
|
||||
}
|
||||
|
||||
private class OverlayRenderer implements IRenderFace {
|
||||
|
||||
@Override
|
||||
public void renderFace(CustomRenderBlocks rb, ForgeDirection face, Block par1Block, double x, double y, double z, IIcon texture, List<Vertex> refVertices,
|
||||
boolean translateToXyz) {
|
||||
|
||||
ccr.getCustomRenderBlocks().doDefaultRenderFace(face,par1Block,x,y,z,texture);
|
||||
if(curEnt != null && par1Block instanceof AbstractMachineBlock) {
|
||||
IoMode mode = curEnt.getIoMode(face);
|
||||
IIcon tex = ((AbstractMachineBlock)par1Block).getOverlayIconForMode(mode);
|
||||
if(tex != null) {
|
||||
// dirty z-fighting hax, avert your eyes!
|
||||
ccr.getCustomRenderBlocks().doDefaultRenderFace(face, par1Block, x + (face.offsetX * 0.0001), y + (face.offsetY * 0.0001), z + (face.offsetZ * 0.0001), tex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.render.CustomCubeRenderer;
|
||||
import crazypants.render.CustomRenderBlocks;
|
||||
import crazypants.render.IRenderFace;
|
||||
import crazypants.util.ForgeDirectionOffsets;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vertex;
|
||||
|
||||
public class OverlayRenderer implements IRenderFace {
|
||||
|
||||
private static final CustomCubeRenderer ccr = CustomCubeRenderer.instance;
|
||||
private AbstractMachineEntity te;
|
||||
|
||||
public void setTile(AbstractMachineEntity te) {
|
||||
this.te = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFace(CustomRenderBlocks rb, ForgeDirection face, Block par1Block, double x, double y, double z, IIcon texture, List<Vertex> refVertices,
|
||||
boolean translateToXyz) {
|
||||
|
||||
if(te != null && par1Block instanceof AbstractMachineBlock) {
|
||||
Vector3d offset = ForgeDirectionOffsets.offsetScaled(face, 0.001);
|
||||
Tessellator.instance.addTranslation((float) offset.x, (float) offset.y, (float) offset.z);
|
||||
|
||||
IoMode mode = te.getIoMode(face);
|
||||
IIcon tex = ((AbstractMachineBlock<?>) par1Block).getOverlayIconForMode(face, mode);
|
||||
if(tex != null) {
|
||||
ccr.getCustomRenderBlocks().doDefaultRenderFace(face, par1Block, x, y, z, tex);
|
||||
}
|
||||
|
||||
Tessellator.instance.addTranslation(-(float) offset.x, -(float) offset.y, -(float) offset.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import crazypants.render.TechneUtil;
|
||||
import crazypants.render.VertexTransform;
|
||||
|
||||
public class TechneModelRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
private List<GroupObject> model;
|
||||
private int renderId;
|
||||
|
||||
protected VertexTransform vt;
|
||||
|
||||
public TechneModelRenderer(String modelPath, int renderId) {
|
||||
this(modelPath, renderId, null);
|
||||
}
|
||||
|
||||
public TechneModelRenderer(String modelPath, int renderId, VertexTransform vt) {
|
||||
model = TechneUtil.getModel(modelPath);
|
||||
this.renderId = renderId;
|
||||
this.vt = vt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
TechneUtil.vt = this.vt;
|
||||
TechneUtil.renderInventoryBlock(model, block, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
IIcon override = renderer.overrideBlockTexture;
|
||||
|
||||
TechneUtil.vt = this.vt;
|
||||
|
||||
if(override != null) {
|
||||
return TechneUtil.renderWorldBlock(model, override, world, x, y, z, block);
|
||||
}
|
||||
return TechneUtil.renderWorldBlock(model, world, x, y, z, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return renderId;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package crazypants.enderio.machine.farm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -9,19 +7,14 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import crazypants.enderio.machine.TechneModelRenderer;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.TechneUtil;
|
||||
|
||||
public class FarmingStationRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class FarmingStationRenderer extends TechneModelRenderer {
|
||||
|
||||
private List<GroupObject> model = TechneUtil.getModel("models/farm");
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
TechneUtil.renderInventoryBlock(model, block, metadata);
|
||||
public FarmingStationRenderer() {
|
||||
super("models/farm", BlockFarmStation.renderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,19 +33,6 @@ public class FarmingStationRenderer implements ISimpleBlockRenderingHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if(override != null) {
|
||||
return TechneUtil.renderWorldBlock(model, override, world, x, y, z, block);
|
||||
}
|
||||
return TechneUtil.renderWorldBlock(model, world, x, y, z, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return BlockFarmStation.renderId;
|
||||
return super.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
}
|
||||
}
|
||||
+26
@@ -2,6 +2,7 @@ package crazypants.enderio.machine.generator.combustion;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -15,6 +16,7 @@ import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.util.FluidUtil;
|
||||
import crazypants.util.Util;
|
||||
@@ -22,6 +24,8 @@ import crazypants.util.Util;
|
||||
public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustionGenerator> {
|
||||
|
||||
public static int renderId = -1;
|
||||
|
||||
private IIcon overlayPullNoCenter, overlayDisabledNoCenter;
|
||||
|
||||
public static BlockCombustionGenerator create() {
|
||||
PacketHandler.INSTANCE.registerMessage(PacketCombustionTank.class, PacketCombustionTank.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
@@ -108,6 +112,23 @@ public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustio
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
protected void registerOverlayIcons(IIconRegister iIconRegister) {
|
||||
super.registerOverlayIcons(iIconRegister);
|
||||
overlayPullNoCenter = iIconRegister.registerIcon("enderio:machineOverlayPullNoCenter");
|
||||
overlayDisabledNoCenter = iIconRegister.registerIcon("enderio:machineOverlayDisabledNoCenter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getOverlayIconForMode(ForgeDirection face, IoMode mode) {
|
||||
if(face.offsetY == 0) {
|
||||
return super.getOverlayIconForMode(face, mode);
|
||||
} else {
|
||||
return mode == IoMode.PULL ? overlayPullNoCenter : overlayDisabledNoCenter;
|
||||
}
|
||||
}
|
||||
|
||||
public IIcon getBackIcon() {
|
||||
return iconBuffer[0][2];
|
||||
}
|
||||
@@ -125,6 +146,11 @@ public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustio
|
||||
return "enderio:blankMachinePanel";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModelIconKey(boolean active) {
|
||||
return "enderio:combustionGenModel";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
|
||||
+22
-22
@@ -10,6 +10,8 @@ import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
//We're not going to use this anymore
|
||||
@Deprecated
|
||||
public class CombustionGeneratorModel extends ModelBase {
|
||||
//fields
|
||||
ModelRenderer Engine;
|
||||
@@ -57,8 +59,7 @@ public class CombustionGeneratorModel extends ModelBase {
|
||||
Chamber1.mirror = true;
|
||||
setRotation(Chamber1, 0F, 0F, -1.466077F);
|
||||
Chamber1.mirror = false;
|
||||
|
||||
|
||||
|
||||
Chamber2 = new ModelRenderer(this, 0, 52);
|
||||
Chamber2.mirror = true;
|
||||
Chamber2.addBox(0F, -8F, -8F, 9, 8, 16);
|
||||
@@ -67,21 +68,21 @@ public class CombustionGeneratorModel extends ModelBase {
|
||||
Chamber2.mirror = true;
|
||||
setRotation(Chamber2, 0F, 0F, -0.122173F);
|
||||
Chamber2.mirror = false;
|
||||
|
||||
|
||||
Tesla1 = new ModelRenderer(this, 34, 52);
|
||||
Tesla1.addBox(-1F, -4F, -1F, 2, 5, 2);
|
||||
Tesla1.setRotationPoint(5F, 4F, 5F);
|
||||
Tesla1.setTextureSize(256, 256);
|
||||
Tesla1.mirror = true;
|
||||
setRotation(Tesla1, 0F, 0F, 0.1570796F);
|
||||
|
||||
|
||||
Tesla2 = new ModelRenderer(this, 34, 52);
|
||||
Tesla2.addBox(-1F, -4F, -1F, 2, 5, 2);
|
||||
Tesla2.setRotationPoint(5F, 4F, -5F);
|
||||
Tesla2.setTextureSize(256, 256);
|
||||
Tesla2.mirror = true;
|
||||
setRotation(Tesla2, 0F, 0F, 0.1570796F);
|
||||
|
||||
|
||||
Tesla3 = new ModelRenderer(this, 34, 52);
|
||||
Tesla3.addBox(-1F, -4F, -1F, 2, 5, 2);
|
||||
Tesla3.setRotationPoint(5F, 4F, 0F);
|
||||
@@ -112,7 +113,7 @@ public class CombustionGeneratorModel extends ModelBase {
|
||||
Base.setTextureSize(256, 256);
|
||||
Base.mirror = true;
|
||||
setRotation(Base, 0F, 0F, 0F);
|
||||
|
||||
|
||||
Base6 = new ModelRenderer(this, 48, 4);
|
||||
Base6.mirror = true;
|
||||
Base6.addBox(-1F, -2F, -1F, 1, 2, 1);
|
||||
@@ -121,8 +122,7 @@ public class CombustionGeneratorModel extends ModelBase {
|
||||
Base6.mirror = true;
|
||||
setRotation(Base6, 0F, 0F, 0F);
|
||||
Base6.mirror = false;
|
||||
|
||||
|
||||
|
||||
Base5 = new ModelRenderer(this, 48, 4);
|
||||
Base5.mirror = true;
|
||||
Base5.addBox(-1F, -2F, -1F, 1, 2, 1);
|
||||
@@ -131,14 +131,14 @@ public class CombustionGeneratorModel extends ModelBase {
|
||||
Base5.mirror = true;
|
||||
setRotation(Base5, 0F, 0F, 0F);
|
||||
Base5.mirror = false;
|
||||
|
||||
|
||||
Base1 = new ModelRenderer(this, 0, 0);
|
||||
Base1.addBox(-2F, -4F, -1F, 4, 4, 1);
|
||||
Base1.setRotationPoint(-6F, 24F, -7F);
|
||||
Base1.setTextureSize(256, 256);
|
||||
Base1.mirror = true;
|
||||
setRotation(Base1, 0F, 0F, 0F);
|
||||
|
||||
|
||||
Base4 = new ModelRenderer(this, 48, 0);
|
||||
Base4.mirror = true;
|
||||
Base4.addBox(-4F, -1F, -1F, 8, 1, 1);
|
||||
@@ -147,14 +147,14 @@ public class CombustionGeneratorModel extends ModelBase {
|
||||
Base4.mirror = true;
|
||||
setRotation(Base4, 0F, 0F, 0F);
|
||||
Base4.mirror = false;
|
||||
|
||||
|
||||
Base2 = new ModelRenderer(this, 0, 0);
|
||||
Base2.addBox(-2F, -4F, -1F, 4, 4, 1);
|
||||
Base2.setRotationPoint(6F, 24F, -7F);
|
||||
Base2.setTextureSize(256, 256);
|
||||
Base2.mirror = true;
|
||||
setRotation(Base2, 0F, 0F, 0F);
|
||||
|
||||
|
||||
Base3 = new ModelRenderer(this, 48, 0);
|
||||
Base3.mirror = true;
|
||||
Base3.addBox(-4F, -1F, -1F, 8, 1, 1);
|
||||
@@ -163,30 +163,30 @@ public class CombustionGeneratorModel extends ModelBase {
|
||||
Base3.mirror = true;
|
||||
setRotation(Base3, 0F, 0F, 0F);
|
||||
Base3.mirror = false;
|
||||
|
||||
|
||||
Support1 = new ModelRenderer(this, 0, 5);
|
||||
Support1.addBox(-1F, -4F, -1F, 2, 4, 2);
|
||||
Support1.setRotationPoint(-7F, 20F, -7F);
|
||||
Support1.setTextureSize(256, 256);
|
||||
Support1.mirror = true;
|
||||
setRotation(Support1, 0F, 0F, 0F);
|
||||
|
||||
|
||||
Chimney4 = new ModelRenderer(this, 25, 20);
|
||||
Chimney4.mirror = true;
|
||||
Chimney4.addBox(-3F, -4F, -1F, 6, 4, 1);
|
||||
Chimney4.setRotationPoint(-4F, 20F, 0F);
|
||||
Chimney4.setTextureSize(256, 256);
|
||||
Chimney4.mirror = true;
|
||||
setRotation(Chimney4, 0F, 1.570796F, 0F);
|
||||
setRotation(Chimney4, 0F, 1.570796F, 0F);
|
||||
Chimney4.mirror = false;
|
||||
|
||||
|
||||
Support2 = new ModelRenderer(this, 0, 5);
|
||||
Support2.addBox(-1F, -4F, -1F, 2, 4, 2);
|
||||
Support2.setRotationPoint(7F, 20F, -7F);
|
||||
Support2.setTextureSize(256, 256);
|
||||
Support2.mirror = true;
|
||||
setRotation(Support2, 0F, 0F, 0F);
|
||||
|
||||
|
||||
Chimney3 = new ModelRenderer(this, 25, 20);
|
||||
Chimney3.mirror = true;
|
||||
Chimney3.addBox(-3F, -4F, 0F, 6, 4, 1);
|
||||
@@ -195,35 +195,35 @@ public class CombustionGeneratorModel extends ModelBase {
|
||||
Chimney3.mirror = true;
|
||||
setRotation(Chimney3, 0F, 1.570796F, 0F);
|
||||
Chimney3.mirror = false;
|
||||
|
||||
|
||||
Support3 = new ModelRenderer(this, 0, 5);
|
||||
Support3.addBox(-1F, -4F, -1F, 2, 4, 2);
|
||||
Support3.setRotationPoint(-7F, 20F, 7F);
|
||||
Support3.setTextureSize(256, 256);
|
||||
Support3.mirror = true;
|
||||
setRotation(Support3, 0F, 0F, 0F);
|
||||
|
||||
|
||||
Chimney2 = new ModelRenderer(this, 25, 20);
|
||||
Chimney2.addBox(-3F, -4F, 0F, 6, 4, 1);
|
||||
Chimney2.setRotationPoint(0F, 20F, 4F);
|
||||
Chimney2.setTextureSize(256, 256);
|
||||
Chimney2.mirror = true;
|
||||
setRotation(Chimney2, 0F, 0F, 0F);
|
||||
|
||||
|
||||
Support4 = new ModelRenderer(this, 0, 5);
|
||||
Support4.addBox(-1F, -4F, -1F, 2, 4, 2);
|
||||
Support4.setRotationPoint(7F, 20F, 7F);
|
||||
Support4.setTextureSize(256, 256);
|
||||
Support4.mirror = true;
|
||||
setRotation(Support4, 0F, 0F, 0F);
|
||||
|
||||
|
||||
Chimney1 = new ModelRenderer(this, 25, 20);
|
||||
Chimney1.addBox(-3F, -4F, -1F, 6, 4, 1);
|
||||
Chimney1.setRotationPoint(0F, 20F, -4F);
|
||||
Chimney1.setTextureSize(256, 256);
|
||||
Chimney1.mirror = true;
|
||||
setRotation(Chimney1, 0F, 0F, 0F);
|
||||
|
||||
|
||||
Chimney = new ModelRenderer(this, 0, 20);
|
||||
Chimney.addBox(-4F, -4F, -4F, 8, 4, 8);
|
||||
Chimney.setRotationPoint(0F, 20F, 0F);
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Deprecated
|
||||
public class CombustionGeneratorModelRenderer extends TileEntitySpecialRenderer implements IItemRenderer {
|
||||
|
||||
private static final String TEXTURE = "enderio:models/combustionGenerator.png";
|
||||
|
||||
+16
-196
@@ -1,238 +1,58 @@
|
||||
package crazypants.enderio.machine.generator.combustion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.enderio.machine.OverlayRenderer;
|
||||
import crazypants.enderio.machine.TechneModelRenderer;
|
||||
import crazypants.render.CustomCubeRenderer;
|
||||
import crazypants.render.CustomRenderBlocks;
|
||||
import crazypants.render.IRenderFace;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.ForgeDirectionOffsets;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vertex;
|
||||
import crazypants.render.VertexRotationFacing;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CombustionGeneratorRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class CombustionGeneratorRenderer extends TechneModelRenderer {
|
||||
|
||||
private CustomCubeRenderer ccr = new CustomCubeRenderer();
|
||||
|
||||
private OverlayRenderer overlayRenderer = new OverlayRenderer();
|
||||
|
||||
private FacingVertexTransform vt = new FacingVertexTransform();
|
||||
|
||||
private TileCombustionGenerator gen;
|
||||
public CombustionGeneratorRenderer() {
|
||||
super("models/combustionGen", BlockCombustionGenerator.renderId, new VertexRotationFacing(ForgeDirection.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
short facing = (short)ForgeDirection.SOUTH.ordinal();
|
||||
boolean active = false;
|
||||
TileCombustionGenerator gen = null;
|
||||
ForgeDirection facing = ForgeDirection.SOUTH;
|
||||
if(world != null) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileCombustionGenerator) {
|
||||
gen = (TileCombustionGenerator) te;
|
||||
facing = gen.facing;
|
||||
active = gen.isActive();
|
||||
facing = gen.getFacingDir();
|
||||
} else {
|
||||
gen = null;
|
||||
}
|
||||
}
|
||||
|
||||
BoundingBox bb;
|
||||
boolean scaleX = facing != 4 && facing != 5;
|
||||
float scx;
|
||||
float scz;
|
||||
|
||||
IIcon override = renderer.overrideBlockTexture;
|
||||
|
||||
//middle chunk
|
||||
bb = BoundingBox.UNIT_CUBE;
|
||||
bb = bb.scale(1, 0.34, 1);
|
||||
vt.setFacing(facing);
|
||||
TranslatedCubeRenderer.instance.renderBoundingBox(x, y, z, block, bb, vt, override, world != null);
|
||||
|
||||
scaleX = facing != 4 && facing != 5;
|
||||
scx = scaleX ? 0.7f : 1;
|
||||
scz = scaleX ? 1 : 0.7f;
|
||||
|
||||
//top 1/3
|
||||
bb = BoundingBox.UNIT_CUBE;
|
||||
bb = bb.scale(scx, 0.21, scz);
|
||||
bb = bb.translate(0, 0.26f, 0);
|
||||
TranslatedCubeRenderer.instance.renderBoundingBox(x, y, z, block, bb, vt, override ,world != null);
|
||||
|
||||
|
||||
//lower 1/3
|
||||
bb = BoundingBox.UNIT_CUBE;
|
||||
bb = bb.scale(scx, 0.21, scz);
|
||||
bb = bb.translate(0, -0.26f, 0);
|
||||
TranslatedCubeRenderer.instance.renderBoundingBox(x, y, z, block, bb, vt, override ,world != null);
|
||||
|
||||
//top / bottom connectors
|
||||
bb = BoundingBox.UNIT_CUBE.scale(0.35, 1, 0.35);
|
||||
TranslatedCubeRenderer.instance.renderBoundingBox(x, y, z, block, bb, vt, override ,world != null);
|
||||
|
||||
//tanks
|
||||
float size = 0.64f;
|
||||
bb = BoundingBox.UNIT_CUBE.scale(0.98, 1, 0.98);
|
||||
scx = scaleX ? size : 1;
|
||||
scz = scaleX ? 1 : size;
|
||||
bb = bb.scale(scx, 1, scz);
|
||||
|
||||
float tx = scaleX ? 0.5f: 0;
|
||||
float tz = scaleX ? 0 : 0.5f;
|
||||
bb = bb.translate(tx, 0, tz);
|
||||
|
||||
IIcon tex;
|
||||
if(Config.combustionGeneratorUseOpaqueModel) {
|
||||
tex = EnderIO.blockCombustionGenerator.getIcon(4,0);
|
||||
} else {
|
||||
tex = EnderIO.blockFusedQuartz.getDefaultFrameIcon(0);
|
||||
}
|
||||
|
||||
if (override != null) {
|
||||
tex = override;
|
||||
}
|
||||
|
||||
TranslatedCubeRenderer.instance.renderBoundingBox(x, y, z, block, bb, vt, tex, world != null);
|
||||
|
||||
bb = bb.translate(-tx * 2, 0, -tz * 2);
|
||||
TranslatedCubeRenderer.instance.renderBoundingBox(x, y, z, block, bb, vt,tex, world != null);
|
||||
vt = new VertexRotationFacing(ForgeDirection.NORTH);
|
||||
((VertexRotationFacing) vt).setRotation(facing);
|
||||
|
||||
if(gen != null) {
|
||||
overlayRenderer.setTile(gen);
|
||||
ccr.renderBlock(world, block, x, y, z, overlayRenderer);
|
||||
}
|
||||
gen = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
super.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float var8) {
|
||||
|
||||
TileCombustionGenerator gen = (TileCombustionGenerator) tileentity;
|
||||
if(gen.getCoolantTank().getFluidAmount() <= 0 && gen.getFuelTank().getFluidAmount() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().entityRenderer.disableLightmap(0);
|
||||
|
||||
float val = RenderUtil.claculateTotalBrightnessForLocation(tileentity.getWorldObj(), tileentity.xCoord, tileentity.yCoord, tileentity.zCoord);
|
||||
GL11.glColor3f(val, val, val);
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.setTranslation(x, y, z);
|
||||
tes.startDrawingQuads();
|
||||
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(0.96, 0.96, 0.96);
|
||||
renderTank(gen, bb, gen.getCoolantTank(), true);
|
||||
renderTank(gen, bb, gen.getFuelTank(), false);
|
||||
tes.draw();
|
||||
tes.setTranslation(0, 0, 0);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
Minecraft.getMinecraft().entityRenderer.enableLightmap(0);
|
||||
|
||||
}
|
||||
|
||||
private void renderTank(TileCombustionGenerator gen, BoundingBox bb, FluidTank tank, boolean isLeft) {
|
||||
boolean scaleX = gen.getFacing() != 4 && gen.getFacing() != 5;
|
||||
float size = 0.34f;
|
||||
|
||||
if(gen.getFacing() == 5 || gen.getFacing() == 2) {
|
||||
isLeft = !isLeft;
|
||||
}
|
||||
|
||||
if(tank.getFluidAmount() > 0) {
|
||||
IIcon icon = tank.getFluid().getFluid().getStillIcon();
|
||||
if(icon != null) {
|
||||
float fullness = (float) (tank.getFluidAmount() - 1000) / (tank.getCapacity() - 1000);
|
||||
float scx = scaleX ? size : 1f;
|
||||
float scz = scaleX ? 1f : size;
|
||||
bb = bb.scale(scx, 0.97 * fullness, scz);
|
||||
|
||||
float tx = scaleX ? 0.25f * 1.25f : 0;
|
||||
float tz = scaleX ? 0 : 0.25f * 1.25f;
|
||||
float ty = -(0.98f - (bb.maxY - bb.minY)) / 2;
|
||||
if(!isLeft) {
|
||||
tx = -tx;
|
||||
tz = -tz;
|
||||
}
|
||||
bb = bb.translate(tx, ty, tz);
|
||||
CubeRenderer.render(bb, icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
Tessellator tes = Tessellator.instance;
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
tes.startDrawingQuads();
|
||||
renderWorldBlock(null, 0, 0, 0, block, 0, renderer);
|
||||
tes.draw();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
((VertexRotationFacing) vt).setRotation(ForgeDirection.SOUTH);
|
||||
super.renderInventoryBlock(block, metadata, modelId, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return BlockCombustionGenerator.renderId;
|
||||
}
|
||||
|
||||
private class OverlayRenderer implements IRenderFace {
|
||||
|
||||
@Override
|
||||
public void renderFace(CustomRenderBlocks rb, ForgeDirection face, Block par1Block, double x, double y, double z, IIcon texture, List<Vertex> refVertices,
|
||||
boolean translateToXyz) {
|
||||
|
||||
if(gen != null && par1Block instanceof AbstractMachineBlock) {
|
||||
Vector3d offset = ForgeDirectionOffsets.offsetScaled(face, 0.01);
|
||||
Tessellator.instance.addTranslation((float) offset.x, (float) offset.y, (float) offset.z);
|
||||
|
||||
IoMode mode = gen.getIoMode(face);
|
||||
IIcon tex = ((AbstractMachineBlock) par1Block).getOverlayIconForMode(mode);
|
||||
if(tex != null) {
|
||||
ccr.getCustomRenderBlocks().doDefaultRenderFace(face, par1Block, x, y, z, tex);
|
||||
}
|
||||
|
||||
Tessellator.instance.addTranslation(-(float) offset.x, -(float) offset.y, -(float) offset.z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package crazypants.enderio.machine.generator.combustion;
|
||||
|
||||
import crazypants.render.VertexTransform;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
import crazypants.vecmath.Vertex;
|
||||
|
||||
class FacingVertexTransform implements VertexTransform {
|
||||
|
||||
|
||||
boolean transX;
|
||||
|
||||
public FacingVertexTransform() {
|
||||
}
|
||||
|
||||
public void setFacing(int facing) {
|
||||
transX = facing != 4 && facing != 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Vertex vertex) {
|
||||
apply(vertex.xyz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Vector3d vec) {
|
||||
if(vec.y > 0.8 || vec.y < 0.2) {
|
||||
if(transX) {
|
||||
vec.x -= 0.5;
|
||||
vec.x *= 0.6;
|
||||
vec.x += 0.5;
|
||||
} else {
|
||||
vec.z -= 0.5;
|
||||
vec.z *= 0.6;
|
||||
vec.z += 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToNormal(Vector3f vec) {
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -89,7 +89,7 @@ public class TransceiverRenderer extends TileEntitySpecialRenderer implements II
|
||||
rb.setRenderBounds(pushPullBounds.minX, pushPullBounds.minY, pushPullBounds.minZ,
|
||||
pushPullBounds.maxX, pushPullBounds.maxY, pushPullBounds.maxZ);
|
||||
}
|
||||
IIcon icon = EnderIO.blockTransceiver.getOverlayIconForMode(mode);
|
||||
IIcon icon = EnderIO.blockTransceiver.getOverlayIconForMode(dir, mode);
|
||||
if(icon != null) {
|
||||
rb.doDefaultRenderFace(dir, EnderIO.blockTransceiver, 0, 0, 0, icon);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package crazypants.enderio.machine.vat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -11,20 +8,15 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.OverlayRenderer;
|
||||
import crazypants.enderio.machine.generator.combustion.TranslatedCubeRenderer;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CustomCubeRenderer;
|
||||
import crazypants.render.CustomRenderBlocks;
|
||||
import crazypants.render.IRenderFace;
|
||||
import crazypants.render.VertexTransform;
|
||||
import crazypants.util.ForgeDirectionOffsets;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
import crazypants.vecmath.Vertex;
|
||||
@@ -38,9 +30,9 @@ public class VatRenderer implements ISimpleBlockRenderingHandler, IItemRenderer
|
||||
private OverlayRenderer overlayRenderer = new OverlayRenderer();
|
||||
|
||||
private TileVat vat;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,42 +43,39 @@ public class VatRenderer implements ISimpleBlockRenderingHandler, IItemRenderer
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
renderInventoryBlock(Block.getBlockFromItem(item.getItem()), item.getItemDamage(), 0, (RenderBlocks)data[0]);
|
||||
renderInventoryBlock(Block.getBlockFromItem(item.getItem()), item.getItemDamage(), 0, (RenderBlocks) data[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
short facing = 3;
|
||||
boolean active = false;
|
||||
if(world != null) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileVat) {
|
||||
vat = (TileVat) te;
|
||||
facing = vat.facing;
|
||||
active = vat.isActive();
|
||||
} else {
|
||||
vat = null;
|
||||
}
|
||||
}
|
||||
|
||||
float fudge = 1f;
|
||||
|
||||
|
||||
IIcon override = renderer.overrideBlockTexture;
|
||||
|
||||
//-x side
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(0.334, fudge,fudge);
|
||||
bb = bb.translate(0.5f - (0.334f/2),0,0);
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(0.334, fudge, fudge);
|
||||
bb = bb.translate(0.5f - (0.334f / 2), 0, 0);
|
||||
TranslatedCubeRenderer.instance.renderBoundingBox(x, y, z, block, bb, xform, override, world != null);
|
||||
|
||||
bb = BoundingBox.UNIT_CUBE.scale(0.334, fudge,fudge);
|
||||
bb = BoundingBox.UNIT_CUBE.scale(0.334, fudge, fudge);
|
||||
TranslatedCubeRenderer.instance.renderBoundingBox(x, y, z, block, bb, xform, override, world != null);
|
||||
|
||||
bb = BoundingBox.UNIT_CUBE.scale(0.334, fudge,fudge);
|
||||
bb = bb.translate(-0.5f + (0.334f/2),0,0);
|
||||
bb = BoundingBox.UNIT_CUBE.scale(0.334, fudge, fudge);
|
||||
bb = bb.translate(-0.5f + (0.334f / 2), 0, 0);
|
||||
TranslatedCubeRenderer.instance.renderBoundingBox(x, y, z, block, bb, xform, override, world != null);
|
||||
|
||||
if(vat != null) {
|
||||
overlayRenderer.setTile(vat);
|
||||
ccr.renderBlock(world, block, x, y, z, overlayRenderer);
|
||||
}
|
||||
vat = null;
|
||||
@@ -94,7 +83,6 @@ public class VatRenderer implements ISimpleBlockRenderingHandler, IItemRenderer
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
@@ -102,14 +90,14 @@ public class VatRenderer implements ISimpleBlockRenderingHandler, IItemRenderer
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
tes.addTranslation(0, -0.1f, 0);
|
||||
renderWorldBlock(null, 0, 0, 0, block, 0, renderer);
|
||||
tes.addTranslation(0, 0.1f, 0);
|
||||
tes.draw();
|
||||
tes.draw();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
@@ -125,7 +113,7 @@ public class VatRenderer implements ISimpleBlockRenderingHandler, IItemRenderer
|
||||
|
||||
@Override
|
||||
public void apply(Vertex vertex) {
|
||||
apply(vertex.xyz);
|
||||
apply(vertex.xyz);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,26 +130,4 @@ public class VatRenderer implements ISimpleBlockRenderingHandler, IItemRenderer
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class OverlayRenderer implements IRenderFace {
|
||||
|
||||
@Override
|
||||
public void renderFace(CustomRenderBlocks rb, ForgeDirection face, Block par1Block, double x, double y, double z, IIcon texture, List<Vertex> refVertices,
|
||||
boolean translateToXyz) {
|
||||
|
||||
if(vat != null && par1Block instanceof AbstractMachineBlock) {
|
||||
Vector3d offset = ForgeDirectionOffsets.offsetScaled(face, 0.01);
|
||||
Tessellator.instance.addTranslation((float)offset.x, (float)offset.y, (float)offset.z);
|
||||
|
||||
IoMode mode = vat.getIoMode(face);
|
||||
IIcon tex = ((AbstractMachineBlock)par1Block).getOverlayIconForMode(mode);
|
||||
if(tex != null) {
|
||||
ccr.getCustomRenderBlocks().doDefaultRenderFace(face,par1Block,x,y,z, tex);
|
||||
}
|
||||
Tessellator.instance.addTranslation(-(float)offset.x, -(float)offset.y, -(float)offset.z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,7 @@ public class CustomCubeRenderer {
|
||||
}
|
||||
|
||||
public void renderBlock(IBlockAccess ba, Block par1Block, int par2, int par3, int par4, Collection<IRenderFace> renderers) {
|
||||
if(rb == null) {
|
||||
rb = new CustomRenderBlocks(ba);
|
||||
}
|
||||
|
||||
rb.blockAccess = ba;
|
||||
rb.setOverrideTexture(getOverrideTexture());
|
||||
rb.setFaceRenderers(renderers);
|
||||
@@ -52,8 +50,9 @@ public class CustomCubeRenderer {
|
||||
}
|
||||
|
||||
public CustomRenderBlocks getCustomRenderBlocks() {
|
||||
if (rb == null) {
|
||||
rb = new CustomRenderBlocks();
|
||||
}
|
||||
return rb;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -21,6 +21,10 @@ public class CustomRenderBlocks extends RenderBlocks {
|
||||
private final List<IRenderFace> renderFaceCallbacks = new ArrayList<IRenderFace>();
|
||||
private IIcon overrideTexture;
|
||||
|
||||
public CustomRenderBlocks() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CustomRenderBlocks(IBlockAccess par1iBlockAccess) {
|
||||
super(par1iBlockAccess);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import net.minecraft.client.model.ModelBox;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.model.PositionTextureVertex;
|
||||
import net.minecraft.client.model.TexturedQuad;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -65,6 +64,7 @@ import com.google.common.collect.Lists;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
/**
|
||||
* Slightly modified to fit the EnderIO source.
|
||||
@@ -73,6 +73,25 @@ import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
*/
|
||||
public class TechneUtil {
|
||||
|
||||
private static class DefaultVertexTransform implements VertexTransform {
|
||||
|
||||
private static DefaultVertexTransform INSTANCE = new DefaultVertexTransform();
|
||||
|
||||
@Override
|
||||
public void apply(crazypants.vecmath.Vertex vertex) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Vector3d vec) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToNormal(crazypants.vecmath.Vector3f vec) {
|
||||
}
|
||||
}
|
||||
|
||||
public static VertexTransform vt = DefaultVertexTransform.INSTANCE;
|
||||
|
||||
private static final Tessellator tes = Tessellator.instance;
|
||||
|
||||
public static List<GroupObject> bakeModel(ModelRenderer model) {
|
||||
@@ -181,12 +200,20 @@ public class TechneUtil {
|
||||
}
|
||||
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, Tessellator tes) {
|
||||
renderWithIcon(model, icon, tes, null);
|
||||
}
|
||||
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, Tessellator tes, VertexTransform vt) {
|
||||
for (GroupObject go : model) {
|
||||
for (Face f : go.faces) {
|
||||
Vertex n = f.faceNormal;
|
||||
tes.setNormal(n.x, n.y, n.z);
|
||||
for (int i = 0; i < f.vertices.length; i++) {
|
||||
Vertex v = f.vertices[i];
|
||||
Vertex vert = f.vertices[i];
|
||||
Vector3d v = new Vector3d(vert);
|
||||
if(vt != null) {
|
||||
vt.apply(v);
|
||||
}
|
||||
TextureCoordinate t = f.textureCoordinates[i];
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, icon.getInterpolatedU(t.u * 16), icon.getInterpolatedV(t.v * 8));
|
||||
}
|
||||
@@ -202,9 +229,10 @@ public class TechneUtil {
|
||||
tes.startDrawingQuads();
|
||||
tes.setColorOpaque_F(1, 1, 1);
|
||||
tes.addTranslation(0, -0.5f, 0);
|
||||
renderWithIcon(model, icon, tes);
|
||||
renderWithIcon(model, icon, tes, vt);
|
||||
tes.addTranslation(0, 0.5f, 0);
|
||||
tes.draw();
|
||||
resetVT();
|
||||
}
|
||||
|
||||
public static boolean renderWorldBlock(List<GroupObject> model, IBlockAccess world, int x, int y, int z, Block block) {
|
||||
@@ -216,11 +244,16 @@ public class TechneUtil {
|
||||
tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tes.setColorOpaque_F(1, 1, 1);
|
||||
tes.addTranslation(x + .5F, y + 0.0375f, z + .5F);
|
||||
renderWithIcon(model, icon, tes);
|
||||
renderWithIcon(model, icon, tes, vt);
|
||||
tes.addTranslation(-x - .5F, -y - 0.0375f, -z - .5F);
|
||||
resetVT();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void resetVT() {
|
||||
vt = DefaultVertexTransform.INSTANCE;
|
||||
}
|
||||
|
||||
private static IIcon getIconFor(Block block, IBlockAccess world, int x, int y, int z) {
|
||||
if(block instanceof AbstractMachineBlock<?>) {
|
||||
return ((AbstractMachineBlock<?>) block).getModelIcon(world, x, y, z);
|
||||
|
||||
@@ -35,6 +35,10 @@ public class VertexRotation implements VertexTransform {
|
||||
this.angle = angle;
|
||||
quat = Quat4d.makeRotate(angle, axis);
|
||||
}
|
||||
|
||||
public double getAngle() {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public void setAxis(Vector3d axis) {
|
||||
this.axis.set(axis);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package crazypants.render;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class VertexRotationFacing extends VertexRotation {
|
||||
|
||||
private ForgeDirection defaultDir;
|
||||
|
||||
public VertexRotationFacing(ForgeDirection defaultDir) {
|
||||
super(0, new Vector3d(0, 0.5, 0), new Vector3d(0, 0, 0));
|
||||
this.defaultDir = defaultDir;
|
||||
}
|
||||
|
||||
// No I have no idea why this value works.
|
||||
private double rotationAmount = 1.571;
|
||||
|
||||
public void setRotation(ForgeDirection dir) {
|
||||
if(dir == defaultDir) {
|
||||
setAngle(0);
|
||||
} else if(dir == defaultDir.getOpposite()) {
|
||||
setAngle(rotationAmount * 2);
|
||||
} else if(dir == defaultDir.getRotation(ForgeDirection.DOWN)) {
|
||||
setAngle(rotationAmount);
|
||||
} else {
|
||||
setAngle(rotationAmount * 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package crazypants.vecmath;
|
||||
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.client.model.obj.Vertex;
|
||||
|
||||
public class Vector3d {
|
||||
|
||||
@@ -28,6 +29,10 @@ public class Vector3d {
|
||||
this(corner.x, corner.y, corner.z);
|
||||
}
|
||||
|
||||
public Vector3d(Vertex vert) {
|
||||
this(vert.x, vert.y, vert.z);
|
||||
}
|
||||
|
||||
public void set(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
Reference in new issue
Block a user