Make TemplateBlock more copy-pasteable
This commit is contained in:
parent
db3730bb21
commit
a793bad0ed
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user