Make TemplateBlock more copy-pasteable

This commit is contained in:
quat1024 2023-07-09 00:46:59 -04:00
parent db3730bb21
commit a793bad0ed
7 changed files with 19 additions and 6 deletions

View File

@ -135,6 +135,7 @@ public class TemplateInteractionUtil {
}
}
//Returns "null" to signal "no opinion". Imagine it like an InteractionResult.PASS.
public static @Nullable VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) {
return view.getBlockEntity(pos) instanceof TemplateEntity be && !be.isSolid() ? VoxelShapes.empty() : null;
}

View File

@ -40,7 +40,9 @@ public class TemplateBlock extends Block implements BlockEntityProvider {
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
ActionResult r = TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
if(!r.isAccepted()) r = super.onUse(state, world, pos, player, hand, hit);
return r;
}
@Override

View File

@ -42,7 +42,9 @@ public class TemplateCarpetBlock extends CarpetBlock implements BlockEntityProvi
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
ActionResult r = TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
if(!r.isAccepted()) r = super.onUse(state, world, pos, player, hand, hit);
return r;
}
@Override

View File

@ -42,7 +42,9 @@ public class TemplateFenceBlock extends FenceBlock implements BlockEntityProvide
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
ActionResult r = TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
if(!r.isAccepted()) r = super.onUse(state, world, pos, player, hand, hit);
return r;
}
@Override

View File

@ -46,7 +46,9 @@ public class TemplatePressurePlateBlock extends PressurePlateBlock implements Bl
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
ActionResult r = TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
if(!r.isAccepted()) r = super.onUse(state, world, pos, player, hand, hit);
return r;
}
@Override

View File

@ -42,7 +42,9 @@ public class TemplateSlabBlock extends SlabBlock implements BlockEntityProvider
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
ActionResult r = TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
if(!r.isAccepted()) r = super.onUse(state, world, pos, player, hand, hit);
return r;
}
@Override

View File

@ -50,7 +50,9 @@ public class TemplateWallBlock extends WallBlock implements BlockEntityProvider
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
ActionResult r = TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
if(!r.isAccepted()) r = super.onUse(state, world, pos, player, hand, hit);
return r;
}
@Override