Jump to content

badner

Members
  • Posts

    25
  • Joined

  • Last visited

  • Days Won

    1

badner last won the day on October 12 2020

badner had the most liked content!

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

badner's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. Hi, I am trying to use the Checkbox. The MC implementation of the checkbox doesnt have a feature to save the current state if the checkbox is clicked. Therefore I added the save feature by extending the Checkbox class. Here you can see the source code: GuiCheckBox: The CheckBoxOption is a field inside the config class to provide easy access to a setting. CheckBoxOption: The Config is a simple class to store settings. IConfig: And the initialization of a GuiCheckbox: There is no compile error, but if I open the Screen with the GuiCheckbox, the game is crashing and I get an error message which I do not understand: To fix the error I found a trivial solution, but its blowing up my code... Hence I want a better solution or fix the error above. Any ideas?
  2. It seems that rendering the HUD has changed. With a hook inside the InGameHud, we can render a text on the hud: package de.d4n1el89.chunkinfo.mixins; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.hud.InGameHud; @Mixin({ InGameHud.class }) public class MixinInGameHud { @Inject(method = { "renderStatusEffectOverlay" }, at = { @At("RETURN") }) private void onRenderStatusEffectOverlay(CallbackInfo ci) { MinecraftClient.getInstance().textRenderer.draw("THIS IS SPARTA", 50, 50, 16777215); } }
  3. Okay, thats strange. I guess the reason for that difference is that Forge and Fabric (I am using Fabric) are using different deobfuscation tools? Anyway you said that FontRenderer is pretty much unchanged, then I have to try it again.
  4. Hey, I am migrating from 1.12.2 to 1.15.1. In 1.12.2 you can use FontRenderer.drawString(String text, int x, int y, int color) and you get a simple Text on HUD. I tried similar stuff in 1.15.1 with TextRenderer.draw(String text, float x, float y, int color), but that doesnt work. I also took a look inside "InGameHud", but this didnt help me neither. There is some stuff going on with e.g. client.getProfiler().push("bossHealth"); and client.getProfiler().pop(); which I dont understand. How can I simply draw a text on HUD? Thanks in advance.
  5. Hi, I am trying to create a Mod which can show "Ghost-Items" in the world and cover them with a colored glowing effect. NOTICE: clientside only! Here you can see how the "Ghost-Items" are generated: ghostEntity = new EntityItem(mc.player.getEntityWorld(), 0, 70, 0, new ItemStack(Blocks.COBBLESTONE)); To render the Ghost-Items, I created a custom renderer which can render the Ghost-Item at a specific location in the world: (based on RenderEntityItem.class) public void doRender(EntityItem entity, double xPos, double yPos, double zPos, float entityYaw, float partialTicks) { ItemStack itemstack = entity.getItem(); // Noetig damit Item keine Defaulttextur bekommt bindEntityTexture(entity); GlStateManager.enableRescaleNormal(); GlStateManager.alphaFunc(516, 0.1F); GlStateManager.enableBlend(); RenderHelper.enableStandardItemLighting(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.pushMatrix(); IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(itemstack, entity.world, (EntityLivingBase) null); boolean forceGlowing = true; if (forceGlowing) { // FORCE ENTITY GLOWING GlStateManager.enableColorMaterial(); GlStateManager.enableOutlineMode(this.getTeamColor(entity)); } Minecraft mc = Minecraft.getMinecraft(); float playerX = (float) (mc.player.lastTickPosX + (mc.player.posX - mc.player.lastTickPosX) * partialTicks); float playerY = (float) (mc.player.lastTickPosY + (mc.player.posY - mc.player.lastTickPosY) * partialTicks); float playerZ = (float) (mc.player.lastTickPosZ + (mc.player.posZ - mc.player.lastTickPosZ) * partialTicks); float dx = (float) (xPos - playerX); float dy = (float) (yPos - playerY); float dz = (float) (zPos - playerZ); GlStateManager.translate(dx, dy, dz); // Groesse aendern! wenn auskommentiert, wird voller Block gerendert ibakedmodel.getItemCameraTransforms().applyTransform(ItemCameraTransforms.TransformType.GROUND); // Item Rendern itemRenderer.renderItem(itemstack, ibakedmodel); if (forceGlowing) { // FORCE ENTITY GLOWING GlStateManager.disableOutlineMode(); GlStateManager.disableColorMaterial(); } GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); } To add the colored glowing effect, I created a custom team and added the Ghost-Item Scoreboard scoreboard = mc.player.getWorldScoreboard(); if(scoreboard != null){ if(scoreboard.getTeam("Test1") == null){ System.out.println("create Team"); scoreboard.createTeam("Test1"); scoreboard.getTeam("Test1").setColor(TextFormatting.GOLD); ghostEntity = new EntityItem(mc.player.getEntityWorld(), 0, 70, 0, new ItemStack(Blocks.COBBLESTONE)); ghostEntity.setGlowing(true); scoreboard.addPlayerToTeam(ghostEntity.getCachedUniqueIdString(), "Test1"); } } The problem is, that if the glowing effect is enabled, the whole Ghost-Item is rendered white. Picture 1: Ghost-Item at a specific location in the world without glowing effect: CLICK Picture 2: Ghost-Item at a specific location in the world with glowing effect: CLICK How can I fix this? The teamcolor is e.g GOLD. Thank you for your help.
  6. Hi, I want to draw a nametag on a given position in the World: /** * x,y,z the Position(BlockPos) * string, the String to render */ public static void renderName(double x, double y, double z, String string, float partialTicks){ RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); Entity player = Minecraft.getMinecraft().thePlayer; FontRenderer fontRenderer = renderManager.getFontRenderer(); //Tessellator tessellator = Tessellator.getInstance(); //float scale = (float) (0.016666668F * getDistanceScalled(d3)); int string_length = fontRenderer.getStringWidth(string) / 2; double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX); double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY); double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ); double diffX = x - playerX * (double) partialTicks; double diffY = y - playerY * (double) partialTicks; double diffZ = z - playerZ * (double) partialTicks; GlStateManager.pushMatrix(); GlStateManager.translate(diffX, diffY + 2D, diffZ); GlStateManager.rotate(-player.rotationYaw, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(player.rotationPitch, 1.0F, 0.0F, 0.0F); //GlStateManager.scale(-scale, -scale, scale); GlStateManager.depthMask(false); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); GlStateManager.disableBlend(); //Minecraft.getMinecraft().ingameGUI.drawRect(-string_length - 2, -2,fontRenderer.getStringWidth(string) + 1 - string_length, fontRenderer.FONT_HEIGHT, 0x50000000); //Minecraft.getMinecraft().ingameGUI.drawRect(-string_length - 1, -1,fontRenderer.getStringWidth(string) - string_length, fontRenderer.FONT_HEIGHT - 1, 0x50FF0000); fontRenderer.drawString(string, -string_length, 0, -1); GlStateManager.enableTexture2D(); GlStateManager.enableLighting(); GlStateManager.disableBlend(); GlStateManager.depthMask(true); GlStateManager.popMatrix(); } The problem is, that the string is buzzing around and other self definded things to render are gray now... Whats the mistake?
  7. Hi, gradlew setupDecompWorkspace doesnt work on my Laptop (but works fine on my Desktop -.- ) OS: WIN8 64 bit, JAVA: jdk 8_77 (64 bit) and jdk 8_92 (32 bit) i7-4710 8 GB RAM gradlew setupDecompWorkspace -info: http://pastebin.com/vE2u5kH7 gradlew setupDecompWorkspace -stacktrace: http://pastebin.com/gzZB6X2G Solution:
  8. I am using nativ Minecraft code to submit the inventory changes to the server: package net.minecraft.client.multiplayer; class PlayerControllerMP /** * Handles slot clicks sends a packet to the server. */ public ItemStack windowClick(int windowId, int slotId, int mouseButtonClicked, int mode, EntityPlayer playerIn) { short var6 = playerIn.openContainer.getNextTransactionID(playerIn.inventory); ItemStack var7 = playerIn.openContainer.slotClick(slotId, mouseButtonClicked, mode, playerIn); this.netClientHandler.addToSendQueue(new C0EPacketClickWindow(windowId, slotId, mouseButtonClicked, mode, var7, var6)); return var7; } This should handle the Itemstackmovement on clientside? ItemStack var7 = playerIn.openContainer.slotClick(slotId, mouseButtonClicked, mode, playerIn);
  9. Hi guys, I got a problem with my slot auto refill method. The method is called every gametick and should detect when an itemstack is empty and then refill it. There is an other problem too. If an itemstack was refilled, the itemstack is(/become invisible, sometimes you can see it for < 1 second, I guess this happens when the tagged code below is called twice) invisible (-> clientside only!), on the next rightclick the itemstack appears. private void autorefill(Minecraft mc){ EntityPlayer player = mc.thePlayer; if(mc.playerController.isInCreativeMode()){ return; } InventoryPlayer inventory = player.inventory; ItemStack currentItemstack = inventory.getCurrentItem(); int currentSlot = inventory.currentItem; if(currentSlot == lastSlot){ if(lastItem != null && currentItemstack == null){ System.out.println("Slot empty -> refill"); // The part below here is called twice, but it shouldnt! <- tagged code if(lastItem.isDamageable()){ return; } int refillItemstack = findItemStack(inventory.mainInventory, lastItem, currentSlot); // This method returns the slotnumber which is containing a compatible itemstack, or if there is no matching itemstack -1 if(refillItemstack != -1){ mc.playerController.windowClick(0, refillItemstack, 0, 0, player); mc.playerController.windowClick(0, currentSlot + 36, 0, 0, player); }else{ System.out.println("no itemstack found"); lastItem = null; } } }else{ System.out.println("different slot detected"); lastSlot = currentSlot; if(currentItemstack != null){ lastItem = currentItemstack.getItem(); }else{ lastItem = null; } } } Thank you, Daniel
  10. Hi, I have a problem with the mouse position on different gui. Picture 1: http://www.pic-upload.de/view-28275565/pic1.png.html ---> GuiMain mouseclick to button "Details" open a new gui/window: mc.displayGuiScreen(null); //<--- close GuiMain mc.displayGuiScreen(new GuiDetails(someStuff)); //<--- open gui/window GuiDetails Picture 2: http://www.pic-upload.de/view-28275596/pic2.png.html ---> GuiDetails I expect the mouse position on the same coordinates (x, y -> red triangle) like on the GuiMain, but the mouse position is at the cross at the center of the screen (red circle). How can I pass the x, y coordinates of the mouse position from GuiMain to GuiDetails?
  11. Thats a optical illusion (is that the correct word?^^). Is there a better Way to draw a Cube without surfaces? like this -> http://www.pic-upload.de/view-28254561/cube.png.html ArrayList<Vec3> lineList = new ArrayList<Vec3>(); // Storage of vertices for all lines Vec3[] cube = new Vec3[8]; // Example public void setCubeList(){ // vertices of a cube; cube[0] = new Vec3(0,10,0); cube[1] = new Vec3(10,10,0); cube[2] = new Vec3(0,10,10); cube[3] = new Vec3(10,10,10); cube[4] = new Vec3(0,20,0); cube[5] = new Vec3(10,20,0); cube[6] = new Vec3(10,20,10); cube[7] = new Vec3(0,20,10); lineList.add(cube[0]); // edge 1-2 lineList.add(cube[1]); lineList.add(cube[1]); // edge 2-4 lineList.add(cube[3]); lineList.add(cube[0]); // edge 1-3 lineList.add(cube[2]); lineList.add(cube[2]); // edge 3-4 lineList.add(cube[3]); lineList.add(cube[4]); // edge 5-8 lineList.add(cube[7]); lineList.add(cube[4]); // edge 5-6 lineList.add(cube[5]); lineList.add(cube[6]); // edge 7-8 lineList.add(cube[7]); lineList.add(cube[5]); // edge 6-7 lineList.add(cube[6]); lineList.add(cube[0]); // edge 1-5 lineList.add(cube[4]); lineList.add(cube[1]); // edge 2-6 lineList.add(cube[5]); lineList.add(cube[3]); // edge 4-7 lineList.add(cube[6]); lineList.add(cube[2]); // edge 3-8 lineList.add(cube[7]); } @SubscribeEvent public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event){ GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); double d0 = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * (double)event.partialTicks; double d1 = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * (double)event.partialTicks; double d2 = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * (double)event.partialTicks; Vec3 pos = new Vec3(d0, d1, d2); GL11.glTranslated(-pos.xCoord, -pos.yCoord, -pos.zCoord); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST); for(int a = 0; a<lineList.size(); a+=2){ drawLineWithGL(lineList.get(a), lineList.get(a+1)); } GL11.glPopAttrib(); GL11.glPopMatrix(); }
  12. Finally I got it @SubscribeEvent public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event){ GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); double d0 = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * (double)event.partialTicks; double d1 = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * (double)event.partialTicks; double d2 = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * (double)event.partialTicks; Vec3 pos = new Vec3(d0, d1, d2); //Vec3 pos = event.player.getPositionEyes(event.partialTicks); Doesnt work because y-part +(double)this.getEyeHeight() GL11.glTranslated(-pos.xCoord, -pos.yCoord, -pos.zCoord); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST); // draw the line on top of the geometry Vec3 posA = new Vec3 (0,10,0); Vec3 posB = new Vec3 (10,10,0); drawLineWithGL(posA, posB); GL11.glPopAttrib(); GL11.glPopMatrix(); } private void drawLineWithGL(Vec3 blockA, Vec3 blockB) { GL11.glColor4f(1F, 0F, 1F, 0F); // change color an set alpha GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex3d(blockA.xCoord, blockA.yCoord, blockA.zCoord); GL11.glVertex3d(blockB.xCoord, blockB.yCoord, blockB.zCoord); GL11.glEnd(); } Vec3 pos = event.player.getPosition(event.partialTicks); First i used getPositionEyes Instead of getPosition but this Method didnt return the correct y-value. You can see this if you look into the declaration. I also switched from GL11.glColor3f to GL11.glColor4f, but alpha 1F or alpha 0F change nothing. The "color" of the line is still depending on the block behind. How can I fix this? Daniel
  13. Vec3 pos = event.player.getPosition(event.partialTicks); Which event (from net.minecraftforge.client.event package e.g.) should I use? According to the previous posts, I can use this: Vec3 pos1= new Vec3 (0,5,0); // [b]Vector from 0,0,0 to 0,5,0 -> Blockcoords[/b] Vec3 pos2= new Vec3 (5,5,0); // [b]Vector from 0,0,0 to 5,5,0 -> Blockcoords[/b] //you will need to supply your own position vectors drawLineWithGL(pos1, pos2); This is never used: int d = Math.round((float)blockA.distanceTo(blockB)+0.2f);
  14. //Your code here e.e renderer.addVertex(x,y,z); Here is my Problem, I dont know what kind of coordinates are x,y,z have to be.
×
×
  • Create New...

Important Information

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