-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
LootJS.modifiers(event => { | ||
event.addTableModifier(LootType.CHEST, /minecraft:entities.*/).customAction(() => { | ||
console.log("Triggerd LootJS.modifiers for Chests and all entities"); | ||
}) | ||
}); | ||
|
||
LootJS.lootTables(event => { | ||
console.log("All Chest and Entity loot tables: ") | ||
for (let lt of event.modifyLootTables(LootType.CHEST, /minecraft:entities.*/)) { | ||
console.log(" - " + lt.location) | ||
} | ||
}) |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/almostreliable/lootjs/core/filters/LootTableFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.almostreliable.lootjs.core.filters; | ||
|
||
import com.almostreliable.lootjs.core.LootType; | ||
import com.almostreliable.lootjs.loot.extension.LootContextExtension; | ||
import net.minecraft.world.level.storage.loot.LootContext; | ||
import net.minecraft.world.level.storage.loot.LootTable; | ||
|
||
public interface LootTableFilter { | ||
|
||
boolean test(LootTable table); | ||
|
||
boolean test(LootContext context); | ||
|
||
record ByIdFilter(IdFilter filter) implements LootTableFilter { | ||
|
||
@Override | ||
public boolean test(LootTable table) { | ||
return filter.test(table.getLootTableId()); | ||
} | ||
|
||
@Override | ||
public boolean test(LootContext context) { | ||
return filter.test(context.getQueriedLootTableId()); | ||
} | ||
} | ||
|
||
record ByLootType(LootType type) implements LootTableFilter { | ||
|
||
@Override | ||
public boolean test(LootTable lootTable) { | ||
return type == LootType.getLootType(lootTable.getParamSet()); | ||
} | ||
|
||
@Override | ||
public boolean test(LootContext context) { | ||
return LootContextExtension.cast(context).lootjs$isType(type); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters