コード例 #1
0
  public ItemStack decrStackSize(int index, int amount) {
    if (index >= stacks.length) {
      return null;
    }

    if (isGhostSlot(index) || isGhostOutputSlot(index)) {
      ItemStack old = stacks[index];
      stacks[index] = null;
      if (old == null) {
        return null;
      }
      old.stackSize = 0;
      return old;
    } else {
      if (stacks[index] != null) {
        if (stacks[index].stackSize <= amount) {
          ItemStack old = stacks[index];
          stacks[index] = null;
          tileEntity.markDirty();
          return old;
        }
        ItemStack its = stacks[index].splitStack(amount);
        if (stacks[index].stackSize == 0) {
          stacks[index] = null;
        }
        tileEntity.markDirty();
        return its;
      }
      return null;
    }
  }
コード例 #2
0
  public void setInventorySlotContents(int stackLimit, int index, ItemStack stack) {
    if (index >= stacks.length) {
      return;
    }

    if (isGhostSlot(index)) {
      if (stack != null) {
        stacks[index] = stack.copy();
        if (index < 9) {
          stacks[index].stackSize = 1;
        }
      } else {
        stacks[index] = null;
      }
    } else if (isGhostOutputSlot(index)) {
      if (stack != null) {
        stacks[index] = stack.copy();
      } else {
        stacks[index] = null;
      }
    } else {
      stacks[index] = stack;
      if (stack != null && stack.stackSize > stackLimit) {
        stack.stackSize = stackLimit;
      }
      tileEntity.markDirty();
    }
  }
コード例 #3
0
 @Override
 public void markDirty() {
   if (myChest != null) {
     myChest.updateChestContents(this.chestContents);
   }
   this.accessTicks = 80;
   this.updateAccessTicks();
   super.markDirty();
 }
コード例 #4
0
 public boolean rotateLittleChunk(World world, int x, int y, int z, ForgeDirection axis) {
   TileEntity tileentity = world.getTileEntity(x, y, z);
   if (tileentity != null && tileentity instanceof TileEntityLittleChunk) {
     ((TileEntityLittleChunk) tileentity).rotateContents(axis);
     tileentity.markDirty();
     world.markBlockForUpdate(x, y, z);
   }
   return false;
 }
コード例 #5
0
ファイル: itemRiftRemover.java プロジェクト: Jaitsu/DimDoors
  @Override
  public boolean onItemUseFirst(
      ItemStack stack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ) {

    // We want to use onItemUseFirst() here so that this code will run on the server side,
    // so we don't need the client to send link-related updates to the server. Still,
    // check whether we have a rift in sight before passing the request over.

    // On integrated servers, the link won't be removed immediately because of the rift
    // removal animation. That means we'll have a chance to check for the link before
    // it's deleted. Otherwise the Rift Remover's durability wouldn't drop.
    MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
    if (hit != null) {
      x = hit.blockX;
      y = hit.blockY;
      z = hit.blockZ;

      NewDimData dimension = PocketManager.createDimensionData(world);
      DimLink link = dimension.getLink(x, y, z);
      if (world.getBlock(x, y, z) == mod_pocketDim.blockRift
          && link != null
          && player.canPlayerEdit(x, y, z, side, stack)) {
        // Tell the rift's tile entity to do its removal animation
        TileEntity tileEntity = world.getTileEntity(x, y, z);
        if (tileEntity != null && tileEntity instanceof TileEntityRift) {
          ((TileEntityRift) tileEntity).shouldClose = true;
          tileEntity.markDirty();
        } else if (!world.isRemote) {
          // Only set the block to air on the server side so that we don't
          // tell the server to remove the rift block before it can use the
          // Rift Remover. Otherwise, it won't know to reduce durability.
          world.setBlockToAir(x, y, z);
        }
        if (world.isRemote) {
          // Tell the server about this
          return false;
        } else {
          if (!player.capabilities.isCreativeMode) {
            stack.damageItem(1, player);
          }
          player.worldObj.playSoundAtEntity(player, mod_pocketDim.modid + ":riftClose", 0.8f, 1);
        }
      }
    }
    return true;
  }
コード例 #6
0
 @Override
 public void markDirty() {
   super.markDirty();
   if (this.controllerPosition != null) {
     TileEntity te =
         worldObj.getTileEntity(controllerPosition.x, controllerPosition.y, controllerPosition.z);
     if (te instanceof WorkSiteWarehouse) {
       ((WorkSiteWarehouse) te).onInputInventoryUpdated(this);
     }
   }
 }
コード例 #7
0
 @Override
 public void markDirty() {
   super.markDirty();
   PacketHandler.INSTANCE.sendToAllAround(
       new MessageFluid(this),
       new NetworkRegistry.TargetPoint(
           this.worldObj.provider.dimensionId,
           (double) this.xCoord,
           (double) this.yCoord,
           (double) this.zCoord,
           128d));
 }
コード例 #8
0
  /** Method to indicate that this TE has changed its data. */
  @Override
  public void markDirty() {
    if (isRemote()) return;

    getState().onStateUpdated();

    // Vanilla compatibility
    super.markDirty();
    getWorld().markChunkDirty(getPos(), this);

    // Notify the events system of a update.
    SmithsCore.getRegistry().getCommonBus().post(new TileEntityDataUpdatedEvent(this));
  }
コード例 #9
0
  public static boolean setTileEntityNBT(
      World worldIn, BlockPos p_179224_1_, ItemStack p_179224_2_) {
    if (p_179224_2_.hasTagCompound() && p_179224_2_.getTagCompound().hasKey("BlockEntityTag", 10)) {
      TileEntity var3 = worldIn.getTileEntity(p_179224_1_);
      if (var3 != null) {
        NBTTagCompound var4 = new NBTTagCompound();
        NBTTagCompound var5 = (NBTTagCompound) var4.copy();
        var3.writeToNBT(var4);
        NBTTagCompound var6 =
            (NBTTagCompound) p_179224_2_.getTagCompound().getTag("BlockEntityTag");
        var4.merge(var6);
        var4.setInteger("x", p_179224_1_.getX());
        var4.setInteger("y", p_179224_1_.getY());
        var4.setInteger("z", p_179224_1_.getZ());
        if (!var4.equals(var5)) {
          var3.readFromNBT(var4);
          var3.markDirty();
          return true;
        }
      }
    }

    return false;
  }
コード例 #10
0
 public void markDirty() {
   super.markDirty();
   onInventoryChanged();
 }
コード例 #11
0
 @Override
 public void markDirty() {
   for (TileEntity handler : _listener) {
     handler.markDirty();
   }
 }
コード例 #12
0
  @Override
  public void markDirty() {

    super.markDirty();
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
  }