9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-19 15:09:15 +00:00
This commit is contained in:
jhqwqmc
2025-12-06 19:34:35 +08:00
parent e2170f54ba
commit b1d91cb0f0
9 changed files with 38 additions and 34 deletions

View File

@@ -27,7 +27,9 @@ public class MMOItemsSource implements ExternalItemSource<ItemStack> {
split = split[0].split("_", 2); split = split[0].split("_", 2);
} }
if (split.length == 1) return new ItemStack(Material.AIR); if (split.length == 1) return new ItemStack(Material.AIR);
MMOItem mmoItem = MMOItems.plugin.getMMOItem(Type.get(split[0]), split[1].toUpperCase(Locale.ROOT)); // 这里与使用和mmoitems相同的转换id方法
String mmoItemId = split[1].toUpperCase().replace("-", "_").replace(" ", "_");
MMOItem mmoItem = MMOItems.plugin.getMMOItem(Type.get(split[0]), mmoItemId);
return mmoItem == null ? new ItemStack(Material.AIR) : requireNonNull(mmoItem.newBuilder().build()); return mmoItem == null ? new ItemStack(Material.AIR) : requireNonNull(mmoItem.newBuilder().build());
} }

View File

@@ -182,7 +182,13 @@ public class ItemDisplayBlockEntityElementConfig implements BlockEntityElementCo
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(xRot, yRot, position, translation, rotation); int result = 17;
result = 31 * result + Double.hashCode(xRot);
result = 31 * result + Double.hashCode(yRot);
result = 31 * result + (position != null ? position.hashCode() : 0);
result = 31 * result + (translation != null ? translation.hashCode() : 0);
result = 31 * result + (rotation != null ? rotation.hashCode() : 0);
return result;
} }
public static class Factory implements BlockEntityElementConfigFactory<ItemDisplayBlockEntityElement> { public static class Factory implements BlockEntityElementConfigFactory<ItemDisplayBlockEntityElement> {

View File

@@ -156,7 +156,13 @@ public class TextDisplayBlockEntityElementConfig implements BlockEntityElementCo
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(xRot, yRot, position, translation, rotation); int result = 17;
result = 31 * result + Double.hashCode(xRot);
result = 31 * result + Double.hashCode(yRot);
result = 31 * result + (position != null ? position.hashCode() : 0);
result = 31 * result + (translation != null ? translation.hashCode() : 0);
result = 31 * result + (rotation != null ? rotation.hashCode() : 0);
return result;
} }
public static class Factory implements BlockEntityElementConfigFactory<TextDisplayBlockEntityElement> { public static class Factory implements BlockEntityElementConfigFactory<TextDisplayBlockEntityElement> {

View File

@@ -43,7 +43,7 @@ public class ItemDisplayFurnitureElement implements FurnitureElement {
this.position.x, this.position.y, this.position.z, 0, this.position.yRot, this.position.x, this.position.y, this.position.z, 0, this.position.yRot,
MEntityTypes.ITEM_DISPLAY, 0, CoreReflections.instance$Vec3$Zero, 0 MEntityTypes.ITEM_DISPLAY, 0, CoreReflections.instance$Vec3$Zero, 0
), ),
FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(this.entityId, this.config.metadata().apply(player, this.colorSource)) FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(this.entityId, this.config.metadata.apply(player, this.colorSource))
)), false); )), false);
} }

View File

@@ -31,23 +31,23 @@ import java.util.function.BiFunction;
public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig<ItemDisplayFurnitureElement> { public class ItemDisplayFurnitureElementConfig implements FurnitureElementConfig<ItemDisplayFurnitureElement> {
public static final Factory FACTORY = new Factory(); public static final Factory FACTORY = new Factory();
private final BiFunction<Player, FurnitureColorSource, List<Object>> metadata; public final BiFunction<Player, FurnitureColorSource, List<Object>> metadata;
private final Key itemId; public final Key itemId;
private final Vector3f scale; public final Vector3f scale;
private final Vector3f position; public final Vector3f position;
private final Vector3f translation; public final Vector3f translation;
private final float xRot; public final float xRot;
private final float yRot; public final float yRot;
private final Quaternionf rotation; public final Quaternionf rotation;
private final ItemDisplayContext displayContext; public final ItemDisplayContext displayContext;
private final Billboard billboard; public final Billboard billboard;
private final float shadowRadius; public final float shadowRadius;
private final float shadowStrength; public final float shadowStrength;
private final boolean applyDyedColor; public final boolean applyDyedColor;
private final Color glowColor; public final Color glowColor;
private final int blockLight; public final int blockLight;
private final int skyLight; public final int skyLight;
private final float viewRange; public final float viewRange;
public ItemDisplayFurnitureElementConfig(Key itemId, public ItemDisplayFurnitureElementConfig(Key itemId,
Vector3f scale, Vector3f scale,

View File

@@ -181,7 +181,7 @@ public final class BlockStateGenerator {
if (state == null) return thisObj; if (state == null) return thisObj;
Property<Boolean> waterloggedProperty = (Property<Boolean>) state.owner().value().getProperty("waterlogged"); Property<Boolean> waterloggedProperty = (Property<Boolean>) state.owner().value().getProperty("waterlogged");
if (waterloggedProperty == null) return thisObj; if (waterloggedProperty == null) return thisObj;
return state.with(waterloggedProperty, (Boolean) args[1]).customBlockState().literalObject(); return state.with(waterloggedProperty, (boolean) args[1]).customBlockState().literalObject();
} }
} }

View File

@@ -43,7 +43,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
public final class SelfHostHttpServer { public final class SelfHostHttpServer {
private static volatile SelfHostHttpServer instance; private static SelfHostHttpServer instance;
private final Cache<String, String> oneTimePackUrls = Caffeine.newBuilder() private final Cache<String, String> oneTimePackUrls = Caffeine.newBuilder()
.maximumSize(1024) .maximumSize(1024)
.scheduler(Scheduler.systemScheduler()) .scheduler(Scheduler.systemScheduler())
@@ -94,11 +94,7 @@ public final class SelfHostHttpServer {
public static SelfHostHttpServer instance() { public static SelfHostHttpServer instance() {
if (instance == null) { if (instance == null) {
synchronized (SelfHostHttpServer.class) { instance = new SelfHostHttpServer();
if (instance == null) {
instance = new SelfHostHttpServer();
}
}
} }
return instance; return instance;
} }

View File

@@ -2,13 +2,10 @@ package net.momirealms.craftengine.core.util;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
public class MarkedArrayList<T> extends ArrayList<T> { public class MarkedArrayList<T> extends ArrayList<T> {
@Serial
private static final long serialVersionUID = 1L;
public MarkedArrayList() { public MarkedArrayList() {
} }

View File

@@ -1,9 +1,6 @@
package net.momirealms.craftengine.core.util; package net.momirealms.craftengine.core.util;
import java.io.Serial;
import java.util.HashMap; import java.util.HashMap;
public class MarkedHashMap<K, V> extends HashMap<K, V> { public class MarkedHashMap<K, V> extends HashMap<K, V> {
@Serial
private static final long serialVersionUID = 1L;
} }