-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
69 additions
and
1 deletion.
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
66 changes: 66 additions & 0 deletions
66
src/main/java/io/github/rektroth/whiteout/mixin/mc147659/CatSpawnMixin.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,66 @@ | ||
/* | ||
* Patch for MC-147659 | ||
* | ||
* Authored for CraftBukkit/Spigot by Jake Potrebic <[email protected]> on July 11, 2022. | ||
* Ported to Fabric by Rektroth <[email protected]> on July 4, 2024. | ||
*/ | ||
|
||
package io.github.rektroth.whiteout.mixin.mc147659; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalRef; | ||
import net.minecraft.entity.passive.CatEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.spawner.CatSpawner; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(CatSpawner.class) | ||
public abstract class CatSpawnMixin { | ||
/** | ||
* Sets the cat's position before it's type is set. | ||
* @param pos The cat's spawn position. | ||
* @param world boilerplate | ||
* @param cir boilerplate | ||
* @param catEntity The cat. | ||
*/ | ||
@Inject( | ||
at = @At( | ||
target = "Lnet/minecraft/entity/passive/CatEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;)Lnet/minecraft/entity/EntityData;", | ||
value = "INVOKE" | ||
), | ||
method = "spawn(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/server/world/ServerWorld;)I" | ||
) | ||
private void refreshPositionAndAnglesBeforeInitialize( | ||
BlockPos pos, | ||
ServerWorld world, | ||
CallbackInfoReturnable<Integer> cir, | ||
@Local LocalRef<CatEntity> catEntity | ||
) { | ||
CatEntity cat2 = catEntity.get(); | ||
cat2.refreshPositionAndAngles(pos, 0.0F, 0.0F); | ||
catEntity.set(cat2); | ||
} | ||
|
||
/** | ||
* Skips the old position set. | ||
* @param instance boilerplate | ||
* @param blockPos boilerplate | ||
* @param yaw boilerplate | ||
* @param pitch boilerplate | ||
*/ | ||
@Redirect( | ||
at = @At( | ||
target = "Lnet/minecraft/entity/passive/CatEntity;refreshPositionAndAngles(Lnet/minecraft/util/math/BlockPos;FF)V", | ||
value = "INVOKE" | ||
), | ||
method = "spawn(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/server/world/ServerWorld;)I" | ||
) | ||
private void skipRefreshPositionAndAngles(CatEntity instance, BlockPos blockPos, float yaw, float pitch) { | ||
return; | ||
} | ||
} |
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