This commit is contained in:
gnembon committed 2023-12-18 19:20:26 +01:00
1 parent ab79e76b51
commit d76d013acb
9 files changed
+58 -56

No files matched your search

@@ -4,7 +4,7 @@ import carpet.CarpetSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.cauldron.CauldronInteraction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
@@ -19,13 +19,16 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(AbstractCauldronBlock.class)
public class AbstractCauldronBlock_stackableSBoxesMixin
{
@Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/cauldron/CauldronInteraction;interact(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/InteractionResult;"))
private InteractionResult wrapInteractor(CauldronInteraction cauldronBehavior, BlockState blockState, Level world, BlockPos blockPos, Player playerEntity, InteractionHand hand, ItemStack itemStack)
@Redirect(method = "useItemOn", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/core/cauldron/CauldronInteraction;interact(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/ItemInteractionResult;"
))
private ItemInteractionResult wrapInteractor(final CauldronInteraction cauldronBehavior, final BlockState blockState, final Level world, final BlockPos blockPos, final Player playerEntity, final InteractionHand hand, final ItemStack itemStack)
{
int count = -1;
if (CarpetSettings.shulkerBoxStackSize > 1 && itemStack.getItem() instanceof BlockItem && ((BlockItem)itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock)
count = itemStack.getCount();
InteractionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack);
ItemInteractionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack);
if (count > 0 && result.consumesAction())
{
ItemStack current = playerEntity.getItemInHand(hand);
@@ -19,7 +19,7 @@ public abstract class Gui_tablistMixin
@Shadow @Final private PlayerTabOverlay tabList;
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isLocalServer()Z"))
@Redirect(method = "renderTabList", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isLocalServer()Z"))
private boolean onDraw(Minecraft minecraftClient)
{
return this.minecraft.isLocalServer() && !((PlayerListHudInterface) tabList).hasFooterOrHeader();
@@ -1,32 +1,39 @@
package carpet.mixins;
import carpet.CarpetSettings;
import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerPlayerGameMode;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(value = ServerPlayerGameMode.class, priority = 69420) // not that important for carpet
public class ServerPlayerGameMode_antiCheatMixin
@Mixin(value = ServerPlayer.class)
public abstract class ServerPlayerGameMode_antiCheatMixin extends Player
{
// that shoudn't've been a constant at the first place
// resolves problems with mobs using reach entity attributes.
@Redirect(method = "handleBlockBreakAction", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerPlayer;getEyePosition()Lnet/minecraft/world/phys/Vec3;"
))
private Vec3 getEyePos(ServerPlayer instance,
final BlockPos pos, final ServerboundPlayerActionPacket.Action action, final Direction direction, final int maxBuildHeight, final int sequence)
public ServerPlayerGameMode_antiCheatMixin(final Level level, final BlockPos blockPos, final float f, final GameProfile gameProfile)
{
if (CarpetSettings.antiCheatDisabled &&
instance.getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) < 1024
) return Vec3.atCenterOf(pos);
return instance.getEyePosition();
super(level, blockPos, f, gameProfile);
}
@Inject(method = "canInteractWithBlock", at = @At("HEAD"), cancellable = true)
private void canInteractLongRangeBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir)
{
double maxRange = blockInteractionRange() + 1.0;
maxRange = maxRange * maxRange;
if (CarpetSettings.antiCheatDisabled && maxRange < 1024 && getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) < 1024) cir.setReturnValue(true);
}
@Inject(method = "canInteractWithEntity", at = @At("HEAD"), cancellable = true)
private void canInteractLongRangeEntity(AABB aabb, CallbackInfoReturnable<Boolean> cir)
{
double maxRange = entityInteractionRange() + 1.0;
maxRange = maxRange * maxRange;
if (CarpetSettings.antiCheatDisabled && maxRange < 1024 && aabb.distanceToSqr(getEyePosition()) < 1024) cir.setReturnValue(true);
}
}
@@ -3,8 +3,9 @@ package carpet.mixins;
import carpet.helpers.BlockRotator;
import net.minecraft.server.level.ServerPlayerGameMode;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
@@ -18,14 +19,14 @@ public class ServerPlayerGameMode_cactusMixin
@Redirect(method = "useItemOn", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/state/BlockState;use(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;"
target = "Lnet/minecraft/world/level/block/state/BlockState;useItemOn(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/ItemInteractionResult;"
))
private InteractionResult activateWithOptionalCactus(BlockState blockState, Level world_1, Player playerEntity_1, InteractionHand hand_1, BlockHitResult blockHitResult_1)
private ItemInteractionResult activateWithOptionalCactus(final BlockState blockState, final ItemStack itemStack, final Level world_1, final Player playerEntity_1, final InteractionHand hand_1, final BlockHitResult blockHitResult_1)
{
boolean flipped = BlockRotator.flipBlockWithCactus(blockState, world_1, playerEntity_1, hand_1, blockHitResult_1);
if (flipped)
return InteractionResult.SUCCESS;
return ItemInteractionResult.SUCCESS;
return blockState.use(world_1, playerEntity_1, hand_1, blockHitResult_1);
return blockState.useItemOn(itemStack, world_1, playerEntity_1, hand_1, blockHitResult_1);
}
}