Everything posted by Flenix
-
Help with my crafting table?
Fixed that now, didn't change anything =/ The recipes were staying inside anyway, so that's quite strange. I removed that anyway, doesn't seem to have changed anything but at least I don't have a bit of useless code now
-
Vanilla Textures on Custom Blocks
I'm trying to do this too, but with an item. What would I use for that? Items don't have sides, and I don't think meta changes the appearance either so that's also not relevant.
-
Help with my crafting table?
Hey guys, I'm trying to make a custom 5x5 crafting table, but it doesn't seem to be working. Everything is ok, except it doesn't craft - I don't get a result when I place my recipe inside! I followed a tutorial so I probably did something wrong, but the author never got back to me when I tried to contact them. Here's all the classes for my table. It's worth noting also that I want the table to store items, so when you exit the items should STAY inside. Not sure what classes you need to see (or even what I need to have, It seems like there's quite a few for something I expected to be relatively simple) so I just put all the ones directly relevant. Container GUI Crafting Manager Recipe Sorter Shaped Recipe Shapeless Recipe Slot Block TileEntity Renderer I'm also getting a strange bug whereby sometimes items fall out of your inventory when you click them instead of picking them up. I've not quite worked out what causes it, because it's not consistant, so any ideas? The other issue is much more important right now though.
-
How can I create a custom sign?
Well, it'd ask me to create a constructor. I'd click the link to auto-make it, and get this: public TileEntityRoadSignBlock(int roadSignID, Class par2Class, boolean par3) { //Todo: Auto Generated Stub } So, obviously I needed to add a few things, so I added: super(roadSignID, Material.iron); this.isFreestanding = par3; and also private Class signEntityClass; (All of which are directly from the Sign's block class) Then it accepts that as no errors, but back in my main block class it simply tells me I need a constructor again and would auto-create that same thing, going around in circles. I'm not quite sure what I did, but I seem to have fixed it again now. However, when I try and place the sign in-game I get "Unable to locate sign at [coords]" You seem to know literally everything about Forge.. any idea what I'm missing? I've registered the tile entity so I'm not sure what else there is. Maybe the sign has another class that I've not found yet?
-
How can I create a custom sign?
Hey guys, I want to make a few of my own signs (kind of similar to the vanilla signs) The main difference will be shape, and the position/amount of lines or characters that can be written. I tried copying the vanilla sign block + entity classes to experiment, but eclipse wasn't very happy about that (It kept telling me I had to create a constructor, then I'd create it and it'd tell me it was wrong...) Can anyone point me in the right direction?
-
A couple of Tile Entity + Crafting things...
Hey guys, got 3 questions all related to the same block so I thought I'd put them in the same thread for convenience! Alright, #1 How would I go about making my own crafting table? I know that's a big topic really so just any links to a tutorial or anything? (I want it to keep the items inside when you exit the inventory though, they shouldn't fall out) #2 I want a certain slot to accept only one block as an input, but also work as an output at the same time. How can I go about doing this? #3 When that certain block is in that slot, I want to change the model. I understand I need to use Switch statements(?), but other than that I have no idea what to do? Here's the code I have so far: [spoiler=Block] package co.uk.silvania.roads.tileentities.blocks; import java.util.Random; import co.uk.silvania.roads.Roads; import co.uk.silvania.roads.tileentities.entities.TileEntityRoadPainterEntity; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; 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; public class TileEntityRoadPainterBlock extends BlockContainer { public TileEntityRoadPainterBlock(int id) { super(id, Material.iron); this.setCreativeTab(Roads.tabRoads); this.setHardness(1.0F); } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityRoadPainterEntity(); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float j, float k, float l) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (tileEntity == null || player.isSneaking()) { return false; } player.openGui(Roads.instance, 0, world, x, y, z); return true; } @Override public void breakBlock(World world, int x, int y, int z, int par5, int par6) { dropItems(world, x, y, z); super.breakBlock(world, x, y, z, par5, par6); } @Override public int getRenderType() { return -1; } @Override public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack) { int var6 = MathHelper .floor_double(par5EntityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; if (var6 == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 0); } if (var6 == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 0); } if (var6 == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 0); } if (var6 == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 0); } } private void dropItems(World world, int x, int y, int z){ Random rand = new Random(); TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); if (item != null && item.stackSize > 0) { float rx = rand.nextFloat() * 0.8F + 0.1F; float ry = rand.nextFloat() * 0.8F + 0.1F; float rz = rand.nextFloat() * 0.8F + 0.1F; EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.itemID, item.stackSize, item.getItemDamage())); if (item.hasTagCompound()) { entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy()); } float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; world.spawnEntityInWorld(entityItem); item.stackSize = 0; } } } public void registerIcons(IconRegister icon) { this.blockIcon = icon.registerIcon("Roads:CementBlock"); } } [spoiler=GUI] package co.uk.silvania.roads.tileentities; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; import co.uk.silvania.roads.tileentities.entities.TileEntityRoadPainterEntity; public class GuiRoadPainter extends GuiContainer { public GuiRoadPainter (InventoryPlayer inventoryPlayer, TileEntityRoadPainterEntity tileEntity) { super(new ContainerRoadPainter(inventoryPlayer, tileEntity)); } /** The X size of the inventory window in pixels. */ protected int xSize = 176; /** The Y size of the inventory window in pixels. */ protected int ySize = 204; @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { fontRenderer.drawString("Road Painter", 8, -12, 4210752); fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 113, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture("/mods/Roads/textures/gui/RoadPainterGui.png"); int x = (width - xSize) / 2; int y = (height - ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); } } [spoiler=Tile Entity] package co.uk.silvania.roads.tileentities.entities; import java.util.Iterator; import java.util.List; import co.uk.silvania.roads.Roads; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryLargeChest; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.AxisAlignedBB; public class TileEntityRoadPainterEntity extends TileEntityChest implements IInventory { private ItemStack[] roadPainterContents = new ItemStack[25]; public int numUsingPlayers; private int ticksSinceSync; private String field_94045_s; public int getSizeInventory() { return 25; } public ItemStack getStackInSlot(int par1) { return this.roadPainterContents[par1]; } public ItemStack decrStackSize(int par1, int par2) { if (this.roadPainterContents[par1] != null) { ItemStack var3; if (this.roadPainterContents[par1].stackSize <= par2) { var3 = this.roadPainterContents[par1]; this.roadPainterContents[par1] = null; this.onInventoryChanged(); return var3; } else { var3 = this.roadPainterContents[par1].splitStack(par2); if (this.roadPainterContents[par1].stackSize == 0) { this.roadPainterContents[par1] = null; } this.onInventoryChanged(); return var3; } } else { return null; } } public ItemStack getStackInSlotOnClosing(int par1) { if (this.roadPainterContents[par1] != null) { ItemStack var2 = this.roadPainterContents[par1]; this.roadPainterContents[par1] = null; return var2; } else { return null; } } /** * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). */ public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.roadPainterContents[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } this.onInventoryChanged(); } public String getInvName() { return "Road Painter"; } public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items"); this.roadPainterContents = new ItemStack[this.getSizeInventory()]; if (par1NBTTagCompound.hasKey("CustomName")) { this.field_94045_s = par1NBTTagCompound.getString("CustomName"); } for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; if (j >= 0 && j < this.roadPainterContents.length) { this.roadPainterContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.roadPainterContents.length; ++i) { if (this.roadPainterContents[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.roadPainterContents[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } par1NBTTagCompound.setTag("Items", nbttaglist); if (this.isInvNameLocalized()) { par1NBTTagCompound.setString("CustomName", this.field_94045_s); } } public int getInventoryStackLimit() { return 64; } public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; } public boolean receiveClientEvent(int par1, int par2) { if (par1 == 1) { this.numUsingPlayers = par2; return true; } else { return super.receiveClientEvent(par1, par2); } } public void openChest() { ++this.numUsingPlayers; this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, Roads.roadPainter.blockID, 1, this.numUsingPlayers); } public void closeChest() { --this.numUsingPlayers; this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, Roads.roadPainter.blockID, 1, this.numUsingPlayers); } public void invalidate() { super.invalidate(); this.updateContainingBlockInfo(); this.checkForAdjacentChests(); } } [spoiler=Renderer] package co.uk.silvania.roads.tileentities.renderers; import org.lwjgl.opengl.GL11; import co.uk.silvania.roads.Roads; import co.uk.silvania.roads.client.models.LightBollardModel; import co.uk.silvania.roads.client.models.RoadPainterEmptyModel; import co.uk.silvania.roads.client.models.RoadPainterFullModel; import co.uk.silvania.roads.client.models.TrafficLightModel; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; 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.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class TileEntityRoadPainterRenderer extends TileEntitySpecialRenderer { private final RoadPainterEmptyModel modelempty; private final RoadPainterFullModel modelfull; public TileEntityRoadPainterRenderer() { this.modelempty = new RoadPainterEmptyModel(); this.modelfull = new RoadPainterFullModel(); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { int i = te.getBlockMetadata(); int meta = 180; if (i == 3) { meta = 0; } if (i == 5) { meta = 90; } if (i == 2) { meta = 180; } if (i == 4) { meta = 270; } bindTextureByName("/mods/Roads/textures/blocks/RoadPainter.png"); GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glRotatef(meta, 0.0F, 1.0F, 0.0F); //GL11.glRotatef(((TileEntityBarrierEntity)tile).getRotationPivot()), 0.0F, 1.0F, 0.0F); GL11.glScalef(1.0F, -1F, -1F); this.modelempty.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } private void adjustLightFixture(World world, int i, int j, int k, Block block) { Tessellator tess = Tessellator.instance; float brightness = block.getBlockBrightness(world, i, j, k); int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int modulousModifier = skyLight % 65536; int divModifier = skyLight / 65536; tess.setColorOpaque_F(brightness, brightness, brightness); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); } }
-
How can I say "If block X is powered, my block should be powered"?
I don't think you understood what I meant. I'll show you with the powered rail as an example. This works (I think you thought I meant like this): However, I want it to work like this: Cool, I'll try that Having redstone issues anyway but I'll write that down for when they're fixed
-
How can I say "If block X is powered, my block should be powered"?
Sorry for a confusing title, I couldn't think of how to word it Basically, I want to be able to accept redstone power to my Tile Entity. However, players need to be able to hide the redstone for aesthetic appearance. So, what I want to do is say if the block below my tile entity is powered, the tile entity itself should be powered. How can I do this?
-
Custom Block Model
You do have a renderer... Looks like you took it from my (wrong) tutorial. I'll be updating it later tonight but this render code works better (both of you can use it ) package co.uk.silvania.roads.tileentities.renderers; import org.lwjgl.opengl.GL11; import co.uk.silvania.roads.Roads; import co.uk.silvania.roads.client.models.TrafficLightModel; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; 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.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class TileEntityTrafficLightRenderer extends TileEntitySpecialRenderer { private final TrafficLightModel model; private final boolean powered; public TileEntityTrafficLightRenderer(boolean power) { this.model = new TrafficLightModel(); this.powered = power; } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { int i = te.getBlockMetadata(); int meta = 180; if (i == 3) { meta = 0; } if (i == 5) { meta = 90; } if (i == 2) { meta = 180; } if (i == 4) { meta = 270; } bindTextureByName("/mods/Roads/textures/blocks/TrafficLightPoleGreen.png"); GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glRotatef(meta, 0.0F, 1.0F, 0.0F); //GL11.glRotatef(((TileEntityBarrierEntity)tile).getRotationPivot()), 0.0F, 1.0F, 0.0F); GL11.glScalef(1.0F, -1F, -1F); this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } private void adjustLightFixture(World world, int i, int j, int k, Block block) { Tessellator tess = Tessellator.instance; float brightness = block.getBlockBrightness(world, i, j, k); int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int modulousModifier = skyLight % 65536; int divModifier = skyLight / 65536; tess.setColorOpaque_F(brightness, brightness, brightness); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); } }
-
Model randomly vanishes depending on where I look..
It may well be something in the bounding box actually. I'd only tested it with the eclipse testing environment. I just compiled it all and put it in a real forge environment, and the vanishing bug stopped. BUT, the bounding boxes are bugging out at the same time. When I look at them the black lines are in the right place, but if I move into the full block area, my character glitches out. Did you play minecraft in alpha/early beta? Remember when you jumped on a fence and it bugged? Same kind of thing. Any ideas?
-
How to put multiple TE models onto a single block ID?
RP is sneaky. It uses item metadata (which goes up to 32768) and... somehow... transfers that to TE NBT data. Um... it looks like you override onItemUse(), set the block, then set the TE data for that block (casting to your TE first of course.) Ah ok, I have no idea how NBT works. Even with rotation I doubt I'd have more than 64 things so I guess just normal meta would be enough really, I wont overcomplicate things for the sake of 3 IDs
-
How to put multiple TE models onto a single block ID?
I don't suppose you know how Redpower does it? Your method is just standard metadata (only up to 15) but Redpower has thousands... On the wiki it also says something like "If you want more than 16, use a tile entity"- which is essentially what I'm trying to do?
-
How to put multiple TE models onto a single block ID?
Hey guys, So, I'm getting the hang of modelling now and I've got a few models in my mod. Each has it's own ID. However, for an idea I had, I need quite a lot of models. I don't want to take up loads of IDs, so how can I put them all on the same ID? I need rotation on them, and I want each block to be available in creative and craftable (but only one for each, not the other 3 rotated states) I know it must be possible, Redpower does it with the Microblocks - So can anyone push me in the right direction?
-
Mod won't zip & mcmod.info problems
^^ What he said. If you don't want to share the release zip with us, I have no idea how you plan on releasing your mod. Even once you've got a working zip or jar, it's all of about 6 seconds for absolutely anyone to unzip that.
-
Model problem
The bounding box is only the hitbox. Your actual block still only uses one block in the world. If you want it to do more (like a bed) there's a tutorial on the wiki, but it doesn't work 100% so you'll need to search around to get it working. I don't know how to do it sorry
-
HELP CREATING MOD
^^ What he said. Just install all the mods you want compatibility with, check their ID's and find a large free gap. If you want to be compatible with all tech mods though that might be a challenge. I know quite a few are in the works atm. Just gonna throw it out there, mine is using 900-1200
-
Model randomly vanishes depending on where I look..
It's not at all I spent a bit of time lining up the bounding boxes perfectly with the models; It's the exact right size, so that can't be the issue or I'd never notice it...
-
Model randomly vanishes depending on where I look..
Hey guys, I'm adding my blocks to the game as TileEntities. However, when I look around, the blocks randomly disappear if I look in certain directions... When they disappear, the bounding box vanishes too, so I can walk through it (if I stand on the block and look around, I'll just fall down when it vanishes) Screenshots: There's three blocks you can see here: Then I look slightly to the left, and the right one vanishes! Code: Block: Renderer: The TileEntity is empty at the moment. Any ideas? Someone also told me to try using "GL11.glRotatef(((TileEntityBarrierEntity)tile).getRotationPivot()), 0.0F, 1.0F, 0.0F);" instead of the if statements I have for rotation, but they didn't go as far as to telling me how to use getRotationPivot so right now, that's useless for me. At any rate, removing the rotation code altogether doesn't fix the issue.
-
Model problem
In your Block, same place as you specify the creative tab: this.setBlockBounds(0.0F, 0.25F, 0.875F, 1.0F, 0.75F, 1.0F); First three numbers are X Y Z of one corner, the second three numbers are X Y Z of the other corner
-
Couple of redstone questions
thanks I think I can combine your code with what I already have to make my block emit in all six directions. If I get it working, do you want the code? Also, a third redstone question. Is it possible to make a block say "If the block beneath me has power, I will do something"? With my traffic lights, I want them to be redstone controlled for their state. But, I don't want the redstone on show, so it'd make sense to check if the block below it is powered. EDIT: Also, any chance I can see your "BaseRedstone" class? You have a few references to it, I wanna see what I need to change those to
-
Render custom model as a tile entity
That's a lot more important than you think it is I'll write the wiki when I've got a few hours free, so it'll be sunday or monday. It's one of those things that's really underdocumented (same as liquids which I wrote the 1.4.7 wiki page on... I should update that...) As we've both got it working I'll lock this now. Anyone else who gets stuck can use my code as mentioned above, or PM me
-
Render custom model as a tile entity
I'm on my phone ATM sorry If you go on google and search FlenixRoads one of the first results is my GitHub repo. In there, you need to find my Tileentities package. Pick one of the block names (TileEntityTrafficLight is a good example) and copy the block, entity and renderer classes. Then go to my client package and get TrafficLightModel (just for now). Also look in the client proxy and copy the one line for the traffic light. After that just do registerblock as normal for TileEntityTrafficLightBlock. Test it and all should be working, so then you can edit it as required. Ill write a wiki on it when I'm home
-
Couple of redstone questions
Hey guys, I have two different questions regarding the use of Redstone. 1. I'm making a set of blocks which work just like redstone wire, but it's a physical block that can be placed anywhere. It's all worked except one thing; the redstone wont transmit vertically. Anyone know how I might achieve that? Here's the block's class file: 2. Is it possible to change the texture of a tile entity, using redstone? Here's my Renderer class, the if function takes no effect right now so what do I need to change?
-
I have an odd question.
Why are you judging him for a mod idea? You have no idea what his mod is going to achieve, it might help immersion. Saying anyones idea is "stupid" on these forums certainly wont earn you friends. It's supposed to be a place to support modders, not criticize them if you don't like their idea. Grow up. @OP, sorry got no idea how to do it, I just wanted to reply to that guy. I'm sure it's possible, but you may need to edit base files to do it (or override the pause screen)
-
Render custom model as a tile entity
That's certainly... interesting. Anyways, figured it out now. Here's the working code: package co.uk.silvania.roads.tileentities; import org.lwjgl.opengl.GL11; import co.uk.silvania.roads.Roads; import co.uk.silvania.roads.client.TrafficLightModel; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; 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.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class TileEntityTrafficLightRenderer extends TileEntitySpecialRenderer { private final TrafficLightModel model; private final boolean powered; public TileEntityTrafficLightRenderer(boolean par2) { this.model = new TrafficLightModel(); this.powered = par2; } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); if (this.powered) { bindTextureByName("/mods/roads/textures/blocks/TrafficLightPoleGreen.png"); } else { bindTextureByName("/mods/roads/textures/blocks/TrafficLightPoleRed.png"); } GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); //This was the important bit. But you need the extra Push/Pop! this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } private void adjustRotatePivotViaMeta(World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glPopMatrix(); } private void adjustLightFixture(World world, int i, int j, int k, Block block) { Tessellator tess = Tessellator.instance; float brightness = block.getBlockBrightness(world, i, j, k); int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int modulousModifier = skyLight % 65536; int divModifier = skyLight / 65536; tess.setColorOpaque_F(brightness, brightness, brightness); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); } }
IPS spam blocked by CleanTalk.