Skip to content

Commit

Permalink
Fix ManualAttachment
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 6, 2024
1 parent 5cb1f49 commit 0e60130
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 10 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private PolymerCommonUtils() {}

public static final SimpleEvent<ResourcePackChangeCallback> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec3d> posSupplier) implements HolderAttachment {
public final class ManualAttachment implements HolderAttachment {
private final ElementHolder holder;
private final ServerWorld world;
private final Supplier<Vec3d> posSupplier;

public ManualAttachment {
public ManualAttachment(ElementHolder holder, ServerWorld world, Supplier<Vec3d> posSupplier) {
this.holder = holder;
this.world = world;
this.posSupplier = posSupplier;
holder.setAttachment(this);
}

Expand All @@ -32,8 +39,47 @@ public ServerWorld getWorld() {
}

@Override
public void updateCurrentlyTracking(Collection<ServerPlayNetworkHandler> currentlyTracking) {}
public void updateCurrentlyTracking(Collection<ServerPlayNetworkHandler> 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<Vec3d> 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 + ']';
}

}

0 comments on commit 0e60130

Please sign in to comment.