Merge branch 'master' into 1.16
This commit is contained in:
commit
359b89b46f
13 files changed
+295
-2
No files matched your search
@@ -37,6 +37,7 @@ import static carpet.script.CarpetEventServer.Event.PLAYER_STARTS_SNEAKING;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_STARTS_SPRINTING;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_STOPS_SNEAKING;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_STOPS_SPRINTING;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_SWAPS_HANDS;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_SWITCHES_SLOT;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_USES_ITEM;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_WAKES_UP;
|
||||
@@ -67,6 +68,17 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
PLAYER_DROPS_ITEM.onPlayerEvent(player);
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerAction", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;getStackInHand(Lnet/minecraft/util/Hand;)Lnet/minecraft/item/ItemStack;",
|
||||
ordinal = 0,
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void onHandSwap(PlayerActionC2SPacket playerActionC2SPacket_1, CallbackInfo ci)
|
||||
{
|
||||
PLAYER_SWAPS_HANDS.onPlayerEvent(player);
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerAction", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;dropSelectedItem(Z)Z",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ServerPlayerInteractionManagerInterface;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
@@ -7,10 +8,12 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerInteractionManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -24,10 +27,18 @@ import static carpet.script.CarpetEventServer.Event.PLAYER_INTERACTS_WITH_BLOCK;
|
||||
|
||||
|
||||
@Mixin(ServerPlayerInteractionManager.class)
|
||||
public class ServerPlayerInteractionManager_scarpetEventsMixin
|
||||
public class ServerPlayerInteractionManager_scarpetEventsMixin implements ServerPlayerInteractionManagerInterface
|
||||
{
|
||||
@Shadow public ServerPlayerEntity player;
|
||||
|
||||
@Shadow private boolean mining;
|
||||
|
||||
@Shadow private BlockPos miningPos;
|
||||
|
||||
@Shadow private int blockBreakingProgress;
|
||||
|
||||
@Shadow public ServerWorld world;
|
||||
|
||||
@Inject(method = "tryBreakBlock", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/Block;onBreak(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)V",
|
||||
@@ -46,4 +57,25 @@ public class ServerPlayerInteractionManager_scarpetEventsMixin
|
||||
{
|
||||
PLAYER_INTERACTS_WITH_BLOCK.onBlockHit(player, hand, hitResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCurrentBreakingBlock()
|
||||
{
|
||||
if (!mining) return null;
|
||||
return miningPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentBlockBreakingProgress()
|
||||
{
|
||||
if (!mining) return -1;
|
||||
return blockBreakingProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBreakingProgress(int progress)
|
||||
{
|
||||
blockBreakingProgress = MathHelper.clamp(progress, -1, 10);
|
||||
world.setBlockBreakingInfo(-1*this.player.getEntityId(), miningPos, blockBreakingProgress);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user