Skip to content

Commit

Permalink
Fixed crash on dedicated servers (PacketSpellProperties), Fixes #780, #…
Browse files Browse the repository at this point in the history
  • Loading branch information
WinDanesz committed Mar 6, 2022
1 parent 89a0a90 commit 6690564
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ public IMessage onMessage(Message message, MessageContext ctx){

net.minecraft.client.Minecraft.getMinecraft().addScheduledTask(() -> {

int first = message.firstId;
for(int i = first; i <message.propertiesArray.length; i++){
Spell.byNetworkID(i).setPropertiesClient(message.propertiesArray[i]);
int spellId = message.firstId;

for(int i = 0; i <message.propertiesArray.length; i++){
Spell spell = Spell.byNetworkID(spellId);
SpellProperties props = message.propertiesArray[i];
spell.setPropertiesClient(props);
spellId++;
}
});
}
Expand All @@ -43,16 +47,22 @@ public Message(int firstId, int count, SpellProperties... properties){
this.firstId = firstId;
this.count = count;
this.propertiesArray = properties;

}

@Override
public void fromBytes(ByteBuf buf){
List<SpellProperties> propertiesList = new ArrayList<>();
int i = buf.readInt();
firstId = buf.readInt();
count = buf.readInt();
firstId = i;
while(buf.isReadable() && i < count){
propertiesList.add(new SpellProperties(Spell.byNetworkID(i++), buf));

int k = 0;
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]);
Expand Down

0 comments on commit 6690564

Please sign in to comment.