PluginBugs / Issues-ItemsAdder

Repository used to keep track of issues of my plugin ItemsAdder
https://itemsadder.devs.beer
49 stars 21 forks source link

Type of custom blocks cannot be changed via setType #2116

Closed Th3Shadowbroker closed 1 year ago

Th3Shadowbroker commented 1 year ago

Terms

Discord tag (optional)

No response

What happened?

A user of OuroborosMines reported an Issue with custom blocks being unbreakable. I did a few hours of debugging but it seems that the behaviour of IA has changed in regard to handling block-breaking. As OM does some internal handling of the BlockBreakEvent the original event is cancelled and the blocks type is set to a specific material. This worked totally fine in the past, however that does not seem to be the case anymore. Changes to the type of custom blocks are getting completely ignored. Is there any IA specific way to do these things via the API?

Steps to reproduce the issue

Here's a replication plugin that breaks down the problem, so you don't have to dig trough any OM code. A pre-compiled version can be found here.

  1. Write a plugin that cancels a BlockBreakEvent and 1.1 set the blocks type to Material.AIR 1.2 cancel the BlockBreakEvent

You'll notice that custom blocks cannot be broken, while vanilla blocks can.

Server version

git-Paper-388 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT)

ItemsAdder Version

I tried:

ProtocolLib Version

4.8.0

LoneLibs Version

1.0.21

LightAPI Version (optional)

No response

LibsDisguises Version (optional)

No response

FULL server log

latest.log

Error (optional)

No response

ItemsAdder config.yml

metrics: true
update-checker: true
disable-plugin-loading-messages_DONT_ASK_ME_FOR_SUPPORT_IF_YOU_SET_TRUE__THANKS: false
ignore-server-compatibility-check: false
resource-pack:
  hosting:
    no-host:
      enabled: false
    auto-external-host:
      enabled: false
    self-host:
      enabled: true
      server-ip: 127.0.0.1
      pack-port: 8163
    external-host:
      enabled: false
      url: ''
      skip-url-file-type-check___DONT_ASK_HELP_IF_SET_TRUE: false
  apply-on-join: true
  kick-player-on-decline: false
  kick-player-on-fail: false
  delay-ticks: 1
  notify-other-plugins-interfering: true
  title:
    enabled: true
  protect-player:
    black-screen: true
    hide-hud: true
    cancel-movement: true
    lock-player: true
  command:
    usage-cooldown-seconds: 60
  custom-font:
    enabled: false
    name: ipaexg.ttf
    shift: '[0,0]'
    size: 11.0
    oversample: 2.0
  thin-font:
    enabled: false
  zip:
    protect-file-from-unzip:
      protection_1: true
      protection_2: true
    compress-png-files: true
    compress-json-files: true
    generate-custom-armors-textures:
      vanilla_1_17: true
      optifine: true
    disable-overwrite-leather-armor-layers-textures: false
    ignore-files-ext:
    - db
    - yml
    - xcf
    - psd
    - html
    - gz
    - rar
    - zip
    - 7z
    - bbmodel
    - iaentitymodel
    fix_transparent_noteblocks: false
    contents-folders-priority:
    - vanilla
    - _iainternal
    overwrite-vanilla-models: false
    overwrite-vanilla-lang-json: false
    fix_transparent_noteblocks__disable-for-more-performance: false
  items:
    CustomModelData-starting-value:
      ALL: 10000
      DIAMOND: 11000
config_files:
  lang: en
  dictionaries-lang: en
  force-sync-loading: false
  extract-default-configs: true
  legacy_pack: false
blocks:
  light-api: true
  fix-liquids-flow: true
  fix-floating-blocks: true
  fix-glitched-blocks:
    enabled: true
    only-new-chunks: false
  cancel-break-wrong-tool:
    enabled: true
    send-actionbar: true
  campfire:
    unlit-on-place: true
    allow-any-item: true
  disable-REAL: false
  disable-REAL_NOTE: false
  disable-REAL_TRANSPARENT: false
  disable-REAL_WIRE: true
  disable-FIRE: false
  convert-vanilla-blocks:
    enabled: false
    only-new-chunks: true
items:
  fix-show-attack-and-damage-as-lore: true
  give_death_location_maps: true
  hide-custom-durability-lore: false
liquids:
  enabled: true
huds:
  enabled: true
loots:
  allow-loots-drop-from-spawners-using-silk-touch: false
mobs:
  disable-MOB-behaviour__DISABLE_AT_YOUR_OWN_RISK: false
