Skip to content

Commit

Permalink
1.20.50
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 authored Dec 5, 2023
1 parent 6ed56ca commit 25cabab
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 7 deletions.
31 changes: 31 additions & 0 deletions src/main/java/cn/nukkit/inventory/CraftingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private void loadRecipes(Config config) {
List<Map> recipes = config.getMapList("recipes");
MainLogger.getLogger().info("Loading recipes...");
for (Map<String, Object> recipe : recipes) {
top:
try {
switch (Utils.toInt(recipe.get("type"))) {
case 0:
Expand Down Expand Up @@ -123,6 +124,12 @@ private void loadRecipes(Config config) {
char ingredientChar = ingredientEntry.getKey().charAt(0);
Item ingredient = Item.fromJson(ingredientEntry.getValue());

// TODO: update recipes
if (ingredient.getId() == Item.PLANKS && Utils.toInt(ingredientEntry.getValue().getOrDefault("damage", 0)) == -1) {
createLegacyPlanksRecipe(recipe, first);
break top;
}

ingredients.put(ingredientChar, ingredient);
}

Expand Down Expand Up @@ -189,6 +196,30 @@ private void loadRecipes(Config config) {
}
}

private void createLegacyPlanksRecipe(Map<String, Object> recipe, Map<String, Object> first) {
List<Map> outputs = (List<Map>) recipe.get("output");
String[] shape = ((List<String>) recipe.get("shape")).toArray(new String[0]);
List<Item> extraResults = new ArrayList<>();
for (Map<String, Object> data : outputs) {
extraResults.add(Item.fromJson(data));
}
for (int planksMeta = 0; planksMeta <= 5; planksMeta++) {
Map<Character, Item> ingredients = new CharObjectHashMap<>();
Map<String, Map<String, Object>> input = (Map) recipe.get("input");
for (Map.Entry<String, Map<String, Object>> ingredientEntry : input.entrySet()) {
char ingredientChar = ingredientEntry.getKey().charAt(0);
ingredientEntry.getValue().put("damage", 0);
Item ingredient = Item.fromJson(ingredientEntry.getValue());
if (ingredient.getId() == Item.PLANKS) {
ingredient.setDamage(planksMeta);
}
ingredients.put(ingredientChar, ingredient);
}
this.registerRecipe(
new ShapedRecipe(recipe.get("id") + "_" + planksMeta, Utils.toInt(recipe.get("priority")), Item.fromJson(first), shape, ingredients, extraResults));
}
}

public void rebuildPacket() {
CraftingDataPacket pk = new CraftingDataPacket();
pk.cleanRecipes = true;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/network/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class Network {
public static final byte CHANNEL_TEXT = 7; //Chat and other text stuff
public static final byte CHANNEL_END = 31;

private Class<? extends DataPacket>[] packetPool = new Class[256];
private Class<? extends DataPacket>[] packetPool = new Class[512];

private final Server server;

Expand Down Expand Up @@ -332,7 +332,7 @@ public void unblockAddress(InetAddress address) {
}

private void registerPackets() {
this.packetPool = new Class[256];
this.packetPool = new Class[512];

this.registerPacket(ProtocolInfo.ADD_ENTITY_PACKET, AddEntityPacket.class);
this.registerPacket(ProtocolInfo.ADD_ITEM_ENTITY_PACKET, AddItemEntityPacket.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public class AddEntityPacket extends DataPacket {
.put(EntityFrog.NETWORK_ID, "minecraft:frog")
.put(EntityTadpole.NETWORK_ID, "minecraft:tadpole")
.put(EntityAllay.NETWORK_ID, "minecraft:allay")
.put(138, "minecraft:camel")
.build();

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/network/protocol/ProtocolInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public interface ProtocolInfo {
* Actual Minecraft: PE protocol version
*/
@SuppressWarnings("UnnecessaryBoxing")
int CURRENT_PROTOCOL = Integer.valueOf("622"); // DO NOT REMOVE BOXING
int CURRENT_PROTOCOL = Integer.valueOf("630"); // DO NOT REMOVE BOXING

List<Integer> SUPPORTED_PROTOCOLS = Ints.asList(CURRENT_PROTOCOL);

String MINECRAFT_VERSION_NETWORK = "1.20.40";
String MINECRAFT_VERSION_NETWORK = "1.20.50";
String MINECRAFT_VERSION = 'v' + MINECRAFT_VERSION_NETWORK;

byte BATCH_PACKET = (byte) 0xff;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/creative_items.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/resources/item_mappings.json

Large diffs are not rendered by default.

Binary file modified src/main/resources/runtime_block_states.dat
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/resources/runtime_item_states.json

Large diffs are not rendered by default.

0 comments on commit 25cabab

Please sign in to comment.