Dread_Boy Posted August 4, 2016 Share Posted August 4, 2016 This is a mockup of my idea: http://imgur.com/a/VJPNA. It's automatic villager trading mod that simulates player's trading. Is it possible to do this in a way it would be useable also on vanilla servers? Trade with villager until it's locked, close UI, look away for few seconds, look back, trade again... Trade order would be determined in UI, check the pictures. If you have any feedback, feel free to voice it. I've already installed Eclipse and created sample mod, where would I go from there? I can code but I find Forge docs ... lacking? It explains 1.7 to 1.8 transition but almost nothing other than that. All tutorials I found are mostly targeted for beginners. And last question. What causes lag with XP farms? Pure amount of entities, mobs colliding and being forced to stay in one block or their pathfinding (fucked again because they are in one block)? I'm talking about client lag (FPS dropping), not necessarily server lag. If it is possible to reduce lag, I would also like to write 2nd mod that would address this issue. Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2016 Share Posted August 5, 2016 What do you mean automatic? Are you going to make a new block that opens a Gui and allows players to select possible villager trades? Or is the block going to be placed next to a villager and it will access that inventory to deal with trades? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Dread_Boy Posted August 5, 2016 Author Share Posted August 5, 2016 Nothing of that sort, it's should also work on vanilla servers. You could also call it a hack as it will allow automatic trading... Right now I can do semi-automatic trading with autohotkey script but I wish to replace this with a mod. There will be no block or item, just two buttons added to vanilla villager screen. First one will start trading, 2nd one is for settings (trade orders and such). Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2016 Share Posted August 5, 2016 You would have to override when the player right clicks on the Villager and display a new gui/container which you can't do on a vanilla server. Actually you may be able to subscribe to a ClientTickEvent and check if the players currentScreen is the villager one and if so replace it. Though client tick event could cause lag. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Draco18s Posted August 5, 2016 Share Posted August 5, 2016 You know there is a PlayerContainerEvent that is fired whenever the player opens (or closes) a gui related to a container (of which the GuiMerchant is) as well as the GuiOpenEvent when ever the player....opens a gui (which the GuiMerchant is). Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2016 Share Posted August 5, 2016 You know there is a PlayerContainerEvent that is fired whenever the player opens (or closes) a gui related to a container (of which the GuiMerchant is) as well as the GuiOpenEvent when ever the player....opens a gui (which the GuiMerchant is). Actually I did not though I makes sense that there is those sound mighty useful, though I have never had to do anything like that before. But is it possible to register GuiOpenEvent only client side and have it work? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Leviathan143 Posted August 5, 2016 Share Posted August 5, 2016 You know there is a PlayerContainerEvent that is fired whenever the player opens (or closes) a gui related to a container (of which the GuiMerchant is) as well as the GuiOpenEvent when ever the player....opens a gui (which the GuiMerchant is). Actually I did not though I makes sense that there is those sound mighty useful, though I have never had to do anything like that before. But is it possible to register GuiOpenEvent only client side and have it work? Yes, any eventhandler can be registered on both sides or just one. The subscribed events do have to be fired on that particular side of course. Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2016 Share Posted August 5, 2016 Yes, any eventhandler can be registered on both sides or just one. The subscribed events do have to be fired on that particular side of course. Alright I have never made an only server side mod or a client side mod before good to know. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Dread_Boy Posted August 5, 2016 Author Share Posted August 5, 2016 Great, I'll take a look at events you are describing. How would I go about overlaying these 2 buttons on top of vanilla GUI? Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 5, 2016 Share Posted August 5, 2016 You wouldn't be overlaying you would be creating a new Gui in general, the easiest way would be to extend GuiMerchant and in init add Buttons. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Dread_Boy Posted August 7, 2016 Author Share Posted August 7, 2016 Great, I've been trying to get it working but I can't. Removing all unused or irrelevant code: public class GuiAutoMerchant extends GuiMerchant { GuiButton buttonStart; public GuiAutoMerchant(InventoryPlayer inventory, IMerchant merchant, World worldIn) { super(inventory, merchant, worldIn); // TODO Auto-generated constructor stub this.buttonList.add(this.buttonOptions = new GuiButton(0, 100, 100, 200, 200, "Options")); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { // TODO Auto-generated method stub super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); System.out.println("Drawing default merchant GUI"); } } But my button doesn't show up. I opted to draw default Villager GUI but even with custom background GUI, button wasn't displayed. What am I missing? Quote Link to comment Share on other sites More sharing options...
Dread_Boy Posted August 8, 2016 Author Share Posted August 8, 2016 Apparently, I have to add buttons in initGui instead of constructor: @Override public void initGui() { // TODO Auto-generated method stub super.initGui(); this.buttonList.add(this.buttonStart = new MerchantButton(0, guiLeft + xSize - 28, guiTop + 45, MerchantButton.textureStart)); this.buttonList.add(this.buttonOptions = new MerchantButton(0, guiLeft + xSize - 28, guiTop + 61, MerchantButton.textureOptions)); } Quote Link to comment Share on other sites More sharing options...
Draco18s Posted August 8, 2016 Share Posted August 8, 2016 Yes. Yes you do. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.