Skip to content

Commit

Permalink
Update to 24w12a
Browse files Browse the repository at this point in the history
Signed-off-by: shedaniel <[email protected]>
  • Loading branch information
shedaniel committed Apr 1, 2024
1 parent 7684945 commit d4f399c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@

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.
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -86,15 +83,6 @@ interface LootTableModificationContext {
*
* @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);
}
}
2 changes: 0 additions & 2 deletions common/src/main/resources/architectury.accessWidener
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@
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() {
Expand Down Expand Up @@ -85,7 +83,7 @@ public static void registerCommon() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

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);
}
});
});*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public TestInt(int value) {
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));
});
Expand Down

0 comments on commit d4f399c

Please sign in to comment.