-
Posts
785 -
Joined
-
Last visited
Everything posted by ItsAMysteriousYT
-
Doing something when the player's foodlevel changes
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Thank you all - i solved it Now the only thing that needs to be solved is that the IEEP's do not persist through world save So - here is the complete IEEP class: And the method where i apply them in the event handler: @SubscribeEvent public void onEntityConstructing(EntityConstructing event) { if (event.entity instanceof EntityPlayer) if (RLMPlayerProps.get((EntityPlayer) event.entity) == null) { RLMPlayerProps.register((EntityPlayer) event.entity); System.out.println("Succesfully registered RLMProps"); } } -
Is it possible to display and interact with an html element inside of minecraft? Im planning to embed a YouTube video in one of my GuiScreens.
-
Doing something when the player's foodlevel changes
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
When i save the previous foodlevel to the IEEP's, do i have to add a client check to it? Cuz the prevFoodLevel only exists on ClientSide... Also, do you know how to save a custom enum to NBT? -
Doing something when the player's foodlevel changes
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Mmmm - okay, sounds quite logic - why was i so stupid? Anyway, ill try that -
Hey there,i am trying to add 5 to a variable in my extendedPlayerProps when the player looses some food. For this i look at player.getFoodStats.getFoodLevel&player.getFoodStats().getPrevFoodLevel. So now i check if the prevLevel is larger then the current foodlevel and add 5 to the value. But somehow either the value does only change on the server but not on the client (i saw that prevfoodlevel is @sideonly(side.CLIENT) so i change the value with packethandling under a world.isRemote-check) or it is changed instantly, but i checked - the prevFoodLevel only is changed when the player looses or gets some food - so when i substract the current foodlevel from the previous the sys.out looks like 0.0,0.0,0.0,0.0,0.0,0.0,-1,-1,0.0...). So - this is my code: The updatemehtod in my extendedplayerProperties: The packet: And the packethandler: Btw - YES i registered the packet and the handler properly(To side.SERVER cuz it is send to the serverSide) and the props are working too (except from the saving,but thats not necessary atm ). Hopefully this time i gave enough and detailed information about what i try, what is not working and all that Merry Christmas & Greetings - ItsAMysterious
-
Sure - here they are: The loadNBTData method: @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound tag = compound.getCompoundTag(EXT_PROP_NAME); // Loading the players name,gender & health name = tag.getString("Name"); surname = tag.getString("Surname"); gender = EnumGender.getFromString(tag.getString("Gender")); water = tag.getDouble("Waterlevel"); pee_value = tag.getDouble("Peevalue"); poop_value = tag.getDouble("Poopvalue"); energy = tag.getDouble("Energy"); money = tag.getFloat("Money"); // Saving all the counters timeWaterless = tag.getInteger("Time_Waterless"); waterlowmessagetime = tag.getInteger("WaterMessage_Time"); doneTutorial = tag.getBoolean("Tutorial_Done"); } And the getFromString method: And the gender stuff: package itsamysterious.mods.reallifemod.core.lifesystem.enums; public enum EnumGender { male,female; public static EnumGender getFromString(String string) { return EnumGender.valueOf(string.toLowerCase()); } public static String toString(EnumGender g) { return g.toString(); } }
-
This is my handler class, also the packet class is correct - with an empty constructor as it should be and with one that holds the different variables: package itsamysterious.mods.reallifemod.core.packets; import itsamysterious.mods.reallifemod.RealLifeMod; import itsamysterious.mods.reallifemod.core.RealLifeMod_Items; import itsamysterious.mods.reallifemod.core.lifesystem.RLMPlayerProps; import itsamysterious.mods.reallifemod.core.lifesystem.enums.EnumGender; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.IThreadListener; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; public class SetPropertiesHandler implements IMessageHandler<SetPropertiesPackage, SetPropertiesPackage> { public SetPropertiesHandler() { } @Override public SetPropertiesPackage onMessage(final SetPropertiesPackage message, final MessageContext ctx) { IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; mainThread.addScheduledTask(new Runnable() { EntityPlayerMP player = ctx.getServerHandler().playerEntity; @Override public void run() { RLMPlayerProps props = RLMPlayerProps.get(player); if(props==null){ System.out.println("Properties are NULL!!"); } props.name=message.name; props.surname=message.surname; props.gender=EnumGender.getFromString(message.gender); RealLifeMod.network.sendTo(new PropertiesSetPackage(), player); } }); return null; } } I think im getting just the wrtong player entity in the handler. I just don't know where to get the propper one. I heard that i have to do this with something called UUID, is that correct?
-
As far as i know yes, the handler is activated and tries to apply the properties just when i close the world and then reopen it it is not there anymore like entities when they are only spawned on the client side (when they don't move and have no hitbox etc - i think this happens when they are only on the client side).
-
HEy there, im trying to give the player a name using IExtendedEntityProperties. I apply these properties in the EntityConstructingEvent. Then i open a gui in wich the player should set a name. Now, on the client this works but somehow my packethandling errors. I think the player i get is wrong in the packethandler. See here these are my classes: PacketHandler: And the packet class: I need to get the propper player by the id from my package but i can't find the propper method for it
-
As i already said, i managed to get it working and the snippets from the first time did not work. Those from the second time work. And for the code, this is the whole class:
-
Ok, but youre the best modder i know - is it cuz im doing so many things wrong or cuz im annoing? If so, im sorry - im kinda special.
-
Oh, forgot to write that I call it in onUpdate like this: if (!worldObj.isRemote) { playSounds(); }
-
Sorry that u didn't reply - I managed to get the sound playing now like this: But what i actually trying to do is using my CustomSounds so i can change pitch and stuff, but it errors with a HashByMapError because the sound instance is already excisting. How can i solve this problem?
-
Hey there, im wondering if im doing something wrong when i try to play sounds. I think they have to be played on the client, right? But when i do this, it just keeps silent. Im doing this in the onUpdate method of my entity class like this: if(isClient()){ Minecraft.getMinecraft().getSoundHandler().playSound(this.startsound); } The startsound is an instane of MovingSound and is defined when the vehicle is being loaded from a textfile. What am i doing wrong?
-
Strange problems with vectors
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
I found out, that the values are prperly set in the vectors. The problem is, that the wheels are at the wrong position somehow. This is my EntityWheel class: -
Hey there, for my mod i load the wheelpositions of a vehicle from a textfile. The line that parses the text to a Vector3f is this: if (line.startsWith("wheelPositions: ")) { for (int i = 0; i < 4; i++) { String posVector = line.split(":")[1].split(",")[i].trim(); Vector3f position = new Vector3f(); position.x = Float.parseFloat(posVector.split("/")[0]); position.y = Float.parseFloat(posVector.split("/")[1]); position.z = Float.parseFloat(posVector.split("/")[2]); wheelPositions[i] = position; System.out.println(wheelPositions[i]); } } Now, my problem is, that when i look at the positions the first three are 1.0,1.0,1.0 and only the last vector holds the correct values from the file. Is this problem in the parsing code or somewhere else?
-
General Client-Serverside Questions
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Ahhh Yea yea, google my friend, i searched for YMMV and only found YMCA -
General Client-Serverside Questions
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Sorry, but what you mean with ymmv? -
Hey there, i have some questions related to minecraft(-forge)'s Client/Serverside workflow. They might sound weird, but i better ask than struggle with things that won't work the way i want them too: 1. When i set a value on Client, will it be sinqued on server automaticly(SOmetimes it seems like cuz there is no packethandling stuff) 2. Is it possible to say other entities to update their information about one entity from this one entity 3. Is there a possibility to create a packethandler for all of my packets and if yes - how (I know this is more or less java related)
-
Searching for a NullPointer since two days!
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
It worked thank you -
Searching for a NullPointer since two days!
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Did it recompile Minecraft + Forge or just skip it? If it was skipped, you should force it to be recompiled by updating to a newer Forge version, deleting the JARs for the current version in the Gradle cache or running the cleanCache task to completely wipe the cache. Ok, will cleaning the cash kill my sourcecode? -
Searching for a NullPointer since two days!
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
i did!