chat-preview: false
font_images:
  replace-in-customitems-name-and-lore: true
  chat:
    enabled: true
    doublecheck-permission__disable-for-more-performance: false
    add-hover-suggestion: true
  command:
    enabled: true
    commandblocks: true
    excluded:
    - home
    - sethome
    - tpa
  sign:
    enabled: true
  book:
    enabled: true
  anvil:
    enabled: true
  inventory-title:
    enabled: true
  vault-prefix-suffix:
    enabled: true
    update-every-ticks: 1200
  scoreboard-teams:
    enabled: false
    update-every-ticks: 3600
  player-display-name:
    enabled: true
    update-every-ticks: 1200
effects:
  hide-scoreboard-numbers: false
  text-effects:
    enabled: true
    replace-in-customitems-name-and-lore: true
    chat:
      enabled: true
    sign:
      enabled: true
    book:
      enabled: true
    anvil:
      enabled: true
entities:
  max-furniture-vehicles-per-chunk: 30
  allow-removing-old-furnitures_2_3_11: false
  custom-entitites:
    enabled: true
    emotes: true
    interval-rendering-packets-ticks: 1
    optimized-packets: true
recipes:
  hide-vanilla-unrecognized-recipe-errors: true
  fix-packet-too-large-kick: false
  custom-recipes:
    unlock:
      all-on-join: false
      on-pickup:
        any: false
        ingredients: true
  remove-vanilla-recipes:
    enabled: true
    list:
      DIAMOND_SWORD: false
      IRON_INGOT: false
debug:
  items:
    log-files-loading: false
    log-items-loading: false
    log-items-loading-disabled: false
    log-font-images-loading: false
    log-huds-loading: false
    log-attribute-modifiers-loading: false
    log-warnings: false
    log-loots-loading: false
    log-loots-loading-disabled: false
    log-armors-loading: false
  recipes:
    log-recipes-loading: false
    log-recipes-loading-disabled: false
    log-recipes-removed-vanilla: false
    log-recipes-unknown-item: false
    log-fix-packet-too-large: false
  resource-pack:
    log-extract-default-resources: false
    log-not-extract-default-resources-already-exist: false
  blocks:
    log-save: false
    log-save-on-unload: false
    log-mined-unknown-blocks: true
    log-convert-vanilla-blocks: false
  worlds-populators:
    log-loading: false
    log-loading-disabled: false
    log-loading-no-populators: false
    log-loading-no-world: true
    log-generation: false
  trees-populators:
    log-loading: false
    log-loading-disabled: false
    log-loading-no-populators: false
    log-loading-no-world: true
    log-generation: false
  surface-decorators:
    log-loading: false
    log-loading-disabled: false
    log-loading-no-decorators: false
    log-loading-no-world: true
    log-generation: false
  cave-decorators:
    log-loading: false
    log-loading-disabled: false
    log-loading-no-decorators: false
    log-loading-no-world: true
    log-generation: false
  player-stats:
    log-save: false
  performance:
    loading-ms: true
  huds:
    log-triggers: false
  other:
    log-dictionaries-loading: false
    log-liquids-loading: false
    log-minecraft_lang_overwrite-loading: false
  categories:
    log-total-loaded: true
    log-single-loaded: false
    log-single-loaded-overwrite: false
    log-single-skip: false
    log-icon-failed-load: false
  entities:
    log-files-loading: false
    log-entities-loading: false
    log-entities-loading-disabled: false

Problematic items yml configuration file (optional)

info:
  namespace: iasurvival
items:
  aqua_aura_ore:
    enabled: true
    display_name: display-name-aqua_aura_ore
    permission: iasurvival.items.aqua_aura_ore
    resource:
      material: PAPER
      generate: true
      textures:
        - block/ores/aqua_aura_ore
    specific_properties:
      block:
        hardness: 1.8
        placed_model:
          type: REAL_NOTE
          break_particles_material: DIAMOND_ORE
        cancel_drop: true

Other files, you can drag and drop them here to upload. (optional)

No response

Screenshots/Videos (you can drag and drop files or paste links)

Here's the video I received from the user who reported the problem (I were able to replicate the problem and can confirm that non-custom blocks are not affected):

https://user-images.githubusercontent.com/8280615/203302693-72ba4bed-6085-4a38-baf6-9dddad48e621.mp4

LoneDev6 commented 1 year ago

Remove the custom block then change type using bukkit api https://github.com/LoneDev6/API-ItemsAdder/blob/3ac6df9fdbab1638afba2e5080372852852d3dad/src/main/java/dev/lone/itemsadder/api/CustomBlock.java#L196

Th3Shadowbroker commented 1 year ago

Thank you for the blazingly fast support ⚡

That did the trick 👍🏼 I had already combined the remove and setType call in a previous try but in the wrong order because I thought of remove as an actual removal, not a removal of the CustomBlock "claim".

LoneDev6 commented 1 year ago

Note: the .remove method is setting the block to AIR and removing it from the ItemsAdder registry completely.

Have a nice day!