-
Posts
157 -
Joined
-
Last visited
Everything posted by Torojima
-
my mod is adding a plant. Plant-able from seeds and growing in a few steps from stem to the grown plant. For that I have added an event listener for the BonemealEvent and have it trigger the growing and decreasing of the current itemStack. The growing of the plant is working as before, but the decreasing of the current itemStack does not. When asking the entityPlayer of the BonemealEvent for it's current item stack(1) the itemStack object is null. Even tho, the active item (the item visible in hand) is a stack of bonemeal. Now I know, the behaviour of bonemeal has changed in 1.5, what I don't know is exactly how and how I get the bonemeal to be used ... Edit: even the EntityPlayer is very odd ... when I ask it for it's username I will receive "[Minecraft]" instead of the expected username ... is there a tutorial somewhere for bonemeal use in 1.5 already? --- 1) both event.entityPlayer.inventory.getCurrentItem() as event.entityPlayer.getCurrentEquippedItem() have the same outcome
-
in my event handler I've done the following @ForgeSubscribe public void onBurnDamage(LivingAttackEvent event) { if(event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)event.entity; if(event.source.equals(DamageSource.lava) || event.source.equals(DamageSource.inFire) || event.source.equals(DamageSource.onFire)) { if(player.ridingEntity instanceof EntityChocoboPurple) { event.setCanceled(true); } } } } } which works fine. riding one of my mobs the player can walk through lava, without he'll get his but burned
-
that would be exactly what I am looking for And even as this will make me sound like a complete idiot ... I can not find the described event?! (looking in the package net.minecraftforge.event and respective sub packages... help??) Edit: Anybody any ideas? I have tried EntityJoinWorldEvent with a check if the contained entity is of the EntityPlayer class, but with no prevail ... the event listener is called a hell lot of times for a hell lot of entities as soon as I connect to the server (with calls on server and client side). But no entity is of class EntityPlayer ...
-
I would like to have a special feature of my mod switchable from the server. Thus, if the server host would like to switch the feature on, it will be used as soon as the client is connecting to the respective world, even if the client itself has switched the feature off. But if the client is connected to the internal server, the local setting should be used. (a feature that would be somewhat annoying in ssp, but help reducing the overpowered impact of the mod on smp) Now, the mod initialisation will be done when the client is started, not when the client connects to a world. I thought about a request packet from the client send to the server, which responds with a packet for the client with the respective flags. But ... how can I trigger this event (client connects to the server) to send this messages? (should be triggered again when the client is connecting to the internal server to get the local settings...) And... is there any other more sophisticated way to get a server flag override the client flag when connected
-
How to properly create living entities?
Torojima replied to x2robbie2x's topic in General Discussion
I do all spawning of entities solemnly on the server. Afaik, somebody correct me if I'm wrong, the trigger methods (for example a right click with an item) will be executed on the client and server simultaneously. Thus I check right before the creating of the new entity instance and its spawning if I'm on the server side and only then will spawn. An exception for that of course is a GUI. They only exist in the client side as mentioned before. Here I would have the GUI trigger the sending of a network packet from the client to the packet handler on the server and have the packet handler trigger the correct spawning method on the server... -
yes, very simple, if one would not have organised ones classes in structured packets, but shoved them all into the net.minecraft.src packet. If not one has the problem of the EntityPlayer.isImmuneToFire beeing protected and only available for classes in the above mentioned packet (or classed derived from EntityPlayer). Both options are imho not very attractive. Installing a class in the net.minecraft.src packet only to gain access to the protected fields would be something on my wish-list for the used API and deriving a class from EntityPlayer proprietary only to a specific mod is again imho also not very advisable. The only option left would be reflections, but using that I always feel like a bank robber opening a save with high explosives ... So I guess, my question has been asked slightly wrong. No, not the question, but the explanatory statement before. My problems do not derive from the 1.3.2 update, but from the fact that I have started to organise my code better in structured packets different to the main minecraft src packet. My question stays the same ... is there a way in forge to access this particular field (EntityPlayer.isImmuneToFire)? If not could it go into the planing to incorporate a respective access to these fields from the outside. I would like to follow a policy to not put any of my code into the minecraft core packets, but only access what is visible from the outside or through Forge. If that's not possible, I do have to fall back to the EntityPlayer derived proprietary class in my mod only to access the protected fields ...
-
I am trying to put a list of names into a text field of a gui-view. I have tried to divide them by '\n' or '\r' both did not work. What is the line-break sign to use in the text field strings?
-
what icon will this new tab have?
-
Since the big update to 1.3.2 I have some problems setting the fire/lava immunity status of an entity from the outside. To be exact, I would like to have a player riding a certain mob in my mod gain fire/lava immunity. Thus I have to set the player entity to immune-to-fire from the mounted entity... Does anybody have any idea how to do this?
-
I have a IPacketHandler responsible for receiving packets from server to client and the other way round (thus only one packet handler and not two). The packets I'm using are Packet250CustomPayload packets. First entry is a custom packet id so the packet handler can recognise what to do with them. Now since the last update all routines working by sending packets from the client to the server do not work any more, while all routines working by sending packets form the server to the clients are working fine. I have no idea where to look for clues how to fix this. Does anybody have any pointers for me where I can start looking for faults? ChocoboPacketHandler.java abstract PacketChocobo.java example concrete PacketChocobo class PacketChocoboAttribute.java call of send method in entity class
-
I am trying to control the mob spawn rate at run time. Therefore I thought I could use the methodes public int getMaxSpawnedInChunk() original in EntityLiving and public boolean getCanSpawnHere() original in EntityAnimal But both are not called at all. Tho new entities of my class are spawned in a new world... Now I have the questions a) what method and at what time will call the above methods and b) if not with these methods how can I control the spawning rate of creature type entities?
-
I have build my network communication on one channel sending different classes of Packets, derived from the Packet250CustomPayload class. In the Packet handler I check for the class of the just received packet, to decide which class should do the handling: this works well on the SSP side. But, as I had to learn just now, crashes when I try to run my mod with an SMP server. The problem is, the Packet class does not know about my new Packet classes, so they produce a NullPointerException. The vanilla packets themselve are added statically, hard coded in the Packet class to the list of known Packets. Of course the Packet lists are not protected, but private... from the net.minecraft.src.Packet class: now there is a static method in the Packet class adding new Packets to the list. In fact it is used in the static part of the Packet class to add the vanilla Packets to the above mentioned lists. and this time the method has no explicitly declared access modifier and thus it is effectively private (ARGH!!! sloppy programming, but I presume they would have made it private anyway ...). Thus even so, my Packet class is ultimately derived from the Packet class, I can not access the Packet list nor the add method, thus can not use my Packets in SMP (and I wonder how it is working in SSP in the first place). So, my suggestion is, could you have the Forge packet alter the Packet class so that a) the addIdClassMapping will receive the protected access modifier and b) there is a method to get the next free packetId to be used for the next Packet registration?
-
[solved]registering entities for mc-server
Torojima replied to Torojima's topic in General Discussion
but I still can not mark this topic as solved. The server is running, but no entities are spawning (spawn eggs do not work). Below is what I'm doing for spawning one of my entities. Do I miss anything I should do to wile spawning? here the code, please tell me if other parts are needed: both methods called in the main mod class in the @Init method (spawning after the registering obviously ), not limited to a special side. I've read about an EntityTracker, is this a direction I would have to pursue and seek more information? btw, the Entities are working well in the SSP version Edit: had been connected to my networking of communication Packet. I had created new Packet classes derived from Packet250CustomPayload, which minecraft has not recognised and thus prevented the communication and thus the spawning... Now I use the Packet250CustomPayload Packet itself for communication and all works well... -
quote from the bottom of the tutorial so if I do understand it correctly, the /path/to/your/ is relative to the minecraft folder and not the folder structure in the mod.zip... please correct me if I'm wrong ... But if I'm correct, I'm still pondering if there is a way to have the /path/to/your/ relative to the folder structure in the mod.hip file ...
-
[solved]registering entities for mc-server
Torojima replied to Torojima's topic in General Discussion
ok, didn't see that one coming... I do have a call of a GuiScreen (Class derived from GuiScreen that is) in my entity class. I thought putting it after a check for the client side would be sufficient, but of course the GuiScreen class has to be imported ... I have created a class designated for starting gui's and moved the Gui starting method and the respective import of the needed GuiScreen Class into it. So now my entity class is free of any GuiScreen imports Thanks Yes, the mod is no longer crashing the server and a world can be created. -
is there a way to access audio files out of the mod zip, without extracting them first and putting them into the minecraft resource folder? The tutorial at http://www.minecraftforge.net/wiki/Sounds_For_Forge_1.3.2 describes how to set a custom path to a sound file, but what's the path to a location inside the mod zip file?
-
my mod, dealing mainly with a new entity, is producing the following exception when a server is trying to produce a new world. Is there a special way to register entities so they can work for the server or does anybody know what else this exception is all about? The first line of code I can examine regarding this error is the SpawnerAnimal class, where at line 293 it tries to get the constructor of the entity classes ... since my entities work fine in the SSP version, I believe there is something wrong with registering the entities for the server side ... var21 = (EntityLiving)var8.entityClass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par0World});
-
Multiple Channels={" "} in a mod_.Java ?
Torojima replied to Jade_Knightblazer's topic in General Discussion
true, haven't thought about the channels as a limited resource. Also after changing to single-channel/multiple-packet-classes I found another nifty advantage Now my packet handler is very clean and tiny only checking what packet has arrived and calling the handler included in the respective class. (before that the packet handler had been crowded with the handlers ...) Now all code for one network action is packed together into one class and each packet class only is responsible for one network action. Looks nice, works well, what more to wish for -
Multiple Channels={" "} in a mod_.Java ?
Torojima replied to Jade_Knightblazer's topic in General Discussion
reading that, I'm doing it the other way too ... so, I'm pondering, what are the advantages and disadvantages of using a) single packet class (Packet250CustomPayload) and multiple channels and b) single channel and multiple placket classes. Realising now that of course the vanilla code uses 70+ different packet types, there has to be an advantage of using different packages instead of different channels... -
[solved] Damage to Entities not synchronised?
Torojima replied to Torojima's topic in General Discussion
now using a packetHandler, synchronising the damage myself and all works well -
so I came to the conclusion I have to do it completely myself with a PacketHandler. But is there a convenient time/place to trigger the send? Just in the routine doing the move itself would be imho a bit much for the sake of packet traffic. An elegant solution would be a request from the server to the client to send the current position right before updating the client position. But doesn't the server send it's packets via the PacketHandler only every now and then via a queue and not intermediately after giving the send order? Thus would such a construct be always late... Thus, is there a direct channel from server to client for such functionalities? and additionally, why can't I find anything regarding such issues in the vanilla boat or pig code? Or am I just to daft to recognise it?
-
[solved] Damage to Entities not synchronised?
Torojima replied to Torojima's topic in General Discussion
ok, then it's back to getting my PacketHandler up and running -
Very obviously I lack some experience with minecraft server mods, I hope I do not get to annoying with all the questions I'm trying to find the EntityPlayerMP object, but failing miserably ... When on the client side, getting the player object it's pretty obvious, I just get the minecraft client and get "thePlayer" ... But on the server side, how do I find the correct player object? Any pointers towards some examples?
-
[solved] Double Entity Spawning Problem ...
Torojima replied to Torojima's topic in General Discussion
yes, right now I'm doing both, below is a little method I'm using for registering my entities. Right now it looks like the entity registration works very well (got some other problems, but I hope to fix them too in the near future )