Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.20.6] Update Architectury API's dependencies and require the latest Fabric API and NeoForge. #509

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"icon": "icon.png",
"depends": {
"minecraft": "~1.20.6-",
"fabricloader": ">=0.15.6",
"fabric-api": ">=0.98.0"
"fabricloader": ">=0.15.11",
"fabric-api": ">=0.99.0"
},
"breaks": {
"optifabric": "<1.13.0"
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ base_version=12.1
maven_group=dev.architectury
version_suffix=

fabric_loader_version=0.15.10
fabric_api_version=0.98.0+1.20.6
fabric_loader_version=0.15.11
fabric_api_version=0.99.0+1.20.6
mod_menu_version=10.0.0-beta.1

forge_version=50.0.0
neoforge_version=20.6.70-beta
forge_version=50.0.31
neoforge_version=20.6.98-beta

# Set to empty if not snapshots
neoforge_pr=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.util.TriState;
import net.neoforged.neoforge.event.CommandEvent;
import net.neoforged.neoforge.event.LootTableLoadEvent;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
Expand Down Expand Up @@ -247,20 +248,6 @@ public static void event(FarmlandTrampleEvent event) {
}
}

@SubscribeEvent(priority = EventPriority.HIGH)
public static void event(FillBucketEvent event) {
ItemStack oldItem = event.getEmptyBucket();
CompoundEventResult<ItemStack> result = PlayerEvent.FILL_BUCKET.invoker().fill(event.getEntity(), event.getLevel(), oldItem, event.getTarget());
if (result.interruptsFurtherEvaluation()) {
event.setCanceled(true);
event.setFilledBucket(result.object());

if (result.value() != null) {
event.setResult(result.value() ? Event.Result.ALLOW : Event.Result.DENY);
}
}
}

// TODO: Hook ourselves when mixin is available
// @SubscribeEvent(priority = EventPriority.HIGH)
// public static void event(EnteringChunk event) {
Expand Down Expand Up @@ -294,20 +281,20 @@ public static void event(ItemSmeltedEvent event) {
}

@SubscribeEvent(priority = EventPriority.HIGH)
public static void event(EntityItemPickupEvent event) {
public static void event(ItemEntityPickupEvent.Pre event) {
// note: this event is weird, cancel is equivalent to denying the pickup,
// and setting the result to ALLOW will pick it up without adding it to the player's inventory
var result = PlayerEvent.PICKUP_ITEM_PRE.invoker().canPickup(event.getEntity(), event.getItem(), event.getItem().getItem());
var result = PlayerEvent.PICKUP_ITEM_PRE.invoker().canPickup(event.getPlayer(), event.getItemEntity(), event.getItemEntity().getItem());
if (result.isFalse()) {
event.setCanceled(true);
event.setCanPickup(TriState.FALSE);
} else if (result.isTrue()) {
event.setResult(Event.Result.ALLOW);
event.setCanPickup(TriState.TRUE);
}
}

@SubscribeEvent(priority = EventPriority.HIGH)
public static void event(ItemPickupEvent event) {
PlayerEvent.PICKUP_ITEM_POST.invoker().pickup(event.getEntity(), event.getOriginalEntity(), event.getStack());
public static void event(ItemEntityPickupEvent.Post event) {
PlayerEvent.PICKUP_ITEM_POST.invoker().pickup(event.getPlayer(), event.getItemEntity(), event.getCurrentStack());
}

@SubscribeEvent(priority = EventPriority.HIGH)
Expand Down Expand Up @@ -340,8 +327,8 @@ public static void eventPlayerInteractEvent(PlayerInteractEvent.RightClickBlock
if (result.isPresent()) {
event.setCanceled(true);
event.setCancellationResult(result.asMinecraft());
event.setUseBlock(Event.Result.DENY);
event.setUseItem(Event.Result.DENY);
event.setUseBlock(TriState.FALSE);
event.setUseItem(TriState.FALSE);
}
}

Expand All @@ -360,8 +347,8 @@ public static void eventPlayerInteractEvent(PlayerInteractEvent.LeftClickBlock e
EventResult result = InteractionEvent.LEFT_CLICK_BLOCK.invoker().click(event.getEntity(), event.getHand(), event.getPos(), event.getFace());
if (result.isPresent()) {
event.setCanceled(true);
event.setUseBlock(result.value() ? Event.Result.ALLOW : Event.Result.DENY);
event.setUseItem(result.value() ? Event.Result.ALLOW : Event.Result.DENY);
event.setUseBlock(result.value() ? TriState.TRUE : TriState.FALSE);
event.setUseItem(result.value() ? TriState.TRUE : TriState.FALSE);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021, 2022 architectury
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package dev.architectury.mixin.forge.neoforge;

import dev.architectury.event.events.common.PlayerEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(BucketItem.class)
public class MixinBucketItem {

@Inject(
method = "use",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/phys/BlockHitResult;getType()Lnet/minecraft/world/phys/HitResult$Type;",
ordinal = 0
),
locals = LocalCapture.CAPTURE_FAILHARD,
cancellable = true
)
public void fillBucket(Level level, Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir, ItemStack stack, BlockHitResult target) {
var result = PlayerEvent.FILL_BUCKET.invoker().fill(player, level, stack, target);
if (result.interruptsFurtherEvaluation() && result.value() != null) {
cir.setReturnValue(result.asMinecraft());
cir.cancel();
}
}

}
2 changes: 1 addition & 1 deletion neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ side = "BOTH"
[[dependencies.architectury]]
modId = "neoforge"
type = "required"
versionRange = "[20.6.70-beta,)"
versionRange = "[20.6.98-beta,)"
ordering = "NONE"
side = "BOTH"

Expand Down
1 change: 1 addition & 0 deletions neoforge/src/main/resources/architectury.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"MixinMinecraft"
],
"mixins": [
"neoforge.MixinBucketItem",
"neoforge.BucketItemAccessor",
"neoforge.LiquidBlockAccessor",
"neoforge.MixinChunkSerializer",
Expand Down
Loading