WIP: started working on ForcePlace

This commit is contained in:
moonleay 2024-04-25 02:12:27 +02:00
parent 14f2021748
commit ff77e2b576
Signed by: moonleay
GPG key ID: 82667543CCD715FB
4 changed files with 63 additions and 1 deletions

View file

@ -0,0 +1,19 @@
package net.moonleay.gimble.mixin;
import net.minecraft.block.Block;
import net.minecraft.block.pattern.CachedBlockPosition;
import net.minecraft.item.ItemStack;
import net.minecraft.util.registry.Registry;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ItemStack.class)
public class AlwaysAllowBlock {
@Redirect(method = "useOnBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;canPlaceOn(Lnet/minecraft/util/registry/Registry;Lnet/minecraft/block/pattern/CachedBlockPosition;)Z"))
private boolean func(ItemStack instance, Registry<Block> blockRegistry, CachedBlockPosition pos) {
return true;
}
}

View file

@ -0,0 +1,22 @@
package net.moonleay.gimble.mixin;
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.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 ForcePlaceMixin {
@Inject(method = "interactBlock", at = @At("HEAD"))
private void func(ServerPlayerEntity player, World world, ItemStack stack, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
}
}

View file

@ -0,0 +1,18 @@
package net.moonleay.gimble.mixin;
import net.minecraft.block.BlockState;
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(World.class)
public class WorldSetBlockStateMixin {
@Inject(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", at = @At("HEAD"))
private void func(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, CallbackInfoReturnable<Boolean> cir) {
System.out.println("setBlockState was run");
}
}

View file

@ -4,7 +4,10 @@
"package": "net.moonleay.gimble.mixin", "package": "net.moonleay.gimble.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"mixins": [ "mixins": [
"NoClipMixin" "AlwaysAllowBlock",
"ForcePlaceMixin",
"NoClipMixin",
"WorldSetBlockStateMixin"
], ],
"client": [ "client": [
"HudMixin", "HudMixin",