mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-08 03:40:27 +01:00
Revert "fix declare shaped packet reader (#572)"
This reverts commit d94d07bead
.
This commit is contained in:
parent
ca2d708a40
commit
206d93ed1b
@ -7,7 +7,6 @@ import net.minestom.server.utils.binary.BinaryReader;
|
|||||||
import net.minestom.server.utils.binary.BinaryWriter;
|
import net.minestom.server.utils.binary.BinaryWriter;
|
||||||
import net.minestom.server.utils.binary.Writeable;
|
import net.minestom.server.utils.binary.Writeable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -84,26 +83,10 @@ public record DeclareRecipesPacket(@NotNull List<DeclaredRecipe> recipes) implem
|
|||||||
ingredients = List.copyOf(ingredients);
|
ingredients = List.copyOf(ingredients);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DeclaredShapedCraftingRecipe(DeclaredShapedCraftingRecipe packet) {
|
|
||||||
this(packet.recipeId, packet.width, packet.height, packet.group, packet.ingredients, packet.result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeclaredShapedCraftingRecipe(BinaryReader reader) {
|
public DeclaredShapedCraftingRecipe(BinaryReader reader) {
|
||||||
this(read(reader));
|
this(reader.readSizedString(), reader.readVarInt(), reader.readVarInt(),
|
||||||
}
|
reader.readSizedString(), reader.readVarIntList(Ingredient::new),
|
||||||
|
reader.readItemStack());
|
||||||
private static DeclaredShapedCraftingRecipe read(BinaryReader reader) {
|
|
||||||
|
|
||||||
String recipeId = reader.readSizedString();
|
|
||||||
int width = reader.readVarInt();
|
|
||||||
int height = reader.readVarInt();
|
|
||||||
String group = reader.readSizedString();
|
|
||||||
List<Ingredient> ingredients = new ArrayList<>();
|
|
||||||
for (int slot = 0; slot < width * height; slot++) {
|
|
||||||
ingredients.add(new Ingredient(reader));
|
|
||||||
}
|
|
||||||
ItemStack result = reader.readItemStack();
|
|
||||||
return new DeclaredShapedCraftingRecipe(recipeId, width, height, group, ingredients, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,18 +87,7 @@ public class PacketWriteReadTest {
|
|||||||
"minecraft:sticks",
|
"minecraft:sticks",
|
||||||
"sticks",
|
"sticks",
|
||||||
List.of(new Ingredient(List.of(ItemStack.of(Material.OAK_PLANKS)))),
|
List.of(new Ingredient(List.of(ItemStack.of(Material.OAK_PLANKS)))),
|
||||||
ItemStack.of(Material.STICK)
|
ItemStack.of(Material.STICK)))));
|
||||||
),
|
|
||||||
new DeclareRecipesPacket.DeclaredShapedCraftingRecipe(
|
|
||||||
"minecraft:torch",
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
"",
|
|
||||||
List.of(new Ingredient(List.of(ItemStack.of(Material.COAL))),
|
|
||||||
new Ingredient(List.of(ItemStack.of(Material.STICK)))),
|
|
||||||
ItemStack.of(Material.TORCH)
|
|
||||||
))));
|
|
||||||
|
|
||||||
SERVER_PACKETS.add(new DestroyEntitiesPacket(List.of(5, 5, 5)));
|
SERVER_PACKETS.add(new DestroyEntitiesPacket(List.of(5, 5, 5)));
|
||||||
SERVER_PACKETS.add(new DisconnectPacket(COMPONENT));
|
SERVER_PACKETS.add(new DisconnectPacket(COMPONENT));
|
||||||
SERVER_PACKETS.add(new DisplayScoreboardPacket((byte) 5, "scoreboard"));
|
SERVER_PACKETS.add(new DisplayScoreboardPacket((byte) 5, "scoreboard"));
|
||||||
@ -153,8 +142,7 @@ public class PacketWriteReadTest {
|
|||||||
BinaryReader reader = new BinaryReader(writer.toByteArray());
|
BinaryReader reader = new BinaryReader(writer.toByteArray());
|
||||||
var createdPacket = readerConstructor.newInstance(reader);
|
var createdPacket = readerConstructor.newInstance(reader);
|
||||||
assertEquals(writeable, createdPacket);
|
assertEquals(writeable, createdPacket);
|
||||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException
|
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||||
| IllegalAccessException e) {
|
|
||||||
fail(writeable.toString(), e);
|
fail(writeable.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user