コード例 #1
0
 @SuppressWarnings("rawtypes")
 @Override
 public void addCollisionBoxesToList(
     World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List list, Entity entity) {
   this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.45F, 1.0F);
   super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity);
 }
コード例 #2
0
  @Override
  public void breakBlock(World world, int x0, int y0, int z0, Block var5, int var6) {
    final TileEntity tileAt = world.getTileEntity(x0, y0, z0);

    int fakeBlockCount = 0;

    for (int x = -1; x <= 1; x++) {
      for (int y = 0; y < 3; y += 2) {
        for (int z = -1; z <= 1; z++) {
          if (!(x == 0 && y == 0 && z == 0)) {
            if (world.getBlock(x0 + x, y0 + y, z0 + z) == AsteroidBlocks.fakeTelepad) {
              fakeBlockCount++;
            }
          }
        }
      }
    }

    if (fakeBlockCount > 0 && tileAt instanceof TileEntityShortRangeTelepad) {
      ((TileEntityShortRangeTelepad) tileAt).onDestroy(tileAt);
      ShortRangeTelepadHandler.removeShortRangeTeleporter((TileEntityShortRangeTelepad) tileAt);
    }

    super.breakBlock(world, x0, y0, z0, var5, var6);
  }
コード例 #3
0
  @Override
  public void onBlockPlacedBy(
      World world, int x0, int y0, int z0, EntityLivingBase entityLiving, ItemStack itemStack) {
    super.onBlockPlacedBy(world, x0, y0, z0, entityLiving, itemStack);

    TileEntity tile = world.getTileEntity(x0, y0, z0);

    boolean validSpot = true;

    for (int x = -1; x <= 1; x++) {
      for (int y = 0; y < 3; y += 2) {
        for (int z = -1; z <= 1; z++) {
          if (!(x == 0 && y == 0 && z == 0)) {
            Block blockAt = world.getBlock(x0 + x, y0 + y, z0 + z);

            if (!blockAt.getMaterial().isReplaceable()) {
              validSpot = false;
            }
          }
        }
      }
    }

    if (!validSpot) {
      world.setBlockToAir(x0, y0, z0);

      if (entityLiving instanceof EntityPlayer) {
        if (!world.isRemote) {
          ((EntityPlayer) entityLiving)
              .addChatMessage(
                  new ChatComponentText(
                      EnumColor.RED + GCCoreUtil.translate("gui.warning.noroom")));
        }
        ((EntityPlayer) entityLiving)
            .inventory.addItemStackToInventory(new ItemStack(Item.getItemFromBlock(this), 1, 0));
      }

      return;
    }

    if (tile instanceof TileEntityShortRangeTelepad) {
      ((TileEntityShortRangeTelepad) tile).onCreate(new BlockVec3(x0, y0, z0));
      ((TileEntityShortRangeTelepad) tile)
          .setOwner(((EntityPlayer) entityLiving).getGameProfile().getName());
    }
  }