Track gamemode in 1.20.5 protocol
This commit is contained in:
3 files changed
+19
-8
No files matched your search
+10
-1
@@ -30,6 +30,7 @@ import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.RegistryData
|
||||
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.SecureChatStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.DimensionData;
|
||||
import com.viaversion.viaversion.api.minecraft.GameMode;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
@@ -208,7 +209,10 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
});
|
||||
map(Types.STRING); // World
|
||||
map(Types.LONG); // Seed
|
||||
map(Types.BYTE); // Gamemode
|
||||
handler(wrapper -> {
|
||||
final byte gamemode = wrapper.passthrough(Types.BYTE);
|
||||
tracker(wrapper.user()).setInstaBuild(gamemode == GameMode.CREATIVE.id());
|
||||
});
|
||||
map(Types.BYTE); // Previous gamemode
|
||||
map(Types.BOOLEAN); // Debug
|
||||
map(Types.BOOLEAN); // Flat
|
||||
@@ -234,6 +238,11 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
});
|
||||
map(Types.STRING); // World
|
||||
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking
|
||||
map(Types.LONG); // Seed
|
||||
handler(wrapper -> {
|
||||
final byte gamemode = wrapper.passthrough(Types.BYTE);
|
||||
tracker(wrapper.user()).setInstaBuild(gamemode == GameMode.CREATIVE.id());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+8
-6
@@ -68,6 +68,8 @@ import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.Limit;
|
||||
import com.viaversion.viaversion.util.Unit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.BlockItemPacketRewriter1_21_2.downgradeItemData;
|
||||
import static com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.BlockItemPacketRewriter1_21_2.updateItemData;
|
||||
@@ -575,15 +577,15 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem
|
||||
final String type = tag.getString("type");
|
||||
if ("apply_effects".equals(type)) {
|
||||
final ListTag<CompoundTag> effects = tag.getListTag("effects", CompoundTag.class);
|
||||
final PotionEffect[] potionEffects = new PotionEffect[effects.size()];
|
||||
final List<PotionEffect> potionEffects = new ArrayList<>();
|
||||
for (int i = 0; i < effects.size(); i++) {
|
||||
final CompoundTag effectTag = effects.get(i);
|
||||
final int effect = effectTag.getInt("effect");
|
||||
final PotionEffectData data = convertPotionEffectData(effectTag);
|
||||
potionEffects[i] = new PotionEffect(effect, data);
|
||||
potionEffects.add(new PotionEffect(effect, data));
|
||||
}
|
||||
final float probability = tag.getFloat("probability");
|
||||
return new Consumable1_21_2.ConsumeEffect<>(id, Consumable1_21_2.ApplyStatusEffects.TYPE, new Consumable1_21_2.ApplyStatusEffects(potionEffects, probability));
|
||||
return new Consumable1_21_2.ConsumeEffect<>(id, Consumable1_21_2.ApplyStatusEffects.TYPE, new Consumable1_21_2.ApplyStatusEffects(potionEffects.toArray(PotionEffect[]::new), probability));
|
||||
} else if ("remove_effects".equals(type)) {
|
||||
final HolderSet set = restoreHolderSet(tag, "remove_effects");
|
||||
return new Consumable1_21_2.ConsumeEffect<>(id, Types.HOLDER_SET, set);
|
||||
@@ -671,11 +673,11 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem
|
||||
|
||||
final ListTag<CompoundTag> deathProtection = backupTag.getListTag("death_protection", CompoundTag.class);
|
||||
if (deathProtection != null) {
|
||||
final Consumable1_21_2.ConsumeEffect<?>[] effects = new Consumable1_21_2.ConsumeEffect[deathProtection.size()];
|
||||
final List<Consumable1_21_2.ConsumeEffect<?>> effects = new ArrayList<>();
|
||||
for (int i = 0; i < deathProtection.size(); i++) {
|
||||
effects[i] = convertConsumableEffect(deathProtection.get(i));
|
||||
effects.add(convertConsumableEffect(deathProtection.get(i)));
|
||||
}
|
||||
data.set(StructuredDataKey.DEATH_PROTECTION, new DeathProtection(effects));
|
||||
data.set(StructuredDataKey.DEATH_PROTECTION, new DeathProtection(effects.toArray(Consumable1_21_2.ConsumeEffect[]::new)));
|
||||
}
|
||||
|
||||
removeCustomTag(data, customData);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
projectVersion=5.9.1
|
||||
projectVersion=5.9.2-SNAPSHOT
|
||||
|
||||
# Smile emoji (note that modrinth may not have added the version on release yet)
|
||||
mcVersions=26.1.2, 26.1.1, 26.1, 1.21.11, 1.21.10, 1.21.9, 1.21.8, 1.21.7, 1.21.6, 1.21.5, 1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 1.20.6, 1.20.5, 1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10
|
||||
|
||||
Reference in new issue
Block a user