Bugfix/Cleanup/Polish Pass#1071
Conversation
There was a problem hiding this comment.
Rewrote this as there were a lot of edge cases with the effect, its removal, cooldown, etc, that were not properly handled
There was a problem hiding this comment.
There were a lot of oddities with how Rune & the related interfaces worked, as well as just undocumented behavior for the implementing class, I rewrote it to be a lot more straightforward, cleaner, etc
There was a problem hiding this comment.
This is the new version of the old RuneApplicable interface
There was a problem hiding this comment.
I rewrote and abstracted this into VeinminerTool so that we can do other tools which utilize the same logic while fixing a few bugs with the original implementation
| ItemStack input = fuelInputHatch.inventory.getItem(0); | ||
| if (input != null && !RebarItem.isRebarItem(input)) { | ||
| ItemStack input = fuelInputHatch.inventory.getUnsafeItem(0); | ||
| if (input != null && !RebarItem.isRebarItemAndIsNot(input, VanillaFurnaceFuel.class)) { |
There was a problem hiding this comment.
fixed this not respecting VanillaFurnaceFuel
| public void tryConsumeFuel() { | ||
| ItemInputHatch inputHatch = getMultiblockComponentOrThrow(ItemInputHatch.class, ITEM_INPUT); | ||
| ItemStack stack = inputHatch.inventory.getItem(0); | ||
| if (stack == null || RebarItem.isRebarItem(stack) || stack.isEmpty()) { | ||
| ItemStack stack = inputHatch.inventory.getUnsafeItem(0); | ||
| if (stack == null || RebarItem.isRebarItemAndIsNot(stack, VanillaFurnaceFuel.class)) { | ||
| return; | ||
| } | ||
|
|
||
| ItemType itemType = stack.getType().asItemType(); | ||
| if (itemType == null) { | ||
| if (itemType == null || !itemType.isFuel()) { | ||
| return; | ||
| } | ||
|
|
||
| inputHatch.inventory.setItem(new MachineUpdateReason(), 0, stack.subtract()); | ||
| RebarUtils.unsafeSubtract(inputHatch.inventory, 0, 1); | ||
| startProcess(itemType.getBurnDuration() / 10); | ||
| } |
There was a problem hiding this comment.
Fixed this consuming any item regardless of if it was fuel or not
| ItemType type = fuel.getType().asItemType(); | ||
| if (type == null || !type.isFuel()|| RebarItem.isRebarItemAndIsNot(fuel, VanillaFurnaceFuel.class)) { | ||
| return; | ||
| } | ||
|
|
||
| RebarUtils.unsafeSubtract(fuelInventory, 0, 1); |
There was a problem hiding this comment.
Fixed this not respecting if the item was actually fuel
| gypsum.remove(); | ||
| BlockStorage.placeBlock(against, PylonKeys.BLOOMERY); | ||
| fire.setType(Material.AIR); | ||
| if (BlockStorage.placeBlock(against, PylonKeys.BLOOMERY) != null) { | ||
| Item gypsumDust = (Item) gypsumDusts.iterator().next(); | ||
| ItemStack gypsumStack = gypsumDust.getItemStack(); | ||
| gypsumStack.subtract(); | ||
| gypsumDust.setItemStack(gypsumStack); | ||
| fire.setType(Material.AIR); | ||
| } |
There was a problem hiding this comment.
fixed this not respecting it the bloomery placement fails
| ItemType type = fuel.getType().asItemType(); | ||
| if (type == null || !type.isFuel() || RebarItem.isRebarItemAndIsNot(fuel, VanillaFurnaceFuel.class)) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Fixed it not respecting if it was a fuel item or not
| @@ -57,24 +57,31 @@ public void removeEffect(@NotNull Player player) { | |||
| public static class FarmingTalismanListener implements Listener { | |||
| @EventHandler | |||
| public void onBlockBreak(BlockDropItemEvent event) { | |||
There was a problem hiding this comment.
Fixed a bug where the trigger sound would play more than once
| /** | ||
| * This method is called when an item is inserted into the pedestal. It can be used to check if the item is | ||
| * allowed to be inserted. | ||
| * | ||
| * @return true if the item can be inserted into the pedestal, false otherwise | ||
| * @return true if the item can be placed on the pedestal, false otherwise | ||
| */ | ||
| public boolean isIllegalItem(Player player, ItemStack stack) { | ||
| return false; | ||
| public boolean canPlaceItem(Player player, ItemStack stack) { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Fixed an issue where the javadoc was telling the opposite of what the method actually was
There was a problem hiding this comment.
Fixed a few bugs where the fireproof rune only considered an item to be fireproof if it was only fireproof (i.e. not immune to other different damage types) and where when making an item fireproof it would clear the existing damage immunities if they were there
| if (curStack.getItemMeta().getPersistentDataContainer().has(SOULBOUND_KEY)) { | ||
| event.getItemsToKeep().add(curStack); | ||
| curItem.remove(); | ||
| @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) |
There was a problem hiding this comment.
Fixed a bug where this might operate when the player death event was cancelled
| .set(DataComponentTypes.FIREWORK_EXPLOSION, FireworkEffect.builder() | ||
| .withColor(Color.PURPLE) | ||
| .build()) | ||
| .editPdc(pdc -> pdc.set(SoulboundRune.SOULBOUND_KEY, RebarSerializers.BOOLEAN, true)) |
There was a problem hiding this comment.
Fixed a bug where the soulbound rune wasnt soulbound
| for (ItemStack drop : event.getDrops()) { | ||
| drainBlock.getWorld().dropItemNaturally(drainBlock.getLocation().toCenterLocation(), drop); | ||
| } |
There was a problem hiding this comment.
fixed a bug where this wouldn't respect any drops added by listeners of the event
| FluidLevelChangeEvent event = new FluidLevelChangeEvent(placeBlock, material.createBlockData()); | ||
| if (event.callEvent()) { | ||
| placeBlock.setBlockData(event.getNewData()); |
There was a problem hiding this comment.
Fixed a bug where this wouldn't respect any modifications by listeners of the event
| } | ||
|
|
||
| private boolean cannotVeinMine(Player player, Set<BlockPosition> vein) { | ||
| return vein.size() >= getMaxVeinSize() || getStack().isEmpty() || RebarUtils.hasOneDurabilityLeft(getStack()) || !getStack().equals(player.getInventory().getItemInMainHand()); |
There was a problem hiding this comment.
It seems !getStack().equals(player.getInventory().getItemInMainHand()) always returns true
and RebarUtils.hasOneDurabilityLeft(getStack()) may not work for the tool may be enchanted with Unbreaking or in case that other plugins modify it.
QQ20260708-142726.mp4
There was a problem hiding this comment.
the equals is not guaranteed to be true precisely because other plugins may interfere, I can remove the one durability clause and delay the breakage by a tick if you want instead, I just preferred it to all happen at the same time
There was a problem hiding this comment.
just remove the one durability clause, getStack().isEmpty() will stop the veinmining action.
There was a problem hiding this comment.
Can't do that because that causes the "one durability breaks 2 blocks bug"
There was a problem hiding this comment.
It is because the origin event also breaks a block.
Just cancel the event pass into onBreakBlock, and we can take control of the whole break action. (also needs to make some changes at OFFSETS, put the nearest direction in the front)
There was a problem hiding this comment.
I mean just search the blocks like how water spread.
There was a problem hiding this comment.
I fail to see why or how I would do that. Also water spreads in a very weird and context specific way that does not really apply here
There was a problem hiding this comment.
water spreads in a very weird and context specific way
What context you mean?
I fail to see why or how I would do that
There was a problem hiding this comment.
That still does effectively the same recursion, is less flexible, and also just isn't how water spreads
There was a problem hiding this comment.
I don't think it causes recursion and it's less flexible., can you give some examples..?
| public abstract boolean canVeinmine(Block root); | ||
| public boolean isInVein(Block root, Block block) { | ||
| return root.getType() == block.getType(); | ||
| } |
There was a problem hiding this comment.
Needs some docs on these two methods, I was confused before I realized the difference of canVeinmine and isInVein
There was a problem hiding this comment.
I mean I can add them but the method name & signature are entirely different & imply completely different things so I don't really know how you'd get confused
There was a problem hiding this comment.
canVeinmine means for me: if the block can be veinmined.
I don't know what is root block means at first:
- it only means the first block I break
- or does the block near the first block is also considered as root block?
and when is it called:
- it only checks the first block I break
- or does this also used to check if the block can be veinmined when each time called
tryVeinMine?
I would prefer to rename canVeinmine to canStartVeinmine
| VEIN_MINING.remove(playerId); | ||
| } | ||
|
|
||
| public void tryVeinMine(Player player, Block root, Location rootLocation, Block block, Set<BlockPosition> vein) { |
There was a problem hiding this comment.
Breaks too many blocks
https://github.com/user-attachments/assets/dc6926e7-ecff-43ec-823e-037ef2bb6d93
There was a problem hiding this comment.
Hm that wasn't happening for me, are you sure you didn't change the setting for the vein limit or something?
There was a problem hiding this comment.
No because vein is a set and if it fails to add to it, it returns, also it it was already broken and air it wouldn't even reach player break block
| return; | ||
| } | ||
|
|
||
| BlockPosition position = new BlockPosition(block); |
There was a problem hiding this comment.
not sure if it needs a world border check
Co-authored-by: balugaq <129668183+balugaq@users.noreply.github.com>



requires: pylonmc/rebar#862
Went through a lot of pylon (though attempting to exclude a lot of what's being touched by electricity) and fixed various bugs, improved performance, and just cleaned up code
A few things were rewritten to address major bugs or issues