-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly update and rebase everything to LexForge 47.3.12
- Loading branch information
Showing
12 changed files
with
139 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/xyz/bluspring/kilt/forgeinjects/world/entity/ai/BrainInject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package xyz.bluspring.kilt.forgeinjects.world.entity.ai; | ||
|
||
import com.mojang.datafixers.util.Pair; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.Brain; | ||
import net.minecraft.world.entity.ai.behavior.BehaviorControl; | ||
import net.minecraft.world.entity.ai.memory.ExpirableValue; | ||
import net.minecraft.world.entity.ai.memory.MemoryModuleType; | ||
import net.minecraft.world.entity.ai.memory.MemoryStatus; | ||
import net.minecraft.world.entity.ai.sensing.Sensor; | ||
import net.minecraft.world.entity.ai.sensing.SensorType; | ||
import net.minecraft.world.entity.schedule.Activity; | ||
import net.minecraft.world.entity.schedule.Schedule; | ||
import net.minecraftforge.common.util.BrainBuilder; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import xyz.bluspring.kilt.injections.world.entity.ai.BrainInjection; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
@Mixin(Brain.class) | ||
public abstract class BrainInject<E extends LivingEntity> implements BrainInjection<E> { | ||
@Shadow @Final private Map<MemoryModuleType<?>, Optional<? extends ExpirableValue<?>>> memories; | ||
|
||
@Shadow @Final private Map<SensorType<? extends Sensor<? super E>>, Sensor<? super E>> sensors; | ||
|
||
@Shadow @Final private Map<Integer, Map<Activity, Set<BehaviorControl<? super E>>>> availableBehaviorsByPriority; | ||
|
||
@Shadow public abstract Schedule getSchedule(); | ||
|
||
@Shadow @Final private Map<Activity, Set<Pair<MemoryModuleType<?>, MemoryStatus>>> activityRequirements; | ||
|
||
@Shadow @Final private Map<Activity, Set<MemoryModuleType<?>>> activityMemoriesToEraseWhenStopped; | ||
|
||
@Shadow private Set<Activity> coreActivities; | ||
|
||
@Shadow private Activity defaultActivity; | ||
|
||
@Shadow @Final private Set<Activity> activeActivities; | ||
|
||
@Shadow public abstract void setDefaultActivity(Activity newFallbackActivity); | ||
|
||
@Shadow public abstract void setCoreActivities(Set<Activity> newActivities); | ||
|
||
@Shadow public abstract void setSchedule(Schedule newSchedule); | ||
|
||
@Override | ||
public BrainBuilder<E> createBuilder() { | ||
var builder = new BrainBuilder<>((Brain<E>) (Object) this); | ||
builder.getMemoryTypes().addAll(this.memories.keySet()); | ||
builder.getSensorTypes().addAll(this.sensors.keySet()); | ||
builder.addAvailableBehaviorsByPriorityFrom(this.availableBehaviorsByPriority); | ||
builder.setSchedule(this.getSchedule()); | ||
builder.addActivityRequirementsFrom(this.activityRequirements); | ||
builder.addActivityMemoriesToEraseWhenStoppedFrom(this.activityMemoriesToEraseWhenStopped); | ||
builder.getCoreActivities().addAll(this.coreActivities); | ||
builder.setDefaultActivity(this.defaultActivity); | ||
builder.setActiveActivites(this.activeActivities); | ||
|
||
return builder; | ||
} | ||
|
||
@Override | ||
public void copyFromBuilder(BrainBuilder<E> builder) { | ||
builder.addAvailableBehaviorsByPriorityTo(this.availableBehaviorsByPriority); | ||
this.setSchedule(builder.getSchedule()); | ||
builder.addActivityRequirementsTo(this.activityRequirements); | ||
builder.addActivityMemoriesToEraseWhenStoppedTo(this.activityMemoriesToEraseWhenStopped); | ||
this.setCoreActivities(builder.getCoreActivities()); | ||
this.setDefaultActivity(builder.getDefaultActivity()); | ||
this.activeActivities.addAll(builder.getActiveActivites()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/xyz/bluspring/kilt/injections/world/entity/ai/BrainInjection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package xyz.bluspring.kilt.injections.world.entity.ai; | ||
|
||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraftforge.common.util.BrainBuilder; | ||
|
||
public interface BrainInjection<E extends LivingEntity> { | ||
default BrainBuilder<E> createBuilder() { | ||
throw new IllegalStateException(); | ||
} | ||
|
||
default void copyFromBuilder(BrainBuilder<E> builder) { | ||
throw new IllegalStateException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters