summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling
diff options
context:
space:
mode:
authorMerrg1n <[email protected]>2022-08-13 22:36:35 +0800
committerMerrg1n <[email protected]>2022-08-14 01:42:37 +0800
commit94f092015a05d0179e307468c717ad391e455742 (patch)
tree1e90e0462e8bc2a6d4ae4131808b655089db72a9 /src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling
parent323226a7956b2dc1d56c56e63bc9354e2b8bd244 (diff)
carpet ext
Diffstat (limited to 'src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling')
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling/SchoolingFishEntityMixin.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling/SchoolingFishEntityMixin.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling/SchoolingFishEntityMixin.java
new file mode 100644
index 0000000..9e82f09
--- /dev/null
+++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling/SchoolingFishEntityMixin.java
@@ -0,0 +1,50 @@
+package com.keuin.ohmyvanillamc.mixins.rule.disableFishSchooling;
+
+import com.keuin.ohmyvanillamc.OmvmSettings;
+import net.minecraft.entity.EntityType;
+import net.minecraft.entity.ai.goal.FollowGroupLeaderGoal;
+import net.minecraft.entity.passive.FishEntity;
+import net.minecraft.entity.passive.SchoolingFishEntity;
+import net.minecraft.world.World;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Overwrite;
+import org.spongepowered.asm.mixin.Shadow;
+
+@Mixin(SchoolingFishEntity.class)
+public abstract class SchoolingFishEntityMixin extends FishEntity {
+
+ public SchoolingFishEntityMixin(EntityType<? extends FishEntity> type, World world) {
+ super(type, world);
+ }
+
+ @Shadow
+ public abstract boolean hasLeader();
+
+ @Shadow
+ private SchoolingFishEntity leader;
+
+ /**
+ * @reason To disable SchoolingFish schooling.
+ * @author trueKeuin
+ */
+ @Overwrite
+ public void moveTowardLeader() {
+ if (!OmvmSettings.disableFishSchooling) {
+ if (this.hasLeader()) {
+ this.getNavigation().startMovingTo(this.leader, 1.0D);
+ }
+ }
+ }
+
+ /**
+ * @reason To disable SchoolingFish schooling.
+ * @author trueKeuin
+ */
+ @Overwrite
+ public void initGoals() {
+ super.initGoals();
+ if (!OmvmSettings.disableFishSchooling) {
+ this.goalSelector.add(5, new FollowGroupLeaderGoal((SchoolingFishEntity) (Object) this));
+ }
+ }
+}