Exemplo n.º 1
0
 public static void updateFurnaceBlockState(
     boolean flag,
     World world,
     int i,
     int j,
     int k,
     Block activeID,
     Block idleID,
     boolean sounds) {
   int l = world.getBlockMetadata(i, j, k);
   TileEntity tileentity = world.getTileEntity(i, j, k);
   setKeepInventory(true);
   if (flag) {
     if (sounds) {
       world.playSoundEffect(
           i + 0.5F,
           j + 0.5F,
           k + 0.5F,
           "mob.ghast.fireball",
           1.0F,
           0.8F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F);
       world.playSoundEffect(
           i + 0.5F,
           j + 0.5F,
           k + 0.5F,
           "mob.zombiepig.zpigdeath",
           0.1F,
           0.1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.6F);
       world.playSoundEffect(
           i + 0.5F,
           j + 0.5F,
           k + 0.5F,
           "fire.ignite",
           1.5F,
           1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
     }
     world.setBlock(i, j, k, activeID);
   } else {
     if (sounds)
       world.playSoundEffect(
           i + 0.5F,
           j + 0.5F,
           k + 0.5F,
           "ambient.cave.cave",
           0.1F,
           0.1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
     world.setBlock(i, j, k, idleID);
   }
   setKeepInventory(false);
   world.setBlockMetadataWithNotify(i, j, k, l, 2);
   if (tileentity != null) {
     tileentity.validate();
     world.setTileEntity(i, j, k, tileentity);
   }
 }
Exemplo n.º 2
0
  public static void updateBlockState(int type, World world, int x, int y, int z) {
    int i = world.getBlockMetadata(x, y, z);
    TileEntity entity = world.getTileEntity(x, y, z);
    keepInventory = true;

    if (type == 1) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_generic);
    } else if (type == 2) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_strong);
    } else if (type == 3) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_cluster);
    } else if (type == 4) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_nuclear);
    } else if (type == 5) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_incendiary);
    } else if (type == 6) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_buster);
    } else if (type == 7) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_incendiary_strong);
    } else if (type == 8) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_cluster_strong);
    } else if (type == 9) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_buster_strong);
    } else if (type == 10) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_burst);
    } else if (type == 11) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_inferno);
    } else if (type == 12) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_rain);
    } else if (type == 13) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_drill);
    } else if (type == 14) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_endo);
    } else if (type == 15) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_exo);
    } else if (type == 16) {
      world.setBlock(x, y, z, ModBlocks.launch_pad_mirv);
    } else {
      world.setBlock(x, y, z, ModBlocks.launch_pad);
    }

    keepInventory = false;

    if (entity != null) {
      entity.validate();
      world.setTileEntity(x, y, z, entity);
    }
  }
Exemplo n.º 3
0
  public static void updateBlockState(boolean par0, World par1World, int par2, int par3, int par4) {
    int var5 = par1World.getBlockMetadata(par2, par3, par4);
    TileEntity tileentity = par1World.getTileEntity(par2, par3, par4);

    keepInventory = true;

    if (par0) par1World.setBlockMetadataWithNotify(par2, par3, par4, var5 + 7, 2);
    else par1World.setBlockMetadataWithNotify(par2, par3, par4, var5 - 7, 2);

    keepInventory = false;

    if (tileentity != null) {
      tileentity.validate();
      par1World.setTileEntity(par2, par3, par4, tileentity);
    }
  }
 /* 107:    */
 /* 108:    */ public static boolean saveToSpawner(int x, int y, int z, EntityHumanBase human)
       /* 109:    */ {
   /* 110:101 */ World world = human.worldObj;
   /* 111:102 */ if (world.getBlock(x, y, z) != Blocks.air) {
     /* 112:103 */ y++;
     /* 113:    */ }
   /* 114:105 */ world.setBlock(x, y, z, ChocolateQuest.spawner);
   /* 115:106 */ BlockMobSpawnerTileEntity te = new BlockMobSpawnerTileEntity();
   /* 116:107 */ NBTTagCompound tag = new NBTTagCompound();
   /* 117:108 */ human.writeToNBTOptional(tag);
   /* 118:109 */ human.writeEntityToSpawnerNBT(tag, x, y, z);
   /* 119:110 */ te.mobNBT = tag;
   /* 120:111 */ te.mob = -1;
   /* 121:112 */ world.setTileEntity(x, y, z, te);
   /* 122:113 */ return true;
   /* 123:    */ }
