/** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    super.onBlockAdded(par1World, par2, par3, par4);

    if (par1World.getBlockId(par2, par3, par4) == this.blockID) {
      par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
    }
  }
 /** Switches active state of button or lever at x/y/z to and notifies neighbors */
 public static void activateButton(World world, Block block, int x, int y, int z) {
   int meta = world.getBlockMetadata(x, y, z);
   world.setBlockMetadataWithNotify(x, y, z, (meta < 8 ? meta | 8 : meta & ~8), 3);
   // func_147479_m is markBlockForRenderUpdate
   world.func_147479_m(x, y, z);
   world.playSoundEffect(
       (double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, Sounds.CLICK, 0.3F, 0.6F);
   world.scheduleBlockUpdate(x, y, z, block, block.tickRate(world));
   world.notifyBlocksOfNeighborChange(x, y, z, block);
   switch (meta & 7) {
     case 0: // 0 and 7 are ceiling levers
     case 7:
       world.notifyBlocksOfNeighborChange(x, y + 1, z, block);
       break;
     case 1:
       world.notifyBlocksOfNeighborChange(x - 1, y, z, block);
       break;
     case 2:
       world.notifyBlocksOfNeighborChange(x + 1, y, z, block);
       break;
     case 3:
       world.notifyBlocksOfNeighborChange(x, y, z - 1, block);
       break;
     case 4:
       world.notifyBlocksOfNeighborChange(x, y, z + 1, block);
       break;
     default:
       world.notifyBlocksOfNeighborChange(x, y - 1, z, block);
   }
 }
 @Override
 public void onBlockAdded(World world, int x, int y, int z) {
   // System.out.println("x: "+x+", y: "+y+", z: "+z);
   super.onBlockAdded(world, x, y, z);
   if (world.getBlockId(x, y, z) == blockID) {
     world.scheduleBlockUpdate(x, y, z, blockID, tickRate());
   }
 }
 /** Changes the block ID to that of an updating fluid. */
 private void setNotStationary(World par1World, int par2, int par3, int par4) {
   int var5 = par1World.getBlockMetadata(par2, par3, par4);
   par1World.editingBlocks = true;
   par1World.setBlockAndMetadata(par2, par3, par4, this.blockID - 1, var5);
   par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
   par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID - 1, this.tickRate());
   par1World.editingBlocks = false;
 }
示例#5
0
 @Override
 public void updateTick(World world, int i, int j, int k, Random random) {
   world.setBlockMetadataWithNotify(i, j, k, 1, 2);
   world.notifyBlocksOfNeighborChange(i, j, k, blockID);
   world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
   world.markBlockRangeForRenderUpdate(i, j, k, i, j, k);
   world.scheduleBlockUpdate(i, j, k, blockID, this.tickRate(world));
 }
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   if (l > 0 && Block.blocksList[l].canProvidePower()) {
     // Which direction the power can come from, i is the x coord, j is y, and k is z.
     boolean flag =
         world.isBlockIndirectlyGettingPowered(i, j, k)
             || world.isBlockIndirectlyGettingPowered(i, j - 1, k);
     if (flag) {
       world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
     }
   }
 }
 /** Called whenever the block is added into the world. Args: world, x, y, z */
 public void onBlockAdded(World par1World, int par2, int par3, int par4) {
   if (!par1World.isRemote) {
     if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
       par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
     } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
       int m = par1World.getBlockMetadata(par2, par3, par4);
       par1World.setBlockAndMetadataWithNotify(
           par2, par3, par4, MinecraftPlusBase.holidaylights_1Active.blockID, m);
     }
   }
 }
