Skip to content

Instantly share code, notes, and snippets.

@Kaupenjoe
Created July 8, 2021 19:12
Show Gist options
  • Select an option

  • Save Kaupenjoe/4de02a8c23ed48281c00d968e0743014 to your computer and use it in GitHub Desktop.

Select an option

Save Kaupenjoe/4de02a8c23ed48281c00d968e0743014 to your computer and use it in GitHub Desktop.
"block.tutorialmod.firestone_block": "Firestone Block",
public static final RegistryObject<Block> FIRESTONE_BLOCK = registerBlock("firestone_block",
() -> new FirestoneBlock(AbstractBlock.Properties.create(Material.IRON)
.harvestLevel(2).setRequiresTool().harvestTool(ToolType.PICKAXE).hardnessAndResistance(6f)));
{
"parent": "block/cube_all",
"textures": {
"all": "tutorialmod:block/firestone_block"
}
}
{
"variants": {
"": { "model": "tutorialmod:block/firestone_block" }
}
}
public class FirestoneBlock extends Block {
public FirestoneBlock(Properties properties) {
super(properties);
}
@SuppressWarnings("deprecation")
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player,
Hand handIn, BlockRayTraceResult hit) {
if(!worldIn.isRemote()) {
if(handIn == Hand.MAIN_HAND) {
System.out.println("I right-clicked a FirestoneBlock. Called for the Main Hand!");
}
if(handIn == Hand.OFF_HAND) {
System.out.println("I right-clicked a FirestoneBlock. Called for the Off Hand!");
}
}
return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
}
@SuppressWarnings("deprecation")
@Override
public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
if(!worldIn.isRemote()) {
System.out.println("I left-clicked a FirestoneBlock");
}
}
@Override
public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) {
Firestone.lightEntityOnFire(entityIn, 5);
super.onEntityWalk(worldIn, pos, entityIn);
}
}
{
"parent": "tutorialmod:block/firestone_block"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment