This commit is contained in:
Brian Neumann-Fopiano
2026-07-21 12:00:17 -04:00
parent d76dadec30
commit f6f06c1ab9
141 changed files with 10717 additions and 1725 deletions
@@ -19,15 +19,27 @@
package art.arcane.iris.fabric;
import art.arcane.iris.modded.ModdedLoader;
import art.arcane.iris.modded.service.ModdedTreeFellerService;
import net.fabricmc.api.EnvType;
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.fabricmc.fabric.api.permission.v1.PermissionContextOwner;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.permissions.PermissionLevel;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import java.io.File;
import java.nio.file.Path;
public final class FabricModdedLoader implements ModdedLoader {
private static final Identifier TREE_FELLER_PERMISSION = Identifier.fromNamespaceAndPath("iris", "treefeller");
@Override
public String platformName() {
return "fabric";
@@ -74,4 +86,24 @@ public final class FabricModdedLoader implements ModdedLoader {
.map((Path p) -> p.toFile())
.orElse(null);
}
@Override
public boolean hasTreeFellerPermission(ServerPlayer player) {
return ((PermissionContextOwner) player).checkPermission(
TREE_FELLER_PERMISSION,
PermissionLevel.GAMEMASTERS
);
}
@Override
public boolean canTreeFellerBreak(
ServerLevel level,
ServerPlayer player,
BlockPos position,
BlockState state
) {
BlockEntity blockEntity = state.hasBlockEntity() ? level.getBlockEntity(position) : null;
return ModdedTreeFellerService.runBreakProbe(() -> PlayerBlockBreakEvents.BEFORE.invoker()
.beforeBlockBreak(level, player, position, state, blockEntity));
}
}
@@ -42,6 +42,7 @@ import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
@@ -60,13 +61,19 @@ public final class IrisFabricBootstrap implements ModInitializer {
ServerLifecycleEvents.SERVER_STARTED.register((MinecraftServer server) -> ModdedEngineBootstrap.serverStarted(server));
ServerLifecycleEvents.SERVER_STOPPING.register((MinecraftServer server) -> ModdedEngineBootstrap.stop());
ServerLevelEvents.LOAD.register((MinecraftServer server, ServerLevel level) -> ModdedEngineBootstrap.levelLoaded(level));
ServerLevelEvents.UNLOAD.register((MinecraftServer server, ServerLevel level) -> ModdedEngineBootstrap.levelUnloaded(level));
CommandRegistrationCallback.EVENT.register((CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext buildContext, Commands.CommandSelection selection) -> IrisModdedCommands.register(dispatcher));
PlayerBlockBreakEvents.BEFORE.register((Level level, Player player, BlockPos pos, BlockState state, BlockEntity blockEntity) -> {
if (level instanceof ServerLevel serverLevel) {
ModdedBlockBreakHandler.prepare(serverLevel, pos, state);
if (level instanceof ServerLevel serverLevel && player instanceof ServerPlayer serverPlayer) {
ModdedBlockBreakHandler.prepare(serverLevel, serverPlayer, pos, state);
}
return true;
});
PlayerBlockBreakEvents.CANCELED.register((Level level, Player player, BlockPos pos, BlockState state, BlockEntity blockEntity) -> {
if (level instanceof ServerLevel serverLevel) {
ModdedBlockBreakHandler.cancel(serverLevel, pos);
}
});
AttackBlockCallback.EVENT.register((Player player, Level level, InteractionHand hand, BlockPos pos, Direction direction) ->
ModdedWandService.attackBlock(player, level, hand, pos) ? InteractionResult.SUCCESS : InteractionResult.PASS);
UseBlockCallback.EVENT.register((Player player, Level level, InteractionHand hand, BlockHitResult hit) ->
@@ -0,0 +1,25 @@
package art.arcane.iris.fabric.mixin;
import art.arcane.iris.modded.ModdedBlockBreakHandler;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.state.BlockState;
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;
@Mixin(BlockItem.class)
public final class BlockItemMixin {
@Inject(method = "placeBlock", at = @At("RETURN"))
private void iris$clearTreeProvenance(
BlockPlaceContext context,
BlockState state,
CallbackInfoReturnable<Boolean> info
) {
if (info.getReturnValue() && context.getLevel() instanceof ServerLevel level) {
ModdedBlockBreakHandler.clearPlacedProvenance(level, context.getClickedPos());
}
}
}
@@ -48,6 +48,10 @@ public class BlockMixin {
if (result == null) {
return;
}
if (result.routeCombinedDrops(info.getReturnValue())) {
info.setReturnValue(List.of());
return;
}
List<ItemStack> drops = result.replaceVanillaDrops()
? new ArrayList<>()
: new ArrayList<>(info.getReturnValue());
@@ -4,6 +4,7 @@
"package": "art.arcane.iris.fabric.mixin",
"compatibilityLevel": "JAVA_25",
"mixins": [
"BlockItemMixin",
"BlockMixin",
"ServerPacksSourceMixin"
],