示例#8
0
  public void updateTick(World world, int x, int y, int z, Random par5Random) {

    world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world));
    EntitySergeantStrongstack entity = new EntitySergeantStrongstack(world);
    entity.setLocationAndAngles(x, y + 1, z, world.rand.nextFloat() * 360.0F, 0.0F);
    world.spawnEntityInWorld(entity);
    world.setBlock(x, y + 1, z, 0);
    world.setBlock(x, y + 2, z, 0);
    world.setBlock(x, y + 3, z, 0);
    // world.setBlock(x, y, z, 0);

  }
 public void onBlockAdded(World par1World, int par2, int par3, int par4) {
   /** Change these to your portal frame and Portal block * */
   if ((par1World.getBlockId(par2, par3 - 1, par4) != Block.blockDiamond.blockID)
       || (!Main.TutorialPortal1.tryToCreatePortal(par1World, par2, par3, par4))) {
     if ((!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
         && (!canNeighborBurn(par1World, par2, par3, par4))) {
       par1World.setBlockToAir(par2, par3, par4);
     } else {
       par1World.scheduleBlockUpdate(
           par2, par3, par4, this.blockID, tickRate(par1World) + par1World.rand.nextInt(10));
     }
   }
 }
示例#10
0
 @Override
 public void updateTick(World world, int i, int j, int k, Random random) {
   if (j < 253) {
     if (world.getBlockId(i, j + 1, k) == 0) {
       world.setBlockAndMetadataWithNotify(i, j + 1, k, blockID, world.getBlockMetadata(i, j, k));
       world.scheduleBlockUpdate(i, j + 1, k, blockID, 5);
     }
   } else if (world.getBlockMetadata(i, j, k) == 1) {
     world.setBlockMetadata(i, j, k, 0);
     world.setBlockAndMetadataWithNotify(i, j + 1, k, TooManyPlants.objs.blockpod.blockID, 1);
     world.setBlockWithNotify(i, j + 2, k, TooManyPlants.objs.blockpod.blockID);
   }
 }
示例#11
0
 @Override
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) {
   boolean flag =
       par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)
           || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
   int i1 = par1World.getBlockMetadata(par2, par3, par4);
   boolean flag1 = (i1 & 8) != 0;
   if (flag && !flag1) {
     par1World.scheduleBlockUpdate(par2, par3, par4, this, this.tickRate(par1World));
     par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 | 8, 4);
   } else if (!flag && flag1) {
     par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 & -9, 4);
   }
 }
示例#12
0
 @Override
 public int onBlockPlaced(
     World world,
     int int1,
     int int2,
     int int3,
     int int4,
     float float1,
     float float2,
     float float3,
     int int5) {
   world.scheduleBlockUpdate(int1, int2, int3, this, 1);
   return int5;
 }
示例#13
0
 public boolean onBlockActivated(
     World par1World,
     int par2,
     int par3,
     int par4,
     EntityPlayer par5EntityPlayer,
     int par6,
     float par7,
     float par8,
     float par9) {
   {
     par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
     return true;
   }
 }
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  @Override
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    if (par1World.worldProvider.worldType <= 0
        && par1World.getBlockId(par2, par3 - 1, par4) == Block.obsidian.blockID
        && ((BlockPortal) Block.portal).tryToCreatePortal(par1World, par2, par3, par4)) {
      return;
    }

    if (!par1World.isBlockNormalCube(par2, par3 - 1, par4)
        && !canNeighborBurn(par1World, par2, par3, par4)) {
      par1World.setBlockWithNotify(par2, par3, par4, 0);
      return;
    } else {
      par1World.scheduleBlockUpdate(
          par2, par3, par4, blockID, tickRate() + par1World.rand.nextInt(10));
      return;
    }
  }
示例#15
0
  @Override
  public void updateTick(World var1, int var2, int var3, int var4, Random var5) {

    if (var1.isRemote) return;

    // var1.getBlockMetadata(var2, var3, var4);
    // List var7 = var1.getEntitiesWithinAABB(EntTornado.class,
    // AxisAlignedBB.getBoundingBoxFromPool((double)var2, (double)var3, (double)var4, (double)var2 +
    // 1.0D, (double)var3 + 1.0D, (double)var4 + 1.0D).expand(140.0D, 140.0D, 140.0D));

    boolean enable = false;

    WeatherManagerServer wms =
        ServerTickHandler.lookupDimToWeatherMan.get(var1.provider.dimensionId);
    if (wms != null) {
      StormObject so =
          wms.getClosestStorm(
              Vec3.createVectorHelper(var2, var3, var4),
              ConfigMisc.sensorActivateDistance,
              StormObject.STATE_FORMING);
      if (so != null /* && so.attrib_tornado_severity > 0*/) {
        enable = true;
      }
    }

    if (enable) {
      var1.setBlockMetadataWithNotify(var2, var3, var4, 15, 2);
    } else {
      var1.setBlockMetadataWithNotify(var2, var3, var4, 0, 2);
    }

    /*if(var7.size() > 0) {
       var1.setBlockMetadataWithNotify(var2, var3, var4, 15);
    } else {
       var1.setBlockMetadataWithNotify(var2, var3, var4, 0);
    }*/
    var1.notifyBlocksOfNeighborChange(var2, var3 - 1, var4, this);
    var1.notifyBlocksOfNeighborChange(var2, var3 + 1, var4, this);
    var1.notifyBlocksOfNeighborChange(var2, var3, var4, this);
    var1.markBlockRangeForRenderUpdate(var2, var3, var4, var2, var3, var4);
    var1.scheduleBlockUpdate(var2, var3, var4, this, this.tickRate(var1));
  }
示例#16
0
  @Override
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    if (!par1World.isRemote) {
      List<EntityPlayer> players =
          par1World.getEntitiesWithinAABB(
              EntityPlayer.class,
              AxisAlignedBB.getBoundingBox(par2, par3, par4, par2 + 1, par3 + 1, par4 + 1));
      if (players.isEmpty()) par1World.setBlockToAir(par2, par3, par4);
      else {
        boolean has = false;
        for (EntityPlayer player : players)
          if (player.inventory.hasItem(ModItems.brightNitor.itemID)) {
            has = true;
            break;
          }

        if (!has) par1World.setBlockToAir(par2, par3, par4);
      }
      par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate(par1World));
    }
  }
