interactionUpdates
This commit is contained in:
1 parent
0acb1077a2
commit
4bf27c3d15
4 files changed
+99
No files matched your search
@@ -0,0 +1,81 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.packet.PlayerActionC2SPacket;
|
||||
import net.minecraft.server.network.packet.PlayerInteractBlockC2SPacket;
|
||||
import net.minecraft.server.network.packet.PlayerInteractItemC2SPacket;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
public class ServerPlayNetworkHandler_interactionUpdatesMixin
|
||||
{
|
||||
@Inject(method = "onPlayerInteractBlock", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;interactBlock(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void beforeBlockInteracted(PlayerInteractBlockC2SPacket playerInteractBlockC2SPacket_1, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerInteractBlock", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;interactBlock(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void afterBlockInteracted(PlayerInteractBlockC2SPacket playerInteractBlockC2SPacket_1, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerInteractItem", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void beforeItemInteracted(PlayerInteractItemC2SPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerInteractItem", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void afterItemInteracted(PlayerInteractItemC2SPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
}
|
||||
@Inject(method = "onPlayerAction", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;method_14263(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/server/network/packet/PlayerActionC2SPacket$Action;Lnet/minecraft/util/math/Direction;I)V",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void beforeBlockBroken(PlayerActionC2SPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = true;
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerAction", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;method_14263(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/server/network/packet/PlayerActionC2SPacket$Action;Lnet/minecraft/util/math/Direction;I)V",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void afterBlockBroken(PlayerActionC2SPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (!CarpetSettings.interactionUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(World.class)
|
||||
public abstract class World_fillUpdatesMixin
|
||||
@@ -16,4 +20,14 @@ public abstract class World_fillUpdatesMixin
|
||||
return -1;
|
||||
return original;
|
||||
}
|
||||
|
||||
@Redirect(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V"
|
||||
))
|
||||
private void updateNeighborsMaybe(World world, BlockPos blockPos, Block block)
|
||||
{
|
||||
if (!CarpetSettings.impendingFillSkipUpdates) world.updateNeighbors(blockPos, block);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user