Jump to content

Major Squirrel

Members
  • Posts

    117
  • Joined

  • Last visited

Everything posted by Major Squirrel

  1. Good evening, I'm currently trying to get a field from the ItemArmor class : ItemArmor.maxDamageArray. Using the ReflectionHelper, it works great on Minecraft Client and Minecraft Server configurations. However, I've tested the mod on a friend's server and it doesn't work : NoSuchFieldException. At first, I was using a string to retrieve the field (maxDamageArray), it didn't work. Then I tried to get the value from the declared fields array, it didn't work. I was really surprised to see that it didn't work. Then I took a look at the vanilla server.jar and all the classes (and surely the fields) were obfuscated : I felt really stupid but I learnt something new so it's okay. From now, I suppose I have two ways : either I have to get a deobfuscated version of the server to get it work, or I have to work with the obfuscation which seems to be really complicated. Could you advise me on what should I do now, or what should my friend do to get it work ? By the way, he's using forge-1.8.9-11.15.1.1763-universal.jar Thank you for your time and my apologizes if this is related to a Java issue. EDIT: more info, I use gradlew build to build my mod so that my friend can put in on his server.
  2. Yes, I did know that, I took some time last days reading the Sides concept on readthedocs. Ok, that makes more sense to me now, thank you all. If I have the possibility to open the gui calling EntityPlayer#openGui directly, then I can do it. Otherwise I would need to send a packet from client to server (will be handled to the server then) that will be able to make some checks then opening the gui. That means the packet will be handled in the client ? Which method should I call then ? EntityPlayer#openGui to pass through the GuiHandler or another one from Minecraft base code ?
  3. Actually, I do this : @Override protected boolean interact(EntityPlayer player) { ItemStack itemstack = player.inventory.getCurrentItem(); boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg; boolean flag2 = itemstack != null && itemstack.getItem() == Items.name_tag; if (this.isEntityAlive() && !player.isSneaking()) { if (this.worldObj.isRemote) { player.openGui(Main.instance, Reference.GuiIdentifiers.GUI_MERCHANT, this.worldObj, this.getEntityId(), 0, 0); } return (true); } else if (flag && player.isSneaking()) this.setDead(); else if (flag2 && player.isSneaking()) { this.changeCustomName(); } return super.interact(player); } the isRemote being true is just a test to open a GuiScreen to draw the Entity currently rightclicked the same way it happens when you open a horse inventory. I think I have to tell you what I really want to do. In fact, I have so much questions that are related to my goal but can't be asked in the context of this topic. I want to create an EntityMerchant that acts as an EntityVillager. When rightclicking on it, it opens an interface in which the player can trade with the merchant. While the interface is open, . The EntityMerchant clicked is being drawn on the gui and all the possible trades that the player can do are related to the entityId. When the player quit the interface, the music stops. For this goal, I suppose I have to trade my GuiScreen for a GuiContainer. This would require a server handling. That is all I've thought about for now.
  4. Ok so if I follow your way of coding in order, in my case it would be : Client right clicks on entity --> sends a packet that will be handle to the server --> server decides whether or not to let the client open the gui --> (admitting yes) call openGui method In there, the packet will just be useful to do some "tests" or requirements before deciding to open the gui or not ?
  5. Thank you guys. Yet, something bugs me : what would be the interest to go through a packet to open a gui instead of opening it directly ? In my case, I can avoid using a packet to open the gui, since I can directly pass the entity id in the openGui method. I saw few posts on this forum that advise to use packet to open gui.
  6. Good evening guys, I'm currently trying to create a custom EntityMerchant. Basically, it works the same as the EntityVillager from Minecraft, except that I want to control all the transactions for each merchant (from a DB for example). My entity is currently created, its name is Timmy (yes), and I can't figure out how I could pass the entityId to a gui triggered from server side, so that I can get an Entity object once the gui is open. I took a look at the EntityVillager code : when interacting with the Entity, it displays the villager trade gui passing the Entity (as this) : /** * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. */ public boolean interact(EntityPlayer player) { ItemStack itemstack = player.inventory.getCurrentItem(); boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg; if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking()) { if (!this.worldObj.isRemote && (this.buyingList == null || this.buyingList.size() > 0)) { this.setCustomer(player); player.displayVillagerTradeGui(this); } player.triggerAchievement(StatList.timesTalkedToVillagerStat); return true; } else { return super.interact(player); } } Looking more closely at the code, it seems that a S2DPacketOpenWindow packet is sent. The thing that I don't understand is the way I could possibly do the same (or the entityId), using Forge GuiHandler. Sending a packet ? Why not, but what after then ? Furthermore, LexManos shared a trick to pass the entityId through an int (can't find the topic) in the getServerGuiElement method from GuiHandler, but I still don't know what to do next. It is some kind of missunderstanding here that I would like to kill. Thank you for your time and you help.
  7. If server side isn't able to handle multithreading, why would be the point to rent servers with huge cpu ?
  8. Thank you for your reply jeffryfisher, It seems that Minecraft has a non-dev-friendly side in there. About the recipes, I think I will just use 1.9 fence patterns to make my walls recipes, and when i will update to 1.9, I will reverse the process.
  9. Good evening, I'm trying to make more wall blocks (from BlockWall class), for now it does work but I feel I am doing it the wrong way. Here is a screenshot of what I accomplished from now : http://s11.postimg.org/ptxdoyv83/2016_03_09_19_56_27.png[/img] At first thoughts, I felt that I had to extend the BlockWall class to get a full compatibility between my custom walls and the basic ones (regarding blocks connections for example). When I did this, I encountered some problems : I couldn't add values to the EnumType inside the BlockWall class. So I decided to make my own PropertyEnum but then it crashed because it obivously waited for the default EnumType and not my custom one. On second thoughts, I decided to copy the BlockWall class and I changed the EnumType class to implement my own one, changing some values moreover. There I dunno why but I couldn't access to some protected final variable from Block class (yet, I extended my custom one from Block) so I had to put some "default" values for hardness or resistance (if you don't know what I mean, take a look at the BlockWall constructor for setHardness and setResistance, etc). It does work for now, but I feel that this way is not the right one, furthermore the maintainability or the .json blockstates is awful (see the file). Did everyone achieve this with an easier way ? Do you have some tips to give me to facilitate the work I've already done and so make it more maintainable ? Oh and for last, I have a little problem here that I encountered with another block (BlockCrop) too : when registering the models, it can't find the model definition for inventory : Model definition for location questsystem:block_wall_custom#inventory not found But it registers the other models sucessfully. I saw in some codes that I can manually put the "inventory" variant in the .json file but I was wondering if it was the right way ? BlockWallCustom.java ItemBlockMeta.java BlockWallCustomVariants.java block_wall_custom.json Thank you in advance for your help UPDATE1: fixed inventory registration, I just forgot the .json file in the models/item folder, I'm a bit ashamed. Finally, it does not work, lel.
  10. Is accessing to the player worldObj okay ? @SubscribeEvent public void onArmorWorn(TickEvent.PlayerTickEvent event) { Double result = 0.0D; Item itemArmor; AttributeModifier armorSlowModifier; IAttributeInstance attributeInstance; if (!event.player.worldObj.isRemote && event.phase == TickEvent.Phase.START) { for (int index = 0; index < 4; ++index) { if (event.player.getCurrentArmor(index) != null) { itemArmor = event.player.getCurrentArmor(index).getItem(); result += ItemArmorHelper.getSlowValue(itemArmor); } } result = (1.0D / (1.0D + (result / 1.5D) / 2.0D)); armorSlowModifier = new AttributeModifier(heavinessModifierMalus, "Armor heaviness malus", result - 1, 2).setSaved(false); attributeInstance = event.player.getEntityAttribute(SharedMonsterAttributes.movementSpeed); if (attributeInstance.getModifier(heavinessModifierMalus) != null) attributeInstance.removeModifier(armorSlowModifier); attributeInstance.applyModifier(armorSlowModifier); } }
  11. Thank you diesieben07, I was wondering if I had to check the side of the event (Side.CLIENT or Side.SERVER) since it is a calculation assigned to the player ? I don't understand in which way I should handle sides in events...
  12. At the moment I'm facing a problem : I would like to add a slow effect (not the enchant) to the player when wearing basic Minecraft armors. There is a specific value for each piece of armor, made of each ItemArmor.ArmorMaterial. I suppose I have two possibilities : the first one would be to re-create the existing armors, adding my own onArmorTick event and registering the Items as a substitution, but it seems that it doesn't work very well (cf. Choonster post above). The second one would be to catch a specific TickEvent for my uses and checking each piece of armor the player is wearing, but it is called every tick for players and not every tick for pieces being worn. I would implement this for a private server, and I can't really imagine how fast/slow it would be.
  13. Yeah I paid attention to your thread few days ago, in fact I was wondering if this was fixed in next builds or not. However, the thing that bothers me with events or hooks is that I have to use them as I implement new types of blocks or items, instead of coding them in their own class and be quiet.
  14. There is no way to try the substitution aliases for blocks and item ?
  15. Good evening, This question has surely be asked but I couldn't find an available answer for 1.8.9 with the search engine. Is it possible to change the loot values/probabilities of Minecraft basic entities, and blocks such as BlockBushes ? Also, can I easily change the saturation of existing food ? I suppose this is possible for BlockCrop/BlockBush and ItemFood, using substitution aliases, but I can't see any way for existing entities in Minecraft.
  16. Thank you for the reference. I will keep this link to take a look at implementation ! I didn't think about that ! Thank you too. I will mark this as solved since you both gave explanations and ways to implement it !
  17. Thanks Draco18s for the tip. Is there any way to make it craftable from a basic workbench ? (If not, I would suppose that the "1 unit" consumption is coded in the workbench directly)
  18. Good evening, Everything is in the title. I tried myself using new ItemStack(Items.something, 3) for testing, it obviously didn't work. According to a Wuppy's tutorial, it seems that it isn't possible to do it. But his tutorial is dated from 2014, and I'd like to know if anyone had achieved it for 1.8.9 ?
  19. Thank you very much Choonster, it does work very well ! Before locking this topic and marking it as solved, could you tell me where did you find the code in Minecraft sources ? I couldn't find it, I'm bad.
  20. Good morning, I solved the problem of Item durability. I didn't extend my custom bow to the Minecraft ItemBow class. I had to do this to pass my Item into a specific method from ItemStack, especially a specific if condition : /** * Damages the item in the ItemStack */ public void damageItem(int amount, EntityLivingBase entityIn) { if (!(entityIn instanceof EntityPlayer) || !((EntityPlayer)entityIn).capabilities.isCreativeMode) { if (this.isItemStackDamageable()) { if (this.attemptDamageItem(amount, entityIn.getRNG())) { entityIn.renderBrokenItemStack(this); --this.stackSize; if (entityIn instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entityIn; entityplayer.triggerAchievement(StatList.objectBreakStats[item.getIdFromItem(this.item)]); if (this.stackSize == 0 && this.getItem() instanceof ItemBow) { entityplayer.destroyCurrentEquippedItem(); } } if (this.stackSize < 0) { this.stackSize = 0; } this.itemDamage = 0; } } } } if (this.stackSize == 0 && this.getItem() instanceof ItemBow) only checks for instances of the ItemBow : once I extended my custom bow to the correct one, my Items got destroyed well ! The only problem left is a new one : when using the Minecraft ItemBow, there is a special effect(/render ?) that "zooms" the player vision, to better aim the target. Even extending the ItemBow, it doesn't work on mine, could you guys give me some help/tips there ?
  21. Thank you for you explanation ! I understand better how Minecraft model loading works. The only problem left is the Item durability, I didn't find where the problem could come from. Example : for the custom bow, the durability is set to 3. I can shoot 4 arrows in-game, so it seems that it is +1 in-game (according to the Bow wiki page). After shooting four arrows, the player can hear the "broken object" sound and sees the Item with the red zero over it. It just has to rightclick on the Item so that it disappears. I think I might miss something.
  22. Override Item#getModel to return the ModelResourceLocation of the appropriate model based on the remaining use time (using the same logic as the vanilla bow). You can see an example of this here (model registration is here and here[/urk]). Thank you Choonster, you're the man. Just a question about your code, I don't understand what does your filter do and how do you do to register models in inventory or in hand, in your ModModelManager ? (for now the "pulling models" display successfully in game, thanks to you) Furthermore, why do we have to register our items models from blockstates, especially for bows ?
  23. Good evening, I'm having trouble rendering a custom bow when the player is using it. I noticed that Minecraft has a String array inside the ItemBow class that contains three "bow states" : pulling_0, pulling_1 and plluing_2, and I simply can't find in the code where Minecraft does register their models. I found out how to register the bow on standby, but not the bow on its different pulling states. Furthermore, I'm having trouble with the custom bow item duration. Basically, my custom bow is just a copy/paste of the Minecraft ItemBow (for training purposes) except that I change the maxDamage variable of the Item. For the base ItemBow, the wiki says that its maxDamage default value is 385. I changed it to 4 on my custom one : it works well, meaning that I can shoot four times with my bow, but then it displays the Item with a red zero over it (instead of breaking and disappearing) : http://s12.postimg.org/8ur9z9wrx/2016_03_05_15_01_12.png[/img] Then, when rightclicking on the Item, it just disappears. I must admit I would need a little help here. ItemBow.java (my custom one) Thank you in advance for your time and your precious help. EDIT: currently working on the "pulling bow" models thanks to this topic UPDATE1: after registering the "pulling bow" models, I don't know how to tell the game to render the current bow state model. It seems that it is hardcoded, for the base bow, in RenderItem#renderItemModelForEntity method located in the net.minecraft.client.renderer.entity package. I would need some further infos here. see Choonster answer below !
  24. Hey again, I decided not to use the Item. I definitely wanted to try the block first, and now I'm facing a problem. I don't know which code to trigger on the server side and which one on the client side. Where do I have to register the GuiHandler, client or server ? EDIT: I just read diesieben07 explanation but I don't fully understand it.
  25. Good afternoon, I am bringing you some news. I learnt a lot from coolAlias tutorial and managed to understand some basic Container knowledges such as stacks transfers, slots indexes... I managed to make a nice lil' gui and it works perfectly for now. However, I still don't know how could I implement the consumption part for an Item. I don't need to store data when I close the Item gui : the player can only use the item when he's on it. I would need to store the consumption time, update it every tick and send some data to update the progress bar of the consumption, but all of this seems to be done in the TileEntity (for the furnace) and I don't fully understand how can I accomplish this for an Item. Could you give me some tips ? Following files : ModContainer.java ContainerSieve.java GuiSieve.java
×
×
  • Create New...

Important Information

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