Jump to content

TLHPoE

Members
  • Posts

    638
  • Joined

  • Last visited

Everything posted by TLHPoE

  1. Does anybody know?
  2. Ok, it's not working. Expected Outcome: Outcome: Here's my code: ScaledResolutionT sr = new ScaledResolutionT(mc.gameSettings, this.width, this.height); GL11.glScissor((int) sr.getScaledX(298), (int) sr.getScaledY(20), (int) sr.getScaledX(256), (int) sr.getScaledY(438)); And here's the custom class I use: package tlhpoeCore; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.settings.GameSettings; public class ScaledResolutionT extends ScaledResolution { public ScaledResolutionT(GameSettings gameSettings, int width, int height) { super(gameSettings, width, height); } public double getScaledX(double x) { return (x / ReferenceT.DEFAULT_WIDTH) * getScaledWidth_double(); } public double getScaledY(double y) { return (y / ReferenceT.DEFAULT_HEIGHT) * getScaledHeight_double(); } }
  3. I'm almost there I think. The region gets out of scale if sX and sY aren't equal though. double sX = (double) mc.displayWidth / ReferenceT.DEFAULT_WIDTH; double sY = (double) mc.displayHeight / ReferenceT.DEFAULT_HEIGHT; System.err.println("SX:" + sX + "|SY:" + sY); GL11.glScissor((int) (298 * sX), (int) (20 * sY), (int) (256 * sX), (int) (438 * sY));
  4. I'm using glScissor to render some things on a gui, but when I resize the window, it doesn't scale automatically. How would I go about scaling the arguments inside of the glScissor method? package flappyworld.gui; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import tlhpoeCore.ReferenceT; import tlhpoeCore.TLHPoE; import tlhpoeCore.UtilT; import flappyworld.ReferenceFW; import flappyworld.UtilFW; import flappyworld.game.ClientGameSessionFW; import flappyworld.game.PipeFW; import flappyworld.game.SteveFW; import flappyworld.network.PacketPlayerJumpFW; public class GuiGameFW extends GuiScreen { public static final ResourceLocation TEXTURES = new ResourceLocation(ReferenceFW.ID + ":textures/gui/textureSheet.png"); public static final ResourceLocation locationCreeperPng = new ResourceLocation("textures/entity/creeper/creeper.png"); public boolean canJump = true; @Override public void drawScreen(int par1, int par2, float par3) { this.drawDefaultBackground(); super.drawScreen(par1, par2, par3); Minecraft mc = UtilT.getMC(); GL11.glPushMatrix(); GL11.glScissor(311, 74, 231, 1000); //SCISSOR GL11.glEnable(GL11.GL_SCISSOR_TEST); //ENABLE SCISSOR drawGround(); ClientGameSessionFW clientSession; if(ReferenceFW.clientSession != null) { clientSession = ReferenceFW.clientSession; } else { return; } int x = (this.width / 2) - 58; int y = (int) ((this.height / 2) + 51); GL11.glPushMatrix(); GL11.glTranslated(x, y, 0); drawPipes(clientSession); drawPlayer(clientSession); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_SCISSOR_TEST); //DISABLE SCISSOR GL11.glPopMatrix(); drawPhone(); String score = "" + clientSession.score; x = this.width / 2; y = this.height / 2; GL11.glPushMatrix(); GL11.glScaled(2, 2, 1); UtilT.drawOutlinedString(score, (x / 2) - (mc.fontRenderer.getStringWidth(score) / 2), y - 94, 0xFFE600, 0); GL11.glPopMatrix(); UtilT.drawOutlinedString("High Score: " + clientSession.highScore, 4, 4, 0xFFFFFF, 0); } public void drawGround() { int x = this.width / 2; int y = (this.height / 2) + 67; mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); IIcon icon = Blocks.grass.getIcon(3, 0); for(int i = 0; i < 8; i++) { this.drawTexturedModelRectFromIcon((x - 64) + (16 * i), y, icon, 16, 16); } } public void drawPhone() { int width = 128; int height = 224; int x = (this.width - width) / 2; int y = (this.height - height) / 2; mc.renderEngine.bindTexture(TEXTURES); this.drawTexturedModalRect(x, y, 0, 0, width, height); width = height = 16; } public void drawPipes(ClientGameSessionFW clientSession) { if(clientSession.pipes != null) { for(int i = 0; i < clientSession.pipes.length; i++) { PipeFW pipe = clientSession.pipes[i]; int pipeHeight = pipe.height; int pipeX = (int) pipe.posX; mc.renderEngine.bindTexture(locationCreeperPng); UtilFW.drawTexturedQuad(pipeX + 4, -pipeHeight, 16, 16, 16, 8, 8, 8, 64, 32, 0); UtilFW.drawTexturedQuad(pipeX + 8, (-pipeHeight + 16), 8, pipeHeight - 12, 28, 20, 4, 12, 64, 32, 0); UtilFW.drawTexturedQuad(pipeX + 16, 4, 8, 12, 8, 20, 4, 6, 64, 32, 0); UtilFW.drawTexturedQuad(pipeX, 4, 8, 12, 8, 20, 4, 6, 64, 32, 0); } } } public void drawPlayer(ClientGameSessionFW clientSession) { mc.renderEngine.bindTexture(AbstractClientPlayer.locationStevePng); GL11.glPushMatrix(); GL11.glTranslated(20, (-clientSession.posY) + 8, 0); GL11.glRotatef((float) (SteveFW.getRotation(clientSession.motionY)) / -1F, 0.0F, 0.0F, 1.0F); UtilFW.drawTexturedQuad(-8, -8, 16, 16, 8, 8, 8, 8, 64, 32, 0); GL11.glPopMatrix(); } @Override public void handleKeyboardInput() { if(Keyboard.getEventKey() == Keyboard.KEY_SPACE) { if(Keyboard.getEventKeyState()) { if(canJump) { TLHPoE.packetHandler.sendToServer(new PacketPlayerJumpFW()); canJump = false; } } else { canJump = true; } } super.handleKeyboardInput(); } @Override public boolean doesGuiPauseGame() { return false; } }
  5. In one of my recipes, I use a wither skeleton skull in the crafting recipe: GameRegistry.addShapedRecipe(new ItemStack(Items.nether_star, 1), "DWD", "WGW", "DWD", 'D', Items.diamond, 'W', new ItemStack(Blocks.skull, 1, 1), 'G', Items.ghast_tear); The recipe isn't working, did I do something wrong? I ran it into debug and it was getting called.
  6. You could set the fall height field to 0 in the onUpdate method.
  7. Look at the class for the golden apple and go off from there.
  8. If I don't use GL calls, then the head texture would be stretched vertically. My current question is how to cut the steve texture down so that just the face portion of the texture is in its own ResoureLocation of IIcon.
  9. I used GL calls to try to rescale it (since the steve texture file is a 64 by 32 or something like that). And the translate was an attempt to get it back in its original position. But once I resize the window, it isn't positioned correctly. The steve head is supposed to be at the center of the screen.
  10. Could you show us where you registered the entity?
  11. You could use events which is probably really unnecessary, or you can override the hitEntity method in Item.
  12. Well, you never asked for an exact explanation. Look into the onUpdate method in Item.
  13. Sorry for the late response, here's the code. Gui Code: package flappyworld.gui; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import tlhpoeCore.UtilT; import flappyworld.ReferenceFW; import flappyworld.game.ClientGameSessionFW; public class GuiGameFW extends GuiScreen { public static final ResourceLocation TEXTURES = new ResourceLocation(ReferenceFW.ID + ":textures/gui/textureSheet.png"); @Override public void drawScreen(int par1, int par2, float par3) { this.drawDefaultBackground(); super.drawScreen(par1, par2, par3); Minecraft mc = UtilT.getMC(); //////////////////////////////////////////////////////////////// int x = this.width / 2; int y = (this.height / 2) + 67; mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); IIcon icon = Blocks.grass.getIcon(3, 0); for(int i = 0; i < 8; i++) { this.drawTexturedModelRectFromIcon((x - 64) + (16 * i), y, icon, 16, 16); } //////////////////////////////////////////////////////////////// int width = 128; int height = 224; x = (this.width - width) / 2; y = (this.height - height) / 2; mc.renderEngine.bindTexture(TEXTURES); this.drawTexturedModalRect(x, y, 0, 0, width, height); width = height = 16; //////////////////////////////////////////////////////////////// if(ReferenceFW.clientSession != null) { ClientGameSessionFW clientSession = ReferenceFW.clientSession; } x = this.width / 2; y = this.height / 2; mc.renderEngine.bindTexture(AbstractClientPlayer.locationStevePng); GL11.glPushMatrix(); GL11.glTranslated(100, 100, 1); GL11.glScaled(0.5, 0.25, 0.5); this.drawTexturedModalRect(x, y, 32, 64, 32, 64); GL11.glPopMatrix(); } @Override public boolean doesGuiPauseGame() { return false; } } Specific Section of the Code: if(ReferenceFW.clientSession != null) { ClientGameSessionFW clientSession = ReferenceFW.clientSession; } x = this.width / 2; y = this.height / 2; mc.renderEngine.bindTexture(AbstractClientPlayer.locationStevePng); GL11.glPushMatrix(); GL11.glTranslated(100, 100, 1); GL11.glScaled(0.5, 0.25, 0.5); this.drawTexturedModalRect(x, y, 32, 64, 32, 64); GL11.glPopMatrix();
  14. If you're talking about the hand bobbing up and down, that can be disabled/enabled from the video setting menu.
  15. Could you tell us where the errors are to save us time? Also please don't name your unlocalized items like this: "GarbageCan" change that to "garbageCan" Same goes with your field names.
  16. Anybody?
  17. public static final String[] woodType = new String[] {"Redwood"}; this.field_111052_c = new Icon[woodType.length]; @SideOnly(Side.CLIENT) /** * The icon for the side of the block. */ protected Icon getSideIcon(int par1) { return this.field_111052_c[par1]; } The crash log says that you're trying to access the 2nd index of the field_111052_c (for the love of god name your fields) array. In your code, field_111052_c only has 1 index, since woodTypes has only 1 index in it. Also, in your getSideIcon method, that method is gonna pass 6 times with 6 different values. Look here at TGG's guide to see what each side's number is.
  18. I'm attempting to render the default steve head on a gui. One problem was that the texture gets warped by the the fact that the default skin dimensions are 64 by 32 instead of 64 by 64. I fixed this by scaling it. Originally, the position of the head was near the center of the screen. You can see that the texture was displaced a lot. I tried fixing it by using translation. This looks like it worked, but it gets displaced when I resize the screen. Is there any way to just get the head texture in an IIcon or ResourceLocation form?
  19. Oh, ok. Thanks.
  20. For some reason it only works in lower resolutions, and bugs out in higher resolutions. Minecraft mc = UtilT.getMC(); int width = 128; int height = 224; int x = (mc.displayWidth - width) / 2; int y = (mc.displayHeight - height) / 2; this.drawTexturedModalRect(x, y, 0, 0, width, height);
  21. I've been trying to use ScaledResolution to center my gui, but it's not really working. My gui coide centers where I want with the default resolution, but when I go full screen (1920 by 1080), it gets shifted to the left. Here's my gui class: package flappyworld.gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.util.ResourceLocation; import tlhpoe.UtilT; import flappyworld.ReferenceFW; public class GuiGameFW extends GuiScreen { private double x = 298.5, y = 15; public static final ResourceLocation phoneTexture = new ResourceLocation(ReferenceFW.ID + ":textures/gui/phone.png"); @Override public void drawScreen(int par1, int par2, float par3) { this.drawDefaultBackground(); super.drawScreen(par1, par2, par3); UtilT.getMC().renderEngine.bindTexture(phoneTexture); ScaledResolution sr = UtilT.getScaledResolution(); this.drawTexturedModalRect((int) UtilT.getScaledX(x, sr), (int) UtilT.getScaledY(y, sr), 0, 0, 128, 224); } @Override public boolean doesGuiPauseGame() { return false; } } Here's the UtilT class: package tlhpoe; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.nbt.NBTTagCompound; public class UtilT { public static Minecraft getMC() { return Minecraft.getMinecraft(); } public static ScaledResolution getScaledResolution() { return new ScaledResolution(getMC().gameSettings, getMC().displayWidth, getMC().displayHeight); } public static double getScaledX(double x, ScaledResolution sr) { return (x / ReferenceT.DEFAULT_WIDTH) * sr.getScaledWidth_double(); } public static double getScaledX(double x) { return getScaledX(x, getScaledResolution()); } public static double getScaledY(double y, ScaledResolution sr) { return (y / ReferenceT.DEFAULT_HEIGHT) * sr.getScaledHeight_double(); } public static double getScaledY(double y) { return getScaledY(y, getScaledResolution()); } } Finally, here are the default width and height variables: public static final int DEFAULT_WIDTH = 854; public static final int DEFAULT_HEIGHT = 480;
  22. Only the player with the gui open would be seeing it. Also, for every player, there is 1 2D entity. With that in mind, yes, I could have over 10 players being synced up every tick. Yes, the 2D entity is only in the gui and needs to be synced. The 2D entity will be controlled on the server, and will sync with the player so they can render it. I'm attempting a sort of 2D game, and there will be a leaderboard in each world displaying the highest scores.
  23. I plan on creating a gui that houses a 2D entity. The 2D entity is gonna be constantly moving around, and my packet to sync the client would have at least 16 doubles. Would it be safe and smooth if I synced the client every tick?
  24. That's just how Minecraft was made. You can see this happening when you use an undamaged diamond pickaxe that's enchanted with Unbreaking.
  25. Fixed it, I don't know exactly what was wrong, but my friend suggested moving the x/y/z coord changes in the nonworking sides to the minimum coords. package fans.tileentity; import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import fans.block.BlockFan; public class TileEntityFan extends TileEntity { @Override public void updateEntity() { if(BlockFan.isPowered(worldObj, xCoord, yCoord, zCoord)) { int current = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); switch(current) { case (0): { //Front List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 9)); if(!entities.isEmpty()) { for(Object obj : entities) { if(obj instanceof Entity && !((Entity) obj).isSneaking()) { ((Entity) obj).motionZ += ((BlockFan) this.getBlockType()).getPower(); } } } break; } case (1): { //Right List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 9, yCoord + 1, zCoord + 1)); if(!entities.isEmpty()) { for(Object obj : entities) { if(obj instanceof Entity && !((Entity) obj).isSneaking()) { ((Entity) obj).motionX += ((BlockFan) this.getBlockType()).getPower(); } } } break; } case (2): { //Back List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord - 8, xCoord + 1, yCoord + 1, zCoord)); if(!entities.isEmpty()) { for(Object obj : entities) { if(obj instanceof Entity && !((Entity) obj).isSneaking()) { ((Entity) obj).motionZ -= ((BlockFan) this.getBlockType()).getPower(); } } } break; } case (3): { //Left List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord - 8, yCoord, zCoord, xCoord, yCoord + 1, zCoord + 1)); if(!entities.isEmpty()) { for(Object obj : entities) { if(obj instanceof Entity && !((Entity) obj).isSneaking()) { ((Entity) obj).motionX -= ((BlockFan) this.getBlockType()).getPower(); } } } break; } case (4): { //Top List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 9, zCoord + 1)); if(!entities.isEmpty()) { for(Object obj : entities) { if(obj instanceof Entity && !((Entity) obj).isSneaking()) { ((Entity) obj).motionY += ((BlockFan) this.getBlockType()).getPower(); } } } break; } case (5): { //Bottom List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord - 8, zCoord, xCoord + 1, yCoord, zCoord + 1)); if(!entities.isEmpty()) { for(Object obj : entities) { if(obj instanceof Entity && !((Entity) obj).isSneaking()) { ((Entity) obj).motionY -= ((BlockFan) this.getBlockType()).getPower(); } } } break; } } } } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.