From 6e66b805a8ba15adf1a3b25710d558cea3a5416d Mon Sep 17 00:00:00 2001 From: JavidPack Date: Tue, 30 Apr 2024 11:56:06 -0600 Subject: [PATCH] Fix #3509 , CanPlace is now called again --- patches/tModLoader/Terraria/ModLoader/ModBlockType.cs | 4 +++- patches/tModLoader/Terraria/Player.cs.patch | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/patches/tModLoader/Terraria/ModLoader/ModBlockType.cs b/patches/tModLoader/Terraria/ModLoader/ModBlockType.cs index 9e1ec041c3b..f3b9f800f69 100644 --- a/patches/tModLoader/Terraria/ModLoader/ModBlockType.cs +++ b/patches/tModLoader/Terraria/ModLoader/ModBlockType.cs @@ -92,7 +92,9 @@ public virtual bool CreateDust(int i, int j, ref int type) } /// - /// 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. + /// For tiles this is also checked during block replacement, but should be used for replace-specific logic. + /// Return false to stop the tile/wall from being placed. Returns true by default. /// /// The x position in tile coordinates. /// The y position in tile coordinates. diff --git a/patches/tModLoader/Terraria/Player.cs.patch b/patches/tModLoader/Terraria/Player.cs.patch index cecd160bc7e..b6072ef2aa6 100644 --- a/patches/tModLoader/Terraria/Player.cs.patch +++ b/patches/tModLoader/Terraria/Player.cs.patch @@ -5610,7 +5610,7 @@ 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); @@ -5618,6 +5618,12 @@ 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;