private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values()) { tileentityspecialrenderer.setRendererDispatcher(this); } }
/** * Updates a specified sign with the specified text lines */ public void handleUpdateSign(S33PacketUpdateSign packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); boolean flag = false; if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); if (tileentity instanceof TileEntitySign) { TileEntitySign tileentitysign = (TileEntitySign) tileentity; if (tileentitysign.getIsEditable()) { System.arraycopy(packetIn.getLines(), 0, tileentitysign.signText, 0, 4); tileentitysign.markDirty(); } flag = true; } } if (!flag && this.gameController.thePlayer != null) { this.gameController.thePlayer.addChatMessage(new ChatComponentText("Unable to locate sign at " + packetIn.getPos().getX() + ", " + packetIn.getPos().getY() + ", " + packetIn.getPos().getZ())); } }
/** * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks, * beacons, skulls, flowerpot */ public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (this.gameController.world.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.world.getTileEntity(packetIn.getPos()); int i = packetIn.getTileEntityType(); boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock; if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign || i == 10 && tileentity instanceof TileEntityShulkerBox) { tileentity.readFromNBT(packetIn.getNbtCompound()); } if (flag && this.gameController.currentScreen instanceof GuiCommandBlock) { ((GuiCommandBlock)this.gameController.currentScreen).updateGui(); } } }
public SignCopy() { branches.add(new CommandBranch(ctx -> { if (mc.objectMouseOver.getBlockPos() != null) { TileEntity tileEntity = mc.theWorld.getTileEntity(mc.objectMouseOver.getBlockPos()); if (tileEntity != null && tileEntity instanceof TileEntitySign) { TileEntitySign sign = (TileEntitySign) tileEntity; StringBuilder builder = new StringBuilder(); for (IChatComponent component : sign.signText) { builder.append(component.getUnformattedText()); builder.append(System.getProperty("line.separator")); } Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(builder.toString()), null); } } })); }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer()); this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); this.mapSpecialRenderers.put(TileEntityStructure.class, new TileEntityStructureRenderer()); this.mapSpecialRenderers.put(TileEntityShulkerBox.class, new TileEntityShulkerBoxRenderer(new ModelShulker())); for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values()) { tileentityspecialrenderer.setRendererDispatcher(this); } }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer()); this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); this.mapSpecialRenderers.put(TileEntityStructure.class, new TileEntityStructureRenderer()); for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values()) { tileentityspecialrenderer.setRendererDispatcher(this); } }
private static void wrapSignText(String containerProperty, TileEntitySign sign) { if (containerProperty.length() < 14) { sign.signText[1] = new ChatComponentText(containerProperty); } else if (containerProperty.length() < 27) { sign.signText[1] = new ChatComponentText( containerProperty.substring(0, 13)); sign.signText[2] = new ChatComponentText( containerProperty.substring(13, containerProperty.length())); } else { sign.signText[1] = new ChatComponentText( containerProperty.substring(0, 13)); sign.signText[1] = new ChatComponentText( containerProperty.substring(13, 26)); sign.signText[2] = new ChatComponentText( containerProperty.substring(26, containerProperty.length())); } }
public @Nonnull Quat4f getSignRotate(final @Nonnull TileEntitySign tile) { // Vanilla Translate final Block block = tile.getBlockType(); if (block==Blocks.standing_sign) { final float f2 = tile.getBlockMetadata()*360f/16f; return RotationMath.quatDeg(-f2, 0f, 1f, 0f); } else { final int j = tile.getBlockMetadata(); float f3; switch (j) { case 2: f3 = 180f; break; case 4: f3 = 90f; break; case 5: f3 = -90f; break; default: f3 = 0f; break; } return RotationMath.quatDeg(-f3, 0f, 1f, 0f); } }
private boolean signContains(TileEntitySign sign, String str) { // If the sign's text is messed up or something if (sign.signText == null) { return false; } // makes the subsequence final CharSequence mySeq = str.subSequence(0, str.length() - 1); // loops through for all sign lines for (int i = 0; i < sign.signText.length; i++) { // name just has to be included in full on one of the lines. if (sign.signText[i].contains(mySeq)) { return true; } } return false; }
@Override public void onReceiveClient(Minecraft client, WorldClient world, EntityPlayerSP player, MessageContext context) { BlockSystem blockSystem = BlockSystems.PROXY.getBlockSystemHandler(world).getBlockSystem(this.blockSystem); if (blockSystem != null) { if (blockSystem.isBlockLoaded(this.pos)) { TileEntity blockEntity = blockSystem.getTileEntity(this.pos); boolean commandBlock = this.type == 2 && blockEntity instanceof TileEntityCommandBlock; if (this.type == 1 && blockEntity instanceof TileEntityMobSpawner || commandBlock || this.type == 3 && blockEntity instanceof TileEntityBeacon || this.type == 4 && blockEntity instanceof TileEntitySkull || this.type == 5 && blockEntity instanceof TileEntityFlowerPot || this.type == 6 && blockEntity instanceof TileEntityBanner || this.type == 7 && blockEntity instanceof TileEntityStructure || this.type == 8 && blockEntity instanceof TileEntityEndGateway || this.type == 9 && blockEntity instanceof TileEntitySign) { blockEntity.readFromNBT(this.data); } else { blockEntity.onDataPacket(client.getConnection().getNetworkManager(), new SPacketUpdateTileEntity(this.pos, this.type, this.data)); } if (commandBlock && client.currentScreen instanceof GuiCommandBlock) { ((GuiCommandBlock) client.currentScreen).updateGui(); } } } }
ColossalBuilder doGen(Coord at, int randSeed) { Coord signAt = at.copy(); ColossalBuilder builder = new ColossalBuilder(randSeed, at); builder.construct(); if (signAt.getTE(TileEntityCommandBlock.class) != null) { signAt.set(BlockStandingSign.ROTATION, 12, true); TileEntitySign sign = signAt.getTE(TileEntitySign.class); if (sign != null) { sign.signText[0] = new ChatComponentText("Colossus Seed"); sign.signText[1] = new ChatComponentText("" + randSeed); signAt.markBlockForUpdate(); } } return builder; }
int cleanPosters() { int ret = 0; for (EntityPoster poster : getPosters()) { if (!poster.isLocked()) continue; if (!ItemUtil.is(poster.getItem(), Core.registry.brokenTool)) continue; poster.setItem(null); poster.setLocked(false); poster.syncData(); ret++; ICoordFunction clearSign = new ICoordFunction() { @Override public void handle(Coord here) { if (!(here.getBlock() instanceof BlockSign)) return; TileEntitySign sign = here.getTE(TileEntitySign.class); if (sign == null) return; for (int i = 0; i < sign.signText.length; i++) { sign.signText[i] = new ChatComponentText(""); } here.markBlockForUpdate(); } }; iterateSign(poster, clearSign); } return ret; }
@Override public boolean populate(World world) { Block curBlock = world.getBlock(x, y, z); if(curBlock == Blocks.standing_sign || curBlock == Blocks.wall_sign) { TileEntitySign sign = (TileEntitySign) world.getTileEntity(x, y, z); if (sign != null) { sign.signText = this.signText; sign.markDirty(); world.markBlockForUpdate(x, y, z); return true; } } return false; }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityRendererPiston()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new RenderEndPortal()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); Iterator var1 = this.mapSpecialRenderers.values().iterator(); while (var1.hasNext()) { TileEntitySpecialRenderer var2 = (TileEntitySpecialRenderer)var1.next(); var2.func_147497_a(this); } }
@Override public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception { switch (method) { case 0: case 1: case 2: { int direction = method == 0 ? turtle.getFacingDir() : (method == 1 ? 1 : 0); Vec3 pos = turtle.getPosition(); int x = (int)Math.floor(pos.xCoord) + Facing.offsetsXForSide[direction]; int y = (int)Math.floor(pos.yCoord) + Facing.offsetsYForSide[direction]; int z = (int)Math.floor(pos.zCoord) + Facing.offsetsZForSide[direction]; TileEntity te = turtle.getWorld().getBlockTileEntity(x, y, z); if (te instanceof TileEntitySign) { return ((TileEntitySign)te).signText.clone(); } } } return new Object[0]; }
/** * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks, * beacons, skulls, flowerpot */ public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); int i = packetIn.getTileEntityType(); boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock; if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign) { tileentity.readFromNBT(packetIn.getNbtCompound()); } else { tileentity.onDataPacket(netManager, packetIn); } if (flag && this.gameController.currentScreen instanceof GuiCommandBlock) { ((GuiCommandBlock)this.gameController.currentScreen).updateGui(); } } }
@Override public boolean isTileValid(TileEntitySign te) { if (!te.signText[0].startsWith(Sign.IDENTIFIER)) { return false; } try { NBTTagCompound rootTag = SignClassTransformer.getMyEssentialsDataValue(te); if (rootTag == null) return false; if (!rootTag.getString("Type").equals(SellSignType.instance.getTypeID())) return false; NBTBase data = rootTag.getTag("Value"); if (!(data instanceof NBTTagCompound)) return false; NBTTagCompound signData = (NBTTagCompound) data; MyTownUniverse.instance.getOrMakeResident(UUID.fromString(signData.getString("Owner"))); return true; } catch (Exception ex) { return false; } }
public static void checkBlockInteraction(Resident res, BlockPos bp, PlayerInteractEvent.Action action, Event ev) { if(!ev.isCancelable()) { return; } World world = MinecraftServer.getServer().worldServerForDimension(bp.getDim()); Block block = world.getBlock(bp.getX(), bp.getY(), bp.getZ()); // Bypass for SellSign if (block instanceof BlockSign) { TileEntity te = world.getTileEntity(bp.getX(), bp.getY(), bp.getZ()); if(te instanceof TileEntitySign && SellSign.SellSignType.instance.isTileValid((TileEntitySign) te)) { return; } } for(SegmentBlock segment : segmentsBlock.get(block.getClass())) { if(!segment.shouldInteract(res, bp, action)) { ev.setCanceled(true); } } }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityRendererPiston()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new RenderEndPortal()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); Iterator iterator = this.mapSpecialRenderers.values().iterator(); while (iterator.hasNext()) { TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next(); tileentityspecialrenderer.func_147497_a(this); } }
@Override public void render(TileEntitySign entity, double x, double y, double z, float partialTicks, int destroyStage, float partial) { if (!isDropOff(entity, x, y, z)) return; ITextComponent [] temporaryText = null; if (!CheckVisibleState(entity)) { temporaryText = getSignText(entity); deleteSignText(entity); } if ((!SkipSignCore.ModSetting.HideBoard.Bool()) || (SkipSignCore.ModSetting.HideBoard.Bool() && CheckVisibleState(entity))) { super.render(entity, x, y, z, partialTicks, destroyStage, partial); } if (temporaryText != null) setSignText(entity, temporaryText); }
public boolean CheckVisibleState(TileEntitySign tileEntitySign) { if (SkipSignCore.ModSetting.SignVisible.Int() == 1) return true; if (SkipSignCore.ModSetting.SignVisible.Int() == 2) return false; if (Keyboard.isKeyDown(SkipSignCore.ModSetting.Zoom_Key.Int())) return true; if (SkipSignHelper.IsInRangeToRenderDist( SkipSignHelper.GetDistancePlayerToTileEntity(tileEntitySign), SkipSignCore.ModSetting.SignRange.Int())) return true; return false; }
private TileEntityRenderer() { this.field_76966_m.put(TileEntitySign.class, new TileEntitySignRenderer()); this.field_76966_m.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.field_76966_m.put(TileEntityPiston.class, new TileEntityRendererPiston()); this.field_76966_m.put(TileEntityChest.class, new TileEntityChestRenderer()); this.field_76966_m.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.field_76966_m.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable()); this.field_76966_m.put(TileEntityEndPortal.class, new RenderEndPortal()); this.field_76966_m.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.field_76966_m.put(TileEntitySkull.class, new TileEntitySkullRenderer()); Iterator var1 = this.field_76966_m.values().iterator(); while(var1.hasNext()) { TileEntitySpecialRenderer var2 = (TileEntitySpecialRenderer)var1.next(); var2.func_76893_a(this); } }
public void func_72487_a(Packet130UpdateSign p_72487_1_) { boolean var2 = false; if(this.field_72563_h.field_71441_e.func_72899_e(p_72487_1_.field_73311_a, p_72487_1_.field_73309_b, p_72487_1_.field_73310_c)) { TileEntity var3 = this.field_72563_h.field_71441_e.func_72796_p(p_72487_1_.field_73311_a, p_72487_1_.field_73309_b, p_72487_1_.field_73310_c); if(var3 instanceof TileEntitySign) { TileEntitySign var4 = (TileEntitySign)var3; if(var4.func_70409_a()) { for(int var5 = 0; var5 < 4; ++var5) { var4.field_70412_a[var5] = p_72487_1_.field_73308_d[var5]; } var4.func_70296_d(); } var2 = true; } } if(!var2 && this.field_72563_h.field_71439_g != null) { this.field_72563_h.field_71439_g.func_70006_a(ChatMessageComponent.func_111066_d("Unable to locate sign at " + p_72487_1_.field_73311_a + ", " + p_72487_1_.field_73309_b + ", " + p_72487_1_.field_73310_c)); } }
private TileEntityRenderer() { this.specialRendererMap.put(TileEntitySign.class, new TileEntitySignRenderer()); this.specialRendererMap.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.specialRendererMap.put(TileEntityPiston.class, new TileEntityRendererPiston()); this.specialRendererMap.put(TileEntityChest.class, new TileEntityChestRenderer()); this.specialRendererMap.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.specialRendererMap.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable()); this.specialRendererMap.put(TileEntityEndPortal.class, new RenderEndPortal()); this.specialRendererMap.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.specialRendererMap.put(TileEntitySkull.class, new TileEntitySkullRenderer()); Iterator iterator = this.specialRendererMap.values().iterator(); while (iterator.hasNext()) { TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next(); tileentityspecialrenderer.setTileEntityRenderer(this); } }
public void func_142031_a(Packet133TileEditorOpen par1Packet133TileEditorOpen) { TileEntity tileentity = this.worldClient.getBlockTileEntity(par1Packet133TileEditorOpen.field_142035_b, par1Packet133TileEditorOpen.field_142036_c, par1Packet133TileEditorOpen.field_142034_d); if (tileentity != null) { this.mc.thePlayer.displayGUIEditSign(tileentity); } else if (par1Packet133TileEditorOpen.field_142037_a == 0) { TileEntitySign tileentitysign = new TileEntitySign(); tileentitysign.setWorldObj(this.worldClient); tileentitysign.xCoord = par1Packet133TileEditorOpen.field_142035_b; tileentitysign.yCoord = par1Packet133TileEditorOpen.field_142036_c; tileentitysign.zCoord = par1Packet133TileEditorOpen.field_142034_d; this.mc.thePlayer.displayGUIEditSign(tileentitysign); } }
/** * Adds text to a sign in the world. Use EnumChatFormatting to set colors. Text of more * than 15 characters per line will be truncated automatically. * @param text A String array of no more than 4 elements; additional elements will be ignored * @return false if no sign tile entity was found at x/y/z */ public static final boolean setSignText(World world, String[] text, int x, int y, int z) { TileEntitySign sign = (world.getTileEntity(x, y, z) instanceof TileEntitySign ? (TileEntitySign) world.getTileEntity(x, y, z) : null); if (sign != null) { for (int i = 0; i < sign.signText.length && i < text.length; ++i) { if (text[i] == null) { LogHelper.warning("Uninitialized String element while setting sign text at index " + i); continue; } else if (text[i].length() > 15) { LogHelper.warning(text[i] + " is too long to fit on a sign; maximum length is 15 characters."); sign.signText[i] = text[i].substring(0, 15); } else { sign.signText[i] = text[i]; } } return true; } LogHelper.warning("No TileEntitySign was found at " + x + "/" + y + "/" + z); return false; }
public CraftSign(final Block block) { super(block); CraftWorld world = (CraftWorld) block.getWorld(); sign = (net.minecraft.tileentity.TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ()); // Spigot start if (sign == null) { lines = new String[]{"", "", "", ""}; return; } // Spigot end lines = new String[sign.signText.length]; System.arraycopy(sign.signText, 0, lines, 0, lines.length); }
public static String[] sanitizeLines(String[] lines) { String[] astring = new String[4]; for(int i = 0; i < 4; i++) { if (i < lines.length && lines[i] != null) { astring[i] = lines[i]; } else { astring[i] = ""; } } return TileEntitySign.sanitizeLines(astring); }
public void processUpdateSign(C12PacketUpdateSign packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer()); this.playerEntity.markPlayerActive(); WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); BlockPos blockpos = packetIn.getPosition(); if (worldserver.isBlockLoaded(blockpos)) { TileEntity tileentity = worldserver.getTileEntity(blockpos); if (!(tileentity instanceof TileEntitySign)) { return; } TileEntitySign tileentitysign = (TileEntitySign)tileentity; if (!tileentitysign.getIsEditable() || tileentitysign.getPlayer() != this.playerEntity) { this.serverController.logWarning("Player " + this.playerEntity.getName() + " just tried to change non-editable sign"); return; } IChatComponent[] aichatcomponent = packetIn.getLines(); for (int i = 0; i < aichatcomponent.length; ++i) { tileentitysign.signText[i] = new ChatComponentText(EnumChatFormatting.getTextWithoutFormattingCodes(aichatcomponent[i].getUnformattedText())); } tileentitysign.markDirty(); worldserver.markBlockForUpdate(blockpos); } }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity instanceof TileEntitySign ? ((TileEntitySign)tileentity).executeCommand(playerIn) : false; } }
/** * Updates a specified sign with the specified text lines */ public void handleUpdateSign(S33PacketUpdateSign packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); boolean flag = false; if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); if (tileentity instanceof TileEntitySign) { TileEntitySign tileentitysign = (TileEntitySign)tileentity; if (tileentitysign.getIsEditable()) { System.arraycopy(packetIn.getLines(), 0, tileentitysign.signText, 0, 4); tileentitysign.markDirty(); } flag = true; } } if (!flag && this.gameController.thePlayer != null) { this.gameController.thePlayer.addChatMessage(new ChatComponentText("Unable to locate sign at " + packetIn.getPos().getX() + ", " + packetIn.getPos().getY() + ", " + packetIn.getPos().getZ())); } }