77using System . Linq ;
88using System . Text ;
99using Microsoft . Xna . Framework ;
10+ using OTAPI . Tile ;
1011using Terraria . ID ;
1112using Terraria . Localization ;
1213using DPoint = System . Drawing . Point ;
@@ -434,7 +435,7 @@ select pt.TileLocation
434435
435436 bool isInvalidEntry = false ;
436437 DPoint chestLocation = new DPoint ( tChest . x , tChest . y ) ;
437- Tile chestTile = TerrariaUtils . Tiles [ chestLocation ] ;
438+ ITile chestTile = TerrariaUtils . Tiles [ chestLocation ] ;
438439 if ( chestTile . active ( ) && ( chestTile . type == TileID . Containers || chestTile . type == TileID . Containers2 || chestTile . type == TileID . Dressers ) ) {
439440 chestLocation = TerrariaUtils . Tiles . MeasureObject ( chestLocation ) . OriginTileLocation ;
440441 lock ( this . WorldMetadata . Protections ) {
@@ -1684,7 +1685,7 @@ private void RefillChestManyCommand_Exec(CommandArgs args) {
16841685 continue ;
16851686
16861687 DPoint chestLocation = new DPoint ( chest . x , chest . y ) ;
1687- Tile chestTile = TerrariaUtils . Tiles [ chestLocation ] ;
1688+ ITile chestTile = TerrariaUtils . Tiles [ chestLocation ] ;
16881689 if ( ! chestTile . active ( ) || ( chestTile . type != TileID . Containers && chestTile . type != TileID . Containers2 ) )
16891690 continue ;
16901691
@@ -2090,15 +2091,11 @@ public override bool HandleTileEdit(
20902091
20912092 switch ( editType ) {
20922093 case TileEditType . PlaceTile : {
2093- Tile tile = TerrariaUtils . Tiles [ location ] ;
2094- if ( tile == null )
2095- Main . tile [ location . X , location . Y ] = tile = new Tile ( ) ;
2094+ WorldGen . PlaceTile ( location . X , location . Y , blockType , false , true , - 1 , objectStyle ) ;
20962095
2097- WorldGen . PlaceTile ( location . X , location . Y , ( int ) blockType , false , true , - 1 , objectStyle ) ;
2096+ NetMessage . SendData ( ( int ) PacketTypes . Tile , - 1 , player . Index , NetworkText . Empty , 1 , location . X , location . Y , blockType , objectStyle ) ;
20982097
2099- NetMessage . SendData ( ( int ) PacketTypes . Tile , - 1 , player . Index , NetworkText . Empty , 1 , location . X , location . Y , ( int ) blockType , objectStyle ) ;
2100-
2101- if ( this . Config . AutoProtectedTiles [ ( int ) blockType ] )
2098+ if ( this . Config . AutoProtectedTiles [ blockType ] )
21022099 this . TryCreateAutoProtection ( player , location ) ;
21032100
21042101 return true ;
@@ -2109,7 +2106,7 @@ public override bool HandleTileEdit(
21092106 //if (blockType != 0)
21102107 // break;
21112108
2112- Tile tile = TerrariaUtils . Tiles [ location ] ;
2109+ ITile tile = TerrariaUtils . Tiles [ location ] ;
21132110 bool isChest = ( tile . type == TileID . Containers || tile . type == TileID . Containers2 || tile . type == TileID . Dressers ) ;
21142111 foreach ( ProtectionEntry protection in this . ProtectionManager . EnumerateProtectionEntries ( location ) ) {
21152112 // If the protection is invalid, just remove it.
@@ -2118,7 +2115,7 @@ public override bool HandleTileEdit(
21182115 continue ;
21192116 }
21202117
2121- Tile protectedTile = TerrariaUtils . Tiles [ protection . TileLocation ] ;
2118+ ITile protectedTile = TerrariaUtils . Tiles [ protection . TileLocation ] ;
21222119 // If the protection is invalid, just remove it.
21232120 if ( ! protectedTile . active ( ) || protectedTile . type != protection . BlockType ) {
21242121 this . ProtectionManager . RemoveProtection ( TSPlayer . Server , protection . TileLocation , false ) ;
@@ -2328,7 +2325,7 @@ public virtual bool HandleChestOpen(TSPlayer player, int chestIndex, DPoint ches
23282325 if ( chest == null )
23292326 return false ;
23302327
2331- Tile chestTile = TerrariaUtils . Tiles [ chest . Location ] ;
2328+ ITile chestTile = TerrariaUtils . Tiles [ chest . Location ] ;
23322329 bool isLocked ;
23332330 ChestStyle chestStyle = TerrariaUtils . Tiles . GetChestStyle ( chestTile , out isLocked ) ;
23342331 if ( isLocked )
@@ -2821,7 +2818,7 @@ public virtual bool HandlePlayerSpawn(TSPlayer player, DPoint spawnTileLocation)
28212818 return false ;
28222819
28232820 DPoint bedTileLocation = new DPoint ( spawnTileLocation . X , spawnTileLocation . Y - 1 ) ;
2824- Tile spawnTile = TerrariaUtils . Tiles [ bedTileLocation ] ;
2821+ ITile spawnTile = TerrariaUtils . Tiles [ bedTileLocation ] ;
28252822 bool isInvalidBedSpawn = ( ! spawnTile . active ( ) || spawnTile . type != TileID . Beds ) ;
28262823
28272824 bool allowNewSpawnSet = true ;
@@ -3177,7 +3174,7 @@ private bool TryRemoveProtection(TSPlayer player, DPoint tileLocation, bool send
31773174 }
31783175
31793176 private bool TryGetProtectionInfo ( TSPlayer player , DPoint tileLocation , bool sendFailureMessages = true ) {
3180- Tile tile = TerrariaUtils . Tiles [ tileLocation ] ;
3177+ ITile tile = TerrariaUtils . Tiles [ tileLocation ] ;
31813178 if ( ! tile . active ( ) )
31823179 return false ;
31833180
@@ -3751,7 +3748,7 @@ public void EnsureProtectionData(TSPlayer player) {
37513748 }
37523749
37533750 private void DestroyBlockOrObject ( DPoint tileLocation ) {
3754- Tile tile = TerrariaUtils . Tiles [ tileLocation ] ;
3751+ ITile tile = TerrariaUtils . Tiles [ tileLocation ] ;
37553752 if ( ! tile . active ( ) )
37563753 return ;
37573754
0 commit comments