Jump to content

BusyBeever

Members
  • Posts

    201
  • Joined

  • Last visited

Everything posted by BusyBeever

  1. My mistake was the wrong ElementType for the event. ElementType.Experience works fine
  2. Well ur code works, so I got something to work with but there is one thing u should seriously improve Integer.parseInt("FFFFFF", 16) Replace that with 0xFFFFFF .. What u are doing is slow and dirty
  3. Hey everyone, first of all I know a lot of people will be complaining that 1.7 is ancient, but I cant update until mods I depent on do. I got an GUIOverlay that is supposed to render text to the screen. It works fince in 1.10 (with some minor adjustments to the newer version) but in 1.7 there is no text showing, and I have no idea why. The code is getting called, I see my sysout on the console @SubscribeEvent public void onRenderExperienceBar(RenderGameOverlayEvent event) { if(holder==null) holder = QuestHolder.get(); if(event.isCancelable() && (event.type==ElementType.ALL)) { mc.getTextureManager().bindTexture(texture); ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); int i=0; int height = 30; mc.fontRenderer.drawStringWithShadow("Test", sr.getScaledWidth()/2, sr.getScaledHeight()/2, 0xFFFFFF); for (Quest quest : holder.getQuests()) { System.out.println(holder.getQuests().size()); if(!quest.isFollowed()) { mc.fontRenderer.drawString(quest.getName(), 100, height, WHITE); for(Condition condition:quest.getConditions()) { i+=1; mc.fontRenderer.drawString(condition.getDescription(), 30, height+10*i, condition.isFinished()? GREEN: RED); } i=0; height+=50; } } } }
  4. to be honest. it doesnt matter if I have Minecraft.getMinecraft().thePlayer in the handler method, because I am 100% sure that when I am inside this method it is on client side. But changing to the other event isnt helping..
  5. This should be everything that is problem related.. I found one solution but that one sucks seriously EventHandler @SubscribeEvent public void playerJoined(final PlayerLoggedInEvent event) { final QuestHolder holder =event.player.getCapability(CapabilityQuestHolder.CAPABILITY_QUEST_HANDLER, null); /* *Dirty workaround .. new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } for (Quest quest : holder.getQuests()) { Questmod.network.sendTo(new PacketAddQuest(quest), (EntityPlayerMP) event.player); } } }).start(); */ for (Quest quest : holder.getQuests()) { Questmod.network.sendTo(new PacketAddQuest(quest), (EntityPlayerMP) event.player); } } PacketHandler @Override public IMessage onMessage(final PacketAddQuest message, MessageContext ctx) { Minecraft.getMinecraft().addScheduledTask(new Runnable() { @Override public void run() { QuestHolder holder = QuestHolderHandler.get(); holder.addQuest(message.quest); System.out.println(holder.getQuests().size()); } }); return null; } QuestHolderHandler#get @SideOnly(Side.CLIENT) public static QuestHolder get() { System.out.println(Minecraft.getMinecraft().thePlayer); //Prints null return Minecraft.getMinecraft().thePlayer.getCapability(CapabilityQuestHolder.CAPABILITY_QUEST_HANDLER, null); //Crash happens here (obvious reasons) } Crashlog
  6. Well. This reduced the occurency of the error but didnt removed it.. Its still there sometimes.
  7. Tarded me. Thank you very much ernio
  8. You just need to increment degrees on client side. I dont know the best place to do it, but doing it every time you render it will do the trick, althought there might be better solutions
  9. Hey everyone, I need to send data from server to client whenever the client joins (some quests) My problem is that I cant find the correct event for it. I felt like PlayerLoggedInEvent should do the job, but sometimes the packet is "so fast" it reaches before Minecraft.getMinecraft.thePlayer is populated, which I need. So what event do I use, what am I missing? SideNote: Yes I know I should replace the PacketAddQuest with one Packet to sync allquests when the player joins, but thats a task for later EventHandler @SubscribeEvent public void playerJoined(PlayerLoggedInEvent event) { QuestHolder holder =event.player.getCapability(CapabilityQuestHolder.CAPABILITY_QUEST_HANDLER, null); for (Quest quest : holder.getQuests()) { Questmod.network.sendTo(new PacketAddQuest(quest), (EntityPlayerMP) event.player); } } PacketAddQuestHandler @Override public IMessage onMessage(PacketAddQuest message, MessageContext ctx) { QuestHolder holder = QuestHolderHandler.get(); holder.addQuest(message.quest); return null; } QuestHolder#get @SideOnly(Side.CLIENT) public static QuestHolder get() { System.out.println(Minecraft.getMinecraft().thePlayer); //null sometimes return Minecraft.getMinecraft().thePlayer.getCapability(CapabilityQuestHolder.CAPABILITY_QUEST_HANDLER, null); }
  10. you should not be copy pasting code that a tutorial guy made.
  11. Hey everyone, I was out of modding for a while and missed the jump to 1.10. So I want to catch back up and ask for a good guide of changes to 1.10. Things that went deprecated, things we should use now, new nifty stuff the forge modding team gave us etc Greetz BusyBeever
  12. you still need to call World#spawnEntityInWorld (I think that was the method name) on the world object where u want to spawn the entity
  13. you can use 1.9 tutorials. 1.8 is also fine for most of forge, 1.8 is easy to update with solid java knowledge
  14. It gets called once for server, once for client side. makes two
  15. http://www.minecraftforge.net/forum/index.php?topic=12753.0
  16. use github/bitbucket (git)
  17. You can check if the item has a result in furnace recipes and then do what diesieben said
  18. So you are in 1.9 right? Then you must see that big compile error you get because you need to return an action result
  19. Check out youtube, there is enough if you need detailed explanations
  20. you dont need the information who is shooting the bullet on client side. applying damage should be done on server side. see ernios post..
  21. depende on where you need. you need it to get passed in the method where you want to use it. if you dont understand that learn java and come back
  22. To be honest it is okay to use it directly in netty context, because if you have a packet that you send from server to client side you always know that you are safe to use Minecraft.getMinecraft()
  23. onBlockRightClick get the item in players hand, check for null, if its not null you can do stack.stacksize++
  24. Don't copy paste code you don't understand
×
×
  • Create New...

Important Information

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