Tree Feller non-wood drop rate reduced by 90%

This commit is contained in:
nossr50 2024-01-15 10:47:45 -08:00
parent dda5b45bb1
commit 377bf1be4d
4 changed files with 36 additions and 30 deletions

View File

@ -10,6 +10,7 @@ Version 2.2.000
TODO: Add unit test to determine crossbow or bow skill TODO: Add unit test to determine crossbow or bow skill
TODO: Add unit test for trident xp processing TODO: Add unit test for trident xp processing
TODO: Add missing entries to changelog TODO: Add missing entries to changelog
Tree Feller now drops 90% less non-wood blocks (leaves/etc) on average
Replaced 'Experience_Formula.Modifier' in experience.yml with 'Experience_Formula.Skill_Multiplier' which is easier to understand and less prone to divide by zero bugs Replaced 'Experience_Formula.Modifier' in experience.yml with 'Experience_Formula.Skill_Multiplier' which is easier to understand and less prone to divide by zero bugs
Treasure drop rate from Shake, Fishing, Hylian, and Excavation now benefit from the Luck perk Treasure drop rate from Shake, Fishing, Hylian, and Excavation now benefit from the Luck perk
Added 'Send_To_Console' settings to chat.yml to toggle sending party or admin chat messages to console Added 'Send_To_Console' settings to chat.yml to toggle sending party or admin chat messages to console

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.2.000-BETA-02-SNAPSHOT</version> <version>2.2.000-BETA-04-SNAPSHOT</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm> <scm>

View File

@ -34,6 +34,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
//TODO: Seems to not be using the item drop event for bonus drops, may want to change that.. or may not be able to be changed? //TODO: Seems to not be using the item drop event for bonus drops, may want to change that.. or may not be able to be changed?
public class WoodcuttingManager extends SkillManager { public class WoodcuttingManager extends SkillManager {
@ -323,10 +324,7 @@ public class WoodcuttingManager extends SkillManager {
processBonusDropCheck(blockState); processBonusDropCheck(blockState);
} else if (BlockUtils.isNonWoodPartOfTree(blockState)) { } else if (BlockUtils.isNonWoodPartOfTree(blockState)) {
//Drop displaced non-woodcutting XP blocks //Drop displaced non-woodcutting XP blocks
if(RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) { if(RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) {
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(itemStack), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
if(RankUtils.hasReachedRank(2, player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) { if(RankUtils.hasReachedRank(2, player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) {
if(mcMMO.p.getAdvancedConfig().isKnockOnWoodXPOrbEnabled()) { if(mcMMO.p.getAdvancedConfig().isKnockOnWoodXPOrbEnabled()) {
//TODO: Test the results of this RNG, should be 10% //TODO: Test the results of this RNG, should be 10%
@ -336,8 +334,10 @@ public class WoodcuttingManager extends SkillManager {
} }
} }
} }
}
} else { // 90% of the time do not drop leaf blocks
if (ThreadLocalRandom.current().nextInt(100) > 90) {
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(itemStack), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK, 1); Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(itemStack), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK, 1);
} }
} }

View File

