From ea90f266373c94ffaf2bb553bcb3d2e7eca4ef6a Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Tue, 20 May 2025 08:09:18 +0700 Subject: [PATCH] fruit chipper --- Items/CalamityGlobalItemTweaks.cs | 2 +- Items/Tools/FellerofEvergreens.cs | 2 +- Tiles/Abyss/AcidWoodTree.cs | 12 +++++++++++- Tiles/Astral/AstralTree.cs | 12 +++++++++++- Tiles/AstralDesert/AstralPalmTree.cs | 15 +++++++++++++-- Tiles/AstralSnow/AstralSnowTree.cs | 12 +++++++++++- Tiles/CalamityGlobalTile.cs | 8 +++++--- 7 files changed, 53 insertions(+), 10 deletions(-) diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 89826e8e40..649f7bb974 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -333,7 +333,7 @@ namespace CalamityMod.Items #endregion #region CATEGORY 3: Tool Balancing - { ItemID.AcornAxe, Do(AxePower(125)) }, // Axe of Regrowth + { ItemID.AcornAxe, Do(AxePower(100)) }, // Axe of Regrowth { ItemID.AdamantiteChainsaw, Do(TrueMeleeNoSpeed, AxePower(90), UseTimeExact(4), TileBoostExact(+0), DamageExact(75)) }, { ItemID.AdamantiteDrill, Do(TrueMeleeNoSpeed, PickPower(180), UseTimeExact(4), TileBoostExact(+1), DamageExact(32)) }, { ItemID.AdamantitePickaxe, Do(PickPower(180), UseTimeExact(8), TileBoostExact(+1)) }, diff --git a/Items/Tools/FellerofEvergreens.cs b/Items/Tools/FellerofEvergreens.cs index 4d95f705b3..ed226d2ac1 100644 --- a/Items/Tools/FellerofEvergreens.cs +++ b/Items/Tools/FellerofEvergreens.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Tools { CreateRecipe(). AddRecipeGroup("AnySilverBar", 18). - AddRecipeGroup("Wood", 18). + AddIngredient(ItemID.RichMahogany, 18). AddTile(TileID.Anvils). Register(); } diff --git a/Tiles/Abyss/AcidWoodTree.cs b/Tiles/Abyss/AcidWoodTree.cs index 59f1194b03..0e790dcafb 100644 --- a/Tiles/Abyss/AcidWoodTree.cs +++ b/Tiles/Abyss/AcidWoodTree.cs @@ -3,6 +3,7 @@ using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.AcidRain; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -54,6 +55,15 @@ namespace CalamityMod.Tiles.Abyss // Returning false at the end prevents vanilla behavior as the default is palm tree behavior which can include undesirable stuff like seagulls public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) @@ -115,7 +125,7 @@ namespace CalamityMod.Tiles.Abyss if (type != -1) Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.NextBool(3)) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/Astral/AstralTree.cs b/Tiles/Astral/AstralTree.cs index 4361cf3493..d7440d736b 100644 --- a/Tiles/Astral/AstralTree.cs +++ b/Tiles/Astral/AstralTree.cs @@ -3,6 +3,7 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -73,6 +74,15 @@ namespace CalamityMod.Tiles.Astral // Returning false at the end prevents vanilla behavior as the default is forest tree behavior which can include undesirable stuff like squirrels and butterflies public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) { @@ -137,7 +147,7 @@ namespace CalamityMod.Tiles.Astral type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.NextBool(3)) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/AstralDesert/AstralPalmTree.cs b/Tiles/AstralDesert/AstralPalmTree.cs index 6c0d7fc4fe..3fb709e4d8 100644 --- a/Tiles/AstralDesert/AstralPalmTree.cs +++ b/Tiles/AstralDesert/AstralPalmTree.cs @@ -3,6 +3,7 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -71,6 +72,16 @@ namespace CalamityMod.Tiles.AstralDesert // Returning false at the end prevents vanilla behavior as the default is palm tree behavior which can include undesirable stuff like seagulls public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? (WorldGen.genRand.NextBool() ? ItemID.Coconut : ItemID.Banana) + : (WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType()); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) @@ -123,12 +134,12 @@ namespace CalamityMod.Tiles.AstralDesert type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.Next(36) < 5) // Vanilla palm fruit logic goes first + else if (Main.rand.NextBool(12)) // Vanilla palm fruit logic goes first { int fruitType = Main.rand.NextBool() ? ItemID.Coconut : ItemID.Banana; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); } - else if (Main.rand.Next(36) < 5) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/AstralSnow/AstralSnowTree.cs b/Tiles/AstralSnow/AstralSnowTree.cs index aaa2519155..e8becab1b5 100644 --- a/Tiles/AstralSnow/AstralSnowTree.cs +++ b/Tiles/AstralSnow/AstralSnowTree.cs @@ -3,6 +3,7 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -74,6 +75,15 @@ namespace CalamityMod.Tiles.AstralSnow // Returning false at the end prevents vanilla behavior as the default is forest tree behavior which can include undesirable stuff like squirrels and butterflies public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) @@ -137,7 +147,7 @@ namespace CalamityMod.Tiles.AstralSnow type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.NextBool(3)) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 653abbc334..cee684049a 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Enums; using CalamityMod.Items.Accessories.Vanity; +using CalamityMod.Items.Tools; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Tiles.Abyss; @@ -24,7 +25,6 @@ namespace CalamityMod.Tiles { public class CalamityGlobalTile : GlobalTile { - public static List GrowthTiles = new List() { TileType(), @@ -48,8 +48,10 @@ namespace CalamityMod.Tiles public override void PreShakeTree(int x, int y, TreeTypes treeType) { - // Add an additional 25% chance to drop vanilla fruits - if (WorldGen.genRand.NextBool(4)) + // All trees have a 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ItemType() && WorldGen.genRand.NextBool(3)) { int treeDropItemType = 0; switch (treeType)