Exemplo n.º 5
0
  @Override
  public SpellCastResult beginStackStage(
      ItemSpellBase item,
      ItemStack stack,
      EntityLivingBase caster,
      EntityLivingBase target,
      World world,
      double x,
      double y,
      double z,
      int side,
      boolean consumeMBR,
      int useCount) {
    int procs =
        SpellUtils.instance.getModifiedInt_Add(
            1, stack, caster, target, world, 0, SpellModifiers.PROCS);
    boolean targetWater =
        SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
    MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, 8.0f, true, targetWater);
    if (mop == null || mop.typeOfHit == MovingObjectType.ENTITY)
      return SpellCastResult.EFFECT_FAILED;

    if (!BlocksCommonProxy.spellRune.placeAt(
        world,
        mop.blockX,
        mop.blockY + 1,
        mop.blockZ,
        SpellUtils.instance.mainAffinityFor(stack).ordinal())) {
      return SpellCastResult.EFFECT_FAILED;
    }
    if (!world.isRemote) {
      world.setTileEntity(
          mop.blockX,
          mop.blockY + 1,
          mop.blockZ,
          BlocksCommonProxy.spellRune.createTileEntity(world, 0));
      BlocksCommonProxy.spellRune.setSpellStack(
          world, mop.blockX, mop.blockY + 1, mop.blockZ, SpellUtils.instance.popStackStage(stack));
      BlocksCommonProxy.spellRune.setPlacedBy(
          world, mop.blockX, mop.blockY + 1, mop.blockZ, caster);
      int meta = world.getBlockMetadata(mop.blockX, mop.blockY + 1, mop.blockZ);
      BlocksCommonProxy.spellRune.setNumTriggers(
          world, mop.blockX, mop.blockY + 1, mop.blockZ, meta, procs);
    }

    return SpellCastResult.SUCCESS;
  }
 public static void updateBlockState(
     boolean active, World worldObj, int xCoord, int yCoord, int zCoord) {
   int i = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
   TileEntity tileentity = worldObj.getTileEntity(xCoord, yCoord, zCoord);
   keepInventory = true;
   if (active) {
     worldObj.setBlock(xCoord, yCoord, zCoord, NCBlocks.oxidiserActive);
   } else {
     worldObj.setBlock(xCoord, yCoord, zCoord, NCBlocks.oxidiserIdle);
   }
   keepInventory = false;
   worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, i, 2);
   if (tileentity != null) {
     tileentity.validate();
     worldObj.setTileEntity(xCoord, yCoord, zCoord, tileentity);
   }
 }
  @Override
  public void breakBlock(World world, int x, int y, int z, Block oldBlockID, int oldMetadata) {
    TileEntityFlickerHabitat habitat = (TileEntityFlickerHabitat) world.getTileEntity(x, y, z);

    // if there is no habitat at the location break out
    if (habitat == null) return;

    // if the habitat has a flicker throw it on the ground
    if (habitat.hasFlicker()) {
      Random rand = new Random();
      ItemStack stack = habitat.getStackInSlot(0);

      float offsetX = rand.nextFloat() * 0.8F + 0.1F;
      float offsetY = rand.nextFloat() * 0.8F + 0.1F;
      float offsetZ = rand.nextFloat() * 0.8F + 0.1F;
      float force = 0.05F;

      EntityItem entityItem = new EntityItem(world, x + offsetX, y + offsetY, z + offsetZ, stack);
      entityItem.motionX = (float) rand.nextGaussian() * force;
      entityItem.motionY = (float) rand.nextGaussian() * force + 0.2F;
      entityItem.motionZ = (float) rand.nextGaussian() * force;
      world.spawnEntityInWorld(entityItem);
    }

    if (!habitat.isUpgrade()) {
      for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity te =
            world.getTileEntity(
                x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ);
        if (te != null && te instanceof TileEntityFlickerHabitat) {
          TileEntityFlickerHabitat upgHab = (TileEntityFlickerHabitat) te;

          if (upgHab.isUpgrade()) {
            world.func_147480_a(
                x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ, true);
            world.setTileEntity(
                x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ, null);
          }
        }
      }
    }

    super.breakBlock(world, x, y, z, oldBlockID, oldMetadata);
    return;
  }
Exemplo n.º 8
0
  public static void syncTileEntityWithData(World world, int x, int y, int z, int metadata) {
    if (metadata < 16) {
      world.removeTileEntity(x, y, z);
      return;
    }

    TileEntityWoodProxy te = (TileEntityWoodProxy) world.getTileEntity(x, y, z);
    if (te == null) {
      te = new TileEntityWoodProxy();
      world.setTileEntity(x, y, z, te);
    }

    Block block = getBlockFromComposedMetadata(metadata);
    int protoMeta = getMetaFromComposedMetadata(metadata);

    if (block != null) te.setProtoBlock(block, protoMeta);

    te.markDirty();
  }