示例#17
0
  public void onEntityCollidedWithBlock(
      World par1World, int par2, int par3, int par4, Entity par5Entity) {

    if (par1World.isRemote) {
      return;
    } else {
      if (par5Entity instanceof EntityPlayer && !deactivated) {
        par1World.setBlock(par2, par3, par4, mod_SecurityCraft.deactivatedCageTrap);
        par1World.scheduleBlockUpdate(
            par2, par3, par4, mod_SecurityCraft.unbreakableIronBars, 1200);

        par1World.setBlock(par2, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars);
        par1World.scheduleBlockUpdate(
            par2, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars, 1200);

        par1World.setBlock(par2 + 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars);
        par1World.scheduleBlockUpdate(
            par2 + 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars, 1200);

        par1World.setBlock(par2 - 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars);
        par1World.scheduleBlockUpdate(
            par2 - 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars, 1200);

        par1World.setBlock(par2, par3 + 4, par4 + 1, mod_SecurityCraft.unbreakableIronBars);
        par1World.scheduleBlockUpdate(
            par2, par3 + 4, par4 + 1, mod_SecurityCraft.unbreakableIronBars, 1200);

        par1World.setBlock(par2, par3 + 4, par4 - 1, mod_SecurityCraft.unbreakableIronBars);
        par1World.scheduleBlockUpdate(
            par2, par3 + 4, par4 - 1, mod_SecurityCraft.unbreakableIronBars, 1200);

        HelpfulMethods.setBlockInBox(
            par1World, par2, par3, par4, mod_SecurityCraft.unbreakableIronBars);

        par1World.playSoundAtEntity(par5Entity, "random.anvil_use", 3.0F, 1.0F);
        // ChatMessageComponent.createFromText(((EntityPlayer) par5Entity).getCommandSenderName() +
        // " was captured in a trap at" + HelpfulMethods.getFormattedCoordinates(par2, par3, par4))
        MinecraftServer.getServer()
            .getConfigurationManager()
            .sendChatMsg(
                new ChatComponentTranslation(
                    ((EntityPlayer) par5Entity).getCommandSenderName()
                        + " was captured in a trap at"
                        + HelpfulMethods.getFormattedCoordinates(par2, par3, par4)));
      }
    }
  }
 @Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int notifierID) {
   if (notifierID != DECore.ElevatorButton.blockID) {
     if (notifierID <= 0
         || notifierID == DECore.Elevator.blockID
         || !Block.blocksList[notifierID].canProvidePower()
         || !isBeingPoweredByNonElevator(world, i, j, k)) {
       previouslyPowered = false;
       return;
     }
     if (!previouslyPowered) {
       world.scheduleBlockUpdate(i, j, k, blockID, 2);
     }
   } else {
     boolean foundButton = false;
     for (int iter = 0; iter < 6; iter++) {
       int tempX = i;
       int tempZ = k;
       int tempY = j;
       if (iter == 0) {
         tempX--;
       } else if (iter == 1) {
         tempX++;
       } else if (iter == 2) {
         tempZ--;
       } else if (iter == 3) {
         tempZ++;
       }
       if (world.getBlockId(tempX, j, tempZ) == DECore.ElevatorButton.blockID
           && (world.getBlockMetadata(tempX, j, tempZ) & 8) > 0) {
         foundButton = true;
       }
     }
     if (foundButton) {
       findAndActivateElevator(world, i, j, k, 0);
     }
   }
 }
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor blockID
   */
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
    if (!par1World.isRemote) {
      if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
        par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
      } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
        int m = par1World.getBlockMetadata(par2, par3, par4);
        par1World.setBlockAndMetadataWithNotify(
            par2, par3, par4, MinecraftPlusBase.holidaylights_1Active.blockID, m);
      }
    }
    int var6 = par1World.getBlockMetadata(par2, par3, par4);
    boolean var7 = false;

    if (var6 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) {
      var7 = true;
    }

    if (var6 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) {
      var7 = true;
    }

    if (var6 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST)) {
      var7 = true;
    }

    if (var6 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST)) {
      var7 = true;
    }

    if (!var7) {
      this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0);
      par1World.setBlockWithNotify(par2, par3, par4, 0);
    }

    super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
  }
  // 右クリック処理
  @Override
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem();
    int meta = par1World.getBlockMetadata(par2, par3, par4);
    TileIncenseBase tile = (TileIncenseBase) par1World.getTileEntity(par2, par3, par4);

    AMTBlockRightClickEvent event =
        new AMTBlockRightClickEvent(par1World, par5EntityPlayer, itemstack, par2, par3, par4);
    MinecraftForge.EVENT_BUS.post(event);

    if (event.isCanceled()) {
      return true;
    }

    if (itemstack == null) // 回収動作
    {
      if (!par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(this, 1))) {
        if (!par1World.isRemote) par5EntityPlayer.entityDropItem(new ItemStack(this, 1), 1);
      }

      par1World.setBlockToAir(par2, par3, par4);
      par1World.playSoundAtEntity(par5EntityPlayer, "random.pop", 0.4F, 1.8F);
      return true;
    } else if (itemstack.getItem() == Item.getItemFromBlock(this)) {
      if (!par1World.isRemote) {
        EntityItem entity =
            new EntityItem(
                par1World,
                par5EntityPlayer.posX,
                par5EntityPlayer.posY,
                par5EntityPlayer.posZ,
                new ItemStack(this, 1));
        par1World.spawnEntityInWorld(entity);
      }

      par1World.setBlockToAir(par2, par3, par4);
      par1World.playSoundAtEntity(par5EntityPlayer, "random.pop", 0.4F, 1.8F);
      return true;
    } else if (itemstack.getItem() instanceof IIncenseEffect) // お香アイテムの場合
    {
      if (tile != null && !tile.hasItem()) {
        ItemStack put = itemstack.copy();
        tile.setItemstack(put);
        if (!par5EntityPlayer.capabilities.isCreativeMode
            && (itemstack.stackSize - put.stackSize) <= 0) {
          par5EntityPlayer.inventory.setInventorySlotContents(
              par5EntityPlayer.inventory.currentItem, (ItemStack) null);
        }
        tile.markDirty();
        par5EntityPlayer.inventory.markDirty();
        par1World.markBlockForUpdate(par2, par3, par4);
        par1World.playSoundAtEntity(par5EntityPlayer, "random.pop", 0.4F, 1.8F);
        return true;
      }
      return false;
    } else if (itemstack.getItem() == Items.flint_and_steel
        || itemstack.getItem() == DCsAppleMilk.firestarter) {
      if (tile != null && tile.hasItem() && !tile.getActive()) {
        par5EntityPlayer.triggerAchievement(AchievementRegister.useIncense);
        itemstack.attemptDamageItem(1, par1World.rand);
        tile.setActive();
        tile.markDirty();
        par1World.setBlockMetadataWithNotify(par2, par3, par4, 1, 3);
        par1World.playSoundAtEntity(par5EntityPlayer, "random.pop", 0.4F, 1.8F);
        par1World.scheduleBlockUpdate(par2, par3, par4, this, this.tickRate(par1World));
        return true;
      }
      return false;
    } else {
      return false;
    }
  }
 public void onNeighborBlockChange(
     World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) {
   p_149695_1_.scheduleBlockUpdate(
       p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_));
 }
