mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
Temporary fix with inventory held click
This commit is contained in:
parent
c363b715ca
commit
f97328a3bd
@ -8,6 +8,7 @@ import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.ThreadInfo;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static net.minestom.server.MinecraftServer.*;
|
||||
|
||||
@ -27,7 +28,7 @@ public class BenchmarkManager {
|
||||
private Map<Long, Long> lastUserTimeMap = new HashMap<>();
|
||||
private Map<Long, Long> lastBlockedMap = new HashMap<>();
|
||||
|
||||
private Map<String, ThreadResult> resultMap = new HashMap<>();
|
||||
private Map<String, ThreadResult> resultMap = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean enabled = false;
|
||||
private volatile boolean stop = false;
|
||||
|
@ -333,21 +333,22 @@ public class Chunk implements Viewable {
|
||||
}
|
||||
|
||||
public ChunkDataPacket getFreshFullDataPacket() {
|
||||
ChunkDataPacket fullDataPacket = new ChunkDataPacket();
|
||||
ChunkDataPacket fullDataPacket = getFreshPacket();
|
||||
fullDataPacket.fullChunk = true;
|
||||
fullDataPacket.biomes = biomes.clone();
|
||||
fullDataPacket.chunkX = chunkX;
|
||||
fullDataPacket.chunkZ = chunkZ;
|
||||
fullDataPacket.blocksId = blocksId.clone();
|
||||
fullDataPacket.customBlocksId = customBlocksId.clone();
|
||||
fullDataPacket.blockEntities = new CopyOnWriteArraySet<>(blockEntities);
|
||||
fullDataPacket.blocksData = new Int2ObjectOpenHashMap<>(blocksData);
|
||||
return fullDataPacket;
|
||||
}
|
||||
|
||||
public ChunkDataPacket getFreshPartialDataPacket() {
|
||||
ChunkDataPacket fullDataPacket = new ChunkDataPacket();
|
||||
ChunkDataPacket fullDataPacket = getFreshPacket();
|
||||
fullDataPacket.fullChunk = false;
|
||||
return fullDataPacket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a {@link ChunkDataPacket} containing a copy this chunk data
|
||||
*/
|
||||
private ChunkDataPacket getFreshPacket() {
|
||||
ChunkDataPacket fullDataPacket = new ChunkDataPacket();
|
||||
fullDataPacket.biomes = biomes.clone();
|
||||
fullDataPacket.chunkX = chunkX;
|
||||
fullDataPacket.chunkZ = chunkZ;
|
||||
|
@ -328,6 +328,9 @@ public class Inventory implements InventoryModifier, InventoryClickHandler, View
|
||||
if (!clickResult.isCancel())
|
||||
callClickEvent(player, this, slot, ClickType.CHANGE_HELD, clicked, getCursorItem(player));
|
||||
|
||||
// Weird synchronization issue when omitted
|
||||
updateFromClick(clickResult, player);
|
||||
|
||||
return !clickResult.isCancel();
|
||||
}
|
||||
|
||||
|
@ -219,14 +219,14 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
|
||||
|
||||
this.items[slot] = itemStack;
|
||||
|
||||
// Refresh slot
|
||||
update();
|
||||
//refreshSlot(slot); seems to break things concerning +64 stacks
|
||||
|
||||
// Sync equipment
|
||||
if (equipmentSlot != null) {
|
||||
player.syncEquipment(equipmentSlot);
|
||||
}
|
||||
|
||||
// Refresh slot
|
||||
update();
|
||||
//refreshSlot(slot); seems to break things concerning +64 stacks
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,8 +365,9 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
|
||||
|
||||
InventoryClickResult clickResult = clickProcessor.changeHeld(null, player, slot, key, clicked, heldItem);
|
||||
|
||||
if (clickResult.doRefresh())
|
||||
if (clickResult.doRefresh()) {
|
||||
sendSlotRefresh((short) slot, clicked);
|
||||
}
|
||||
|
||||
setItemStack(slot, OFFSET, clickResult.getClicked());
|
||||
setItemStack(key, clickResult.getCursor());
|
||||
@ -374,6 +375,9 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
|
||||
if (!clickResult.isCancel())
|
||||
callClickEvent(player, null, slot, ClickType.CHANGE_HELD, clicked, getCursorItem());
|
||||
|
||||
// Weird synchronization issue when omitted
|
||||
update();
|
||||
|
||||
return !clickResult.isCancel();
|
||||
}
|
||||
|
||||
|
@ -145,8 +145,8 @@ public class InventoryClickProcessor {
|
||||
|
||||
if (clicked.isAir()) {
|
||||
// Set held item [key] to slot
|
||||
resultClicked = ItemStack.getAirItem();
|
||||
resultHeld = clicked.clone();
|
||||
resultClicked = cursor.clone();
|
||||
resultHeld = ItemStack.getAirItem();
|
||||
} else {
|
||||
if (cursor.isAir()) {
|
||||
// if held item [key] is air then set clicked to held
|
||||
|
Loading…
Reference in New Issue
Block a user