Skip to content

Commit

Permalink
dont access ticking maps from outside
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Jan 6, 2025
1 parent 26e225b commit db91ba3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ private static synchronized ComponentContainer.Factory<BlockEntity> getBeCompone
factory = /* recursive call */ getBeComponentFactory(superclass);

// if parent class needs to tick, this one does, too!
if(StaticBlockComponentPlugin.INSTANCE.clientTicking.contains(superclass)) StaticBlockComponentPlugin.INSTANCE.clientTicking.add(entityClass);
if(StaticBlockComponentPlugin.INSTANCE.serverTicking.contains(superclass)) StaticBlockComponentPlugin.INSTANCE.serverTicking.add(entityClass);
StaticBlockComponentPlugin.INSTANCE.registerTickersFor(entityClass, superclass);
}
entityContainerFactories.put(entityClass, factory);
return factory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ public ComponentContainer.Factory<BlockEntity> buildDedicatedFactory(Class<? ext
return builder.build();
}

public void registerTickersFor(Class<? extends BlockEntity> entityClass, Class<? extends BlockEntity> parentClass) {
if(this.clientTicking.contains(parentClass)) {
this.clientTicking.add(entityClass);
}
if(this.serverTicking.contains(parentClass)) {
this.serverTicking.add(entityClass);
}
}

private <C extends Component> void addToBuilder(ComponentContainer.Factory.Builder<BlockEntity> builder, Map.Entry<ComponentKey<?>, QualifiedComponentFactory<ComponentFactory<? extends BlockEntity, ?>>> entry) {
@SuppressWarnings("unchecked") var key = (ComponentKey<C>) entry.getKey();
@SuppressWarnings("unchecked") var factory = (ComponentFactory<BlockEntity, C>) entry.getValue().factory();
Expand Down

0 comments on commit db91ba3

Please sign in to comment.