示例#22
0
 /**
  * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
  * (coordinates passed are their own) Args: x, y, z, neighbor blockID
  */
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
   par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
 }
 public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) {
   p_149726_1_.scheduleBlockUpdate(
       p_149726_2_, p_149726_3_, p_149726_4_, this, this.tickRate(p_149726_1_));
 }
 @Override
 public void updateTick(World world, int x, int y, int z, Random random) {
   // System.out.println("x: "+x+", y: "+y+", z: "+z);
   int tex = ((LiquidTextureLogic) world.getBlockTileEntity(x, y, z)).getLiquidType();
   int l = getFlowDecay(world, x, y, z);
   byte byte0 = 1;
   boolean flag = true;
   if (l > 0) {
     int i1 = -100;
     i1 = getSmallestFlowDecay(world, x - 1, y, z, i1);
     i1 = getSmallestFlowDecay(world, x + 1, y, z, i1);
     i1 = getSmallestFlowDecay(world, x, y, z - 1, i1);
     i1 = getSmallestFlowDecay(world, x, y, z + 1, i1);
     int j1 = i1 + byte0;
     if (j1 >= 8 || i1 < 0) {
       j1 = -1;
     }
     if (getFlowDecay(world, x, y + 1, z) >= 0) {
       int l1 = getFlowDecay(world, x, y + 1, z);
       if (l1 >= 8) {
         j1 = l1;
       } else {
         j1 = l1 + 8;
       }
     }
     if (j1 != l) {
       l = j1;
       if (l < 0) {
         world.setBlockWithNotify(x, y, z, 0);
       } else {
         world.setBlockMetadataWithNotify(x, y, z, l);
         world.scheduleBlockUpdate(x, y, z, blockID, tickRate());
         world.notifyBlocksOfNeighborChange(x, y, z, blockID);
       }
     } else if (flag) {
       updateFlow(world, x, y, z);
     }
   } else {
     updateFlow(world, x, y, z);
   }
   if (liquidCanDisplaceBlock(world, x, y - 1, z)) {
     if (l >= 8) {
       world.setBlockAndMetadataWithNotify(x, y - 1, z, blockID, l);
     } else {
       world.setBlockAndMetadataWithNotify(x, y - 1, z, blockID, l + 8);
     }
     ((LiquidTextureLogic) world.getBlockTileEntity(x, y - 1, z)).setTexturePos(tex);
   } else if (l >= 0 && (l == 0 || blockBlocksFlow(world, x, y - 1, z))) {
     boolean aflag[] = getOptimalFlowDirections(world, x, y, z);
     int k1 = l + byte0;
     if (l >= 8) {
       k1 = 1;
     }
     if (k1 >= 8) return;
     if (aflag[0]) {
       flowIntoBlock(world, x - 1, y, z, k1, tex);
     }
     if (aflag[1]) {
       flowIntoBlock(world, x + 1, y, z, k1, tex);
     }
     if (aflag[2]) {
       flowIntoBlock(world, x, y, z - 1, k1, tex);
     }
     if (aflag[3]) {
       flowIntoBlock(world, x, y, z + 1, k1, tex);
     }
   }
 }
