This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
ScriptCraft/src/main/java/com/thebrokenrail/scriptcraft/api/CustomBlock.java

29 lines
1.1 KiB
Java
Raw Normal View History

2020-04-25 13:33:17 +00:00
package com.thebrokenrail.scriptcraft.api;
import com.thebrokenrail.scriptcraft.util.Util;
import com.thebrokenrail.scriptcraft.quickjs.QuickJSManager;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@SuppressWarnings("deprecation")
public class CustomBlock extends Block {
private final Identifier id;
public CustomBlock(Settings settings, Identifier id) {
super(settings);
this.id = id;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return Util.getEnumValue(ActionResult.class, (String) QuickJSManager.bridge("CustomBlock.onUse", id.toString(), world, state, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), hit.getSide().name(), player, hand.name()), ActionResult.PASS);
}
}