Jump to content

[1.7.2] Help needed for Watch dogs mod


Gaktan

Recommended Posts

Hello,

 

I recently started making a Watch dogs mod for minecraft. You can have more info on that here :

 

But right now, I am facing major modding problems. Mostly client/server synchronisation, NBTdata not saving and loading. That sort of stuff.

The reason why I can't get anything to work is because every single tutorial is outdated and I can't find anything that still works. Also, I find network stuff very confusing and I just don't understand what I'm supposed to do.

 

So, if anyone could help me with this or even with the mod if you want, that would be very nice. Maybe via PM or skype ?

 

Thank you for your time

 

Edit: I'm also having huges troubles with gradles, so I'm unable to update minecraft and forge because of a Compile error in the recompi task

Link to comment
Share on other sites

It's nothing related to the code really.

It's just that I don't know how to handle client/server. Right now, it's only client side. Like I said, I tried reading tutorials and such but I just don't understand. Even by following tutorials, I don't get the basic idea of how it works.

 

And also, I have an IExtendedEntityProperties with both save and load nbtdata. But these fonctions are never called. THe class itself is registered and works perfectly. But at no point the save and load functions are called. (PS: I followed step by step this (http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and)

Link to comment
Share on other sites

And also, I have an IExtendedEntityProperties with both save and load nbtdata. But these fonctions are never called. THe class itself is registered and works perfectly. But at no point the save and load functions are called. (PS: I followed step by step this (http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and)

 

Did you make the EntityConstructing event handler and register it correctly? Save and load nbt are automatically called when saving and loading world (are you sure those methods are overrides?)

 

Also, for the network stuff I recommend using SimpleNetworkWrapper and IMessage, its tutorial is in those forums

http://www.minecraftforge.net/forum/index.php/topic,20138.0.html

http://www.minecraftforge.net/forum/index.php/topic,20135.0.html

Link to comment
Share on other sites

diesieben07> I made a github repo for you : https://github.com/Gaktan/watchdogsmod/tree/master/com/gak/watchdogsmod

 

imadnsn> Yes, as I said. The class is working perfectly, the register works fine and the get too. These methods are for sure overriden because the class implements IExtendedEntityProperties.

 

I have seen the links you have sent. But I just don't know how to use the network. When do I send packets ? When do I retrieve them ? I'm very confused

Link to comment
Share on other sites

I thought @sideonly was a good thing. Is it not ?

(I removed the @sideonly and now nbt saving works ! thanks :) )

 

Now, the problem is that the data is out of sync. Do I have to send packets to client as soon as they join ?

 

Also, are the nbt data automatically transmitted ? Or do I have to do it manually ?

(Because in the code I posted on github, the network registering crashes the game...)

Link to comment
Share on other sites

What data? Define "out of sync". Where do you modify the data?

 

When a villager spawns, the IExtendedEntityProperties constructor is called to generate a random name, surname and info. This constructor is called by both server and client (which I don't want). Because the data is chosen randomly, the server and client have different names.

 

You need to sync IExtendedEntityProperties manually using packets.

 

This is one of my main problem, I don't know how to do that.

Link to comment
Share on other sites

Oh, I'm sorry. I didn't pay attention to that

 

But the thing is that gradle doesn't want to update. The compilation fails at the recompile

 

I change the build.gradle file and change the version to "1.7.10-10.13.0.1180"

I run the command "gradlew.bat setupDecompWorkspace --stacktrace --info" and it fails.

 

Here is the log

http://pastebin.com/M1kcvs7K

Link to comment
Share on other sites

Nevermind, I updated JDK 6 to JDK 7, that was the issue.

Now everything is up to date.

 

But, the mod doesn't want to compile at all.

 

 

[01:17:38] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker

[01:17:38] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker

[01:17:38] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker

[01:17:38] [main/INFO] [FML]: Forge Mod Loader version 7.10.18.1180 for Minecraft 1.7.10 loading

[01:17:38] [main/INFO] [FML]: Java is Java HotSpot 64-Bit Server VM, version 1.7.0_65, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre7

[01:17:38] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation

[01:17:38] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker

[01:17:38] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker

[01:17:38] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker

[01:17:38] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker

[01:17:38] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper

[01:17:38] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!

[01:17:40] [main/ERROR] [FML]: The minecraft jar file:/C:/Users/Gaktan/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.0.1180/forgeSrc-1.7.10-10.13.0.1180.jar!/net/minecraft/client/ClientBrandRetriever.class appears to be corrupt! There has been CRITICAL TAMPERING WITH MINECRAFT, it is highly unlikely minecraft will work! STOP NOW, get a clean copy and try again!

[01:17:40] [main/ERROR] [FML]: FML has been ordered to ignore the invalid or missing minecraft certificate. This is very likely to cause a problem!

[01:17:40] [main/ERROR] [FML]: Technical information: ClientBrandRetriever was at jar:file:/C:/Users/Gaktan/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.0.1180/forgeSrc-1.7.10-10.13.0.1180.jar!/net/minecraft/client/ClientBrandRetriever.class, there were 0 certificates for it

[01:17:40] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing

[01:17:40] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper

[01:17:40] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker

[01:17:41] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}

[01:17:42] [main/ERROR] [LaunchWrapper]: Unable to launch

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_65]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_65]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]