示例#25
0
 // @Override
 public void onBlockAdded(World par1World, int par2, int par3, int par4) {
   par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
 }
 public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
   if (par1World.getGameRules().getGameRuleBooleanValue("doFireTick")) {
     Block base = Block.blocksList[par1World.getBlockId(par2, par3 - 1, par4)];
     boolean flag =
         (base != null)
             && (base.isFireSource(
                 par1World,
                 par2,
                 par3 - 1,
                 par4,
                 par1World.getBlockMetadata(par2, par3 - 1, par4),
                 ForgeDirection.UP));
     if (!canPlaceBlockAt(par1World, par2, par3, par4)) {
       par1World.setBlockToAir(par2, par3, par4);
     }
     if ((!flag)
         && (par1World.isRaining())
         && ((par1World.canLightningStrikeAt(par2, par3, par4))
             || (par1World.canLightningStrikeAt(par2 - 1, par3, par4))
             || (par1World.canLightningStrikeAt(par2 + 1, par3, par4))
             || (par1World.canLightningStrikeAt(par2, par3, par4 - 1))
             || (par1World.canLightningStrikeAt(par2, par3, par4 + 1)))) {
       par1World.setBlockToAir(par2, par3, par4);
     } else {
       int l = par1World.getBlockMetadata(par2, par3, par4);
       if (l < 15) {
         par1World.setBlockMetadataWithNotify(par2, par3, par4, l + par5Random.nextInt(3) / 2, 4);
       }
       par1World.scheduleBlockUpdate(
           par2, par3, par4, this.blockID, tickRate(par1World) + par5Random.nextInt(10));
       if ((!flag) && (!canNeighborBurn(par1World, par2, par3, par4))) {
         if ((!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)) || (l > 3)) {
           par1World.setBlockToAir(par2, par3, par4);
         }
       } else if ((!flag)
           && (!canBlockCatchFire(par1World, par2, par3 - 1, par4, ForgeDirection.UP))
           && (l == 15)
           && (par5Random.nextInt(4) == 0)) {
         par1World.setBlockToAir(par2, par3, par4);
       } else {
         boolean flag1 = par1World.isBlockHighHumidity(par2, par3, par4);
         byte b0 = 0;
         if (flag1) {
           b0 = -50;
         }
         tryToCatchBlockOnFire(
             par1World, par2 + 1, par3, par4, 300 + b0, par5Random, l, ForgeDirection.WEST);
         tryToCatchBlockOnFire(
             par1World, par2 - 1, par3, par4, 300 + b0, par5Random, l, ForgeDirection.EAST);
         tryToCatchBlockOnFire(
             par1World, par2, par3 - 1, par4, 250 + b0, par5Random, l, ForgeDirection.UP);
         tryToCatchBlockOnFire(
             par1World, par2, par3 + 1, par4, 250 + b0, par5Random, l, ForgeDirection.DOWN);
         tryToCatchBlockOnFire(
             par1World, par2, par3, par4 - 1, 300 + b0, par5Random, l, ForgeDirection.SOUTH);
         tryToCatchBlockOnFire(
             par1World, par2, par3, par4 + 1, 300 + b0, par5Random, l, ForgeDirection.NORTH);
         for (int i1 = par2 - 1; i1 <= par2 + 1; i1++) {
           for (int j1 = par4 - 1; j1 <= par4 + 1; j1++) {
             for (int k1 = par3 - 1; k1 <= par3 + 4; k1++) {
               if ((i1 != par2) || (k1 != par3) || (j1 != par4)) {
                 int l1 = 100;
                 if (k1 > par3 + 1) {
                   l1 += (k1 - (par3 + 1)) * 100;
                 }
                 int i2 = getChanceOfNeighborsEncouragingFire(par1World, i1, k1, j1);
                 if (i2 > 0) {
                   int j2 = (i2 + 40 + par1World.difficultySetting * 7) / (l + 30);
                   if (flag1) {
                     j2 /= 2;
                   }
                   if ((j2 > 0)
                       && (par5Random.nextInt(l1) <= j2)
                       && ((!par1World.isRaining())
                           || (!par1World.canLightningStrikeAt(i1, k1, j1)))
                       && (!par1World.canLightningStrikeAt(i1 - 1, k1, par4))
                       && (!par1World.canLightningStrikeAt(i1 + 1, k1, j1))
                       && (!par1World.canLightningStrikeAt(i1, k1, j1 - 1))
                       && (!par1World.canLightningStrikeAt(i1, k1, j1 + 1))) {
                     int k2 = l + par5Random.nextInt(5) / 4;
                     if (k2 > 15) {
                       k2 = 15;
                     }
                     par1World.setBlock(i1, k1, j1, this.blockID, k2, 3);
                   }
                 }
               }
             }
           }
         }
       }
     }
   }
 }
  @Override
  public void updateTick(World world, int x, int y, int z, Random rand) {
    if (!world.isRemote) {
      TileIncenseBase tile = (TileIncenseBase) world.getTileEntity(x, y, z);
      boolean active = tile.getActive();

      if (active) {
        ItemStack item = tile.getItemstack();
        if (item != null && item.getItem() instanceof IIncenseEffect) {
          IIncenseEffect effect = (IIncenseEffect) item.getItem();

          EffectType type = effect.getEffectType();
          int area = effect.effectAreaRange();

          if (type == EffectType.Player) {
            List list = this.searchPlayer(world, x, y, z, area);

            if (list != null && !list.isEmpty()) {
              Iterator iterator = list.iterator();

              while (iterator.hasNext()) {
                Entity entity = (Entity) iterator.next();

                if (entity instanceof EntityLivingBase) {
                  EntityLivingBase target = (EntityLivingBase) entity;

                  effect.formEffect(world, x, y, z, target, effect);
                }
              }
            }
          } else if (type == EffectType.EntityLiving) {
            List list = this.searchEntity(world, x, y, z, area);

            if (list != null && !list.isEmpty()) {
              Iterator iterator = list.iterator();

              while (iterator.hasNext()) {
                Entity entity = (Entity) iterator.next();

                if (entity instanceof EntityLivingBase) {
                  EntityLivingBase target = (EntityLivingBase) entity;

                  effect.formEffect(world, x, y, z, target, effect);
                }
              }
            }
          } else if (type == EffectType.Block) {
            for (int i = 0; i < effect.effectAreaRange(); i++) {
              int[] pos = this.searchBlock(world, x, y, z, area);

              if (pos != null && pos.length == 3) {
                effect.formEffect(world, pos[0], pos[1], pos[2], null, effect);
              }
            }
          }
        }

        world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
      }
    }
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float clickX,
      float clickY,
      float clickZ) {
    TileEntityDoorController tileEntity = (TileEntityDoorController) world.getTileEntity(x, y, z);
    if (tileEntity == null || player.isSneaking()) {
      return false;
    }

    // If the user is not the owner, or the user is not in creative drop out.
    if (tileEntity.getOwner() != null) {
      if (!tileEntity.getOwner().equals(player.getUniqueID().toString())
          && !player.capabilities.isCreativeMode) {
        if (!tileEntity.getOwner().isEmpty()) {
          return false;
        }
      }
    }
    // Change the block texture
    if (player.getCurrentEquippedItem() != null
        && player.getCurrentEquippedItem().getItem() instanceof ItemBlock) {
      Block block = Block.getBlockFromItem(player.getCurrentEquippedItem().getItem());
      Item oldBlock = tileEntity.DoorControllerCamo[0].getItem();
      if (block.isOpaqueCube()
          || block instanceof BlockGlass
          || block instanceof BlockStainedGlass) {
        if (!tileEntity
            .DoorControllerCamo[0]
            .getItem()
            .equals(player.getCurrentEquippedItem().getItem())) {
          if (player.capabilities.isCreativeMode) {
            tileEntity.overrideTexture(
                block,
                player.getCurrentEquippedItem().splitStack(0),
                ForgeDirection.getOrientation(side));
          } else {
            tileEntity.overrideTexture(
                block,
                player.getCurrentEquippedItem().splitStack(1),
                ForgeDirection.getOrientation(side));
          }
          world.scheduleBlockUpdate(x, y, z, tileEntity.block, 5);
          if (!world.isRemote) {
            ItemStack testAgainst = new ItemStack(oldBlock);
            if (!testAgainst
                .getItem()
                .equals(Item.getItemFromBlock(ContentRegistry.DoorController))) {
              EntityItem myItemEntity = new EntityItem(world, x, y, z, testAgainst);
              world.spawnEntityInWorld(myItemEntity);
            }
          }
        }
      }
      // Remove the block texture with the scrench
    } else if (player.getCurrentEquippedItem() != null
        && player.getCurrentEquippedItem().getItem() instanceof Wrench) {
      if (!world.isRemote) {
        if (!tileEntity
            .DoorControllerCamo[0]
            .getItem()
            .equals(Item.getItemFromBlock(ContentRegistry.DoorController))) {
          EntityItem myItemEntity =
              new EntityItem(world, x, y, z, tileEntity.DoorControllerCamo[0]);
          world.spawnEntityInWorld(myItemEntity);
        }
      }
      tileEntity.overrideTexture(
          ContentRegistry.DoorController,
          new ItemStack(Item.getItemFromBlock(ContentRegistry.DoorController)),
          ForgeDirection.getOrientation(side));
      world.scheduleBlockUpdate(x, y, z, tileEntity.block, 5);
    }
    return true;
  }
  @Override
  public void updateTick(World world, int x, int y, int z, Random rand) {

    int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z);
    int expQuanta = -101;

    // check adjacent block levels if non-source
    if (quantaRemaining < quantaPerBlock) {
      int y2 = y - densityDir;

      if ((world.getBlockId(x, y2, z) == blockID)
          || (world.getBlockId(x - 1, y2, z) == blockID)
          || (world.getBlockId(x + 1, y2, z) == blockID)
          || (world.getBlockId(x, y2, z - 1) == blockID)
          || (world.getBlockId(x, y2, z + 1) == blockID)) {
        expQuanta = quantaPerBlock - 1;

      } else {
        int maxQuanta = -100;
        maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta);
        maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta);
        maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta);
        maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta);

        expQuanta = maxQuanta - 1;
      }
      // decay calculation
      if (expQuanta != quantaRemaining) {
        quantaRemaining = expQuanta;

        if (expQuanta <= 0) {
          world.setBlockToAir(x, y, z);
        } else {
          world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3);
          world.scheduleBlockUpdate(x, y, z, blockID, tickRate);
          world.notifyBlocksOfNeighborChange(x, y, z, blockID);
        }
      }
    } else if (quantaRemaining > quantaPerBlock) {
      world.setBlockMetadataWithNotify(x, y, z, 0, 3);
    }
    // Flow vertically if possible
    if (canDisplace(world, x, y + densityDir, z)) {
      flowIntoBlock(world, x, y + densityDir, z, 1);
      return;
    }
    // Flow outward if possible
    int flowMeta = (quantaPerBlock - quantaRemaining) + 1;
    if (flowMeta >= quantaPerBlock) {
      return;
    }

    if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)) {

      if (world.getBlockId(x, y - densityDir, z) == blockID) {
        flowMeta = 1;
      }
      boolean flowTo[] = getOptimalFlowDirections(world, x, y, z);

      if (flowTo[0]) {
        flowIntoBlock(world, x - 1, y, z, flowMeta);
      }
      if (flowTo[1]) {
        flowIntoBlock(world, x + 1, y, z, flowMeta);
      }
      if (flowTo[2]) {
        flowIntoBlock(world, x, y, z - 1, flowMeta);
      }
      if (flowTo[3]) {
        flowIntoBlock(world, x, y, z + 1, flowMeta);
      }
    }
  }
示例#30
0
 public void grow(World world, int i, int j, int k) {
   world.scheduleBlockUpdate(i, j, k, blockID, 5);
 }