Axe of Regrowth can now replant Spine Trees

This commit is contained in:
CongratsIsTrash authored and Cameron Ewell committed 2026-03-10 21:50:20 -04:00
1 parent fe18cfbd9f
commit aaf65e9dae
2 files changed
+31 -5

No files matched your search

+26
View File
@@ -10,6 +10,32 @@ namespace CalamityMod.Tiles.Crags.Tree
{
public class SpineSapling : ModTile
{
public override void Load()
{
On_Player.TryReplantingTree += LetAxeofRegrowthReplant;
}
private static void LetAxeofRegrowthReplant(On_Player.orig_TryReplantingTree orig, Player self, int x, int y)
{
if (Main.tile[x, y + 1].TileType == ModContent.TileType<BrimstoneSlag>())
{
// Destroy the Spine Tree tile above the base to give space for the Small Spine to place
WorldGen.KillTile(x, y - 1);
if (!TileObject.CanPlace(Player.tileTargetX, Player.tileTargetY, ModContent.TileType<SpineSapling>(), 0, self.direction, out var objectData))
return;
bool placed = TileObject.Place(objectData);
WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY);
if (placed)
{
TileObjectData.CallPostPlacementPlayerHook(Player.tileTargetX, Player.tileTargetY, ModContent.TileType<SpineSapling>(), 0, self.direction, objectData.alternate, objectData);
if (Main.netMode == NetmodeID.MultiplayerClient)
NetMessage.SendObjectPlacement(-1, Player.tileTargetX, Player.tileTargetY, objectData.type, objectData.style, objectData.alternate, objectData.random, self.direction);
}
}
else
orig(self, x, y);
}
public override void SetStaticDefaults()
{
Main.tileFrameImportant[Type] = true;
+5 -5
View File
@@ -171,14 +171,14 @@ namespace CalamityMod.Tiles.Crags.Tree
public override void NearbyEffects(int i, int j, bool closer)
{
//kill the tree tiles if there are no tiles below it
if (!Framing.GetTileSafely(i, j + 1).HasTile)
// Kill the tree tiles if there are no tiles below it or if a Sapling is below it
// The Sapling check exists for Axe of Regrowth sapling replanting
Tile belowTile = Framing.GetTileSafely(i, j + 1);
if (!belowTile.HasTile || belowTile.TileType == ModContent.TileType<SpineSapling>())
{
WorldGen.KillTile(i, j, false, false, false);
WorldGen.KillTile(i, j);
if (Main.netMode == NetmodeID.MultiplayerClient)
{
NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, i, j);
}
}
}