diff options
author | Keuin <[email protected]> | 2020-12-18 22:26:09 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2020-12-18 22:26:09 +0800 |
commit | 7b712c6b88017e5615c2b9d438d5c6aed6c25bf3 (patch) | |
tree | 6c53c3dddbc33063740b3824ad5922a58f0b0721 /src | |
parent | ac5bdf4a3ca555fa4638d6fad6b06b9941ad3ba2 (diff) |
Bugfix: now the disabling of fish schooling works.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/keuin/ohmyvanillamc/mixin/DisableFishSchooling.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/DisableFishSchooling.java b/src/main/java/com/keuin/ohmyvanillamc/mixin/DisableFishSchooling.java index 28342c9..b48b2b1 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixin/DisableFishSchooling.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixin/DisableFishSchooling.java @@ -1,21 +1,37 @@ package com.keuin.ohmyvanillamc.mixin; import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft; +import net.minecraft.entity.EntityType; +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; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(SchoolingFishEntity.class) -public class DisableFishSchooling { +public abstract class DisableFishSchooling extends FishEntity { + + public DisableFishSchooling(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 */ - @Inject(method = "moveTowardLeader()V", at = @At("HEAD")) - protected void moveTowardLeader(CallbackInfo ci) { - if (OhMyVanillaMinecraft.disableFishSchooling) - ci.cancel(); + @Overwrite + public void moveTowardLeader() { + if (!OhMyVanillaMinecraft.disableFishSchooling) { + if (this.hasLeader()) { + this.getNavigation().startMovingTo(this.leader, 1.0D); + } + } } } |