Skip to content

Commit

Permalink
fix (doesn't work? at least not with /place)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rektroth committed Jul 4, 2024
1 parent e2c8dee commit 74c0350
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
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) {
// nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mc84789=true
mc108513=false
mc123450=true
mc123848=true
mc147659=false
mc153086=true
mc157464=true
mc158900=false
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/whiteout.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"mc108513.EndSpikeFeatureMixin",
"mc123450.ItemFrameEntityMixin",
"mc123848.ItemFrameEntityMixin",
"mc147659.CatSpawnMixin",
"mc153086.BeaconBlockEntityMixin",
"mc157464.VillagerTaskListProviderMixin",
"mc158900.PlayerManagerMixin",
Expand Down

0 comments on commit 74c0350

Please sign in to comment.