
TheEpicTekkit
Members-
Posts
361 -
Joined
-
Last visited
Everything posted by TheEpicTekkit
-
Actually, this has for some reason just decided to not work at all, it is now giving a stackOverflow when it wasn't before. So, scrap that idea, I am going to try this: as That One Guy said: I didn't actually see this reply before, and yes, this was really helpful. Thanks. I actually think this is looking like my best option now. Also, I already have that array of connections. I am using it to determine weather to render the connections between cables or not. So, I could just use that. The only problem is that sometimes on world load, or chunk load, some of the connections will have disappeared, and I need to update the block to reconnect them. I could be checking the connections in updateEntity (which I was doing, but was noticing a framerate drop in doing so, so changed it to update connections in onBlockAdded, breakBlock, and onNeighborBlockChange) and when I was using updateEntity, I didn't have any problems with the cables disconnecting, so I need a way to fix this. I think I will make it re check the connections every couple of seconds, I just need to know how to count how many ticks have passed.
-
I don't quite understand why this doesn't work, I want the cable to scan around itself, and if it finds a cable, trigger the scan method on that cable with one less range, so it should go for 40 blocks. [s] public int scanRange = 40; public void scan(World world, int x, int y, int z, int remaining, List<TileEntity> map) { TileEntity tile = world.getTileEntity(x, y, z); List<TileEntity> networkMap = new ArrayList<TileEntity>(); while (remaining != 0) { if (tile instanceof IEnergyHandler) { networkMap.add(tile); } if (tile instanceof TileEntityCable) { ((TileEntityCable) tile).scan(world, x, y, z, this.scanRange - 1, networkMap); //Re-Triggering the scan on the next cable with a new weight (int remaining), and passing on the current known list of IEnergyHandlers ((TileEntityCable) tile).scanRange = this.scanRange - 1; this.scanRange = 0; } } } public void triggerScan() { List<TileEntity> map = new ArrayList<TileEntity>(); map.clear(); this.scan(worldObj, xCoord + 1, yCoord, zCoord, this.scanRange, map); this.scan(worldObj, xCoord - 1, yCoord, zCoord, this.scanRange, map); this.scan(worldObj, xCoord, yCoord + 1, zCoord, this.scanRange, map); this.scan(worldObj, xCoord, yCoord - 1, zCoord, this.scanRange, map); this.scan(worldObj, xCoord, yCoord, zCoord + 1, this.scanRange, map); this.scan(worldObj, xCoord, yCoord, zCoord - 1, this.scanRange, map); } public void reset() { this.scanRange = 40; } [/s] And, this method is called 6 times, x + 1, x - 1, y + 1, y - 1, z + 1, and z - 1. Now, I haven't included it, but I have been testing this by making the cable scan around itself, trigger the scan on the next cable (not working) and then setting any adjacent IEnergyHandlers to stone. So, what should be happening is all the IEnergyHandlers connected to the network should turn to stone. Now, all that seems to be happening is only the first cable sets any surrounding IEnergyHandlers to stone. The way I am triggering the scan in the first place, is I have a certain block (Fuse Box) that when placed next to a cable, will trigger the scan.
-
Model Animations [UNSOLVED] [1.7.10]
TheEpicTekkit replied to TheEpicTekkit's topic in Modder Support
Okay, I got the door animation working, now I would like to know how to do acceleration, and deceleration. -
Model Animations [UNSOLVED] [1.7.10]
TheEpicTekkit replied to TheEpicTekkit's topic in Modder Support
Would this work? public float lidAngle; //irrelevant code here... @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityFuseBox) { //System.out.println(tileEntity.xCoord + ", " + tileEntity.yCoord + ", " + tileEntity.zCoord); //Debugging this.fuseBox = (TileEntityFuseBox)tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); if (this.fuseBox.isOpen && this.lidAngle < 90 && this.fuseBox.openingTime != 0) { //If the lid isn't open, but the gui is this.fuseBox.openingTime--; this.lidAngle += 2.25F; } if (!this.fuseBox.isOpen && this.lidAngle > 0 && this.fuseBox.openingTime != 20) { //If the lid is open but the gui isn't this.fuseBox.openingTime++; this.lidAngle -= 2.25F; } if (this.lidAngle < 0) this.lidAngle = 0; if (this.lidAngle > 90) this.lidAngle = 90; doRender = true; int meta = tileEntity.getBlockMetadata(); if (doRender) { GL11.glPushMatrix(); GL11.glTranslatef((float)x, (float)y, (float)z); Minecraft.getMinecraft().renderEngine.bindTexture(texture); this.renderModelBasedOnMeta(meta); //This has all the render info about my model. GL11.glPopMatrix(); } } } //RenderModelBasedOnMeta() method here (really big as 12 possible metadatas, and an if statement for each) public void renderLid() { this.model.Door.rotateAngleY = this.lidAngle; } -
Model Animations [UNSOLVED] [1.7.10]
TheEpicTekkit replied to TheEpicTekkit's topic in Modder Support
How would I do the acceleration and deceleration? -
Model Animations [UNSOLVED] [1.7.10]
TheEpicTekkit replied to TheEpicTekkit's topic in Modder Support
This is what I have already tried. int maxAngle = 90; for (int angle = 0; angle < maxAngle; angle++) { GL11.glRotatef(angle, 0, 1, 0); //rotate on the Y axis. model.Door.rotateAngleY = angle; //Apparently 90 degrees for this is 1.5F, dont know why, but I had to do some maths to get angle as close to that as possible. //I have tried both of these methods (not at the same time) and neither of them worked. } Now, I have noticed the setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity)... method in the model class, but how do I use it? what are the parameters? I do know that this is what is used to animate players and mobs. -
Hello everyone. I would like to animate a part of a model I have for a block, and I don't know how I can do this. I know I can use GL11, but I only want it to affect one part of the model, instead, it seems to affect all of the model, or be really glitchy and flicker. What I am trying to do is animate the open and close motion for the door on my block when the player opens the gui. So, I don't want something that is simple and just it immediately swings open, and suddenly stops, and the same with closing, I want there to be some acceleration and deceleration to it. Now, is it possible to load a model from a program like Maya, Cinema 4D or Blender, and load any animations on the model too? If not, I'll just use GL11 to animate it, but I need to know how to properly animate an individual part of the model. Also, if this is relevant information, I am using a techne model. Thanks.
-
Okay, so, I have got it working (still without understanding the maths behind l, and k) using trial and error. This does still have all my debugging System.out.printlns public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) { int l = MathHelper.floor_double((double)(entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int k = MathHelper.floor_double((double)(entityLiving.rotationPitch * 3.0F / 360.0F) + 0.5D) & 3; System.out.println("Players Rotation Yaw: " + l); System.out.println("Players Rotation Pitch: " + k); if (k == 3) { //If the player is looking up if (l == 0) { //South world.setBlockMetadataWithNotify(x, y, z, 0, 2); System.out.println("Faceing South"); } if (l == 1) { //West world.setBlockMetadataWithNotify(x, y, z, 1, 2); System.out.println("Faceing West"); } if (l == 2) { //North world.setBlockMetadataWithNotify(x, y, z, 2, 2); System.out.println("Faceing North"); } if (l == 3) { //East world.setBlockMetadataWithNotify(x, y, z, 3, 2); System.out.println("Faceing East"); } System.out.println("Player Is Looking Up"); } if (k == 1) { //If the player is looking Down if (l == 0) { //South world.setBlockMetadataWithNotify(x, y, z, 4, 2); System.out.println("Faceing South"); } if (l == 1) { //West world.setBlockMetadataWithNotify(x, y, z, 5, 2); System.out.println("Faceing West"); } if (l == 2) { //North world.setBlockMetadataWithNotify(x, y, z, 6, 2); System.out.println("Faceing North"); } if (l == 3) { //East world.setBlockMetadataWithNotify(x, y, z, 7, 2); System.out.println("Faceing East"); } System.out.println("Player Is Looking Down"); } if ((k != 1) && (k != 3)) { //If the player is looking forwards (not down or up) if (l == 0) { //South world.setBlockMetadataWithNotify(x, y, z, 8, 2); System.out.println("Faceing South"); } if (l == 1) { //West world.setBlockMetadataWithNotify(x, y, z, 9, 2); System.out.println("Faceing West"); } if (l == 2) { //North world.setBlockMetadataWithNotify(x, y, z, 10, 2); System.out.println("Faceing North"); } if (l == 3) { //East world.setBlockMetadataWithNotify(x, y, z, 11, 2); System.out.println("Faceing East"); } System.out.println("Player Is Looking Forwards"); } System.out.println("Metadata: " + world.getBlockMetadata(x, y, z)); } So, this seems to work, and know what metadata to assign the block. Now all I have to do is make the model rotate with GL11 in the renderer depending on the metadata.
-
Actually, it might be easier to use the yaw and pitch rotation of the player, would this work? public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) { int l = MathHelper.floor_double((double)(entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int k = MathHelper.floor_double((double)(entityLiving.rotationPitch * 4.0F / 360.0F) + 0.5D) & 3; if (k == 0) { //If the player is looking down if (l == 0) { world.setBlockMetadataWithNotify(x, y, z, 0, 2); } if (l == 1) { world.setBlockMetadataWithNotify(x, y, z, 1, 2); } if (l == 2) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } if (l == 3) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } } if (k == 1) { //If the player is looking up if (l == 0) { world.setBlockMetadataWithNotify(x, y, z, 4, 2); } if (l == 1) { world.setBlockMetadataWithNotify(x, y, z, 5, 2); } if (l == 2) { world.setBlockMetadataWithNotify(x, y, z, 6, 2); } if (l == 3) { world.setBlockMetadataWithNotify(x, y, z, 7, 2); } } if ((k != 1) && (k != 0)) { //If the player is looking forwards (not down or up) if (l == 0) { world.setBlockMetadataWithNotify(x, y, z, 8, 2); } if (l == 1) { world.setBlockMetadataWithNotify(x, y, z, 9, 2); } if (l == 2) { world.setBlockMetadataWithNotify(x, y, z, 10, 2); } if (l == 3) { world.setBlockMetadataWithNotify(x, y, z, 11, 2); } } } One thing to note, I don't actually understand how int l or k work, I don't understand the bitwise operator (& 3), so really, I don't know what I need to change here other than rotationYaw to rotationPitch. I also don't know why * 4, I'm guessing because there is 4 orientations for yaw, so would I need to change the * 4 on the pitch to * 3? because the player can look up, down and forward? also, why + 0.5D? If I understand how these integers work, I would probable have no trouble with this whole 12 orientations block thing.
-
Okay, thanks, I have used the onBlockAdded method, and the onBlockPlacedBy method, but I forgot about the onBlockPlaced method. Isn't the onBlockPlaced method the method that is called by things like block placers? if so, how will it handle orientating the block then? I haven't actually used the onBlockPlaced method before, do I have to return the metadata? also, how would I use the onBlockPlaced method and the onBlockPlacedBy method at the same time? in the onBlockPlaced method, I would handle things like figuring out what direction the block should face (north south east west up or down), and in the onBlockPlacedBy method, I would handle the rotation of the block (what direction the bottom of the model is facing) if it was placed on the bottom or top of the block. So, which of these two methods would get called first?
-
Okay, I also have another question, how do I get what side of a block the player clicks to place a block? or can I? because, I could make a method that determines what to do depending on if the player clicks on side 1 (top), side 0 (bottom) or sides 2 to 5 (the rest of the sides). So, I need a way to get that information. I also want it so if the player shift clicks on the top or bottom, it will place the block up right. I know this is quite complicated, also, before it is mentioned, I have looked at the stairs class, and the BlockRotatedPillar class, but it is confusing because most of the methods are named stupid things, such as func_150162_k (from blockrotatedpillar), and there are loads of methods like this in the stairs class.
-
Hello everyone. So I am trying to create a block that can have 12 different orientations, now, I can make a block face in 4 different directions, but what I am trying to achieve is hard to explain. Just a note, I am not trying to achieve a diagonal block, I can look at the the sign to see this. So, I am making a block, it has a model, the model is pretty much just a slab on its side. Now, I want this block to be able to do the following: When the player places this block, if the player clicks on the top side of a block, my block will face upward, and the bottom of the model will face the player, so there is now 4 possible orientations from placing it on top of a block, I want the same to happen if the player clicks on the bottom of a block, the only difference being that my model now faces down, so, there is now 8 possible orientations from placing it on the bottom or top of a block. Now as for placing this block on the north south east or west side of a block, the bottom of the model will always face down, so there is no rotation other than the direction. So this adds up to 12 possible orientations. So, 4 orientations for placing this block flat on top of a block, 4 orientations for placing this block facing down on the bottom of a block, and 4 more orientations depending on the if the block is placed on the north, south, east or west side of a block.. I really hope this makes sense, as it is really hard to explain what I am trying to achieve here. Thanks.
-
How to code a sword that lights the mob on fire when hit?
TheEpicTekkit replied to Kander16's topic in Modder Support
Yeah, I realised that after I posted the reply, I have modified the reply now. He needs to use EntityLivingBase not EntityLiving. -
How to code a sword that lights the mob on fire when hit?
TheEpicTekkit replied to Kander16's topic in Modder Support
put "@Override" above the method. Also, you are supposed to use an EntityLivingBase, not an EntityLiving @Override public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLiving, EntityLivingBase par3EntityLiving) { par1ItemStack.damageItem(1, par3EntityLiving); par2EntityLiving.setFire(10); return true; } -
Hello everyone. So I would like to know how I can load an obj model, and manipulate parts of it. By manipulate, I mean move parts of it. So for example, if I were to create a custom chest, and it had an obj model, How would I go about moving the lid? What I am trying to achieve is (if you look at my other post "Trigger a search down a line of blocks" here) for my fuse box I would like to give it a custom render, and I would like to use an obj model that I am making now in Autodesk Maya. Now, when the player opens the gui, I want there to be like a lid on the front that swings open. Now, I know how to do this with tessellators or techne models, but they are quite primitive, and restricted in the actual quality of the model. I haven't used any obj models yet in my mod, and never have successfully loaded them at all. So, how would I use GL11 to rotate or translate a part of the model?
-
By node, I mean any block that can interact with energy (implements IEnergyHandler) this doesn't include cables. So, generators, machines, and stores, this allows other mods that use the api I havn't set up yet to add blocks that interact with the network. For the fuse box to be able to tell if a node is an emitter, machine, or store, the node will have an enum ID saying emitter, consumer (machine) and store. Another interesting scenario that I haven't considered (yet again) what if there are multiple fuse boxes connected to the network? how would a node decide which fuse box to use? it cant just use the closest, because that means that some machines will use one, and others will use another, and this will cause problems. Also, what if a fuse box has more than one network connected to it? like for example, there is a cable on one side leading to one network, and there is another cable on the other side, not connected to the first network at all, leading to a separate network. Btw, Hugo, you have been really helpful, none of my other topics have got this much help from one person