add callbacks for ticking

This commit is contained in:
Tofaa 2024-01-19 07:32:11 +03:00
parent a4f57da66f
commit 4988e00ba8
5 changed files with 25 additions and 8 deletions

View file

@ -5,12 +5,7 @@
</component>
<component name="ChangeListManager">
<list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/meta/types/DisplayMeta.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/meta/types/DisplayMeta.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/SpawnClickableFrogCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/SpawnClickableFrogCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestDisplayCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestDisplayCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/entity/WrapperEntityCreature.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/entity/WrapperEntityCreature.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -215,7 +210,7 @@
<workItem from="1705192736239" duration="496000" />
<workItem from="1705534524814" duration="15424000" />
<workItem from="1705578156456" duration="78000" />
<workItem from="1705636302508" duration="1873000" />
<workItem from="1705636302508" duration="2201000" />
</task>
<servers />
</component>

View file

@ -2,6 +2,11 @@ package me.tofaa.entitylib;
public interface Tickable {
void update(long time);
/** Internal method for actual logic ticking, if you want to add custom logic to your entity, override {@link #tick(long)} instead. */
default void update(long time) {
}
void tick(long time);
}

View file

@ -242,6 +242,11 @@ public class WrapperEntity implements Tickable {
@Override
public void update(long time) {
tick(time);
}
@Override
public void tick(long time) {
}
}

View file

@ -31,6 +31,12 @@ public class WrapperEntityCreature extends WrapperLivingEntity {
this.aiGroups = new HashSet<>();
}
@Override
public void update(long time) {
super.update(time);
aiGroups.forEach(aiGroup -> aiGroup.update(time));
}
@Override
public void kill() {
super.kill();

View file

@ -64,6 +64,12 @@ public class AIGroup implements Tickable {
if (currentGoalSelector != null) {
currentGoalSelector.tick(time);
}
tick(time);
}
@Override
public void tick(long time) {
}
}