mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 15:03:07 +00:00
CP 'dodgy special' model done for Enchanter
This commit is contained in:
1 parent
468f3dbd5f
commit
9b8b41489f
8 files changed
+200
-4
No files matched your search
@@ -51,6 +51,8 @@ import crazypants.enderio.item.darksteel.SoundRenderer;
|
||||
import crazypants.enderio.item.darksteel.SoundDetector;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.AbstractMachineRenderer;
|
||||
import crazypants.enderio.machine.enchanter.BlockEnchanter;
|
||||
import crazypants.enderio.machine.enchanter.EnchanterRenderer;
|
||||
import crazypants.enderio.machine.farm.BlockFarmStation;
|
||||
import crazypants.enderio.machine.farm.FarmingStationRenderer;
|
||||
import crazypants.enderio.machine.generator.combustion.BlockCombustionGenerator;
|
||||
@@ -156,6 +158,11 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemBrokenSpawner, new BrokenSpawnerRenderer());
|
||||
|
||||
BlockEnchanter.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
EnchanterRenderer enchRen = new EnchanterRenderer();
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEnchanter), enchRen);
|
||||
RenderingRegistry.registerBlockHandler(enchRen);
|
||||
|
||||
|
||||
BlockFusedQuartz.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(new FusedQuartzRenderer());
|
||||
|
||||
@@ -183,7 +183,7 @@ public class EnderIO {
|
||||
public static BlockPoweredSpawner blockPoweredSpawner;
|
||||
public static ItemBrokenSpawner itemBrokenSpawner;
|
||||
|
||||
public static BlockEnchanter blockEncahnter;
|
||||
public static BlockEnchanter blockEnchanter;
|
||||
|
||||
public static BlockElectricLight blockElectricLight;
|
||||
public static BlockLightNode blockLightNode;
|
||||
@@ -273,7 +273,7 @@ public class EnderIO {
|
||||
blockReservoir = BlockReservoir.create();
|
||||
blockVacuumChest = BlockVacuumChest.create();
|
||||
|
||||
blockEncahnter = BlockEnchanter.create();
|
||||
blockEnchanter = BlockEnchanter.create();
|
||||
|
||||
blockDarkSteelPressurePlate = BlockDarkSteelPressurePlate.create();
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
@@ -18,6 +19,7 @@ import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.vacuum.BlockVacuumChest;
|
||||
import crazypants.enderio.machine.vacuum.ContainerVacuumChest;
|
||||
import crazypants.enderio.machine.vacuum.GuiVacuumChest;
|
||||
@@ -44,6 +46,33 @@ public class BlockEnchanter extends BlockEio implements IGuiHandler, IResourceTo
|
||||
super.init();
|
||||
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_ENCHANTER, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
TileEnchanter te = (TileEnchanter) world.getTileEntity(x, y, z);
|
||||
switch (heading) {
|
||||
case 0:
|
||||
te.setFacing((short) 2);
|
||||
break;
|
||||
case 1:
|
||||
te.setFacing((short) 5);
|
||||
break;
|
||||
case 2:
|
||||
te.setFacing((short) 3);
|
||||
break;
|
||||
case 3:
|
||||
te.setFacing((short) 4);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(world.isRemote) {
|
||||
return;
|
||||
}
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) {
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
package crazypants.enderio.machine.enchanter;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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 cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.render.VertexRotation;
|
||||
import crazypants.render.VertexTransform;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
import crazypants.vecmath.Vertex;
|
||||
|
||||
public class EnchanterRenderer implements ISimpleBlockRenderingHandler, IItemRenderer {
|
||||
|
||||
@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) {
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
renderWorldBlock(null, 0, 0, 0, null, 0, null);
|
||||
tes.draw();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.addTranslation(x, y, z);
|
||||
tes.setColorOpaque_F(1, 1, 1);
|
||||
|
||||
IIcon[] icons = new IIcon[6];
|
||||
for(int i=0;i<icons.length;i++) {
|
||||
if(i == ForgeDirection.UP.ordinal() || i == ForgeDirection.DOWN.ordinal()) {
|
||||
icons[i] = Blocks.obsidian.getBlockTextureFromSide(0);
|
||||
} else {
|
||||
icons[i] = EnderIO.blockConduitBundle.getConnectorIcon();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IIcon tex = EnderIO.blockConduitBundle.getConnectorIcon();
|
||||
|
||||
float max = 0.85f;
|
||||
float min = 0.15f;
|
||||
float minY = 0;
|
||||
float maxY = 0.1f;
|
||||
BoundingBox bb = new BoundingBox(min, minY, min, max, maxY, max);
|
||||
CubeRenderer.render(bb,tex,true);
|
||||
|
||||
min = 0.40f;
|
||||
max = 0.6f;
|
||||
minY = 0.1f;
|
||||
maxY = 0.75f;
|
||||
|
||||
bb = new BoundingBox(min, minY, min, max, maxY, max);
|
||||
CubeRenderer.render(bb, icons, true);
|
||||
|
||||
min = 0.00f;
|
||||
max = 1.0f;
|
||||
minY = 0.75f;
|
||||
maxY = 0.85f;
|
||||
|
||||
bb = new BoundingBox(min, minY, min, max, maxY, max);
|
||||
CubeRenderer.render(bb, icons, true);
|
||||
|
||||
|
||||
minY = 0.85f;
|
||||
maxY = 0.90f;
|
||||
min = 0.3f;
|
||||
max = 0.7f;
|
||||
|
||||
int facing = ForgeDirection.NORTH.ordinal();
|
||||
if(world != null) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileEnchanter) {
|
||||
facing = ((TileEnchanter)te).getFacing();
|
||||
}
|
||||
}
|
||||
boolean flip = facing == ForgeDirection.EAST.ordinal() || facing == ForgeDirection.WEST.ordinal();
|
||||
|
||||
// float xOff = flip ? 0 : 0.1f;
|
||||
// float zOff = flip ? 0.1f : 0f;
|
||||
float xOff = 0.1f;
|
||||
float zOff = 0f;
|
||||
|
||||
tex = EnderIO.blockEnchanter.getBlockTextureFromSide(0);
|
||||
bb = new BoundingBox(min - xOff, minY, min - zOff, max + xOff, maxY, max + zOff);
|
||||
if(flip) {
|
||||
CubeRenderer.render(bb, tex, new VertexRotation(Math.PI / 2, new Vector3d(0, 1, 0), new Vector3d(0.5, 0.5, 0.5)), true);
|
||||
} else {
|
||||
CubeRenderer.render(bb, tex, true);
|
||||
}
|
||||
tes.addTranslation(-x, -y, -z);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return BlockEnchanter.renderId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.TileEntityEio;
|
||||
import crazypants.enderio.enderface.TileEnderIO;
|
||||
@@ -19,6 +20,16 @@ import crazypants.enderio.enderface.TileEnderIO;
|
||||
public class TileEnchanter extends TileEntityEio implements ISidedInventory {
|
||||
|
||||
private ItemStack[] inv = new ItemStack[3];
|
||||
|
||||
private short facing = (short)ForgeDirection.NORTH.ordinal();
|
||||
|
||||
public void setFacing(short s) {
|
||||
facing = s;
|
||||
}
|
||||
|
||||
public short getFacing() {
|
||||
return facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeCustomNBT(NBTTagCompound root) {
|
||||
@@ -32,6 +43,7 @@ public class TileEnchanter extends TileEntityEio implements ISidedInventory {
|
||||
}
|
||||
}
|
||||
root.setTag("Items", itemList);
|
||||
root.setShort("facing", facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,6 +58,7 @@ public class TileEnchanter extends TileEntityEio implements ISidedInventory {
|
||||
}
|
||||
}
|
||||
}
|
||||
facing = root.getShort("facing");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,7 @@ public final class CubeRenderer {
|
||||
public static void render(BoundingBox bb, IIcon tex, VertexTransform xForm) {
|
||||
render(bb, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV(), xForm, false);
|
||||
}
|
||||
|
||||
|
||||
public static void render(BoundingBox bb, IIcon tex, VertexTransform xForm, float[] brightnessPerSide, boolean tintSides) {
|
||||
float minU = 0;
|
||||
float minV = 0;
|
||||
@@ -166,6 +166,18 @@ public final class CubeRenderer {
|
||||
addVecWithUV(verts[3], minU, maxV);
|
||||
}
|
||||
|
||||
public static void render(BoundingBox bb, IIcon[] icons, boolean tintSides) {
|
||||
float[] brightnessPerSide = null;
|
||||
if(tintSides) {
|
||||
brightnessPerSide = new float[6];
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
brightnessPerSide[dir.ordinal()] = RenderUtil.getColorMultiplierForFace(dir);
|
||||
}
|
||||
}
|
||||
render(bb, icons, null, brightnessPerSide);
|
||||
|
||||
}
|
||||
|
||||
public static void render(BoundingBox bb, IIcon[] faceTextures, VertexTransform xForm, float[] brightnessPerSide) {
|
||||
setupVertices(bb, xForm);
|
||||
float minU;
|
||||
@@ -296,4 +308,6 @@ public final class CubeRenderer {
|
||||
private CubeRenderer() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user