@@ -21,13 +21,19 @@ public class IllegalComponentTypes extends IllegalItemModule {
2121
2222 private final Set <DataComponentType > illegalComponentTypes ;
2323 private final Set <Material > whitelistedTypes ;
24- private final boolean useWhitelist , blacklistMode , checkStored ;
24+ private final boolean useWhitelist , blacklistMode , checkStored , resetToDefaults ;
2525
2626 public IllegalComponentTypes () {
2727 super ("illegals.components.ban-component-types" , false , AEFPermission .BYPASS_ILLEGAL_COMPONENT_TYPES ,
2828 "Bypass permission: " + AEFPermission .BYPASS_ILLEGAL_COMPONENT_TYPES .node () + "\n " +
2929 "Deletes items that have one or more illegal component types set." );
30- this .checkStored = config .getBoolean (configPath + ".check-stored-items" , false );
30+ this .resetToDefaults = config .getBoolean (configPath + ".reset-to-defaults" , true , """
31+ Will reset DataComponent values specified below to their default values for that
32+ specific ItemStack.""" );
33+ this .checkStored = config .getBoolean (configPath + ".check-stored-items" , false , """
34+ If set to true, will check inside shulkers and bundles as well.
35+ Note: If handling is set to ACTION_ON_USE or STRICT, will delete shulkers / bundles
36+ if they contain any illegal item.""" );
3137 this .illegalComponentTypes = config .getList (configPath + ".component-types" , List .of ("minecraft:max_stack_size" ),
3238 "The exact DataComponentType you want to filter." )
3339 .stream ()
@@ -86,8 +92,13 @@ public IllegalComponentTypes() {
8692 @ Override
8793 public void handleItem (ItemStack itemStack , ItemLegality legality ) {
8894 if (illegalHandling == IllegalHandling .PREVENT_USE_ONLY ) return ;
95+ if (legality == ItemLegality .LEGAL ) return ;
8996
90- if (legality != ItemLegality .LEGAL ) {
97+ if (resetToDefaults && legality == ItemLegality .ILLEGAL ) {
98+ for (DataComponentType componentType : illegalComponentTypes ) {
99+ itemStack .resetData (componentType );
100+ }
101+ } else {
91102 itemStack .setAmount (0 );
92103 }
93104 }
0 commit comments