Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix illegal blastmining drops #5068

Closed
wants to merge 3 commits into from
Closed

Fix illegal blastmining drops #5068

wants to merge 3 commits into from

Conversation

RasmusKD
Copy link

Fixed so now spawners actually dont drop from blastmining, mining wont spawn illegal items anymore, before items like suspisous sand, infested_stone and similar illegal items were requiable with blastmining.

Removed double drops from non-mining related blocks Added stone types back into the drops w/o double drops

Added Javadoc

Fixed so now spawners actually dont drop from blastmining, mining wont spawn illegal items anymore, before items like suspisous sand, infested_stone and similar illegal items were requiable with blastmining.

Removed double drops from non-mining related blocks
Added stone types back into the drops w/o double drops
Added Javadoc
Added the new 1.21 potions to alchemy
Added all new potion effect types
Fix Herbalism replanting to remove renamed crops from player inventory
Previously, players could replant crops infinitely if the replant material was renamed, as it wasn't removed from the inventory.
Copy link
Member

@nossr50 nossr50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find your changes to MiningManager a bit hard to follow, please minimize the diff and I'll review again.

I would also prefer you to split these commits into their own PRs if possible.

// Remove from main inventory
for (ItemStack itemStack : player.getInventory().getContents()) {
if (itemStack != null && itemStack.getType() == material) {
int stackAmount = itemStack.getAmount();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be final

@@ -147,18 +149,29 @@ public static boolean hasItemIncludingOffHand(Player player, Material material)
* @param amount Amount of the material to remove
*/
public static void removeItemIncludingOffHand(@NotNull Player player, @NotNull Material material, int amount) {
// Checks main inventory / item bar
if (player.getInventory().contains(material)) {
player.getInventory().removeItem(new ItemStack(material, amount));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain why you had to replace lines 150-153? It does not seem obvious why the code you've replaced it with would do anything differently.

offHandItem.setAmount(newAmount);
// Remove from off-hand
ItemStack offHandItem = player.getInventory().getItemInOffHand();
if (offHandItem != null && offHandItem.getType() == material) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this to avoid a NPE or something else?

@@ -104,6 +104,8 @@ private static String getMCName(PotionType type) {
case WEAKNESS :
case TURTLE_MASTER:
case SLOW_FALLING:
case INFESTED:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be compatible with older versions, you'll have to change the switch case to operate on string value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: PotionConfigGenerator disgusts me 😆 , I appreciate that you went through the trouble to update it.


return getSkillLevel() >= BlastMining.getBiggerBombsUnlockLevel() && Permissions.biggerBombs(getPlayer());
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_BIGGER_BOMBS)
&& getSkillLevel() >= BlastMining.getBiggerBombsUnlockLevel()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skill level check is unnecessary

@@ -175,66 +210,56 @@ public void remoteDetonation() {
* @param event The {@link EntityExplodeEvent}
*/
public void blastMiningDropProcessing(float yield, EntityExplodeEvent event) {
if (yield == 0)
return;
if (yield == 0) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a fan of this change, would like it changed back


var increasedYieldFromBonuses = yield + (yield * getOreBonus());
// Strip out only stuff that gives mining XP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting comments is an unusual thing to do in a PR, try to keep your diff minimal

return canUseBlastMining() && player.isSneaking()
&& (isPickaxe(getPlayer().getInventory().getItemInMainHand()) || player.getInventory().getItemInMainHand().getType() == mcMMO.p.getGeneralConfig().getDetonatorItem())
&& (isPickaxe(player.getInventory().getItemInMainHand())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate trying to clean up the mess that is the existing code, but try to keep the diff minimal for review

for (Block targetBlock : event.blockList()) {
BlockState blockState = targetBlock.getState();

if(mcMMO.getUserBlockTracker().isIneligible(targetBlock))
continue;
if (mcMMO.getUserBlockTracker().isIneligible(targetBlock)) continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't put executions on the same line as ifs, not a fan.

@nossr50
Copy link
Member

nossr50 commented Aug 28, 2024

PR title seems a bit odd, if you are going to keep it as 3 commits and one PR (which I would prefer you did not), I would like the title of the PR changed to reflect the changes, please add a description of all changes in the PR as well.

@RasmusKD RasmusKD closed this Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants