Fixed: Исправлен стак больше максимального
- Более стабильная реализация getCurrentWorldGenRegion
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.zhekasmirnov.apparatus.api.container;
|
||||
|
||||
import com.reider745.item.ItemMethod;
|
||||
import com.zhekasmirnov.apparatus.adapter.innercore.game.item.ItemStack;
|
||||
import com.zhekasmirnov.apparatus.mcpe.NativeBlockSource;
|
||||
import com.zhekasmirnov.apparatus.mcpe.NativePlayer;
|
||||
@@ -640,7 +641,7 @@ public class ItemContainer implements WorkbenchField {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
if (amount > 0) {
|
||||
/*if (amount > 0) {
|
||||
ItemContainerSlot slot = getSlot(slotName);
|
||||
if (slot.id != 0 && slot.count > 0) {
|
||||
NativePlayer player = new NativePlayer(playerUid);
|
||||
@@ -656,6 +657,35 @@ public class ItemContainer implements WorkbenchField {
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
//Фикс максимально стака
|
||||
if(amount > 0){
|
||||
ItemContainerSlot slot = getSlot(slotName);
|
||||
if (slot.id != 0 && slot.count > 0) {
|
||||
NativePlayer player = new NativePlayer(playerUid);
|
||||
if (player.isValid()) {
|
||||
int id = slot.id;
|
||||
int data = slot.data;
|
||||
NativeItemInstanceExtra extra = slot.extra;
|
||||
amount = getFromSlot(slotName, id, amount, data, extra, playerUid);
|
||||
int maxStack = ItemMethod.getMaxStackForId(id, data);
|
||||
|
||||
if (amount > 0) {
|
||||
if(amount <= maxStack){
|
||||
synchronized (playerInventoryLock) {
|
||||
player.addItemToInventory(id, amount, data, extra, true);
|
||||
}
|
||||
}else{
|
||||
synchronized (playerInventoryLock) {
|
||||
while (amount > 0) {
|
||||
player.addItemToInventory(id, Math.min(amount, maxStack), data, extra, true);
|
||||
amount -= maxStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zhekasmirnov.apparatus.mcpe;
|
||||
|
||||
import cn.nukkit.Server;
|
||||
import cn.nukkit.blockentity.BlockEntity;
|
||||
import cn.nukkit.entity.Entity;
|
||||
import cn.nukkit.level.Level;
|
||||
@@ -64,6 +65,7 @@ public class NativeBlockSource {
|
||||
|
||||
public static NativeBlockSource getCurrentWorldGenRegion() {
|
||||
Level level = CallbackHelper.getForCurrentThread();
|
||||
if(level == null) Server.getInstance().getDefaultLevel();
|
||||
return level != null ? new NativeBlockSource(level, false) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Change resolution of pack that client should have to log into server.
|
||||
# However, no deprecated or unimplemented methods will be added.
|
||||
pack: Inner Core Test
|
||||
pack-version: 2.3.0b118
|
||||
pack-version-code: 158
|
||||
pack-version: 2.3.0b119
|
||||
pack-version-code: 159
|
||||
|
||||
# Sets the list of mods and configs to load, you can specify
|
||||
# name, folder name of a modpack from /modpacks or a path.
|
||||
|
||||
Reference in New Issue
Block a user