mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-30 00:57:55 +00:00
Merge pull request #45 from hugeblank/disk-use
Fix Disk Drive & Disk Interaction
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
package dan200.computercraft.mixin;
|
||||||
|
|
||||||
|
import dan200.computercraft.shared.ComputerCraftRegistry;
|
||||||
|
import net.minecraft.advancement.criterion.Criteria;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.server.network.ServerPlayerInteractionManager;
|
||||||
|
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.world.World;
|
||||||
|
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.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(ServerPlayerInteractionManager.class)
|
||||||
|
public class MixinServerPlayerInteractionManager {
|
||||||
|
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;copy()Lnet/minecraft/item/ItemStack;", ordinal = 0), method = "interactBlock(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;", cancellable = true)
|
||||||
|
private void interact(ServerPlayerEntity player, World world, ItemStack stack, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
|
||||||
|
BlockPos pos = hitResult.getBlockPos();
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
if (player.getMainHandStack().getItem() == ComputerCraftRegistry.ModItems.DISK && state.getBlock() == ComputerCraftRegistry.ModBlocks.DISK_DRIVE) {
|
||||||
|
ActionResult actionResult = state.onUse(world, player, hand, hitResult);
|
||||||
|
if (actionResult.isAccepted()) {
|
||||||
|
Criteria.ITEM_USED_ON_BLOCK.test(player, pos, stack);
|
||||||
|
cir.setReturnValue(actionResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -10,7 +10,8 @@
|
|||||||
"MixinWorld",
|
"MixinWorld",
|
||||||
"SignBlockEntityAccess",
|
"SignBlockEntityAccess",
|
||||||
"SoundEventAccess",
|
"SoundEventAccess",
|
||||||
"WorldSavePathAccess"
|
"WorldSavePathAccess",
|
||||||
|
"MixinServerPlayerInteractionManager"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"AffineTransformationAccess",
|
"AffineTransformationAccess",
|
||||||
|
Reference in New Issue
Block a user