Exemplo n.º 9
0
  public static void updateBlockState(boolean burning, World world, int x, int y, int z) {
    int direction = world.getBlockMetadata(x, y, z);
    TileEntity tileentity = world.getTileEntity(x, y, z);
    isBurning = true;

    if (burning) {
      world.setBlock(x, y, z, Machines_Main.crusherActive);
    } else {
      world.setBlock(x, y, z, Machines_Main.crusher);
    }

    isBurning = false;
    world.setBlockMetadataWithNotify(x, y, z, direction, 2);

    if (tileentity != null) {
      tileentity.validate();
      world.setTileEntity(x, y, z, tileentity);
    }
  }
 /*  87:    */
 /*  88:    */ public boolean saveEntityToSpawner(int x, int y, int z, Entity entity)
       /*  89:    */ {
   /*  90: 83 */ World world = entity.worldObj;
   /*  91: 84 */ if (world.getBlock(x, y, z) != Blocks.air) {
     /*  92: 85 */ y++;
     /*  93:    */ }
   /*  94: 87 */ world.setBlock(x, y, z, ChocolateQuest.spawner);
   /*  95: 88 */ BlockMobSpawnerTileEntity te = new BlockMobSpawnerTileEntity();
   /*  96: 89 */ NBTTagCompound tag = new NBTTagCompound();
   /*  97: 90 */ boolean wrote = entity.writeToNBTOptional(tag);
   /*  98: 91 */ if (wrote)
   /*  99:    */ {
     /* 100: 92 */ te.mobNBT = tag;
     /* 101: 93 */ te.mob = -1;
     /* 102: 94 */ world.setTileEntity(x, y, z, te);
     /* 103: 95 */ return true;
     /* 104:    */ }
   /* 105: 97 */ return false;
   /* 106:    */ }
  @Override
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    Block block = world.getBlock(x, y, z);

    SkinPointer skinPointer = EquipmentNBTHelper.getSkinPointerFromStack(stack);

    if (skinPointer != null && skinPointer.getSkinType() == SkinTypeRegistry.skinBlock) {
      ForgeDirection dir = ForgeDirection.getOrientation(side);
      Block replaceBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
      if (replaceBlock.isReplaceable(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) {
        if (!world.isRemote) {
          int l =
              MathHelper.floor_double((double) (player.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15;
          world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.skinnable);
          world.setBlockMetadataWithNotify(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, l, 2);
          world.setTileEntity(
              x + dir.offsetX,
              y + dir.offsetY,
              z + dir.offsetZ,
              ((ITileEntityProvider) ModBlocks.skinnable).createNewTileEntity(world, 0));
          TileEntitySkinnable te =
              (TileEntitySkinnable)
                  world.getTileEntity(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
          te.setSkinPointer(skinPointer);
          stack.stackSize--;
        }
        return true;
      }
    }

    return false;
  }
  public static void setState(boolean active, World worldIn, BlockPos pos) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    TileEntity tileentity = worldIn.getTileEntity(pos);
    keepInventory = true;

    if (active) {
      worldIn.setBlockState(
          pos,
          MBlocks.melter_active
              .getDefaultState()
              .withProperty(FACING, iblockstate.getValue(FACING)),
          3);
      worldIn.setBlockState(
          pos,
          MBlocks.melter_active
              .getDefaultState()
              .withProperty(FACING, iblockstate.getValue(FACING)),
          3);
    } else {
      worldIn.setBlockState(
          pos,
          MBlocks.melter.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)),
          3);
      worldIn.setBlockState(
          pos,
          MBlocks.melter.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)),
          3);
    }

    keepInventory = false;

    if (tileentity != null) {
      tileentity.validate();
      worldIn.setTileEntity(pos, tileentity);
    }
  }
 public void didPlaceBlock(World world, BlockPos pos, IBlockState state) {
   super.didPlaceBlock(world, pos, state);
   world.setTileEntity(pos, this.createTileEntity(world, 0));
 }
