mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-18 16:17:45 +01:00
Use enhanced switch in more places, fix typo (#831)
This commit is contained in:
parent
99618af747
commit
136678b0b7
@ -27,8 +27,8 @@ public final class BukkitAdvancementCriteriaProvider extends AdvancementCriteria
|
||||
private static final String[] EMPTY_CRITERIA = new String[0];
|
||||
|
||||
@Override
|
||||
public String[] getCriteria(final String key) {
|
||||
final Advancement advancement = Bukkit.getAdvancement(NamespacedKey.fromString(key));
|
||||
public String[] getCriteria(final String advancementKey) {
|
||||
final Advancement advancement = Bukkit.getAdvancement(NamespacedKey.fromString(advancementKey));
|
||||
return advancement == null ? EMPTY_CRITERIA : advancement.getCriteria().toArray(EMPTY_CRITERIA);
|
||||
}
|
||||
}
|
||||
|
@ -444,28 +444,30 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
}
|
||||
|
||||
public int villagerDataToProfession(VillagerData data) {
|
||||
return switch (data.profession()) { // Armorer
|
||||
// Mason
|
||||
// Toolsmith
|
||||
case 1, 10, 13, 14 -> // Weaponsmith
|
||||
3; // Blacksmith
|
||||
// Butcher
|
||||
case 2, 8 -> // Leatherworker
|
||||
4; // Butcher
|
||||
// Cartographer
|
||||
case 3, 9 -> // Librarian
|
||||
1; // Librarian
|
||||
case 4 -> // Cleric
|
||||
2; // Priest
|
||||
// Farmer
|
||||
// Fisherman
|
||||
// Fletcher
|
||||
case 5, 6, 7, 12 -> // Shepherd
|
||||
0; // Farmer
|
||||
// None
|
||||
// Nitwit
|
||||
default -> 5; // Nitwit
|
||||
};
|
||||
switch (data.profession()) {
|
||||
case 1: // Armorer
|
||||
case 10: // Mason
|
||||
case 13: // Toolsmith
|
||||
case 14: // Weaponsmith
|
||||
return 3; // Blacksmith
|
||||
case 2: // Butcher
|
||||
case 8: // Leatherworker
|
||||
return 4; // Butcher
|
||||
case 3: // Cartographer
|
||||
case 9: // Librarian
|
||||
return 1; // Librarian
|
||||
case 4: // Cleric
|
||||
return 2; // Priest
|
||||
case 5: // Farmer
|
||||
case 6: // Fisherman
|
||||
case 7: // Fletcher
|
||||
case 12: // Shepherd
|
||||
return 0; // Farmer
|
||||
case 0: // None
|
||||
case 11: // Nitwit
|
||||
default:
|
||||
return 5; // Nitwit
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,6 @@ import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_19_3to1_19_1.Protocol1_19_3To1_19_1;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.packet.ClientboundPackets1_19_3;
|
||||
@ -73,7 +72,7 @@ public final class BlockItemPacketRewriter1_19_3 extends BackwardsItemRewriter<C
|
||||
final String type = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING));
|
||||
wrapper.passthrough(Types.STRING); // Recipe Identifier
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
case "crafting_shapeless" -> {
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
final int ingredients = wrapper.passthrough(Types.VAR_INT);
|
||||
@ -84,9 +83,8 @@ public final class BlockItemPacketRewriter1_19_3 extends BackwardsItemRewriter<C
|
||||
}
|
||||
}
|
||||
handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result
|
||||
break;
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
case "crafting_shaped" -> {
|
||||
final int ingredients = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT);
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
@ -97,12 +95,8 @@ public final class BlockItemPacketRewriter1_19_3 extends BackwardsItemRewriter<C
|
||||
}
|
||||
}
|
||||
handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result
|
||||
break;
|
||||
}
|
||||
case "smelting":
|
||||
case "campfire_cooking":
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "smelting", "campfire_cooking", "blasting", "smoking" -> {
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
final Item[] items = wrapper.passthrough(Types.ITEM1_13_2_ARRAY); // Ingredients
|
||||
@ -112,25 +106,13 @@ public final class BlockItemPacketRewriter1_19_3 extends BackwardsItemRewriter<C
|
||||
handleItemToClient(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2)); // Result
|
||||
wrapper.passthrough(Types.FLOAT); // EXP
|
||||
wrapper.passthrough(Types.VAR_INT); // Cooking time
|
||||
break;
|
||||
case "crafting_special_armordye":
|
||||
case "crafting_special_bookcloning":
|
||||
case "crafting_special_mapcloning":
|
||||
case "crafting_special_mapextending":
|
||||
case "crafting_special_firework_rocket":
|
||||
case "crafting_special_firework_star":
|
||||
case "crafting_special_firework_star_fade":
|
||||
case "crafting_special_tippedarrow":
|
||||
case "crafting_special_bannerduplicate":
|
||||
case "crafting_special_shielddecoration":
|
||||
case "crafting_special_shulkerboxcoloring":
|
||||
case "crafting_special_suspiciousstew":
|
||||
case "crafting_special_repairitem":
|
||||
wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
break;
|
||||
default:
|
||||
recipeRewriter.handleRecipeType(wrapper, type);
|
||||
break;
|
||||
}
|
||||
case "crafting_special_armordye", "crafting_special_bookcloning", "crafting_special_mapcloning",
|
||||
"crafting_special_mapextending", "crafting_special_firework_rocket", "crafting_special_firework_star",
|
||||
"crafting_special_firework_star_fade", "crafting_special_tippedarrow", "crafting_special_bannerduplicate",
|
||||
"crafting_special_shielddecoration", "crafting_special_shulkerboxcoloring", "crafting_special_suspiciousstew",
|
||||
"crafting_special_repairitem" -> wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
default -> recipeRewriter.handleRecipeType(wrapper, type);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -78,21 +78,14 @@ public final class Protocol1_19_4To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
@Override
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) {
|
||||
switch (argumentType) {
|
||||
case "minecraft:heightmap":
|
||||
wrapper.write(Types.VAR_INT, 0);
|
||||
break;
|
||||
case "minecraft:time":
|
||||
wrapper.read(Types.INT); // Minimum
|
||||
break;
|
||||
case "minecraft:resource":
|
||||
case "minecraft:resource_or_tag":
|
||||
case "minecraft:heightmap" -> wrapper.write(Types.VAR_INT, 0);
|
||||
case "minecraft:time" -> wrapper.read(Types.INT); // Minimum
|
||||
case "minecraft:resource", "minecraft:resource_or_tag" -> {
|
||||
final String resource = wrapper.read(Types.STRING);
|
||||
// Replace damage types with... something
|
||||
wrapper.write(Types.STRING, resource.equals("minecraft:damage_type") ? "minecraft:mob_effect" : resource);
|
||||
break;
|
||||
default:
|
||||
super.handleArgument(wrapper, argumentType);
|
||||
break;
|
||||
}
|
||||
default -> super.handleArgument(wrapper, argumentType);
|
||||
}
|
||||
}
|
||||
}.registerDeclareCommands1_19(ClientboundPackets1_19_4.COMMANDS);
|
||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||
|
||||
public class AdvancementCriteriaProvider implements Provider {
|
||||
|
||||
public String[] getCriteria(final String advacementKey) {
|
||||
public String[] getCriteria(final String advancementKey) {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user