Caused by: joptsimple.MissingRequiredOptionException: Missing required option(s) ['userProperties']

at joptsimple.OptionParser.ensureRequiredOptions(OptionParser.java:447) ~[OptionParser.class:?]

at joptsimple.OptionParser.parse(OptionParser.java:437) ~[OptionParser.class:?]

at net.minecraft.client.main.Main.main(Main.java:89) ~[Main.class:?]

... 6 more

 

 

 

 

 

Link to comment
Share on other sites

THank you very much, it worked.

 

Now, the tough part : sending infos from the server to the client. I did as you said

 

	
public void onPlayerStartTracking(PlayerEvent.StartTracking event){
	Entity e = event.target;
	EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
	if (e instanceof EntityVillager && EntityAdvancedVillager.get((EntityVillager) e) == null){

		EntityVillager villager = (EntityVillager) e;

		EntityAdvancedVillager eav = EntityAdvancedVillager.get(villager);
	}
}

 

I believe this is happening server side, right ?

But I'm not sure how to send the EntityAvancedVillager (which is the IEEP) to the client. And also how are they supposed to receive this data and know where it belongs ?

 

Because all I have right now is this :

 

	@Override
public void fromBytes(ByteBuf buf) {
	text = ByteBufUtils.readUTF8String(buf);
}

@Override
public void toBytes(ByteBuf buf) {
	ByteBufUtils.writeUTF8String(buf, text);
}

Link to comment
Share on other sites

diesieben07> Thank you very much for your help. I tried to do that, but the event StartTracking is called before the event EntityConstruction, so what I try to send always returns null. I tried to set priorities but nope, doesn't work.

 

lolgamerbob> Thanks, the rendering part works very well for now, you can have an idea of what it looks like on the first comment

Link to comment
Share on other sites

Mh, maybe. How do I make sure that only the client OR the server can do certain tasks ?

 

Also, I tried to send packets to all and it doesn't work : WatchDogsMod.network.sendToAll(new WatchPackets("hi :)"));

Nothing is recieved. But I still can send packets to the server

Link to comment
Share on other sites

Ok, I wasn't sure which one was the good one. But still, I can't send packets to player. Or at least, they never receive them. THis is the handler class :

 

@Override
	public IMessage onMessage(WatchPackets message, MessageContext ctx) {

		EntityPlayerMP player = ctx.getServerHandler().playerEntity;
		System.out.println(String.format("Received %s from %s", message.text, ctx.getServerHandler().playerEntity.getDisplayName()));
	}

 

But now I'm thinking about it, it looks more like a function to send messages TO the server not from it. Since it's the only function available, how do I send retrieve packets FROM the client ?

Link to comment
Share on other sites

Yes, that's what I said from the beginning  :D

 

But I'm still confused. The onMessage is called by the side receiving the packet, right ?

I made a basic "I received a message", in the function.

 

I made this little block of code in the onEntityConstructing :

if(!e.worldObj.isRemote){

			if (e instanceof EntityVillager){

				EntityVillager villager = (EntityVillager) e;

				EntityAdvancedVillager.register(villager);

				WatchDogsMod.network.sendToAll(new WatchPackets("hi "));
				WatchDogsMod.network.sendToServer(new WatchPackets("Hello "));
			}
		}

 

Only the sendToServer is showing in the console. And the sender indicated the player. But you can see in the code that I used "! is remote". I am very confused

Link to comment
Share on other sites

Thank you very much, I can now send and receive messages yay !

But not everything is working, this is what happens when the client receives the message :

 

public static class ClientHandler implements IMessageHandler<WatchPackets, IMessage> {

	@Override
	public IMessage onMessage(WatchPackets message, MessageContext ctx) {

		StringTokenizer st = new StringTokenizer(message.text, "\n");
		int id = Integer.parseInt(st.nextToken());

		EntityVillager villager = (EntityVillager) MinecraftServer.getServer().getEntityWorld().getEntityByID(id);
		EntityAdvancedVillager.register(villager);
		EntityAdvancedVillager eav = EntityAdvancedVillager.get(villager);

		eav.name = st.nextToken();
		eav.surname = st.nextToken();

		eav.info = st.nextToken();
		eav.age = Integer.parseInt(st.nextToken());
		eav.occupation = st.nextToken();

		return null;
	}
}

 

Suprisingly, (with a bunch of sysos again) it turns out the client already has these infos... (it even says that the ri

But when I check again in an other class :

 

public void onVillagerRender(RenderLivingEvent.Post event){
	if(event.entity.worldObj.isRemote){
		if (event.entity instanceof EntityVillager) {

			EntityVillager villager = (EntityVillager) event.entity;

			EntityAdvancedVillager adv = EntityAdvancedVillager.get(villager);
			if(adv == null)
				return;
			if(adv.isRenderingInfos()){
				EntityAdvancedVillager.renderLabel(villager, adv.toStringList(), villager.posX, villager.posY, villager.posZ, 5);
			}
		}
	}
}

 

EntityAdvancedVillager adv = EntityAdvancedVillager.get(villager)

Always returns null... What the actual f**k

Link to comment
Share on other sites

1. Yes, but how to I get the world then ? So I can get the villager by its ID ?

2. That makes sense

3. So I should remove isRemote ? (because the client IEEP is registered when the packet is received, as shown in the code above)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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