mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-30 05:05:19 -05:00
@@ -21,11 +21,10 @@ package dev.architectury.event.events.common;
|
||||
|
||||
import dev.architectury.event.Event;
|
||||
import dev.architectury.event.EventFactory;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.storage.loot.LootDataManager;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.storage.loot.LootPool;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Events related to loot tables and loot generation.
|
||||
@@ -57,23 +56,21 @@ public interface LootEvent {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @see ModifyLootTable#modifyLootTable(LootDataManager, ResourceLocation, LootTableModificationContext, boolean)
|
||||
* @see ModifyLootTable#modifyLootTable(ResourceKey, LootTableModificationContext, boolean)
|
||||
*/
|
||||
Event<ModifyLootTable> MODIFY_LOOT_TABLE = EventFactory.createLoop();
|
||||
// Event<ModifyLootTable> MODIFY_LOOT_TABLE = EventFactory.createLoop();
|
||||
|
||||
@FunctionalInterface
|
||||
interface ModifyLootTable {
|
||||
/**
|
||||
* Modifies a loot table.
|
||||
*
|
||||
* @param lootDataManager the {@link LootDataManager} instance containing all loot tables,
|
||||
* may be {@code null}
|
||||
* @param id the loot table ID
|
||||
* @param context the context used to modify the loot table
|
||||
* @param builtin if {@code true}, the loot table is built-in;
|
||||
* if {@code false}, it is from a user data pack
|
||||
* @param key the loot table key
|
||||
* @param context the context used to modify the loot table
|
||||
* @param builtin if {@code true}, the loot table is built-in;
|
||||
* if {@code false}, it is from a user data pack
|
||||
*/
|
||||
void modifyLootTable(@Nullable LootDataManager lootDataManager, ResourceLocation id, LootTableModificationContext context, boolean builtin);
|
||||
void modifyLootTable(ResourceKey<LootTable> key, LootTableModificationContext context, boolean builtin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,15 +83,6 @@ public interface LootEvent {
|
||||
*
|
||||
* @param pool the pool to add
|
||||
*/
|
||||
void addPool(LootPool pool);
|
||||
|
||||
/**
|
||||
* Adds a pool to the loot table.
|
||||
*
|
||||
* @param pool the pool to add
|
||||
*/
|
||||
default void addPool(LootPool.Builder pool) {
|
||||
addPool(pool.build());
|
||||
}
|
||||
void addPool(LootPool.Builder pool);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties
|
||||
mutable field net/minecraft/world/level/block/state/BlockBehaviour$Properties speedFactor F
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties jumpFactor F
|
||||
mutable field net/minecraft/world/level/block/state/BlockBehaviour$Properties jumpFactor F
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties drops Lnet/minecraft/resources/ResourceLocation;
|
||||
mutable field net/minecraft/world/level/block/state/BlockBehaviour$Properties drops Lnet/minecraft/resources/ResourceLocation;
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties canOcclude Z
|
||||
mutable field net/minecraft/world/level/block/state/BlockBehaviour$Properties canOcclude Z
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties isAir Z
|
||||
|
||||
@@ -38,12 +38,10 @@ import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseItemCallback;
|
||||
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
|
||||
// import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
|
||||
import net.fabricmc.fabric.api.message.v1.ServerMessageDecoratorEvent;
|
||||
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class EventHandlerImpl {
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static void registerClient() {
|
||||
@@ -85,7 +83,7 @@ public class EventHandlerImpl {
|
||||
AttackBlockCallback.EVENT.register((player, world, hand, pos, face) -> InteractionEvent.LEFT_CLICK_BLOCK.invoker().click(player, hand, pos, face).asMinecraft());
|
||||
AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> PlayerEvent.ATTACK_ENTITY.invoker().attack(player, world, entity, hand, hitResult).asMinecraft());
|
||||
|
||||
LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> LootEvent.MODIFY_LOOT_TABLE.invoker().modifyLootTable(lootManager, id, new LootTableModificationContextImpl(tableBuilder), source.isBuiltin()));
|
||||
// LootTableEvents.MODIFY.register((key, tableBuilder, source) -> LootEvent.MODIFY_LOOT_TABLE.invoker().modifyLootTable(lootManager, id, new LootTableModificationContextImpl(tableBuilder), source.isBuiltin()));
|
||||
|
||||
ServerMessageDecoratorEvent.EVENT.register(ServerMessageDecoratorEvent.CONTENT_PHASE, (player, component) -> {
|
||||
ChatEvent.ChatComponent chatComponent = new ChatComponentImpl(component);
|
||||
|
||||
@@ -30,11 +30,6 @@ final class LootTableModificationContextImpl implements LootEvent.LootTableModif
|
||||
this.tableBuilder = tableBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPool(LootPool pool) {
|
||||
tableBuilder.pool(pool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPool(LootPool.Builder pool) {
|
||||
tableBuilder.withPool(pool);
|
||||
|
||||
@@ -3,8 +3,8 @@ org.gradle.daemon=false
|
||||
|
||||
platforms=fabric
|
||||
|
||||
minecraft_version=24w09a
|
||||
supported_version=1.20.5 (24w09a)
|
||||
minecraft_version=24w12a
|
||||
supported_version=1.20.5 (24w12a)
|
||||
|
||||
artifact_type=beta
|
||||
|
||||
@@ -14,7 +14,7 @@ base_version=12.0
|
||||
maven_group=dev.architectury
|
||||
|
||||
fabric_loader_version=0.15.7
|
||||
fabric_api_version=0.96.6+1.20.5
|
||||
fabric_api_version=0.96.12+1.20.5
|
||||
mod_menu_version=9.0.0
|
||||
|
||||
forge_version=49.0.14
|
||||
|
||||
@@ -27,13 +27,13 @@ import net.minecraft.world.level.storage.loot.entries.LootItem;
|
||||
|
||||
public class TestLoot {
|
||||
public static void init() {
|
||||
LootEvent.MODIFY_LOOT_TABLE.register((lootTables, id, context, builtin) -> {
|
||||
/*LootEvent.MODIFY_LOOT_TABLE.register((lootTables, id, context, builtin) -> {
|
||||
// Check that the loot table is dirt and built-in
|
||||
if (builtin && Blocks.DIRT.getLootTable().equals(id)) {
|
||||
// Create a loot pool with a single item entry of Items.DIAMOND
|
||||
LootPool.Builder pool = LootPool.lootPool().add(LootItem.lootTableItem(Items.DIAMOND));
|
||||
context.addPool(pool);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class TestRegistries {
|
||||
public static final RegistrySupplier<Item> TEST_EQUIPPABLE = ITEMS.register("test_eqippable", () ->
|
||||
new EquippableTickingItem(new Item.Properties().arch$tab(TestRegistries.TEST_TAB)));
|
||||
public static final RegistrySupplier<Item> TEST_EDIBLE = ITEMS.register("test_edible", () -> {
|
||||
FoodProperties.Builder fpBuilder = new FoodProperties.Builder().nutrition(8).saturationMod(0.8F).meat();
|
||||
FoodProperties.Builder fpBuilder = new FoodProperties.Builder().nutrition(8).saturationModifier(0.8F);
|
||||
FoodPropertiesHooks.effect(fpBuilder, () -> new MobEffectInstance(TEST_EFFECT, 100), 1);
|
||||
return new Item(new Item.Properties().food(fpBuilder.build()).arch$tab(TestRegistries.TEST_TAB));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user