Skip to content

Commit

Permalink
Make some stuff final, Add some doc
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph T. McQuigg <[email protected]>
  • Loading branch information
JT122406 committed Dec 20, 2024
1 parent a66322e commit c66748a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void init() {
ToolInteractions.registerFlattenables(ShovelItem.FLATTENABLES::put);
}

public static void registerVanillaCompatEvents(IEventBus bus) {
public static void registerVanillaCompatEvents(final IEventBus bus) {
bus.addListener(VanillaCompatForge::registerTillables);
bus.addListener(VanillaCompatForge::registerFuels);
if (BWGTradesConfig.INSTANCE.get().enableTrades()) bus.addListener(VanillaCompatForge::onVillagerTrade);
Expand All @@ -57,6 +57,10 @@ public static void registerVanillaCompatEvents(IEventBus bus) {
bus.addListener(VanillaCompatForge::onEnderManAnger);
}

/**
* Register tillable blocks.
* @see BlockEvent.BlockToolModificationEvent
*/
private static void registerTillables(final BlockEvent.BlockToolModificationEvent event) {
if (event.getToolAction() == ToolActions.HOE_TILL && event.getLevel().getBlockState(event.getPos().above()).isAir()) {
BlockState state = event.getState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ public static void init() {
ToolInteractions.registerFlattenables(ShovelItem.FLATTENABLES::put);
}

public static void registerVanillaCompatEvents(IEventBus bus) {
public static void registerVanillaCompatEvents(final IEventBus bus) {
bus.addListener(VanillaCompatNeoForge::registerTillables);
if (BWGTradesConfig.INSTANCE.get().enableTrades()) bus.addListener(VanillaCompatNeoForge::onVillagerTrade);
bus.addListener(VanillaCompatNeoForge::onBoneMealUse);
bus.addListener(VanillaCompatNeoForge::registerBrewingRecipes);
bus.addListener(VanillaCompatNeoForge::onEnderManAnger);
}

/**
* Register tillable blocks.
* @see BlockEvent.BlockToolModificationEvent
*/
private static void registerTillables(final BlockEvent.BlockToolModificationEvent event) {
if (event.getItemAbility() == ItemAbilities.HOE_TILL && event.getLevel().getBlockState(event.getPos().above()).isAir()) {
BlockState state = event.getState();
Expand All @@ -66,6 +70,10 @@ else if (state.is(BWGBlocks.PEAT.get()))
}
}

/**
* Register villager trades.
* @see VillagerTradesEvent
*/
private static void onVillagerTrade(final VillagerTradesEvent event) {
if (BWGVillagerTrades.TRADES.containsKey(event.getType())) {
Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades();
Expand Down

0 comments on commit c66748a

Please sign in to comment.