Fabric Mod
GettingOverItMod
a mod that adds mechanics from the climbing game "getting over it" and you cant walk and you need to use the hammer to explore etc to break blocks and you can still place blocks interact etc and you will spawn with the hammer in the first hotbar slot
src/main/java/eu/codexe/gettingoveritmod/util/HammerLogic.java
package eu.codexe.gettingoveritmod.util;
import eu.codexe.gettingoveritmod.GettingOverItMod;
import eu.codexe.gettingoveritmod.item.ModItems;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public final class HammerLogic {
private HammerLogic() {
}
public static ActionResult onUseOnBlock(ItemUsageContext context) {
World world = context.getWorld();
PlayerEntity player = context.getPlayer();
if (player == null) {
return ActionResult.PASS;
}
ItemStack stack = context.getStack();
BlockPos pos = context.getBlockPos();
BlockState state = world.getBlockState(pos);
if (!world.isClient) {
world.playSound(null, pos, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 0.8f, 1.2f);
state.onUse(world, player, context.getHand(), context);
}
return ActionResult.success(world.isClient);
}
public static ActionResult onUse(World world, PlayerEntity user, Hand hand) {
if (!world.isClient) {
world.playSound(null, user.getBlockPos(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 0.9f, 0.9f);
}
return ActionResult.SUCCESS;
}
}