Skip to content

Commit

Permalink
Fix #3509 , CanPlace is now called again
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Apr 30, 2024
1 parent 06996a5 commit 6e66b80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion patches/tModLoader/Terraria/ModLoader/ModBlockType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public virtual bool CreateDust(int i, int j, ref int type)
}

/// <summary>
/// Allows you to stop this tile/wall from being placed at the given coordinates. Return false to stop the tile/wall from being placed. Returns true by default.
/// Allows you to stop this tile/wall from being placed at the given coordinates. This method is called on the local client.
/// <para/> For tiles this is also checked during block replacement, but <see cref="ModTile.CanReplace(int, int, int)"/> should be used for replace-specific logic.
/// <para/> Return false to stop the tile/wall from being placed. Returns true by default.
/// </summary>
/// <param name="i">The x position in tile coordinates.</param>
/// <param name="j">The y position in tile coordinates.</param>
Expand Down
8 changes: 7 additions & 1 deletion patches/tModLoader/Terraria/Player.cs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5610,14 +5610,20 @@
if (inventory[selectedItem].stack == 0)
inventory[selectedItem].SetDefaults();

@@ -30673,6 +_,7 @@
@@ -30673,9 +_,13 @@
int? forcedRandom = null;
TileObject objectData = default(TileObject);
FigureOutWhatToPlace(tile, item, out tileToCreate, out var previewPlaceStyle, out overrideCanPlace, out forcedRandom);
+ PlantLoader.CheckAndInjectModSapling(tileTargetX, tileTargetY, ref tileToCreate, ref previewPlaceStyle);
if (overrideCanPlace.HasValue) {
canPlace = overrideCanPlace.Value;
}
+ else if (!TileLoader.CanPlace(tileTargetX, tileTargetY, tileToCreate)) {
+ canPlace = false;
+ }
else if (TileObjectData.CustomPlace(tileToCreate, previewPlaceStyle) && tileToCreate != 82 && tileToCreate != 227) {
newObjectType = true;
canPlace = TileObject.CanPlace(tileTargetX, tileTargetY, (ushort)tileToCreate, previewPlaceStyle, direction, out objectData, onlyCheck: false, forcedRandom);
@@ -30757,9 +_,15 @@
if (!WorldGen.IsTileReplacable(tileTargetX, tileTargetY))
return false;
Expand Down

0 comments on commit 6e66b80

Please sign in to comment.