mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Possibly fix recipe class cast errors
This commit is contained in:
parent
5206bc3b99
commit
6df9081d6e
1 changed files with 5 additions and 8 deletions
|
@ -39,10 +39,7 @@ import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.descriptor.DefaultDescriptor;
|
import com.nukkitx.protocol.bedrock.data.inventory.descriptor.DefaultDescriptor;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.descriptor.ItemDescriptorWithCount;
|
import com.nukkitx.protocol.bedrock.data.inventory.descriptor.ItemDescriptorWithCount;
|
||||||
import com.nukkitx.protocol.bedrock.packet.CraftingDataPacket;
|
import com.nukkitx.protocol.bedrock.packet.CraftingDataPacket;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.*;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
|
import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
|
||||||
|
@ -221,7 +218,7 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
|
||||||
Ingredient ingredient = ingredients[i];
|
Ingredient ingredient = ingredients[i];
|
||||||
Map<GroupedItem, List<ItemDescriptorWithCount>> groupedByIds = Arrays.stream(ingredient.getOptions())
|
Map<GroupedItem, List<ItemDescriptorWithCount>> groupedByIds = Arrays.stream(ingredient.getOptions())
|
||||||
.map(item -> ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, item)))
|
.map(item -> ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, item)))
|
||||||
.collect(Collectors.groupingBy(item -> new GroupedItem(((DefaultDescriptor) item.getDescriptor()).getItemId(), item.getCount())));
|
.collect(Collectors.groupingBy(item -> item == ItemDescriptorWithCount.EMPTY ? new GroupedItem(0, 0) : new GroupedItem(((DefaultDescriptor) item.getDescriptor()).getItemId(), item.getCount())));
|
||||||
Set<ItemDescriptorWithCount> optionSet = new HashSet<>(groupedByIds.size());
|
Set<ItemDescriptorWithCount> optionSet = new HashSet<>(groupedByIds.size());
|
||||||
for (Map.Entry<GroupedItem, List<ItemDescriptorWithCount>> entry : groupedByIds.entrySet()) {
|
for (Map.Entry<GroupedItem, List<ItemDescriptorWithCount>> entry : groupedByIds.entrySet()) {
|
||||||
if (entry.getValue().size() > 1) {
|
if (entry.getValue().size() > 1) {
|
||||||
|
@ -236,7 +233,7 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
|
||||||
if (entry.getValue().size() < idCount) {
|
if (entry.getValue().size() < idCount) {
|
||||||
optionSet.addAll(entry.getValue());
|
optionSet.addAll(entry.getValue());
|
||||||
} else {
|
} else {
|
||||||
optionSet.add(new ItemDescriptorWithCount(new DefaultDescriptor(groupedItem.id, Short.MAX_VALUE), groupedItem.count));
|
optionSet.add(groupedItem.id == 0 ? ItemDescriptorWithCount.EMPTY : new ItemDescriptorWithCount(new DefaultDescriptor(groupedItem.id, Short.MAX_VALUE), groupedItem.count));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ItemDescriptorWithCount item = entry.getValue().get(0);
|
ItemDescriptorWithCount item = entry.getValue().get(0);
|
||||||
|
@ -270,8 +267,8 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
|
||||||
for (ItemDescriptorWithCount item : set) {
|
for (ItemDescriptorWithCount item : set) {
|
||||||
for (int j = 0; j < totalCombinations / set.size(); j++) {
|
for (int j = 0; j < totalCombinations / set.size(); j++) {
|
||||||
final int comboIndex = (i * x) + (j % x) + ((j / x) * set.size() * x);
|
final int comboIndex = (i * x) + (j % x) + ((j / x) * set.size() * x);
|
||||||
for (int slot : slotSet) {
|
for (IntIterator it = slotSet.iterator(); it.hasNext(); ) {
|
||||||
combinations[comboIndex][slot] = item;
|
combinations[comboIndex][it.nextInt()] = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
Loading…
Reference in a new issue