remove Better ShulkerBox and Update Upstream(Luminol)
This commit is contained in:
@@ -96,7 +96,7 @@ public class CullTask implements Runnable {
|
||||
lastCheckedTime = (System.currentTimeMillis() - start);
|
||||
}
|
||||
}
|
||||
}finally {
|
||||
} finally {
|
||||
if (this.scheduleNext) {
|
||||
this.worker.execute(this);
|
||||
}
|
||||
|
||||
-5
@@ -20,11 +20,6 @@ public class ContainerExpansionConfig implements IConfigModule {
|
||||
range: 1~64""")
|
||||
public static int shulkerCount = 1;
|
||||
|
||||
@ConfigInfo(baseName = "better_shulker_box", comments =
|
||||
"""
|
||||
Enable sneak + use to open shulker box.""")
|
||||
public static boolean betterShulker = false;
|
||||
|
||||
@Override
|
||||
public EnumConfigCategory getCategory() {
|
||||
return EnumConfigCategory.MISC;
|
||||
|
||||
@@ -7,6 +7,7 @@ import me.earthme.luminol.config.flags.TransformedConfig;
|
||||
|
||||
public class RemovedConfig implements IConfigModule {
|
||||
@TransformedConfig(name = "old_nether_portal_collision", category = {"misc", "old-feature"}, transform = false)
|
||||
@TransformedConfig(name = "better_shulker_box", category = {"misc", "container_expansion"}, transform = false)
|
||||
@ConfigInfo(baseName = "removed", comments =
|
||||
"""
|
||||
RemovedConfig redirect to here, no any function.""")
|
||||
|
||||
@@ -32,10 +32,10 @@ import java.util.function.BiConsumer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/*
|
||||
* authored by: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
* modified by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
|
||||
* Some of diff form Leaves
|
||||
*/
|
||||
* authored by: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
* modified by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
|
||||
* Some of diff form Leaves
|
||||
*/
|
||||
public class ServerI18nUtil {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("LangLoader");
|
||||
|
||||
@@ -1,31 +1,18 @@
|
||||
package fun.bm.lophine.utils;
|
||||
|
||||
import fun.bm.lophine.config.modules.misc.ContainerExpansionConfig;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.SlotAccess;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.component.CustomData;
|
||||
import net.minecraft.world.item.component.ItemContainerContents;
|
||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ShulkerBoxesUtil {
|
||||
// Better ShulkerBoxes used
|
||||
public static HashMap<Player, ShulkerBoxBlockEntity> shulkerMap = new HashMap<>();
|
||||
public static HashMap<ShulkerBoxBlockEntity, Player> playerMap = new HashMap<>();
|
||||
|
||||
// Stackable ShulkerBoxes part
|
||||
public static boolean shouldCheck() {
|
||||
return ContainerExpansionConfig.shulkerCount > 1 && ContainerExpansionConfig.shulkerCount <= 64;
|
||||
}
|
||||
@@ -88,76 +75,4 @@ public class ShulkerBoxesUtil {
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
// Better ShulkerBox part
|
||||
public static boolean checkIfCanOpen(ItemStack itemStack) {
|
||||
return checkIsShulkerBox(itemStack) && itemStack.getCount() == 1;
|
||||
}
|
||||
|
||||
public static boolean checkIfValid(Player player) {
|
||||
return shulkerMap.get(player) != null;
|
||||
}
|
||||
|
||||
public static void openShulkerBox(Player player, ItemStack item, InteractionHand hand) {
|
||||
ItemStack itemInHand = item.copy();
|
||||
ShulkerBoxBlockEntity shulkerBoxEntity = new ShulkerBoxBlockEntity(
|
||||
player.blockPosition(),
|
||||
((BlockItem) itemInHand.getItem()).getBlock().defaultBlockState()
|
||||
);
|
||||
ItemContainerContents container = itemInHand.getOrDefault(
|
||||
DataComponents.CONTAINER,
|
||||
ItemContainerContents.EMPTY
|
||||
);
|
||||
|
||||
NonNullList<ItemStack> items = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
for (int i = 0; i < container.items.size(); i++) {
|
||||
items.set(i, container.items.get(i));
|
||||
}
|
||||
|
||||
shulkerBoxEntity.setItems(items);
|
||||
|
||||
shulkerBoxEntity.haveRealBlock = false;
|
||||
shulkerBoxEntity.slot = hand == InteractionHand.MAIN_HAND ? player.getInventory().getSelectedSlot() : 40;
|
||||
shulkerBoxEntity.setLevel(player.level());
|
||||
|
||||
shulkerMap.put(player, shulkerBoxEntity);
|
||||
playerMap.put(shulkerBoxEntity, player);
|
||||
|
||||
if (player.openMenu(shulkerBoxEntity).isPresent()) {
|
||||
player.awardStat(Stats.OPEN_SHULKER_BOX);
|
||||
}
|
||||
}
|
||||
|
||||
public static void shulkerBoxEntityCallBack(ShulkerBoxBlockEntity shulkerBoxEntity) {
|
||||
Player player = playerMap.get(shulkerBoxEntity);
|
||||
if (player != null) {
|
||||
SlotAccess slot = player.getSlot(shulkerBoxEntity.slot);
|
||||
ItemStack currentItem = slot.get();
|
||||
ItemStack copy = currentItem.copy();
|
||||
|
||||
copy.set(DataComponents.CONTAINER, ItemContainerContents.fromItems(shulkerBoxEntity.getItems()));
|
||||
|
||||
slot.set(copy);
|
||||
}
|
||||
}
|
||||
|
||||
public static void inventoryCallBack(Player player, int slotId) {
|
||||
ShulkerBoxBlockEntity entity = shulkerMap.get(player);
|
||||
if (entity != null) {
|
||||
if ((slotId == entity.slot) && player instanceof ServerPlayer serverPlayer)
|
||||
serverPlayer.closeContainer();
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearMap(Player p) {
|
||||
ShulkerBoxBlockEntity e = shulkerMap.get(p);
|
||||
if (e != null) playerMap.remove(e);
|
||||
shulkerMap.remove(p);
|
||||
}
|
||||
|
||||
public static void clearMap(ShulkerBoxBlockEntity e) {
|
||||
Player p = playerMap.get(e);
|
||||
if (p != null) shulkerMap.remove(p);
|
||||
playerMap.remove(e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user