Exemplo n.º 14
0
  public static boolean swapBlocks(
      Object caller,
      World worldI,
      World worldF,
      int xi,
      int yi,
      int zi,
      int xf,
      int yf,
      int zf,
      boolean doSound,
      int flag) {
    TileEntity tileEntityI = worldI.getTileEntity(xi, yi, zi);
    TileEntity tileEntityF = worldF.getTileEntity(xf, yf, zf);

    NBTTagCompound nbttag1 = new NBTTagCompound();
    NBTTagCompound nbttag2 = new NBTTagCompound();

    if (tileEntityI != null) {
      tileEntityI.writeToNBT(nbttag1);
    }

    if (tileEntityF != null) {
      tileEntityF.writeToNBT(nbttag2);
    }

    Block blockI = worldI.getBlock(xi, yi, zi);
    Block blockF = worldF.getBlock(xf, yf, zf);

    if (blockI.equals(Blocks.air) && blockF.equals(Blocks.air)) {
      return false;
    }

    if (blockI instanceof BlockMobSpawner
            || blockF instanceof BlockMobSpawner
            || caller instanceof TEDemonPortal
        ? false
        : blockI instanceof BlockPortal || blockF instanceof BlockPortal) {
      return false;
    }

    int metaI = worldI.getBlockMetadata(xi, yi, zi);
    int metaF = worldF.getBlockMetadata(xf, yf, zf);

    TeleposeEvent evt =
        new TeleposeEvent(worldI, xi, yi, zi, blockI, metaI, worldF, xf, yf, zf, blockF, metaF);
    if (MinecraftForge.EVENT_BUS.post(evt)) return false;

    if (doSound) {
      worldI.playSoundEffect(xi, yi, zi, "mob.endermen.portal", 1.0F, 1.0F);
      worldF.playSoundEffect(xf, yf, zf, "mob.endermen.portal", 1.0F, 1.0F);
    }

    // CLEAR TILES
    Block finalBlock = blockF;

    if (finalBlock != null) {
      TileEntity tileToSet = finalBlock.createTileEntity(worldF, metaF);

      worldF.setTileEntity(xf, yf, zf, tileToSet);
    }

    if (blockI != null) {
      TileEntity tileToSet = blockI.createTileEntity(worldI, metaI);

      worldI.setTileEntity(xi, yi, zi, tileToSet);
    }

    // TILES CLEARED
    worldF.setBlock(xf, yf, zf, blockI, metaI, flag);

    if (tileEntityI != null) {
      TileEntity newTileEntityI = TileEntity.createAndLoadEntity(nbttag1);

      if (AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityI)) {
        newTileEntityI = createMultipartFromNBT(worldF, nbttag1);
      }

      worldF.setTileEntity(xf, yf, zf, newTileEntityI);

      newTileEntityI.xCoord = xf;
      newTileEntityI.yCoord = yf;
      newTileEntityI.zCoord = zf;

      if (AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityI)) {
        sendDescriptorOfTile(worldF, newTileEntityI);
      }
    }

    worldI.setBlock(xi, yi, zi, finalBlock, metaF, flag);

    if (tileEntityF != null) {
      TileEntity newTileEntityF = TileEntity.createAndLoadEntity(nbttag2);
      if (AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityF)) {
        newTileEntityF = createMultipartFromNBT(worldI, nbttag2);
      }

      worldI.setTileEntity(xi, yi, zi, newTileEntityF);

      newTileEntityF.xCoord = xi;
      newTileEntityF.yCoord = yi;
      newTileEntityF.zCoord = zi;

      if (AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityF)) {
        sendDescriptorOfTile(worldI, newTileEntityF);
      }
    }

    return true;
  }
Exemplo n.º 15
0
 public void makeFakeBlock(World worldObj, BlockPos pos, BlockPos mainBlock, int meta) {
   worldObj.setBlockState(pos, GCBlocks.fakeBlock.getStateFromMeta(meta), 3);
   TileEntityMulti tileEntityMulti = new TileEntityMulti(mainBlock);
   worldObj.setTileEntity(pos, tileEntityMulti);
 }
