public class ChargeableBlock extends Block { [...] @Override public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) { if (world.getBlockState(pos).get(CHARGED)){ // 在方块的位置召唤闪电 LightningEntity lightningEntity = (LightningEntity) EntityType.LIGHTNING_BOLT.create(world); lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(pos)); world.spawnEntity(lightningEntity); }   world.setBlockState(pos, state.with(CHARGED, false)); super.onSteppedOn(world, pos, state, entity); } }