From 0e60130d0143a161c6cb592fc8eac760a55ca11d Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Fri, 6 Dec 2024 20:59:51 +0100 Subject: [PATCH] Fix ManualAttachment --- gradle.properties | 6 +-- .../common/api/PolymerCommonUtils.java | 2 +- .../api/attachment/ChunkAttachment.java | 2 +- .../api/attachment/EntityAttachment.java | 2 +- .../api/attachment/ManualAttachment.java | 54 +++++++++++++++++-- 5 files changed, 56 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index ffe7551c..62cfe815 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,12 @@ org.gradle.jvmargs=-Xmx4G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.21.4-rc1 -yarn_mappings=1.21.4-rc1+build.1 +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.1 loader_version=0.16.9 # Fabric API -fabric_version=0.110.2+1.21.4 +fabric_version=0.111.0+1.21.4 maven_group = eu.pb4 diff --git a/polymer-common/src/main/java/eu/pb4/polymer/common/api/PolymerCommonUtils.java b/polymer-common/src/main/java/eu/pb4/polymer/common/api/PolymerCommonUtils.java index 11d63e5b..2265245e 100644 --- a/polymer-common/src/main/java/eu/pb4/polymer/common/api/PolymerCommonUtils.java +++ b/polymer-common/src/main/java/eu/pb4/polymer/common/api/PolymerCommonUtils.java @@ -33,7 +33,7 @@ private PolymerCommonUtils() {} public static final SimpleEvent ON_RESOURCE_PACK_STATUS_CHANGE = new SimpleEvent<>(); private static Path cachedClientPath; - private final static String SAFE_CLIENT_SHA1 = "e879469d52776f40a14fe8472e8a02dafdf4dc27"; + private final static String SAFE_CLIENT_SHA1 = "a7e5a6024bfd3cd614625aa05629adf760020304"; private final static String SAFE_CLIENT_URL = "https://piston-data.mojang.com/v1/objects/" + SAFE_CLIENT_SHA1 + "/client.jar"; private static Path cachedClientJarRoot; diff --git a/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/ChunkAttachment.java b/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/ChunkAttachment.java index a2ab9a73..4eec7f7b 100644 --- a/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/ChunkAttachment.java +++ b/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/ChunkAttachment.java @@ -29,8 +29,8 @@ public ChunkAttachment(ElementHolder holder, WorldChunk chunk, Vec3d position, b this.chunk = chunk; this.pos = position; this.holder = holder; - this.attach(); this.autoTick = autoTick; + this.attach(); } protected void attach() { diff --git a/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/EntityAttachment.java b/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/EntityAttachment.java index d9bf1086..08272e33 100644 --- a/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/EntityAttachment.java +++ b/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/EntityAttachment.java @@ -22,8 +22,8 @@ public EntityAttachment(ElementHolder holder, Entity entity, boolean autoTick) { this.entity = entity; this.holder = holder; ((HolderAttachmentHolder) entity).polymerVE$addHolder(this); - this.holder.setAttachment(this); this.autoTick = autoTick; + this.holder.setAttachment(this); } public static EntityAttachment of(ElementHolder holder, Entity entity) { diff --git a/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/ManualAttachment.java b/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/ManualAttachment.java index 6f121663..2b89d810 100644 --- a/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/ManualAttachment.java +++ b/polymer-virtual-entity/src/main/java/eu/pb4/polymer/virtualentity/api/attachment/ManualAttachment.java @@ -6,11 +6,18 @@ import net.minecraft.util.math.Vec3d; import java.util.Collection; +import java.util.Objects; import java.util.function.Supplier; -public record ManualAttachment(ElementHolder holder, ServerWorld world, Supplier posSupplier) implements HolderAttachment { +public final class ManualAttachment implements HolderAttachment { + private final ElementHolder holder; + private final ServerWorld world; + private final Supplier posSupplier; - public ManualAttachment { + public ManualAttachment(ElementHolder holder, ServerWorld world, Supplier posSupplier) { + this.holder = holder; + this.world = world; + this.posSupplier = posSupplier; holder.setAttachment(this); } @@ -32,8 +39,47 @@ public ServerWorld getWorld() { } @Override - public void updateCurrentlyTracking(Collection currentlyTracking) {} + public void updateCurrentlyTracking(Collection currentlyTracking) { + } @Override - public void updateTracking(ServerPlayNetworkHandler tracking) {} + public void updateTracking(ServerPlayNetworkHandler tracking) { + } + + @Override + public ElementHolder holder() { + return holder; + } + + public ServerWorld world() { + return world; + } + + public Supplier posSupplier() { + return posSupplier; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (obj == null || obj.getClass() != this.getClass()) return false; + var that = (ManualAttachment) obj; + return Objects.equals(this.holder, that.holder) && + Objects.equals(this.world, that.world) && + Objects.equals(this.posSupplier, that.posSupplier); + } + + @Override + public int hashCode() { + return Objects.hash(holder, world, posSupplier); + } + + @Override + public String toString() { + return "ManualAttachment[" + + "holder=" + holder + ", " + + "world=" + world + ", " + + "posSupplier=" + posSupplier + ']'; + } + }