Exemplo n.º 16
0
  /**
   * this is a method for handling packets that were sent to the client.
   *
   * @param manager
   * @param packet
   * @param player
   * @param dat the data that it can read from
   * @param ID the packet ID
   */
  public void handleClientPacket(
      Packet packet, EntityPlayer player, ByteArrayDataInput dat, short ID) {
    EntityPlayer thePlayer = (EntityPlayer) player;
    World world = thePlayer.worldObj;

    if (world != null) {
      if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiAPressurePlate) {
        if (ID == 1) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            ((EntityPlayerSP) thePlayer).closeScreen();
          }

          return;
        }

        if (ID == 2) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          int allowedmobs = dat.readInt();

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            for (int var1 = 0; var1 < allowedmobs; var1++) {
              boolean bool = dat.readBoolean();
              GuiAPressurePlate.enabled[var1] = bool;
            }
          }

          return;
        }

        if (ID == 3) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            GuiAPressurePlate.tpp.allowedPlayers.clear();
            int allowedPlayers = dat.readInt();
            {
              for (int var1 = 0; var1 < allowedPlayers; var1++) {
                short nameLength = dat.readShort();
                String username = "";

                for (int var2 = 0; var2 < nameLength; var2++) {
                  username = new StringBuilder().append(username).append(dat.readChar()).toString();
                }

                boolean bool = dat.readBoolean();
                GuiAPressurePlate.tpp.addPlayer(username);
                GuiAPressurePlate.tpp.setEnabledForPlayer(username, bool);
              }

              GuiAPressurePlate.lineUp();
            }
          }

          return;
        }

        if (ID == 4) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          int index = dat.readInt();

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            GuiAPressurePlate.switchbutton(index);
          }

          return;
        }

        if (ID == 11) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            if (GuiAPressurePlate.tpp.settings == null) {
              GuiAPressurePlate.tpp.registerSettings();
            }

            int var2 = dat.readInt();

            for (int var3 = 0; var3 < var2; var3++) {
              if (var3 <= GuiAPressurePlate.tpp.settings.size()) {
                GuiAPressurePlate.tpp.setSetting(var3, dat.readBoolean());
              }
            }

            GuiAPressurePlate.LineUpSettings();
          }

          return;
        }

        if (ID == 10) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            int var2 = dat.readInt();

            if (GuiAPressurePlate.tpp.settings.size() >= var2) {
              GuiAPressurePlate.tpp.switchSetting(var2);
            }
          }

          return;
        }
      }

      if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiModifyPressurePlate) {
        if (ID == 1) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            ((EntityPlayerSP) thePlayer).closeScreen();
          }
        }

        if (ID == 3) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            GuiAPressurePlate.tpp.allowedPlayers.clear();
            int allowedPlayers = dat.readInt();
            {
              for (int var1 = 0; var1 < allowedPlayers; var1++) {
                short nameLength = dat.readShort();
                String username = "";

                for (int var2 = 0; var2 < nameLength; var2++) {
                  username = new StringBuilder().append(username).append(dat.readChar()).toString();
                }

                boolean bool = dat.readBoolean();
                GuiAPressurePlate.tpp.setEnabledForPlayer(username, bool);
              }

              GuiAPressurePlate.lineUp();
            }
          }

          return;
        }

        if (ID == 4) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          int index = dat.readInt();

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            GuiAPressurePlate.switchbutton(index);
          }

          return;
        }

        if (ID == 5) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            boolean bool = dat.readBoolean();
            int usernamelength = dat.readInt();
            String username = "";

            for (int var2 = 0; var2 < usernamelength; var2++) {
              char c = dat.readChar();
              username = new StringBuilder().append(username).append(c).toString();
            }

            if (thePlayer.getCommandSenderName().matches(username)) {
              if (bool) {
                GuiModifyPressurePlate.showText("Player added", 20);
              } else {
                GuiModifyPressurePlate.showText("Player is already in list", 20);
              }
            }
          }

          return;
        }

        if (ID == 6) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            boolean bool = dat.readBoolean();
            int usernamelength = dat.readInt();
            String username = "";

            for (int var2 = 0; var2 < usernamelength; var2++) {
              char c = dat.readChar();
              username = new StringBuilder().append(username).append(c).toString();
            }

            if (thePlayer.getCommandSenderName().matches(username)) {
              if (bool) {
                GuiModifyPressurePlate.showText("Player removed", 20);
              } else {
                GuiModifyPressurePlate.showText("Player is not in list", 20);
              }
            }
          }

          return;
        }

        if (ID == 10) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            int index = dat.readInt();

            if (GuiAPressurePlate.tpp.settings.size() >= index) {
              GuiAPressurePlate.tpp.switchSetting(index);
            }
          }

          return;
        }

        if (ID == 11) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          if (GuiAPressurePlate.tpp.xCoord == coords[0]
              && GuiAPressurePlate.tpp.yCoord == coords[1]
              && GuiAPressurePlate.tpp.zCoord == coords[2]) {
            if (GuiAPressurePlate.tpp.settings == null) {
              GuiAPressurePlate.tpp.registerSettings();
            }

            int var2 = dat.readInt();

            for (int var3 = 0; var3 < var2; var3++) {
              if (var3 <= GuiAPressurePlate.tpp.settings.size()) {
                GuiAPressurePlate.tpp.setSetting(var3, dat.readBoolean());
              }
            }

            GuiAPressurePlate.LineUpSettings();
          }

          return;
        }
      }

      if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiPassword) {
        if (ID == 12) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          int length = dat.readInt();
          StringBuilder sb = new StringBuilder();

          for (int var1 = 0; var1 < length; var1++) {
            sb.append(dat.readChar());
          }

          String name = sb.toString();

          if (((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp != null
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.xCoord
                  == coords[0]
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.yCoord
                  == coords[1]
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.zCoord
                  == coords[2]) {
            if (name.matches(thePlayer.getCommandSenderName())) {
              GuiPassword gui = (GuiPassword) FMLClientHandler.instance().getClient().currentScreen;
              gui.enterGui();
            }
          }

          return;
        }

        if (ID == 13) {
          int coords[] = new int[3];

          for (int var1 = 0; var1 < 3; var1++) {
            coords[var1] = dat.readInt();
          }

          boolean b = dat.readBoolean();

          if (((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp != null
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.xCoord
                  == coords[0]
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.yCoord
                  == coords[1]
              && ((GuiPassword) FMLClientHandler.instance().getClient().currentScreen).tpp.zCoord
                  == coords[2]) {
            GuiPassword gui = (GuiPassword) FMLClientHandler.instance().getClient().currentScreen;

            if (b) {
              gui.enterGui();
            } else {
              GuiPassword.showText("Wrong Password!!!", 20);
            }
          }

          return;
        }

        if (ID == 15) {
          return;
        }

        if (ID == 18) {
          int guiID = dat.readInt();

          if (FMLClientHandler.instance().getClient().currentScreen != null
              && FMLClientHandler.instance().getClient().currentScreen instanceof GuiPassword) {
            GuiPassword gui = (GuiPassword) FMLClientHandler.instance().getClient().currentScreen;
            gui.set = guiID;
          }

          return;
        }
      }

      if (ID == 7) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te != null || te instanceof TileEntityPressurePlate) {
          tpp = (TileEntityPressurePlate) te;
        }

        int itemId = dat.readInt();
        int stackSize = dat.readInt();
        int itemDamage = dat.readInt();
        int dimension = dat.readInt();

        if (!PPRegistry.getContainsPressurePlate(coords[0], coords[1], coords[2], dimension)) {
          PPRegistry.addPressurePlate(coords[0], coords[1], coords[2], dimension, false, null);
        }

        if (itemId == 0 && stackSize == 0 & itemDamage == 0) {
          if (tpp != null) {
            tpp.item[0] = null;
          }

          PPRegistry.setItem(coords[0], coords[1], coords[2], dimension, null);
          world.markBlockForUpdate(coords[0], coords[1], coords[2]);
        } else {
          if (tpp != null) {
            tpp.item[0] = new ItemStack(Item.getItemById(itemId), stackSize, itemDamage);
          }

          PPRegistry.setItem(
              coords[0],
              coords[1],
              coords[2],
              dimension,
              new ItemStack(Item.getItemById(itemId), stackSize, itemDamage));
          world.markBlockForUpdate(coords[0], coords[1], coords[2]);
        }

        return;
      }

      if (ID == 8) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te == null || !(te instanceof TileEntityPressurePlate)) {
          world.setTileEntity(coords[0], coords[1], coords[2], new TileEntityPressurePlate());
          tpp = (TileEntityPressurePlate) te;
        } else {
          tpp = (TileEntityPressurePlate) te;
        }

        if (tpp != null) {
          tpp.currentOutput = dat.readInt();
        }

        world.markBlockForUpdate(coords[0], coords[1], coords[2]);
        return;
      }

      if (ID == 9) {
        PPRegistry.sendToServer = true;
        return;
      }

      if (ID == 11) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te != null || te instanceof TileEntityPressurePlate) {
          tpp = (TileEntityPressurePlate) te;
        }

        if (tpp != null) {
          if (tpp.xCoord == coords[0] && tpp.yCoord == coords[1] && tpp.zCoord == coords[2]) {
            if (tpp.settings == null) {
              tpp.registerSettings();
            }

            int var2 = dat.readInt();

            for (int var3 = 0; var3 < var2; var3++) {
              if (var3 <= tpp.settings.size()) {
                tpp.setSetting(var3, dat.readBoolean());
              }
            }
          }
        }

        return;
      }

      if (ID == 12) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        int length = dat.readInt();
        StringBuilder sb = new StringBuilder();

        for (int var1 = 0; var1 < length; var1++) {
          sb.append(dat.readChar());
        }

        sb.toString();
        return;
      }

      if (ID == 14) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        if (te != null || te instanceof TileEntityPressurePlate) {}

        int dimension = dat.readInt();

        if (!PPRegistry.getContainsPressurePlate(coords[0], coords[1], coords[2], dimension)) {
          PPRegistry.addPressurePlate(coords[0], coords[1], coords[2], dimension, false, null);
        }

        PPRegistry.setUsesPassword(coords[0], coords[1], coords[2], dimension, dat.readBoolean());
        return;
      }

      if (ID == 16) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te != null || te instanceof TileEntityPressurePlate) {
          tpp = (TileEntityPressurePlate) te;
        }

        int dimension = dat.readInt();

        if (tpp != null) {
          PPRegistry.removePressurePlate(tpp, dimension);
        }

        return;
      }

      if (ID == 17) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        TileEntityPressurePlate tpp = null;

        if (te != null || te instanceof TileEntityPressurePlate) {
          tpp = (TileEntityPressurePlate) te;
        }

        int dimension = dat.readInt();

        if (tpp != null) {
          PPRegistry.addPressurePlate(tpp, dimension);
        }

        return;
      }
      if (ID == 19) {
        int coords[] = new int[3];

        for (int var1 = 0; var1 < 3; var1++) {
          coords[var1] = dat.readInt();
        }

        TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
        if (te instanceof TileEntityPressurePlate) {
          if (!(FMLClientHandler.instance().getClient().currentScreen
              instanceof GuiAPressurePlate)) {
            ((TileEntityPressurePlate) te).maxOutput = dat.readInt();
            ((TileEntityPressurePlate) te).itemsForMax = dat.readInt();
          } else if (GuiAPressurePlate.tpp != te || GuiAPressurePlate.hasData == false) {
            ((TileEntityPressurePlate) te).maxOutput = dat.readInt();
            ((TileEntityPressurePlate) te).itemsForMax = dat.readInt();
            GuiAPressurePlate.hasData = true;
          }
        }
      }
    }
  }
 public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
   super.onBlockAdded(worldIn, pos, state);
   worldIn.setTileEntity(pos, this.createNewTileEntity(worldIn, 0));
 }
