9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 01:49:30 +00:00

Merge branch 'Xiao-MoMi:dev' into dev

This commit is contained in:
Halogly
2025-07-23 00:04:59 +08:00
committed by GitHub
3 changed files with 27 additions and 8 deletions

View File

@@ -60,6 +60,7 @@ public final class ModernNetworkItemHandler implements NetworkItemHandler<ItemSt
@Override
public Optional<Item<ItemStack>> s2c(Item<ItemStack> wrapped, Player player) {
Item<ItemStack> original = wrapped;
Optional<CustomItem<ItemStack>> optionalCustomItem = wrapped.getCustomItem();
if (optionalCustomItem.isEmpty()) {
if (!Config.interceptItem()) return Optional.empty();
@@ -89,7 +90,7 @@ public final class ModernNetworkItemHandler implements NetworkItemHandler<ItemSt
}
CompoundTag tag = new CompoundTag();
for (ItemDataModifier<ItemStack> modifier : customItem.clientBoundDataModifiers()) {
modifier.prepareNetworkItem(wrapped, context, tag);
modifier.prepareNetworkItem(original, context, tag);
}
for (ItemDataModifier<ItemStack> modifier : customItem.clientBoundDataModifiers()) {
modifier.apply(wrapped, context);

View File

@@ -383,7 +383,7 @@ chunk-system:
target: SECTION
# Enables faster injection method
# Note: May not work with certain server forks that alter chunk class structure (In most cases it won't conflict)
use-fast-method: false
use-fast-method: true
# Auto-convert custom blocks -> vanilla blocks when unloading chunks
#
# - When ENABLED (true):

View File

@@ -20,6 +20,17 @@ import java.util.stream.Stream;
public class HideTooltipModifier<I> implements ItemDataModifier<I> {
public static final Map<Key, Integer> TO_LEGACY;
public static final List<Key> COMPONENTS = List.of(
ComponentKeys.UNBREAKABLE,
ComponentKeys.ENCHANTMENTS,
ComponentKeys.STORED_ENCHANTMENTS,
ComponentKeys.CAN_PLACE_ON,
ComponentKeys.CAN_BREAK,
ComponentKeys.ATTRIBUTE_MODIFIERS,
ComponentKeys.DYED_COLOR,
ComponentKeys.TRIM,
ComponentKeys.JUKEBOX_PLAYABLE
);
static {
ImmutableMap.Builder<Key, Integer> builder = ImmutableMap.builder();
builder.put(ComponentKeys.ENCHANTMENTS, 1);
@@ -52,13 +63,24 @@ public class HideTooltipModifier<I> implements ItemDataModifier<I> {
if (components.isEmpty()) {
this.applier = new DummyApplier<>();
} else if (components.size() == 1) {
this.applier = new SemiModernApplier<>(components.getFirst());
if (COMPONENTS.contains(components.getFirst())) {
this.applier = new SemiModernApplier<>(components.getFirst());
} else {
this.applier = new DummyApplier<>();
}
} else {
List<Applier<I>> appliers = new ArrayList<>();
for (Key key : components) {
if (!COMPONENTS.contains(key)) continue;
appliers.add(new SemiModernApplier<>(key));
}
this.applier = new CompoundApplier<>(appliers);
if (appliers.isEmpty()) {
this.applier = new DummyApplier<>();
} else if (appliers.size() == 1) {
this.applier = appliers.getFirst();
} else {
this.applier = new CompoundApplier<>(appliers);
}
}
} else {
this.applier = new LegacyApplier<>(components);
@@ -134,10 +156,6 @@ public class HideTooltipModifier<I> implements ItemDataModifier<I> {
if (previous instanceof CompoundTag compoundTag) {
compoundTag.putBoolean("show_in_tooltip", false);
item.setNBTComponent(this.component, compoundTag);
} else {
CompoundTag compoundTag = new CompoundTag();
compoundTag.putBoolean("show_in_tooltip", false);
item.setNBTComponent(this.component, compoundTag);
}
}
}