Jump to content

Anonymous1611

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by Anonymous1611

  1. Hello, I am porting a mod from 1.12.2 to 1.13.2. Since actionPeformed is no longer a thing in GuiScreen for 1.13.2 I have looked around the forums to see what the alternative is. Ive come along the following: import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; public class Gui extends GuiScreen { protected void initGui() { GuiButton button = new GuiButton(0, 200, 15, "Ok") { public void onClick(double mouseX, double mouseY) { System.out.println("x"); } }; this.buttons.add(button); } } Sadly I cannot get the onClick to fire once I click on the button. The GUI opens fine and the button is there I just can't wrap my head around it I am pretty sure I am missing something simple. Thanks in advance.
  2. The Function itself does not seem to work at all. I tried different events, checked if they executed and they did. Tried using receiveCanceled and playing with the event priority.
  3. Doesnt seem to change anything. Doesnt work in RenderTick Event or other TickEvents. So i assume thatr mc.fontRenderer just doesnt work because of Laby. Is there any other way to draw text on the screen?
  4. Hello, I have a mod that draws simple text on the screen using: @SubscribeEvent public void Draw(RenderGameOverlayEvent.Pre event) { mc.fontRenderer.drawStringWithShadow("Test", 940, 465, 0xf4cf16); } But once my mod is used with LabyMod the text doesnt show up. I was wondering why and if there is a solution / workarround since i really need the mod to just draw text. So i can draw coordinates on the top left of my screen for example (Without using F3) Minecraft 1.12.2 Thannks in advance!
  5. Yes i get that. So as shown in the code above. The player interacts with the entity (right click, also mounting as in vanilla minecraft) while holding an item and gets an message accordingly. How do i cancel EntityMountEvent then? Or is there a server-sided mod needed for this, if so how do i prevent the player from mounting the entity when it tries to interact (right clicck) on the horse. Thanks in advance im really trying to understand and learn here.
  6. Alright im completly stuck. EntityMountEvent is server-sided, i can read it but cant change it (Ghosting as shown in the gyazo link) Now how do i properly check that EntityPlayerSP is mounting a horse with an specific item in hand so i can prevent it @Mod.EventHandler public void onInit(FMLInitializationEvent event) { Main horseStats = new Main(); FMLCommonHandler.instance().bus().register(horseStats); MinecraftForge.EVENT_BUS.register(horseStats); } @SubscribeEvent public void onInteract(PlayerInteractEvent.EntityInteractSpecific event) { EntityPlayerSP player = Minecraft.getMinecraft().player; if (event.getTarget() instanceof EntityHorse) { if (event.getHand() == EnumHand.MAIN_HAND) { if ((player.getHeldItemMainhand().getItem() == Items.NAME_TAG) && (player.getHeldItemMainhand().getDisplayName().equalsIgnoreCase("Name Tag"))) { if (System.currentTimeMillis() - this.lastTime > 600L) { this.lastTime = System.currentTimeMillis(); sendInfo(player, (EntityHorse) event.getTarget()); } } } } } public void sendInfo(EntityPlayerSP player, EntityHorse horse) { double speed = horse.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue(); double jump = horse.getHorseJumpStrength(); DecimalFormat df = new DecimalFormat("0.00"); String jumpBlock = df.format(-0.1817584952D * Math.pow(jump, 3.0D) + 3.689713992D * Math.pow(jump, 2.0D) + 2.128599134D * jump - 0.343930367D); df = new DecimalFormat("0.0"); player.sendMessage(new TextComponentString(ChatFormatting.GRAY + "[" + ChatFormatting.DARK_GRAY + "HorseStats" + ChatFormatting.GRAY + "]" + ChatFormatting.WHITE + " Dit is een " + df.format(43.1111111D * speed) + " paard die " + jumpBlock + " blokken hoog springt!")); } }
  7. Yea thats what i thought aswell but i dont know how to do that?
  8. Here is the result i am currently getting. https://gyazo.com/d28209b22ba48fcba31e4acde3d60f59 So i thought. To solve this i have to tell the server that i canceled the event and that i am not actually on the horse but im not sure how to do that. Btw this is on a deticated server.
  9. Thank you very mucht. Im facing another issue currently. @SubscribeEvent public void onMount(EntityMountEvent event) { EntityPlayerSP player = Minecraft.getMinecraft().player; if ((player.getHeldItemMainhand().getItem() == Items.NAME_TAG) && (player.getHeldItemMainhand().getDisplayName().equalsIgnoreCase("Name Tag"))) { if (event.isMounting() == true) { if (event.getEntityMounting() != null) { if (event.getEntityMounting() instanceof EntityPlayer) { if (event.getEntityBeingMounted() instanceof EntityHorse) { event.setCanceled(true); } } } } } } Basically if im holding a nametag and trying to mount a horse it has to dismount or cancel the action. I canceled the action so i dont mount the horse. Now how do i tell the server that i canceled the event? Because currently on my screen im not on the horse but the server thinks i am. Thanks in advance im really learning stuff here!
  10. Edit: Figured it out. Im a retard >.> @SubscribeEvent public void onEntityMount(EntityMountEvent event) { if(event.getEntityMounting() instanceof EntityPlayer) { if (event.getEntityBeingMounted() instanceof EntityHorse) { EntityPlayerSP player = Minecraft.getMinecraft().player; double speed = 14.3D; player.sendMessage(new TextComponentString("This is a " + speed)); } } } } Adding solved it.: EntityPlayerSP player = Minecraft.getMinecraft().player;
  11. I dont get it... So appearantly i am accessing client only code on the server? How could that lead to a NullPointer exception that only shows up when adding a int or a double to TextComponentString. Thanks in advance.
  12. Hey guys, Im bussy with a horse mod. Once you mount the horse it shows you the speed etc via a chatmessage. But i keep getting a null pointer exception when adding double and int values to TextComponentString any idea? This works: https://gyazo.com/5a371815b692aa6b8ad4d07a7e26d163 This doesnt (eg nullpointer exception): https://gyazo.com/e648adf81b24f6f67e44a2028c898ee0 Ive tried:https://gyazo.com/d0d82f7b3b67bf1b59f62f4b3fc41557 Any help would be appreciated!
  13. Hey guys, I am quite unexperienced but i am learning what i can. But i cant seem to solve two errors maybe you guys can help me? private boolean hasArmor(EntityPlayer player) { net.minecraft.item.ItemStack[] armor = player.inventory.armorInventory; if ((armor != null) && ( (armor[0] != null) || (armor[1] != null) || (armor[2] != null) || (armor[3] != null))) { return true; } net.minecraft.item.ItemStack[] armor = player.inventory.armorInventory; is giving me the following error >: cannot convert from NonNullList<ItemStack> to ItemStack[] Next error /* */ public float[] getRotationsNeeded(Entity entity) { /* 197 */ if (entity == null) /* 198 */ return null; /* 199 */ double diffX = entity.posX - this.mc.player.posX; /* */ double diffY; /* */ ;//double diffY; /* 202 */ if ((entity instanceof EntityLivingBase)) { /* 203 */ EntityLivingBase entityLivingBase = (EntityLivingBase)entity; /* */ /* */ /* */ /* */ /* */ /* 209 */ diffY = entityLivingBase.posY + entityLivingBase.getEyeHeight() * 0.9D - (this.mc.player.posY + Minecraft.getMinecraft().player.getEyeHeight()); /* */ /* */ } /* */ else /* */ { /* */ /* 215 */ diffY = (entity.boundingBox.minY + entity.boundingBox.maxY) / 2.0D - (this.mc.player.posY + Minecraft.getMinecraft().player.getEyeHeight()); } /* 216 */ double diffZ = entity.posZ - this.mc.player.posZ; /* 217 */ double dist = MathHelper.sqrt(diffX * diffX + diffZ * diffZ); /* */ /* 219 */ float yaw = (float)(Math.atan2(diffZ, diffX) * 180.0D / 3.141592653589793D) - 90.0F; /* 220 */ float pitch = (float)-(Math.atan2(diffY, dist) * 180.0D / 3.141592653589793D); /* 221 */ return new float[] {this.mc.player.rotationYaw + /* */ /* 223 */ MathHelper.wrapDegrees(yaw - this.mc.player.rotationYaw), this.mc.player.rotationPitch + /* */ /* */ /* 226 */ MathHelper.wrapDegrees(pitch - this.mc.player.rotationPitch) }; /* */ } diffY = (entity.boundingBox.minY + entity.boundingBox.maxY) / 2.0D - (this.mc.player.posY + Minecraft.getMinecraft().player.getEyeHeight()); } is giving me "The field Entity.boundingBox is not visible". Thanks!
×
×
  • Create New...

Important Information

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