Fix the utter mess that is spell property syncing (what was I thinking when I wrote this? and how did it ever work in the first place?!)

This fix is kinda cheating but I don't care, it works and it's certainly better than the mess that was there before
This commit is contained in:
Electroblob77
2021-01-01 23:26:24 +00:00
parent e19d324dca
commit 1ddcdafe50
3 changed files with 61 additions and 34 deletions
@@ -3,7 +3,6 @@ package electroblob.wizardry.packet;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.SpellProperties;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
@@ -18,13 +17,11 @@ public class PacketSpellProperties implements IMessageHandler<PacketSpellPropert
public IMessage onMessage(Message message, MessageContext ctx){
// Just to make sure that the side is correct
if(ctx.side.isServer()){
if(ctx.side.isClient()){
final EntityPlayerMP player = ctx.getServerHandler().player;
player.getServerWorld().addScheduledTask(() -> {
net.minecraft.client.Minecraft.getMinecraft().addScheduledTask(() -> {
for(int i=0; i<message.propertiesArray.length; i++){
Spell.byNetworkID(i).setProperties(message.propertiesArray[i]);
Spell.byNetworkID(i).setPropertiesClient(message.propertiesArray[i]);
}
});
}