/** Displays the GUI for editing a sign. Args: tileEntitySign */
 public void displayGUIEditSign(TileEntity p_146100_1_) {
   if (p_146100_1_ instanceof TileEntitySign) {
     ((TileEntitySign) p_146100_1_).func_145912_a(this);
     this.playerNetServerHandler.sendPacket(
         new S36PacketSignEditorOpen(p_146100_1_.xCoord, p_146100_1_.yCoord, p_146100_1_.zCoord));
   }
 }
  /**
   * @Author Zidane
   *
   * <p>Invoke before {@code System.arraycopy(packetIn.getLines(), 0, tileentitysign.signText, 0,
   * 4);} (line 1156 in source) to call SignChangeEvent.
   *
   * @param packetIn Injected packet param
   * @param ci Info to provide mixin on how to handle the callback
   * @param worldserver Injected world param
   * @param blockpos Injected blockpos param
   * @param tileentity Injected tilentity param
   * @param tileentitysign Injected tileentitysign param
   */
  @Inject(
      method = "processUpdateSign",
      at =
          @At(
              value = "INVOKE",
              target =
                  "Lnet/minecraft/network/play/client/C12PacketUpdateSign;getLines()[Lnet/minecraft/util/IChatComponent;"),
      cancellable = true,
      locals = LocalCapture.CAPTURE_FAILSOFT)
  public void callSignChangeEvent(
      C12PacketUpdateSign packetIn,
      CallbackInfo ci,
      WorldServer worldserver,
      BlockPos blockpos,
      TileEntity tileentity,
      TileEntitySign tileentitysign) {
    ci.cancel();
    final Optional<SignData> existingSignData = ((Sign) tileentitysign).getData();
    if (!existingSignData.isPresent()) {
      // TODO Unsure if this is the best to do here...
      throw new RuntimeException("Critical error! Sign data not present on sign!");
    }
    final SignData changedSignData = existingSignData.get().copy();

    for (int i = 0; i < packetIn.getLines().length; i++) {
      changedSignData.setLine(i, SpongeTexts.toText(packetIn.getLines()[i]));
    }
    // I pass changedSignData in here twice to emulate the fact that even-though the current sign
    // data doesn't have the lines from the packet
    // applied, this is what it "is" right now. If the data shown in the world is desired, it can be
    // fetched from Sign.getData
    final SignChangeEvent event =
        SpongeEventFactory.createSignChange(
            Sponge.getGame(),
            new Cause(null, this.playerEntity, null),
            (Sign) tileentitysign,
            changedSignData,
            changedSignData);
    if (!Sponge.getGame().getEventManager().post(event)) {
      ((Sign) tileentitysign).offer(event.getNewData());
    } else {
      // If cancelled, I set the data back that was fetched from the sign. This means that if its a
      // new sign, the sign will be empty else
      // it will be the text of the sign that was showing in the world
      ((Sign) tileentitysign).offer(existingSignData.get());
    }
    tileentitysign.markDirty();
    worldserver.markBlockForUpdate(blockpos);
  }
예제 #3
0
 public void readFromNBT(NBTTagCompound par1) {
   super.readFromNBT(par1);
   this.isConnected = par1.getBoolean("Connected");
 }
예제 #4
0
 public void writeToNBT(NBTTagCompound par1) {
   super.writeToNBT(par1);
   par1.setBoolean("Connected", this.isConnected);
 }