From 39ca849f68acfc6be1d2ca3c7c044751bfaeb38a Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 19 Oct 2024 16:12:01 +0700 Subject: [PATCH] living fire tile drop fix --- .../LivingBrimstoneFireBlockTile.cs | 76 ++----------------- .../LivingGodSlayerFireBlockTile.cs | 75 ++---------------- Tiles/LivingFire/LivingHolyFireBlockTile.cs | 75 ++---------------- Tiles/LivingFire/LivingPlagueFireBlockTile.cs | 75 ++---------------- 4 files changed, 24 insertions(+), 277 deletions(-) diff --git a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs index d47571bd64..ddaee0e086 100644 --- a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs +++ b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs @@ -1,83 +1,25 @@ -using System.Collections.Generic; -using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.LivingFire; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ObjectData; + namespace CalamityMod.Tiles.LivingFire { public class LivingBrimstoneFireBlockTile : ModTile { - //Thank you to Seraph for getting living fire blocks to work properly. public override void SetStaticDefaults() { Main.tileLighted[Type] = true; - HitSound = SoundID.Dig; + TileID.Sets.CanPlaceNextToNonSolidTile[Type] = true; + DustType = (int)CalamityDusts.Brimstone; AddMapEntry(new Color(178, 34, 34)); AnimationFrameHeight = 90; - Main.tileSolid[Type] = false; - Main.tileNoAttach[Type] = false; - Main.tileFrameImportant[Type] = false; - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(CanPlaceAlter, -1, 0, true); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - - TileObjectData.addTile(Type); } - public int CanPlaceAlter(int i, int j, int type, int style, int direction, int alternate) => 1; + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) => offsetY = 2; - public static int AfterPlacement(int i, int j, int type, int style, int direction, int alternate) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileSquare(Main.myPlayer, i, j, 1, 1); - } - return 1; - } - - public override bool CanPlace(int i, int j) - { - List> around = new List> - { - new List() {i, j-1 }, - new List() {i-1, j }, - new List() {i+1, j }, - new List() {i, j+1 } - }; - //if (Main.tile[i, j]) || tile.type == Type - - //return true; //temporary for testing purposes - - if (Main.tile[i, j].WallType != WallID.None) - { - return true; - } - - for (int k = 0; k < around.Count; ++k) - { - Tile tile = Main.tile[around[k][0], around[k][1]]; - if (tile.HasTile && (Main.tileSolid[tile.TileType] || CalamityLists.livingFireBlockList.Contains(tile.TileType))) - { - return true; - } - } - return false; - } - - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frame = Main.tileFrame[TileID.LivingFire]; - } + public override void AnimateTile(ref int frame, ref int frameCounter) => frame = Main.tileFrame[TileID.LivingFire]; public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { @@ -85,11 +27,5 @@ namespace CalamityMod.Tiles.LivingFire g = 0f; b = 0f; } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.Brimstone, 0f, 0f, 1, default, 1f); - return false; - } } } diff --git a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs index 688e1eef69..2ad8f0f689 100644 --- a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs +++ b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs @@ -1,12 +1,9 @@ -using System.Collections.Generic; -using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.LivingFire; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ObjectData; + namespace CalamityMod.Tiles.LivingFire { public class LivingGodSlayerFireBlockTile : ModTile @@ -14,69 +11,15 @@ namespace CalamityMod.Tiles.LivingFire public override void SetStaticDefaults() { Main.tileLighted[Type] = true; - HitSound = SoundID.Dig; + TileID.Sets.CanPlaceNextToNonSolidTile[Type] = true; + DustType = (int)CalamityDusts.PurpleCosmilite; AddMapEntry(new Color(186, 85, 211)); AnimationFrameHeight = 90; - Main.tileSolid[Type] = false; - Main.tileNoAttach[Type] = false; - Main.tileFrameImportant[Type] = false; - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(CanPlaceAlter, -1, 0, true); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - - TileObjectData.addTile(Type); } - public int CanPlaceAlter(int i, int j, int type, int style, int direction, int alternate) => 1; + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) => offsetY = 2; - public static int AfterPlacement(int i, int j, int type, int style, int direction, int alternate) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileSquare(Main.myPlayer, i, j, 1, 1); - } - return 1; - } - - public override bool CanPlace(int i, int j) - { - List> around = new List> - { - new List() {i, j-1 }, - new List() {i-1, j }, - new List() {i+1, j }, - new List() {i, j+1 } - }; - //if (Main.tile[i, j]) || tile.type == Type - - //return true; //temporary for testing purposes - - if (Main.tile[i, j].WallType != WallID.None) - { - return true; - } - - for (int k = 0; k < around.Count; ++k) - { - Tile tile = Main.tile[around[k][0], around[k][1]]; - if (tile.HasTile && (Main.tileSolid[tile.TileType] || CalamityLists.livingFireBlockList.Contains(tile.TileType))) - { - return true; - } - } - return false; - } - - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frame = Main.tileFrame[TileID.LivingFire]; - } + public override void AnimateTile(ref int frame, ref int frameCounter) => frame = Main.tileFrame[TileID.LivingFire]; public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { @@ -84,11 +27,5 @@ namespace CalamityMod.Tiles.LivingFire g = 0f; b = 1f; } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 1, default, 1f); - return false; - } } } diff --git a/Tiles/LivingFire/LivingHolyFireBlockTile.cs b/Tiles/LivingFire/LivingHolyFireBlockTile.cs index 82a99923db..51d1319a34 100644 --- a/Tiles/LivingFire/LivingHolyFireBlockTile.cs +++ b/Tiles/LivingFire/LivingHolyFireBlockTile.cs @@ -1,12 +1,9 @@ -using System.Collections.Generic; -using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.LivingFire; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ObjectData; + namespace CalamityMod.Tiles.LivingFire { public class LivingHolyFireBlockTile : ModTile @@ -14,69 +11,15 @@ namespace CalamityMod.Tiles.LivingFire public override void SetStaticDefaults() { Main.tileLighted[Type] = true; - HitSound = SoundID.Dig; + TileID.Sets.CanPlaceNextToNonSolidTile[Type] = true; + DustType = (int)CalamityDusts.ProfanedFire; AddMapEntry(new Color(255, 215, 0)); AnimationFrameHeight = 90; - Main.tileSolid[Type] = false; - Main.tileNoAttach[Type] = false; - Main.tileFrameImportant[Type] = false; - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(CanPlaceAlter, -1, 0, true); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - - TileObjectData.addTile(Type); } - public int CanPlaceAlter(int i, int j, int type, int style, int direction, int alternate) => 1; + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) => offsetY = 2; - public static int AfterPlacement(int i, int j, int type, int style, int direction, int alternate) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileSquare(Main.myPlayer, i, j, 1, 1); - } - return 1; - } - - public override bool CanPlace(int i, int j) - { - List> around = new List> - { - new List() {i, j-1 }, - new List() {i-1, j }, - new List() {i+1, j }, - new List() {i, j+1 } - }; - //if (Main.tile[i, j]) || tile.type == Type - - //return true; //temporary for testing purposes - - if (Main.tile[i, j].WallType != WallID.None) - { - return true; - } - - for (int k = 0; k < around.Count; ++k) - { - Tile tile = Main.tile[around[k][0], around[k][1]]; - if (tile.HasTile && (Main.tileSolid[tile.TileType] || CalamityLists.livingFireBlockList.Contains(tile.TileType))) - { - return true; - } - } - return false; - } - - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frame = Main.tileFrame[TileID.LivingFire]; - } + public override void AnimateTile(ref int frame, ref int frameCounter) => frame = Main.tileFrame[TileID.LivingFire]; public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { @@ -84,11 +27,5 @@ namespace CalamityMod.Tiles.LivingFire g = 1f; b = 0f; } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.ProfanedFire, 0f, 0f, 1, default, 1f); - return false; - } } } diff --git a/Tiles/LivingFire/LivingPlagueFireBlockTile.cs b/Tiles/LivingFire/LivingPlagueFireBlockTile.cs index 10f9f299e6..a99e7b7b64 100644 --- a/Tiles/LivingFire/LivingPlagueFireBlockTile.cs +++ b/Tiles/LivingFire/LivingPlagueFireBlockTile.cs @@ -1,82 +1,25 @@ -using System.Collections.Generic; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ObjectData; + namespace CalamityMod.Tiles.LivingFire { public class LivingPlagueFireBlockTile : ModTile { - //Thank you to Seraph for getting living fire blocks to work properly. public override void SetStaticDefaults() { Main.tileLighted[Type] = true; - HitSound = SoundID.Dig; + TileID.Sets.CanPlaceNextToNonSolidTile[Type] = true; + DustType = (int)CalamityDusts.Plague; AddMapEntry(new Color(0, 171, 31)); AnimationFrameHeight = 90; - Main.tileSolid[Type] = false; - Main.tileNoAttach[Type] = false; - Main.tileFrameImportant[Type] = false; - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(CanPlaceAlter, -1, 0, true); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - - TileObjectData.addTile(Type); } - public int CanPlaceAlter(int i, int j, int type, int style, int direction, int alternate) => 1; + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) => offsetY = 2; - public static int AfterPlacement(int i, int j, int type, int style, int direction, int alternate) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileSquare(Main.myPlayer, i, j, 1, 1); - } - return 1; - } - - public override bool CanPlace(int i, int j) - { - List> around = new List> - { - new List() {i, j-1 }, - new List() {i-1, j }, - new List() {i+1, j }, - new List() {i, j+1 } - }; - //if (Main.tile[i, j]) || tile.type == Type - - //return true; //temporary for testing purposes - - if (Main.tile[i, j].WallType != WallID.None) - { - return true; - } - - for (int k = 0; k < around.Count; ++k) - { - Tile tile = Main.tile[around[k][0], around[k][1]]; - if (tile.HasTile && (Main.tileSolid[tile.TileType] || CalamityLists.livingFireBlockList.Contains(tile.TileType))) - { - return true; - } - } - return false; - } - - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frame = Main.tileFrame[TileID.LivingFire]; - } + public override void AnimateTile(ref int frame, ref int frameCounter) => frame = Main.tileFrame[TileID.LivingFire]; public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { @@ -84,11 +27,5 @@ namespace CalamityMod.Tiles.LivingFire g = 1f; b = 0.2f; } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.Plague, 0f, 0f, 1, default, 1f); - return false; - } } }