@ -30,6 +30,7 @@ import java.util.UUID;
import java.util.logging.Logger; import java.util.logging.Logger;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
public abstract class MMOTestEnvironment { public abstract class MMOTestEnvironment {
protected MockedStatic<mcMMO> mockedMcMMO; protected MockedStatic<mcMMO> mockedMcMMO;
@ -62,23 +63,24 @@ public abstract class MMOTestEnvironment {
protected String playerName = "testPlayer"; protected String playerName = "testPlayer";
protected ChunkManager chunkManager; protected ChunkManager chunkManager;
protected MaterialMapStore materialMapStore;
protected void mockBaseEnvironment(Logger logger) throws InvalidSkillException { protected void mockBaseEnvironment(Logger logger) throws InvalidSkillException {
mockedMcMMO = Mockito.mockStatic(mcMMO.class); mockedMcMMO = Mockito.mockStatic(mcMMO.class);
mcMMO.p = Mockito.mock(mcMMO.class); mcMMO.p = Mockito.mock(mcMMO.class);
Mockito.when(mcMMO.p.getLogger()).thenReturn(logger); when(mcMMO.p.getLogger()).thenReturn(logger);
// place store // place store
chunkManager = Mockito.mock(ChunkManager.class); chunkManager = Mockito.mock(ChunkManager.class);
Mockito.when(mcMMO.getPlaceStore()).thenReturn(chunkManager); when(mcMMO.getPlaceStore()).thenReturn(chunkManager);
// shut off mod manager for woodcutting // shut off mod manager for woodcutting
Mockito.when(mcMMO.getModManager()).thenReturn(Mockito.mock(ModManager.class)); when(mcMMO.getModManager()).thenReturn(Mockito.mock(ModManager.class));
Mockito.when(mcMMO.getModManager().isCustomLog(any())).thenReturn(false); when(mcMMO.getModManager().isCustomLog(any())).thenReturn(false);
// chat config // chat config
mockedChatConfig = Mockito.mockStatic(ChatConfig.class); mockedChatConfig = Mockito.mockStatic(ChatConfig.class);
Mockito.when(ChatConfig.getInstance()).thenReturn(Mockito.mock(ChatConfig.class)); when(ChatConfig.getInstance()).thenReturn(Mockito.mock(ChatConfig.class));
// general config // general config
mockGeneralConfig(); mockGeneralConfig();
@ -94,10 +96,10 @@ public abstract class MMOTestEnvironment {
// wire skill tools // wire skill tools
this.skillTools = new SkillTools(mcMMO.p); this.skillTools = new SkillTools(mcMMO.p);
Mockito.when(mcMMO.p.getSkillTools()).thenReturn(skillTools); when(mcMMO.p.getSkillTools()).thenReturn(skillTools);
this.transientEntityTracker = new TransientEntityTracker(); this.transientEntityTracker = new TransientEntityTracker();
Mockito.when(mcMMO.getTransientEntityTracker()).thenReturn(transientEntityTracker); when(mcMMO.getTransientEntityTracker()).thenReturn(transientEntityTracker);
mockPermissions(); mockPermissions();
@ -105,26 +107,26 @@ public abstract class MMOTestEnvironment {
// wire server // wire server
this.server = Mockito.mock(Server.class); this.server = Mockito.mock(Server.class);
Mockito.when(mcMMO.p.getServer()).thenReturn(server); when(mcMMO.p.getServer()).thenReturn(server);
// wire plugin manager // wire plugin manager
this.pluginManager = Mockito.mock(PluginManager.class); this.pluginManager = Mockito.mock(PluginManager.class);
Mockito.when(server.getPluginManager()).thenReturn(pluginManager); when(server.getPluginManager()).thenReturn(pluginManager);
// wire world // wire world
this.world = Mockito.mock(World.class); this.world = Mockito.mock(World.class);
// wire Misc // wire Misc
this.mockedMisc = Mockito.mockStatic(Misc.class); this.mockedMisc = Mockito.mockStatic(Misc.class);
Mockito.when(Misc.getBlockCenter(any())).thenReturn(new Location(world, 0, 0, 0)); when(Misc.getBlockCenter(any())).thenReturn(new Location(world, 0, 0, 0));
// setup player and player related mocks after everything else // setup player and player related mocks after everything else
this.player = Mockito.mock(Player.class); this.player = Mockito.mock(Player.class);
Mockito.when(player.getUniqueId()).thenReturn(playerUUID); when(player.getUniqueId()).thenReturn(playerUUID);
// wire inventory // wire inventory
this.playerInventory = Mockito.mock(PlayerInventory.class); this.playerInventory = Mockito.mock(PlayerInventory.class);
Mockito.when(player.getInventory()).thenReturn(playerInventory); when(player.getInventory()).thenReturn(playerInventory);
// PlayerProfile and McMMOPlayer are partially mocked // PlayerProfile and McMMOPlayer are partially mocked
playerProfile = new PlayerProfile("testPlayer", player.getUniqueId(), 0); playerProfile = new PlayerProfile("testPlayer", player.getUniqueId(), 0);
@ -132,16 +134,19 @@ public abstract class MMOTestEnvironment {
// wire user manager // wire user manager
this.mockedUserManager = Mockito.mockStatic(UserManager.class); this.mockedUserManager = Mockito.mockStatic(UserManager.class);
Mockito.when(UserManager.getPlayer(player)).thenReturn(mmoPlayer); when(UserManager.getPlayer(player)).thenReturn(mmoPlayer);
this.materialMapStore = new MaterialMapStore();
when(mcMMO.getMaterialMapStore()).thenReturn(materialMapStore);
} }
private void mockPermissions() { private void mockPermissions() {
mockedPermissions = Mockito.mockStatic(Permissions.class); mockedPermissions = Mockito.mockStatic(Permissions.class);
Mockito.when(Permissions.isSubSkillEnabled(any(Player.class), any(SubSkillType.class))).thenReturn(true); when(Permissions.isSubSkillEnabled(any(Player.class), any(SubSkillType.class))).thenReturn(true);
Mockito.when(Permissions.canUseSubSkill(any(Player.class), any(SubSkillType.class))).thenReturn(true); when(Permissions.canUseSubSkill(any(Player.class), any(SubSkillType.class))).thenReturn(true);
Mockito.when(Permissions.isSubSkillEnabled(any(Player.class), any(SubSkillType.class))).thenReturn(true); when(Permissions.isSubSkillEnabled(any(Player.class), any(SubSkillType.class))).thenReturn(true);
Mockito.when(Permissions.canUseSubSkill(any(Player.class), any(SubSkillType.class))).thenReturn(true); when(Permissions.canUseSubSkill(any(Player.class), any(SubSkillType.class))).thenReturn(true);
Mockito.when(Permissions.lucky(player, PrimarySkillType.WOODCUTTING)).thenReturn(false); // player is not lucky when(Permissions.lucky(player, PrimarySkillType.WOODCUTTING)).thenReturn(false); // player is not lucky
} }
private void mockRankConfig() { private void mockRankConfig() {
@ -150,24 +155,24 @@ public abstract class MMOTestEnvironment {
private void mockAdvancedConfig() { private void mockAdvancedConfig() {
this.advancedConfig = Mockito.mock(AdvancedConfig.class); this.advancedConfig = Mockito.mock(AdvancedConfig.class);
Mockito.when(mcMMO.p.getAdvancedConfig()).thenReturn(advancedConfig); when(mcMMO.p.getAdvancedConfig()).thenReturn(advancedConfig);
} }
private void mockGeneralConfig() { private void mockGeneralConfig() {
generalConfig = Mockito.mock(GeneralConfig.class); generalConfig = Mockito.mock(GeneralConfig.class);
Mockito.when(generalConfig.getTreeFellerThreshold()).thenReturn(100); when(generalConfig.getTreeFellerThreshold()).thenReturn(100);
Mockito.when(generalConfig.getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, Material.OAK_LOG)).thenReturn(true); when(generalConfig.getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, Material.OAK_LOG)).thenReturn(true);
Mockito.when(generalConfig.getLocale()).thenReturn("en_US"); when(generalConfig.getLocale()).thenReturn("en_US");
Mockito.when(mcMMO.p.getGeneralConfig()).thenReturn(generalConfig); when(mcMMO.p.getGeneralConfig()).thenReturn(generalConfig);
} }
private void mockExperienceConfig() { private void mockExperienceConfig() {
experienceConfig = Mockito.mockStatic(ExperienceConfig.class); experienceConfig = Mockito.mockStatic(ExperienceConfig.class);
Mockito.when(ExperienceConfig.getInstance()).thenReturn(Mockito.mock(ExperienceConfig.class)); when(ExperienceConfig.getInstance()).thenReturn(Mockito.mock(ExperienceConfig.class));
// Combat // Combat
Mockito.when(ExperienceConfig.getInstance().getCombatXP("Cow")).thenReturn(1D); when(ExperienceConfig.getInstance().getCombatXP("Cow")).thenReturn(1D);
} }
protected void cleanupBaseEnvironment() { protected void cleanupBaseEnvironment() {