3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 00:22:51 +01:00
Screw entity meta particles
Dieser Commit ist enthalten in:
Nassim Jahnke 2021-10-20 17:24:57 +02:00
Ursprung 431f773b77
Commit a6292988d5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
10 geänderte Dateien mit 257 neuen und 89 gelöschten Zeilen

Datei anzeigen

@ -78,7 +78,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/5", new VersionRange("1.16", 4, 5));
public static final ProtocolVersion v1_17 = register(755, "1.17");
public static final ProtocolVersion v1_17_1 = register(756, "1.17.1");
public static final ProtocolVersion v1_18 = register(757, 45, "1.18");
public static final ProtocolVersion v1_18 = register(757, 46, "1.18");
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) {

Datei anzeigen

@ -26,9 +26,11 @@ import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.data.MappingData;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets.EntityPackets;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets.InventoryPackets;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets.WorldPackets;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.storage.ChunkLightStorage;
import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.rewriter.ItemRewriter;
import com.viaversion.viaversion.rewriter.SoundRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
@ -36,6 +38,7 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
public static final MappingData MAPPINGS = new MappingData();
private final EntityRewriter<Protocol1_18To1_17_1> entityRewriter = new EntityPackets(this);
private final ItemRewriter<Protocol1_18To1_17_1> itemRewriter = new InventoryPackets(this);
public Protocol1_18To1_17_1() {
super(ClientboundPackets1_17_1.class, ClientboundPackets1_18.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
@ -52,6 +55,7 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
@Override
protected void registerPackets() {
entityRewriter.register();
itemRewriter.register();
WorldPackets.register(this);
}
@ -70,4 +74,9 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
public EntityRewriter<Protocol1_18To1_17_1> getEntityRewriter() {
return entityRewriter;
}
@Override
public ItemRewriter<Protocol1_18To1_17_1> getItemRewriter() {
return itemRewriter;
}
}

Datei anzeigen

@ -29,7 +29,7 @@ public final class MappingData extends MappingDataBase {
private final Object2IntMap<String> blockEntityIds = new Object2IntOpenHashMap<>();
public MappingData() {
super("1.17", "1.18");
super("1.17", "1.18", true);
blockEntityIds.defaultReturnValue(-1);
}

Datei anzeigen

@ -42,6 +42,8 @@ public final class EntityPackets extends EntityRewriter<Protocol1_18To1_17_1> {
registerMetadataRewriter(ClientboundPackets1_17_1.ENTITY_METADATA, Types1_17.METADATA_LIST);
registerRemoveEntities(ClientboundPackets1_17_1.REMOVE_ENTITIES);*/
//TODO NEW METATYPE FOR PARTICLE CHANGE
protocol.registerClientbound(ClientboundPackets1_17_1.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {

Datei anzeigen

@ -0,0 +1,89 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2021 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_17_1;
import com.viaversion.viaversion.rewriter.ItemRewriter;
public final class InventoryPackets extends ItemRewriter<Protocol1_18To1_17_1> {
public InventoryPackets(Protocol1_18To1_17_1 protocol) {
super(protocol);
}
@Override
public void registerPackets() {
registerSetCooldown(ClientboundPackets1_17_1.COOLDOWN);
registerWindowItems1_17_1(ClientboundPackets1_17_1.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, Type.FLAT_VAR_INT_ITEM);
registerTradeList(ClientboundPackets1_17_1.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
registerSetSlot1_17_1(ClientboundPackets1_17_1.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_17_1.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
registerEntityEquipmentArray(ClientboundPackets1_17_1.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
protocol.registerClientbound(ClientboundPackets1_17_1.SPAWN_PARTICLE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Particle id
map(Type.BOOLEAN); // Override limiter
map(Type.DOUBLE); // X
map(Type.DOUBLE); // Y
map(Type.DOUBLE); // Z
map(Type.FLOAT); // Offset X
map(Type.FLOAT); // Offset Y
map(Type.FLOAT); // Offset Z
map(Type.FLOAT); // Max speed
map(Type.INT); // Particle Count
handler(wrapper -> {
int id = wrapper.get(Type.INT, 0);
if (id == 2) { // Barrier
wrapper.set(Type.INT, 0, 3); // Block marker
wrapper.write(Type.VAR_INT, 7754);
return;
} else if (id == 3) { // Light block
wrapper.write(Type.VAR_INT, 7786);
return;
}
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()) {
int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} else if (id == mappings.getItemId()) {
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
}
int newId = protocol.getMappingData().getNewParticleId(id);
if (newId != id) {
wrapper.set(Type.INT, 0, newId);
}
});
}
});
new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_17_1.DECLARE_RECIPES);
registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
}
}

Datei anzeigen

@ -46,9 +46,6 @@ import java.util.List;
public final class WorldPackets {
private static final int WIDTH_BITS = 2;
private static final int HORIZONTAL_MASK = 3;
public static void register(final Protocol1_18To1_17_1 protocol) {
protocol.registerClientbound(ClientboundPackets1_17_1.BLOCK_ENTITY_DATA, new PacketRemapper() {
@Override

Datei anzeigen

@ -58,22 +58,53 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
protocol.registerClientbound(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(type); // 1 - Window Values
map(Type.UNSIGNED_BYTE); // Window id
map(type); // Items
handler(itemArrayHandler(type));
}
});
}
public void registerWindowItems1_17_1(ClientboundPacketType packetType, Type<Item[]> itemsType, Type<Item> carriedItemType) {
protocol.registerClientbound(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // Window id
map(Type.VAR_INT); // State id
map(itemsType); // Items
map(carriedItemType); // Carried item
handler(wrapper -> {
Item[] items = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, 0);
for (Item item : items) {
handleItemToClient(item);
}
handleItemToClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
});
}
});
}
public void registerSetSlot(ClientboundPacketType packetType, Type<Item> type) {
protocol.registerClientbound(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot ID
map(type); // 2 - Slot Value
map(Type.UNSIGNED_BYTE); // Window id
map(Type.SHORT); // Slot id
map(type); // Item
handler(itemToClientHandler(type));
}
});
}
public void registerSetSlot1_17_1(ClientboundPacketType packetType, Type<Item> type) {
protocol.registerClientbound(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // Window id
map(Type.VAR_INT); // State id
map(Type.SHORT); // Slot id
map(type); // Item
handler(itemToClientHandler(type));
}
});
@ -164,6 +195,31 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
});
}
public void registerClickWindow1_17_1(ServerboundPacketType packetType, Type<Item> type) {
protocol.registerServerbound(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // Window Id
map(Type.VAR_INT); // State id
map(Type.SHORT); // Slot
map(Type.BYTE); // Button
map(Type.VAR_INT); // Mode
handler(wrapper -> {
// Affected items
int length = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < length; i++) {
wrapper.passthrough(Type.SHORT); // Slot
handleItemToServer(wrapper.passthrough(type));
}
// Carried item
handleItemToServer(wrapper.passthrough(type));
});
}
});
}
public void registerSetCooldown(ClientboundPacketType packetType) {
protocol.registerClientbound(packetType, new PacketRemapper() {
@Override

Datei anzeigen

@ -22271,79 +22271,80 @@
"1024": "minecraft:music_disc_ward",
"1025": "minecraft:music_disc_11",
"1026": "minecraft:music_disc_wait",
"1027": "minecraft:music_disc_pigstep",
"1028": "minecraft:trident",
"1029": "minecraft:phantom_membrane",
"1030": "minecraft:nautilus_shell",
"1031": "minecraft:heart_of_the_sea",
"1032": "minecraft:crossbow",
"1033": "minecraft:suspicious_stew",
"1034": "minecraft:loom",
"1035": "minecraft:flower_banner_pattern",
"1036": "minecraft:creeper_banner_pattern",
"1037": "minecraft:skull_banner_pattern",
"1038": "minecraft:mojang_banner_pattern",
"1039": "minecraft:globe_banner_pattern",
"1040": "minecraft:piglin_banner_pattern",
"1041": "minecraft:composter",
"1042": "minecraft:barrel",
"1043": "minecraft:smoker",
"1044": "minecraft:blast_furnace",
"1045": "minecraft:cartography_table",
"1046": "minecraft:fletching_table",
"1047": "minecraft:grindstone",
"1048": "minecraft:smithing_table",
"1049": "minecraft:stonecutter",
"1050": "minecraft:bell",
"1051": "minecraft:lantern",
"1052": "minecraft:soul_lantern",
"1053": "minecraft:sweet_berries",
"1054": "minecraft:glow_berries",
"1055": "minecraft:campfire",
"1056": "minecraft:soul_campfire",
"1057": "minecraft:shroomlight",
"1058": "minecraft:honeycomb",
"1059": "minecraft:bee_nest",
"1060": "minecraft:beehive",
"1061": "minecraft:honey_bottle",
"1062": "minecraft:honeycomb_block",
"1063": "minecraft:lodestone",
"1064": "minecraft:crying_obsidian",
"1065": "minecraft:blackstone",
"1066": "minecraft:blackstone_slab",
"1067": "minecraft:blackstone_stairs",
"1068": "minecraft:gilded_blackstone",
"1069": "minecraft:polished_blackstone",
"1070": "minecraft:polished_blackstone_slab",
"1071": "minecraft:polished_blackstone_stairs",
"1072": "minecraft:chiseled_polished_blackstone",
"1073": "minecraft:polished_blackstone_bricks",
"1074": "minecraft:polished_blackstone_brick_slab",
"1075": "minecraft:polished_blackstone_brick_stairs",
"1076": "minecraft:cracked_polished_blackstone_bricks",
"1077": "minecraft:respawn_anchor",
"1078": "minecraft:candle",
"1079": "minecraft:white_candle",
"1080": "minecraft:orange_candle",
"1081": "minecraft:magenta_candle",
"1082": "minecraft:light_blue_candle",
"1083": "minecraft:yellow_candle",
"1084": "minecraft:lime_candle",
"1085": "minecraft:pink_candle",
"1086": "minecraft:gray_candle",
"1087": "minecraft:light_gray_candle",
"1088": "minecraft:cyan_candle",
"1089": "minecraft:purple_candle",
"1090": "minecraft:blue_candle",
"1091": "minecraft:brown_candle",
"1092": "minecraft:green_candle",
"1093": "minecraft:red_candle",
"1094": "minecraft:black_candle",
"1095": "minecraft:small_amethyst_bud",
"1096": "minecraft:medium_amethyst_bud",
"1097": "minecraft:large_amethyst_bud",
"1098": "minecraft:amethyst_cluster",
"1099": "minecraft:pointed_dripstone"
"1027": "minecraft:music_disc_otherside",
"1028": "minecraft:music_disc_pigstep",
"1029": "minecraft:trident",
"1030": "minecraft:phantom_membrane",
"1031": "minecraft:nautilus_shell",
"1032": "minecraft:heart_of_the_sea",
"1033": "minecraft:crossbow",
"1034": "minecraft:suspicious_stew",
"1035": "minecraft:loom",
"1036": "minecraft:flower_banner_pattern",
"1037": "minecraft:creeper_banner_pattern",
"1038": "minecraft:skull_banner_pattern",
"1039": "minecraft:mojang_banner_pattern",
"1040": "minecraft:globe_banner_pattern",
"1041": "minecraft:piglin_banner_pattern",
"1042": "minecraft:composter",
"1043": "minecraft:barrel",
"1044": "minecraft:smoker",
"1045": "minecraft:blast_furnace",
"1046": "minecraft:cartography_table",
"1047": "minecraft:fletching_table",
"1048": "minecraft:grindstone",
"1049": "minecraft:smithing_table",
"1050": "minecraft:stonecutter",
"1051": "minecraft:bell",
"1052": "minecraft:lantern",
"1053": "minecraft:soul_lantern",
"1054": "minecraft:sweet_berries",
"1055": "minecraft:glow_berries",
"1056": "minecraft:campfire",
"1057": "minecraft:soul_campfire",
"1058": "minecraft:shroomlight",
"1059": "minecraft:honeycomb",
"1060": "minecraft:bee_nest",
"1061": "minecraft:beehive",
"1062": "minecraft:honey_bottle",
"1063": "minecraft:honeycomb_block",
"1064": "minecraft:lodestone",
"1065": "minecraft:crying_obsidian",
"1066": "minecraft:blackstone",
"1067": "minecraft:blackstone_slab",
"1068": "minecraft:blackstone_stairs",
"1069": "minecraft:gilded_blackstone",
"1070": "minecraft:polished_blackstone",
"1071": "minecraft:polished_blackstone_slab",
"1072": "minecraft:polished_blackstone_stairs",
"1073": "minecraft:chiseled_polished_blackstone",
"1074": "minecraft:polished_blackstone_bricks",
"1075": "minecraft:polished_blackstone_brick_slab",
"1076": "minecraft:polished_blackstone_brick_stairs",
"1077": "minecraft:cracked_polished_blackstone_bricks",
"1078": "minecraft:respawn_anchor",
"1079": "minecraft:candle",
"1080": "minecraft:white_candle",
"1081": "minecraft:orange_candle",
"1082": "minecraft:magenta_candle",
"1083": "minecraft:light_blue_candle",
"1084": "minecraft:yellow_candle",
"1085": "minecraft:lime_candle",
"1086": "minecraft:pink_candle",
"1087": "minecraft:gray_candle",
"1088": "minecraft:light_gray_candle",
"1089": "minecraft:cyan_candle",
"1090": "minecraft:purple_candle",
"1091": "minecraft:blue_candle",
"1092": "minecraft:brown_candle",
"1093": "minecraft:green_candle",
"1094": "minecraft:red_candle",
"1095": "minecraft:black_candle",
"1096": "minecraft:small_amethyst_bud",
"1097": "minecraft:medium_amethyst_bud",
"1098": "minecraft:large_amethyst_bud",
"1099": "minecraft:amethyst_cluster",
"1100": "minecraft:pointed_dripstone"
},
"sounds": [
"ambient.cave",
@ -22979,14 +22980,23 @@
"music_disc.strad",
"music_disc.wait",
"music_disc.ward",
"music_disc.otherside",
"music.dragon",
"music.end",
"music.game",
"music.menu",
"music.nether.basalt_deltas",
"music.nether.nether_wastes",
"music.nether.soul_sand_valley",
"music.nether.crimson_forest",
"music.overworld.dripstone_caves",
"music.overworld.grove",
"music.overworld.jagged_peaks",
"music.overworld.lush_caves",
"music.overworld.meadow",
"music.nether.nether_wastes",
"music.overworld.frozen_peaks",
"music.overworld.snowy_slopes",
"music.nether.soul_sand_valley",
"music.overworld.stony_peaks",
"music.nether.warped_forest",
"music.under_water",
"block.nether_bricks.break",
@ -23544,9 +23554,8 @@
"particles": [
"ambient_entity_effect",
"angry_villager",
"barrier",
"light",
"block",
"block_marker",
"bubble",
"cloud",
"crit",

Datei anzeigen

@ -0,0 +1,6 @@
{
"particles": {
"barrier": "block_marker",
"light": "block_marker"
}
}

Datei anzeigen

@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=4.1.0-21w41a-SNAPSHOT
projectVersion=4.1.0-21w42a-SNAPSHOT
# Gradle properties
org.gradle.daemon=true