Skip to content

Commit 0936cb4

Browse files
committed
Don't add contraption entities without mass as kinematic contraptions
1 parent b564c10 commit 0936cb4

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

neoforge/src/main/java/dev/ryanhcode/sable/neoforge/mixin/compatibility/create/contraptions/AbstractContraptionEntityMixin.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public abstract class AbstractContraptionEntityMixin extends Entity implements K
6262
@Unique
6363
private MassTracker sable$massTracker;
6464
@Unique
65-
private boolean sable$added = false;
65+
private boolean sable$initialized = false;
6666

6767
public AbstractContraptionEntityMixin(final EntityType<?> arg, final Level arg2) {
6868
super(arg, arg2);
@@ -96,11 +96,18 @@ public AbstractContraptionEntityMixin(final EntityType<?> arg, final Level arg2)
9696

9797
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;"), remap = false)
9898
private void sable$contraptionInitialize(final CallbackInfo ci) {
99-
if (!this.sable$added && this.level() instanceof final ServerLevel serverLevel) {
99+
if (!this.sable$initialized && this.level() instanceof final ServerLevel serverLevel) {
100100
this.sable$buildProperties();
101+
102+
if (this.sable$massTracker.getCenterOfMass() == null) {
103+
// The contraption is effectively empty, quit early
104+
this.sable$initialized = true;
105+
return;
106+
}
107+
101108
this.sable$addToPlot();
102109
this.sable$addToPipeline(serverLevel);
103-
this.sable$added = true;
110+
this.sable$initialized = true;
104111
}
105112
}
106113

0 commit comments

Comments
 (0)