Exemplo n.º 18
0
  /** Called on both Client and Server when World#addBlockEvent is called */
  public boolean onBlockEventReceived(
      World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) {
    EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);

    if (!worldIn.isRemote) {
      boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);

      if (flag && eventID == 1) {
        worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(true)), 2);
        return false;
      }

      if (!flag && eventID == 0) {
        return false;
      }
    }

    if (eventID == 0) {
      if (!this.doMove(worldIn, pos, enumfacing, true)) {
        return false;
      }

      worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(true)), 2);
      worldIn.playSoundEffect(
          (double) pos.getX() + 0.5D,
          (double) pos.getY() + 0.5D,
          (double) pos.getZ() + 0.5D,
          "tile.piston.out",
          0.5F,
          worldIn.rand.nextFloat() * 0.25F + 0.6F);
    } else if (eventID == 1) {
      TileEntity tileentity1 = worldIn.getTileEntity(pos.offset(enumfacing));

      if (tileentity1 instanceof TileEntityPiston) {
        ((TileEntityPiston) tileentity1).clearPistonTileEntity();
      }

      worldIn.setBlockState(
          pos,
          Blocks.piston_extension
              .getDefaultState()
              .withProperty(BlockPistonMoving.FACING, enumfacing)
              .withProperty(
                  BlockPistonMoving.TYPE,
                  this.isSticky
                      ? BlockPistonExtension.EnumPistonType.STICKY
                      : BlockPistonExtension.EnumPistonType.DEFAULT),
          3);
      worldIn.setTileEntity(
          pos,
          BlockPistonMoving.newTileEntity(
              this.getStateFromMeta(eventParam), enumfacing, false, true));

      if (this.isSticky) {
        BlockPos blockpos =
            pos.add(
                enumfacing.getFrontOffsetX() * 2,
                enumfacing.getFrontOffsetY() * 2,
                enumfacing.getFrontOffsetZ() * 2);
        Block block = worldIn.getBlockState(blockpos).getBlock();
        boolean flag1 = false;

        if (block == Blocks.piston_extension) {
          TileEntity tileentity = worldIn.getTileEntity(blockpos);

          if (tileentity instanceof TileEntityPiston) {
            TileEntityPiston tileentitypiston = (TileEntityPiston) tileentity;

            if (tileentitypiston.getFacing() == enumfacing && tileentitypiston.isExtending()) {
              tileentitypiston.clearPistonTileEntity();
              flag1 = true;
            }
          }
        }

        if (!flag1
            && block.getMaterial() != Material.air
            && canPush(block, worldIn, blockpos, enumfacing.getOpposite(), false)
            && (block.getMobilityFlag() == 0
                || block == Blocks.piston
                || block == Blocks.sticky_piston)) {
          this.doMove(worldIn, pos, enumfacing, false);
        }
      } else {
        worldIn.setBlockToAir(pos.offset(enumfacing));
      }

      worldIn.playSoundEffect(
          (double) pos.getX() + 0.5D,
          (double) pos.getY() + 0.5D,
          (double) pos.getZ() + 0.5D,
          "tile.piston.in",
          0.5F,
          worldIn.rand.nextFloat() * 0.15F + 0.6F);
    }

    return true;
  }
