Fixed crash on dedicated servers (PacketSpellProperties), Fixes #780, #779, #773, #774, #771, #768

This commit is contained in:
WinDanesz
2022-03-05 22:55:55 +01:00
parent 89a0a900cc
commit 6690564017
@@ -21,9 +21,13 @@ public class PacketSpellProperties implements IMessageHandler<PacketSpellPropert
net.minecraft.client.Minecraft.getMinecraft().addScheduledTask(() -> { net.minecraft.client.Minecraft.getMinecraft().addScheduledTask(() -> {
int first = message.firstId; int spellId = message.firstId;
for(int i = first; i <message.propertiesArray.length; i++){
Spell.byNetworkID(i).setPropertiesClient(message.propertiesArray[i]); for(int i = 0; i <message.propertiesArray.length; i++){
Spell spell = Spell.byNetworkID(spellId);
SpellProperties props = message.propertiesArray[i];
spell.setPropertiesClient(props);
spellId++;
} }
}); });
} }
@@ -43,16 +47,22 @@ public class PacketSpellProperties implements IMessageHandler<PacketSpellPropert
this.firstId = firstId; this.firstId = firstId;
this.count = count; this.count = count;
this.propertiesArray = properties; this.propertiesArray = properties;
} }
@Override @Override
public void fromBytes(ByteBuf buf){ public void fromBytes(ByteBuf buf){
List<SpellProperties> propertiesList = new ArrayList<>(); List<SpellProperties> propertiesList = new ArrayList<>();
int i = buf.readInt(); firstId = buf.readInt();
count = buf.readInt(); count = buf.readInt();
firstId = i;
while(buf.isReadable() && i < count){ int k = 0;
propertiesList.add(new SpellProperties(Spell.byNetworkID(i++), buf)); int j = firstId;
while(k < count){
SpellProperties props = new SpellProperties(Spell.byNetworkID(j), buf);
propertiesList.add(props);
k++;
j++;
} }
propertiesArray = propertiesList.toArray(new SpellProperties[0]); propertiesArray = propertiesList.toArray(new SpellProperties[0]);