Fix packet serialization of block tag ingredients

Fixes pure daisy JEI display on servers
This commit is contained in:
Hubry committed 2020-07-13 16:12:55 +02:00
1 parent d4f6e1e859
commit 069cb964b6
2 files changed
+8 -3

No files matched your search

@@ -52,6 +52,7 @@ public class StateIngredientBlocks implements StateIngredient {
@Override
public void write(PacketBuffer buffer) {
buffer.writeVarInt(0);
Collection<Block> blocks = getBlocks();
buffer.writeVarInt(blocks.size());
for (Block block : blocks) {
buffer.writeRegistryIdUnsafe(ForgeRegistries.BLOCKS, block);
@@ -62,4 +63,8 @@ public class StateIngredientBlocks implements StateIngredient {
public List<BlockState> getDisplayed() {
return blocks.stream().map(Block::getDefaultState).collect(Collectors.toList());
}
protected Collection<Block> getBlocks() {
return blocks;
}
}
@@ -13,11 +13,11 @@ import com.google.gson.JsonObject;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.util.ResourceLocation;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@@ -47,8 +47,8 @@ public class StateIngredientTag extends StateIngredientBlocks {
}
@Override
public void write(PacketBuffer buffer) {
super.write(buffer); // We're sending super's contents instead as tags are sent *after* recipes.
protected Collection<Block> getBlocks() {
return tag.getAllElements();
}
@Override