Exemplo n.º 19
0
  private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending) {
    if (!extending) {
      worldIn.setBlockToAir(pos.offset(direction));
    }

    BlockPistonStructureHelper blockpistonstructurehelper =
        new BlockPistonStructureHelper(worldIn, pos, direction, extending);
    List<BlockPos> list = blockpistonstructurehelper.getBlocksToMove();
    List<BlockPos> list1 = blockpistonstructurehelper.getBlocksToDestroy();

    if (!blockpistonstructurehelper.canMove()) {
      return false;
    } else {
      int i = list.size() + list1.size();
      Block[] ablock = new Block[i];
      EnumFacing enumfacing = extending ? direction : direction.getOpposite();

      for (int j = list1.size() - 1; j >= 0; --j) {
        BlockPos blockpos = (BlockPos) list1.get(j);
        Block block = worldIn.getBlockState(blockpos).getBlock();
        block.dropBlockAsItem(worldIn, blockpos, worldIn.getBlockState(blockpos), 0);
        worldIn.setBlockToAir(blockpos);
        --i;
        ablock[i] = block;
      }

      for (int k = list.size() - 1; k >= 0; --k) {
        BlockPos blockpos2 = (BlockPos) list.get(k);
        IBlockState iblockstate = worldIn.getBlockState(blockpos2);
        Block block1 = iblockstate.getBlock();
        block1.getMetaFromState(iblockstate);
        worldIn.setBlockToAir(blockpos2);
        blockpos2 = blockpos2.offset(enumfacing);
        worldIn.setBlockState(
            blockpos2,
            Blocks.piston_extension.getDefaultState().withProperty(FACING, direction),
            4);
        worldIn.setTileEntity(
            blockpos2, BlockPistonMoving.newTileEntity(iblockstate, direction, extending, false));
        --i;
        ablock[i] = block1;
      }

      BlockPos blockpos1 = pos.offset(direction);

      if (extending) {
        BlockPistonExtension.EnumPistonType blockpistonextension$enumpistontype =
            this.isSticky
                ? BlockPistonExtension.EnumPistonType.STICKY
                : BlockPistonExtension.EnumPistonType.DEFAULT;
        IBlockState iblockstate1 =
            Blocks.piston_head
                .getDefaultState()
                .withProperty(BlockPistonExtension.FACING, direction)
                .withProperty(BlockPistonExtension.TYPE, blockpistonextension$enumpistontype);
        IBlockState iblockstate2 =
            Blocks.piston_extension
                .getDefaultState()
                .withProperty(BlockPistonMoving.FACING, direction)
                .withProperty(
                    BlockPistonMoving.TYPE,
                    this.isSticky
                        ? BlockPistonExtension.EnumPistonType.STICKY
                        : BlockPistonExtension.EnumPistonType.DEFAULT);
        worldIn.setBlockState(blockpos1, iblockstate2, 4);
        worldIn.setTileEntity(
            blockpos1, BlockPistonMoving.newTileEntity(iblockstate1, direction, true, false));
      }

      for (int l = list1.size() - 1; l >= 0; --l) {
        worldIn.notifyNeighborsOfStateChange((BlockPos) list1.get(l), ablock[i++]);
      }

      for (int i1 = list.size() - 1; i1 >= 0; --i1) {
        worldIn.notifyNeighborsOfStateChange((BlockPos) list.get(i1), ablock[i++]);
      }

      if (extending) {
        worldIn.notifyNeighborsOfStateChange(blockpos1, Blocks.piston_head);
        worldIn.notifyNeighborsOfStateChange(pos, this);
      }

      return true;
    }
  }