
Thornack
Members-
Posts
629 -
Joined
-
Last visited
Everything posted by Thornack
-
[1.7.10] Spawning Custom Particle Crashes the game
Thornack replied to Thornack's topic in Modder Support
Also, as a note the on Update method overrides the onUpdate method in EntityThrowable -
[1.7.10] Spawning Custom Particle Crashes the game
Thornack replied to Thornack's topic in Modder Support
When I call them on the client they do not spawn for some reason @Override public void onUpdate() { super.onUpdate(); motionY += 0.01D; if (!worldObj.isRemote) { attackNearbyEntities(); if (ticksExisted > 40) { setDead(); releaseDrops(); } else if (ticksExisted % AttackTypeRanged.AIR.getSoundFrequency() == (AttackTypeRanged.AIR.getSoundFrequency() - 1)) { worldObj.playSoundAtEntity(this, AttackTypeRanged.AIR.getMovingSound(), AttackTypeRanged.AIR.getSoundPitch(rand), AttackTypeRanged.AIR.getSoundVolume(rand)); } } else { spawnParticleRing(); // doesnt spawn atm } } if i put a System.out.println(); above spawnParticleRing() inside that else statement nothing gets printed. Furthermore if I replace the else statement with if(worldObj.isRemote){spawnParticleRing();} and put a System.out.println(); inside that if statement it still doesnt get called. -
I have an entity that spawns a ring of particles around it when it is summoned. I see the particles spawn but then minecraft crashes shortly after. Im not sure how to fix it since I knoe that I need to spawn my particle server side so that players can see it but I need my spawn method to be client side only. Here are my two culprit methods I believe @Override public void onUpdate() { super.onUpdate(); motionY += 0.01D; if (!worldObj.isRemote) { attackNearbyEntities(); if (ticksExisted > 0 && ticksExisted <= 40){ spawnParticleRing(); // crashes minecraft shortly after you see the particles spawn } if (ticksExisted > 40) { setDead(); releaseDrops(); } else if (ticksExisted % AttackTypeRanged.AIR.getSoundFrequency() == (AttackTypeRanged.AIR.getSoundFrequency() - 1)) { worldObj.playSoundAtEntity(this, AttackTypeRanged.AIR.getMovingSound(), AttackTypeRanged.AIR.getSoundPitch(rand), AttackTypeRanged.AIR.getSoundVolume(rand)); } } } This is how I spawn the particle ring and update it /** Updates the particle rings swirling angles and spawns a new ring of particles. */ @SideOnly(Side.CLIENT) private void spawnParticleRing() { yaw += yawVelocity; if (yaw > 2*Math.PI) yaw -= 2*Math.PI; if (Math.random() < 0.1) { pitchVelocity = 0.2f; } pitch += pitchVelocity; if (pitch > maxPitch) pitch = maxPitch; if (pitchVelocity > 0) { pitchVelocity -= 0.05f; } else { pitchVelocity = 0; } if (pitch > 0) { pitch -= 0.07f; } else { pitch = 0; } EffectRenderer effectRenderer = Minecraft.getMinecraft().effectRenderer; VisualEffectTornado ring = new VisualEffectTornado(worldObj, posX, posY + 0.1D, posZ, motionX, motionY, motionZ, yaw, pitch, 0.7f, effectRenderer); effectRenderer.addEffect(ring); ring.setDead(); // I suspect I have to destroy the ring somehow but im stuck as to how to do it } the errors in consol
-
I am comfortable using the scripts I guess to clarify that point what I meant was that the process isnt streamlined and it is annoying when the scripts change. Are you sure that the libraries still exist down to 1.6.4? I tried to set up a dev environment again and it failed cause they seem to be missing or moved. I tried if with the recommended version of forge for 1.7.2 I was wondering if there is a better way to do the reference libraries so that such errors do not occur?
-
Hi everyone, I have noticed a somewhat large annoyance with regards to Forge version support. Every so often, it seems that support for earlier versions of Forge gets removed, for example I tried to set up a dev environment for 1.7.10 a few days ago and could not since it appears some reference libraries have moved. In general I have also found that setting up the dev environment is a bit of a pain due to the issue of having to run the command prompt commands etc etc... Is there anyway to set up a dev environment for previous versions of forge (lets say I would like to set up a dev env for 1.5.1 or 1.7.2) how could this be achieved given that the reference libraries keep getting moved?
-
I figured it out I had to move my logic to the entity class and not use minecraft's prevRotationYaw variable. I noticed that no matter what you do prevRotationYaw = rotationYaw for all entities (at least from what i could tell) still have no idea why but oh well. To solve my problem I created my own version of prevRotationYaw and did the logic for my steering. My steering works perfectly now. There are some weird quirks I discovered though. I animated by calculating a difference between the current and previous rotation yaw angle. This was then used to determine clockwise or counterclockwise direction and based off of that I rotate the steering conditionally up to a max/min angle and this is independent of the entities rotation (the entities rotation is simply just used to determine whether you are turning clockwise or counter clockwise or stopped turning). however this logic had to be moved to the entity class and called in the onUpdate function to work properly. Not sure why it wouldnt work when in the model file, it did some weird stuff that I didnt understand and I only stumbled on the solution by randomly deciding to check whether updating was the issue and this check involved moving the code to the entity class and using the onUpdate method.
-
I have a custom Vehicle and havent been able to get it to jump. I have been trying for a long time and am stuck. This is my class. I have no idea what the issue is, everything else about this vehicle works perfectly except jumping. when the space bar is pressed nothing happens public class EntityVehicle extends EntityAnimal { public float animationPedalAngle = 0.0f; //used clientside by VehicleModelVehicle public float animationHandlebarAngle = 0.0f; protected boolean VehicleJumping; protected float jumpPower; protected float vehicleMovementSpeedMultiplier = 0.5f; // Since moveForward is defined in EntityLivingBase to = 0.98F this multiplier is used to change the Bikes speed public EntityVehicle(World par1World) { super(par1World); this.setSize(1.4F, 1.6F); } public EntityVehicle(World par1World, double par2, double par4, double par6) { this(par1World); this.setPosition(par2, par4 + (double) this.yOffset, par6); } public boolean isVehicleJumping() { return this.VehicleJumping; } public void setVehicleJumping(boolean par1) { this.VehicleJumping = par1; } /** * Returns true if this entity should push and be pushed by other entities * when colliding. */ public boolean canBePushed() { return this.riddenByEntity == null; } /** * Called when the mob is falling. Calculates and applies fall damage. */ protected void fall(float par1) { if (par1 > 1.0F) { this.playSound("mob.Vehicle.land", 0.4F, 1.0F); } int i = MathHelper.ceiling_float_int(par1 * 0.5F - 3.0F); if (i > 0) { Block block = this.worldObj.getBlock( MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY - 0.2D - (double) this.prevRotationYaw), MathHelper.floor_double(this.posZ)); if (block.getMaterial() != Material.air) { Block.SoundType soundtype = block.stepSound; this.worldObj.playSoundAtEntity(this, soundtype.getStepResourcePath(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); } } } /** * Called when a player interacts with a mob. */ public boolean interact(EntityPlayer par1EntityPlayer) { ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); if (itemstack != null && itemstack.getItem() == Items.spawn_egg) { return super.interact(par1EntityPlayer); } if (this.riddenByEntity == null) { if (itemstack != null && itemstack.interactWithEntity(par1EntityPlayer, this)) { return true; } else { this.onPlayerMounted(par1EntityPlayer); return true; } } else { return super.interact(par1EntityPlayer); } } //called when player mounts this entity private void onPlayerMounted(EntityPlayer par1EntityPlayer) { par1EntityPlayer.rotationYaw = this.rotationYaw; par1EntityPlayer.rotationPitch = this.rotationPitch; if (!this.worldObj.isRemote) { par1EntityPlayer.mountEntity(this); } } /** * Called frequently so the entity can update its state every tick as * required. For example, zombies and skeletons use this to react to * sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); } /** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); } private double getVehicleJumpPower(){ return 1.0f; } /** * Moves the entity based on the specified heading. Args: strafe, forward */ public void moveEntityWithHeading(float moveStrafing, float moveForward) { if (this.riddenByEntity != null) { this.rotationYaw = this.riddenByEntity.rotationYaw; this.prevRotationYaw = this.riddenByEntity.prevRotationYaw; this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F; this.setRotation(this.rotationYaw, this.rotationPitch); this.rotationYawHead = this.renderYawOffset = this.rotationYaw; moveStrafing = 0; //moveStrafing = strafing. Should be 0, since we don't want the bike to move side to side. moveForward = ((EntityLivingBase) this.riddenByEntity).moveForward* vehicleMovementSpeedMultiplier; if (moveForward <= 0.0F) { moveForward *= 0.25F; //you move 1/4 of the speed when going backwards } if(this.onGround){ this.jumpPower = 0.0f;//(float)this.getVehicleJumpPower(); } if (this.jumpPower > 0.0F && !this.isVehicleJumping() && this.onGround) { this.motionY = this.jumpPower; //getVehicleJumpPower() System.out.println("JUMPING"); this.onGround = false; this.isAirBorne = true; //System.out.println("jumpPower: "+jumpPower+" if (this.jumpPower > 0.0F && !this.isVehicleJumping() && this.onGround)"); if (moveForward > 0.0F) { float f2 = MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F); float f3 = MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F); this.motionX += (double) (-0.4F * f2 * this.jumpPower); this.motionZ += (double) (0.4F * f3 * this.jumpPower); this.playSound("mob.Vehicle.jump", 0.4F, 1.0F); //System.out.println("jumpPower: "+jumpPower+" if (moveForward > 0.0F)"); } this.jumpPower = 0.0F; //System.out.println("jumpPower: "+jumpPower+" if (this.jumpPower > 0.0F && !this.isVehicleJumping() && this.onGround)"); } this.stepHeight = 1.0F; this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F; if (!this.worldObj.isRemote) { this.setAIMoveSpeed((float) this.getEntityAttribute( SharedMonsterAttributes.movementSpeed) .getAttributeValue()); //System.out.println("moveStrafing: "+moveStrafing+" moveForward: "+moveForward); super.moveEntityWithHeading(moveStrafing, moveForward); } if (this.onGround) { this.jumpPower = 0.0F; this.setVehicleJumping(false); //System.out.println("jumpPower: "+jumpPower+" if (this.onGround)"); } } else { this.stepHeight = 0.5F; this.jumpMovementFactor = 0.02F; super.moveEntityWithHeading(moveStrafing, moveForward); } } public EntityAgeable createChild(EntityAgeable par1EntityAgeable) { return new EntityVehicle(this.worldObj); } /** * Returns true if the newer Entity AI code should be run */ protected boolean isAIEnabled() { return true; } public void setJumpPower(int par1) { System.out.println("setJumpPower: "+jumpPower); if (par1 < 0) { par1 = 0; //System.out.println("jumpPower: "+jumpPower+" if (par1 < 0)"); } if (par1 >= 90) { this.jumpPower = 1.0F; //System.out.println("jumpPower: "+jumpPower+" if (par1 >= 90)"); } else { this.jumpPower = 0.4F + 0.4F * (float) par1 / 90.0F; //System.out.println("jumpPower: "+jumpPower+" else {this.jumpPower = 0.4F + 0.4F * (float) par1 / 90.0F;"); } } @Override public double getMountedYOffset(){ return 1.0; } @Override public void updateRiderPosition() { super.updateRiderPosition(); } @Override public boolean isOnLadder() { return false; } }
-
[1.7.10] Getting the itemstack while in a GUI
Thornack replied to Thornack's topic in Modder Support
Good Point regarding the hacking bit, would this work since Gui is on client side. Player presses a keyboard key then inside the @Override public void handleKeyboardInput() method i check if the key was released and if the key was released then I add 1 to an itemdamage variable and send a request to server (maybe my own packet or the same way as item enchant is done). That request contains the name of requested item that I want to damage. Then somehow get the Server to get this request and make the server get player from server side container (EntityPlayerMP#opencontainer) and then get the itemstack that i want and update the itemstacks damage. Im not 100% sure on how to implement this but logically i think this would work wouldnt it and would get around the hacking issue you mentioned i think? -
Im not sure if the above approach is going to work. Essentially I need a way to determine whether the player is turning counterclockwise or clockwise so that I can animate my steering accordingly. Would this require saving the initial rotation as NBT data [Edit] you do not need NBT data or anything like that instead do the logic in the Entity class and use the onUpdate method and create your own verson of prevRotationYaw
-
The reason why I need the previous rotation (the entities rotation in the previous tick) and the current rotation (the rotation in the current tick) is so I can do something like if (previousVehicleRotation != currentVehicleRotation && currentVehicleRotation < previousVehicleRotation ){ //the vehicle should be rotating counterclockwise if these conditions are met entity.animationAngle = 90-((float) currentVehicleRotation /180) *90; System.out.println(previousVehicleRotation + "they are different"); previousVehicleRotation = currentVehicleRotation; } and so on. I need this so that i can animate my steering wheel
-
note* I checked inside my EntityVehicle class and inside the moveEntityWithHeading method I set the prevRotationYaw to the riddenByEntity's prev rotation yaw in the following way public void moveEntityWithHeading(float moveStrafing, float moveForward) { if (this.riddenByEntity != null) { this.rotationYaw = this.riddenByEntity.rotationYaw; this.prevRotationYaw = this.riddenByEntity.prevRotationYaw; ... other vehicle stuff since this is a long method i cut it out of the post }
-
[1.7.10] I have a vehicle and I wish to animate the steering wheel of it. However for my animation I need to determine the previous rotation and the current rotation angle that is given for the entity. I tried using prevRotationYaw and rotationYaw but both seem to get the entities current rotation. Does anyone know why? inside my model file public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); if (entity!= null && (entity instanceof EntityVehicle)){ float steeringAngle = getVehicleRotationAngle((EntityVehicle)entity); steeringWheel.rotateAngleY = steeringAngle; } } protected float getVehicleRotationAngle(EntityVehicle entity) { double entitiesCurrentRotationInRadians = ((Math.PI/180) * entity.rotationYaw); double entitiesPreviousRotationInRadians = ((Math.PI/180) *entity.prevRotationYaw); if (entitiesPreviousRotationInRadians != entitiesCurrentRotationInRadianss){ System.out.println(entitiesPreviousRotationInRadians + " they are different"); <- never gets printed } if (entitiesPreviousRotationInRadians == entitiesCurrentRotationInRadianss){ System.out.println(entitiesPreviousRotationInRadians + " they are the same"); <- always gets printed } //I need to know the last angle before the current one entity.animationAngle = (float) entitiesCurrentRotationInRadians; return entity.animationAngle; //animationAngle is a public float that is initialized to equal 0 inside EntityVehicle class }
-
[1.7.10] Getting the itemstack while in a GUI
Thornack replied to Thornack's topic in Modder Support
Ok so I wrote this class but I am not sure what to do in the last method public class MessageUpdateCustomItem extends MyCustomAbstractMessage<MessageUpdateCustomItem>{ private int itemDamage; public MessageUpdateCustomItem(){} public MessageUpdateLCustomItem(CustomItem theCustomItem, int damage){ this.itemDamage = damage; } @Override public void fromBytes(ByteBuf buf) { this.itemDamage = buf.readInt(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(this.itemDamage); } @Override public IMessage handleClientMessage(EntityPlayer player, MessageUpdateCustomItem message, MessageContext ctx) { //handle(player, message, ctx); return null; } @Override public IMessage handleServerMessage(EntityPlayer player, MessageUpdateCustomItem message, MessageContext ctx) { handle(player, message, ctx); return message; } private void handle(EntityPlayer player, MessageUpdateCustomItem message, MessageContext ctx){ //I am not sure what to do here } } -
[1.7.10] Getting the itemstack while in a GUI
Thornack replied to Thornack's topic in Modder Support
I tried mc.thePlayer.getCurrentEquippedItem().setItemDamage(damage++); but it didnt work -
I have a gui and I wish to get the current itemstack that the player is holding so that I may conditionally apply damage to it depending on what happens in the GUI whenever a certain key is released. I have the key release code working but havent been able to get the itemstack. Is there a simple solution. I tried the following and the key release code works. Now all I need is to get the itemstack that the player is currently holding. private void keyReleased(int key, int event){ if(key==Keyboard.KEY_W){ this.random = 0; this.numberOfGuesses ++; if(mc.thePlayer.getHeldItem() != null && (mc.thePlayer.getHeldItem().getItem()==CommonProxy.Customitem)){ int damage = 0; // here is where I need to get the itemstack but I am unsure how to do it } } }
-
[1.7.10] Server Client variable generation issue
Thornack replied to Thornack's topic in Modder Support
I solved it, my TileEntity required the following @Override public Packet getDescriptionPacket(){ NBTTagCompound nbtCompound = new NBTTagCompound(); this.writeToNBT(nbtCompound); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbtCompound); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){ NBTTagCompound nbtCompound = pkt.func_148857_g(); this.readFromNBT(nbtCompound); } -
[1.7.10] Server Client variable generation issue
Thornack replied to Thornack's topic in Modder Support
I want the packet sent when the GUI opens but for now I tried it with a button click so I send the packets in the GUI class at the following method @Override protected void actionPerformed(GuiButton button){ if (button.enabled){ if (button.id == BUTTON_DONE_ID){ MessageUpdateBlockState msg = new MessageUpdateBlockState(tileBlock, this.randomNumber);// I think the issue is here i dont think i am sending the random number that is being generated in the TileEntity CustomMod.network.sendToServer(msg); this.mc.displayGuiScreen((GuiScreen)null); } else if(button.id == BUTTON_CANCEL_ID){ this.mc.displayGuiScreen((GuiScreen)null); } } } -
[1.7.10] Server Client variable generation issue
Thornack replied to Thornack's topic in Modder Support
From what I understand, nbt is saving my variable when you write to disk and read from disk, nbt data seems to also be sent from the server to the client when the client initially loads the chunks, but any updates after that require packets. when i try using cpw.mods.fml.common.network.simpleimpl.IMessage; (i created a class to do this) i try to send packets while inside the gui and it seems to que the packets while i am inside the gui but when I close the gui it sends all the packets all at once. Is there a way to enable sending packets without having to close the gui? Also, how would you recommend I try to send the packets from the server to the client containing my variables value given that setup (sorry again for the psuedo code) if you need more info please let me know. The packet code public abstract class MyAbstractMessage<T extends IMessage> implements IMessage, IMessageHandler<T, IMessage>{ @Override public IMessage onMessage(T message, MessageContext ctx) { if (ctx.side == Side.CLIENT) { return handleClientMessage(Minecraft.getMinecraft().thePlayer, message, ctx); } else { return handleServerMessage(ctx.getServerHandler().playerEntity, message, ctx); } } public abstract void fromBytes(ByteBuf buf); public abstract void toBytes(ByteBuf buf); public abstract IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx); public abstract IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx); } Message class public class MessageUpdateBlockState extends MyAbstractMessage<MessageUpdateBlockState>{ private int x,y,z; private int block; public MessageUpdateBlockState(){} public MessageUpdateBlockState(TileEntityBlock tileBlock, int randNumb){ this.x = tileBlock.xCoord; this.y = tileBlock.yCoord; this.z = tileBlock.zCoord; this.block =randNumb; } @Override public void fromBytes(ByteBuf buf) { this.x = buf.readInt(); this.y = buf.readInt(); this.z = buf.readInt(); this.block = buf.readInt(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(this.x); buf.writeInt(this.y); buf.writeInt(this.z); buf.writeInt(this.block); } @Override public IMessage handleClientMessage(EntityPlayer player, MessageUpdateBlockState message, MessageContext ctx) { return null; } @Override public IMessage handleServerMessage(EntityPlayer player, MessageUpdateBlockState message, MessageContext ctx) { handle(player, message, ctx); return message; } private void handle(EntityPlayer player, MessageUpdateBlockState message, MessageContext ctx){ TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z); if(te instanceof TileEntityBlock{ TileEntityBlock blockTE= (TileEntityBlock) te; blockTE.updateBlocksStateNow(blockTE, player.getCurrentEquippedItem(), message.block; } } } -
[1.7.10] Server Client variable generation issue
Thornack replied to Thornack's topic in Modder Support
im not using nbt for that though. I am using cpw.mods.fml.common.network.simpleimpl.IMessage; to send the packets and it is still queing. I cant seem to send the packet from the server to the client using this -
[1.7.10] Server Client variable generation issue
Thornack replied to Thornack's topic in Modder Support
Also, is there a way to send packets inside a GUI without them Queing up (I noticed you have to close all GUIs for the packets to send) and all packets get sent in one go. -
Hi everybody, I have a tile entity that generates a random number and stores this number as a variable. I wish to access this variable inside a GUI. But (and correct me if i am wrong) GUI's seem to stop all packets from being sent. How could I achieve this (how could I get the random number that is generated when the tile entity is placed in the world). When I try using nbt to save the variable and then get the variable again in the gui the gui picks up a different value for the variable because the variable is a random number. in my tile entity class I generate the random number and have a getter for it as well as a setter for it int randomNumber; public void generateRandomNumber(String blockType){ if (blockType.equals("BasicBlock")) { randomNumber = new Random().nextInt(36) + 1; System.out.println("BasicBlock " + randomNumber); } public int getRandomNumber () { return randomNumber; } public void setRandomNumber (int numb) { randomNumber = numb; } @Override public void readFromNBT(NBTTagCompound nbtCompound) { super.readFromNBT(nbtCompound); if (nbtCompound.hasKey("typeOfBlock") && nbtCompound.hasKey("randNumber")) { typeOfBlock = nbtCompound.getString("typeOfBlock"); randomNumber = nbtCompound.getInteger("randNumber"); } } @Override public void writeToNBT(NBTTagCompound nbtCompound) { super.writeToNBT(nbtCompound); if(!typeOfBlock.isEmpty()){ nbtCompound.setString("typeOfBlock",typeOfBlock); } nbtCompound.setInteger("randNumber",randomNumber); } in my GUI class I want to get the random number that is saved server side (at least im pretty sure it is saved server side) private TileEntityRandomBlock tileBlock; //all the stuff required to draw it etc etc... and the render method where I need to access the random number generated by the tile entity @Override public void drawScreen(int mouseX, int mouseY, float p_73863_3_){ super.drawScreen(mouseX, mouseY, p_73863_3_); int blockRandNumb = this.tileBlock.getRandomNumber(); } if I do this then I get what seems to be the clients version of my random number but I need the servers version. How could I achieve this result. Any help is appreciated (sorry for the psuedo code my class is very large and complicated so I tried to isolate what is needed to understand the issue at hand).
-
[1.7.10] How to Rotate a texture inside your GUI
Thornack replied to Thornack's topic in Modder Support
For those of you whom need more explanation You dont actually need to guess the coordinates for x and y you can calculate them in the following way see the comment in the code @Override public void drawScreen(int mouseX, int mouseY, float p_73863_3_){ // ...other stuff // what you want -> GL11.glPushMatrix(); GL11.glTranslatef(233f, 127f, 0); // these two positions can be calculated by taking the parameter from your guiBackground image Rectangle corner Coord(x,y)= 155,30 and adding the width/2 = (156/2 for my case) and height/2 = (195/2 for my case) of this background to its Rectangle corner coordinate giving (156/2) + 155 = 233 and (195/2) + 30 = 127 where 233,127 are the coordinates you want inside your GL11.glTranslate(). Also note, the axises are 45 degrees off of a traditional Cartesian Coordinate system so that is why I use the 45. and no guessing is needed. GL11.glRotatef(this.currentAngle, 0, 0,45); GL11.glTranslatef(-233f, -127f, 0f); //Foreground texture (I want to rotate this) is bound and a textured rectangle is drawn for this GUI part this.mc.getTextureManager().bindTexture(guiForegroundTexture); this.drawTexturedRect(this.guiRect, this.guiForeground, this.textureCoordsForeground, this.guiForegroundTextureSize); GL11.glPopMatrix(); // This resets all the transforms you did after GL11.glPushMatrix } That rotates the GUI around the center at the position that I wanted (the center of my background) -
[1.7.10] How to Rotate a texture inside your GUI
Thornack replied to Thornack's topic in Modder Support
Do you mean @Override public void drawScreen(int mouseX, int mouseY, float p_73863_3_){ super.drawScreen(mouseX, mouseY, p_73863_3_); //This draws the angle that is changed this.drawCenteredString(this.fontRendererObj, "angle: " + this.currentAngle, this.width / 2, 10, 0xFFFFFF); //Background texture is bound and a textured rectangle is drawn for this GUI part this.mc.getTextureManager().bindTexture(guiBackgroundTexture); this.drawTexturedRect(this.guiRect, this.guiBackground, this.textureCoordsBackground, this.guiBackgroundTextureSize); GL11.glPushMatrix(); GL11.glRotatef(this.angle, 84,0, 84); //Foreground texture (I want to rotate this) is bound and a textured rectangle is drawn for this GUI part this.mc.getTextureManager().bindTexture(guiForegroundTexture); this.drawTexturedRect(this.guiRect, this.guiForeground, this.textureCoordsForeground, this.guiForegroundTextureSize); GL11.glPopMatrix(); // This resets all the transforms you did after GL11.glPushMatrix } I tried this and the texture seems to be rotated by the upper left corner, I need some way to rotate it around its very middle -
I have a GUI where I used the keyTyped function to change a value called angle. This value is changed when you press the a or d keys on the keyboard or when you hold them down the value changes alot faster. This angle is displayed in the GUI and can be seen to update while your in the GUI (everytime i hit the keys you see the value change). I wish to use this to rotate the GUI texture live. Any ideas as to how I can achieve this functionality? my GUI has two images the background (I want that to remain stationary) and the foreground (i want this to rotate around its center when I press or hold down the a or d keys). @Override public void drawScreen(int mouseX, int mouseY, float p_73863_3_){ super.drawScreen(mouseX, mouseY, p_73863_3_); //This draws the angle that is changed this.drawCenteredString(this.fontRendererObj, "angle: " + this.currentAngle, this.width / 2, 10, 0xFFFFFF); //Background texture is bound and a textured rectangle is drawn for this GUI part this.mc.getTextureManager().bindTexture(guiBackgroundTexture); this.drawTexturedRect(this.guiRect, this.guiBackground, this.textureCoordsBackground, this.guiBackgroundTextureSize); //Foreground texture (I want to rotate this) is bound and a textured rectangle is drawn for this GUI part this.mc.getTextureManager().bindTexture(guiForegroundTexture); this.drawTexturedRect(this.guiRect, this.guiForeground, this.textureCoordsForeground, this.guiForegroundTextureSize); } This is how I change the angle @Override protected void keyTyped(char key, int event){ super.keyTyped(key, event); //While the user presses the specified keyboard key once this code causes the currentAngle to change if(key=='a'||key=='A'){ this.currentAngle--; } else if (key=='d'||key=='D'){ this.currentAngle++; } //While you hold down the specified keyboard key this code causes the currentAngle to change Keyboard.enableRepeatEvents(true); if(Keyboard.isRepeatEvent()){ if(Keyboard.isKeyDown(Keyboard.KEY_A) == true){ this.currentAngle--; } else if(Keyboard.isKeyDown(Keyboard.KEY_D) == true){ this.currentAngle++; } }} any help is appreciated