mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Update to Loom 0.10.0 and add Mixins
This commit is contained in:
@@ -4,7 +4,10 @@ plugins {
|
||||
}
|
||||
|
||||
loom {
|
||||
// mixinConfigs = ["architectury.mixins.json", "architectury-common.mixins.json"]
|
||||
forge {
|
||||
mixinConfig "architectury.mixins.json"
|
||||
mixinConfig "architectury-common.mixins.json"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -24,10 +27,10 @@ architectury {
|
||||
dependencies {
|
||||
forge "net.minecraftforge:forge:${rootProject.architectury.minecraft}-${rootProject.forge_version}"
|
||||
|
||||
implementation(project(path: ":common")) {
|
||||
implementation(project(path: ":common", configuration: "dev")) {
|
||||
transitive = false
|
||||
}
|
||||
developmentForge(project(path: ":common")) {
|
||||
developmentForge(project(path: ":common", configuration: "dev")) {
|
||||
transitive = false
|
||||
}
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) {
|
||||
|
||||
@@ -410,10 +410,9 @@ public class EventHandlerImplCommon {
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(ChunkDataEvent.Load event) {
|
||||
LevelAccessor level = event.getChunk().getWorldForge();
|
||||
// TODO Fix when mixin is back
|
||||
// if (!(level instanceof ServerLevel)) {
|
||||
// level = ((WorldEventAttachment) event).architectury$getAttachedLevel();
|
||||
// }
|
||||
if (!(level instanceof ServerLevel)) {
|
||||
level = ((WorldEventAttachment) event).architectury$getAttachedLevel();
|
||||
}
|
||||
ChunkEvent.LOAD_DATA.invoker().load(event.getChunk(), level instanceof ServerLevel ? (ServerLevel) level : null, event.getData());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package dev.architectury.mixin.forge;
|
||||
|
||||
/*
|
||||
import dev.architectury.extensions.BlockEntityExtension;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
@@ -51,4 +50,3 @@ public abstract class MixinBlockEntity {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -19,24 +19,26 @@
|
||||
|
||||
package dev.architectury.mixin.forge;
|
||||
|
||||
/*import dev.architectury.extensions.BlockEntityExtension;
|
||||
import dev.architectury.extensions.BlockEntityExtension;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.extensions.IForgeTileEntity;
|
||||
import net.minecraftforge.common.extensions.IForgeBlockEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(BlockEntityExtension.class)
|
||||
public interface MixinBlockEntityExtension extends IForgeTileEntity {
|
||||
public interface MixinBlockEntityExtension extends IForgeBlockEntity {
|
||||
@Override
|
||||
default void handleUpdateTag(BlockState state, CompoundTag tag) {
|
||||
((BlockEntityExtension) this).loadClientData(state, tag);
|
||||
default void handleUpdateTag(CompoundTag tag) {
|
||||
var entity = (BlockEntity) this;
|
||||
if (entity.hasLevel()) {
|
||||
((BlockEntityExtension) this).loadClientData(entity.getBlockState(), tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default void onDataPacket(Connection connection, ClientboundBlockEntityDataPacket packet) {
|
||||
((BlockEntityExtension) this).loadClientData(((BlockEntity) this).getBlockState(), packet.getTag());
|
||||
handleUpdateTag(packet.getTag());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package dev.architectury.mixin.forge;
|
||||
|
||||
/*
|
||||
import dev.architectury.event.forge.EventHandlerImplCommon;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -64,4 +63,3 @@ public class MixinChunkSerializer {
|
||||
return event;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package dev.architectury.mixin.forge;
|
||||
|
||||
/*
|
||||
import dev.architectury.event.events.client.ClientTickEvent;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
@@ -44,7 +43,7 @@ public abstract class MixinClientLevel extends Level {
|
||||
private void tickEntities(CallbackInfo ci) {
|
||||
ProfilerFiller profiler = getProfiler();
|
||||
profiler.push("architecturyClientLevelPreTick");
|
||||
ClientTickEvent.CLIENT_WORLD_PRE.invoker().tick((ClientLevel) (Object) this);
|
||||
ClientTickEvent.CLIENT_LEVEL_PRE.invoker().tick((ClientLevel) (Object) this);
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
@@ -52,8 +51,7 @@ public abstract class MixinClientLevel extends Level {
|
||||
private void tickEntitiesPost(CallbackInfo ci) {
|
||||
ProfilerFiller profiler = getProfiler();
|
||||
profiler.push("architecturyClientLevelPostTick");
|
||||
ClientTickEvent.CLIENT_WORLD_POST.invoker().tick((ClientLevel) (Object) this);
|
||||
ClientTickEvent.CLIENT_LEVEL_POST.invoker().tick((ClientLevel) (Object) this);
|
||||
profiler.pop();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021 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;
|
||||
|
||||
import dev.architectury.event.events.common.BlockEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.item.FallingBlockEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(FallingBlockEntity.class)
|
||||
public abstract class MixinFallingBlockEntity extends Entity {
|
||||
public MixinFallingBlockEntity(EntityType<?> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
@Shadow
|
||||
private BlockState blockState;
|
||||
|
||||
@Inject(method = "tick", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/block/Fallable;onLand(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/item/FallingBlockEntity;)V"),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void handleLand(CallbackInfo ci, Block block, BlockPos blockPos2, boolean bl, boolean bl2, double d, BlockState blockState) {
|
||||
BlockEvent.FALLING_LAND.invoker().onLand(this.level, blockPos2, this.blockState, blockState, (FallingBlockEntity) (Object) this);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package dev.architectury.mixin.forge;
|
||||
|
||||
/*
|
||||
import dev.architectury.extensions.ItemExtension;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -42,4 +41,3 @@ public interface MixinItemExtension extends IForgeItem {
|
||||
return ((ItemExtension) this).getCustomEquipmentSlot(stack);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -19,11 +19,9 @@
|
||||
|
||||
package dev.architectury.mixin.forge;
|
||||
|
||||
/*
|
||||
import dev.architectury.core.RegistryEntry;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(RegistryEntry.class)
|
||||
public class MixinRegistryEntry<T> {
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package dev.architectury.mixin.forge;
|
||||
|
||||
/*
|
||||
import dev.architectury.event.forge.EventHandlerImplCommon;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
@@ -43,4 +42,3 @@ public class MixinWorldEvent implements EventHandlerImplCommon.WorldEventAttachm
|
||||
this.level = new WeakReference<>(level);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021 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;
|
||||
|
||||
/*
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ParticleEngine.class)
|
||||
public interface ParticleEngineAccessor {
|
||||
@Accessor
|
||||
TextureAtlas getTextureAtlas();
|
||||
|
||||
@Mixin(targets = "net/minecraft/client/particle/ParticleEngine$MutableSpriteSet")
|
||||
interface MutableSpriteSetAccessor {
|
||||
@Accessor
|
||||
List<TextureAtlasSprite> getSprites();
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package dev.architectury.plugin.forge;
|
||||
|
||||
/*
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -62,7 +61,7 @@ public class ArchitecturyMixinPlugin implements IMixinConfigPlugin {
|
||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
// Inject our own sugar
|
||||
switch (mixinClassName) {
|
||||
case "me.shedaniel.architectury.mixin.forge.MixinRegistryEntry":
|
||||
case "dev.architectury.mixin.forge.MixinRegistryEntry":
|
||||
targetClass.superName = "net/minecraftforge/registries/ForgeRegistryEntry";
|
||||
for (MethodNode method : targetClass.methods) {
|
||||
if (Objects.equals(method.name, "<init>")) {
|
||||
@@ -87,4 +86,3 @@ public class ArchitecturyMixinPlugin implements IMixinConfigPlugin {
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -66,9 +66,8 @@ public class BlockPropertiesImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public BlockProperties tool(ToolType type, int level) {
|
||||
harvestTool(net.minecraftforge.common.ToolType.get(type.forgeName));
|
||||
harvestLevel(level);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,6 @@ license = "LGPL-3"
|
||||
[[dependencies.architectury]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.16.2,)"
|
||||
versionRange = "[1.17.1,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "me.shedaniel.architectury.mixin.forge",
|
||||
"package": "dev.architectury.mixin.forge",
|
||||
"plugin": "dev.architectury.plugin.forge.ArchitecturyMixinPlugin",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
"dev.architectury.architectury.mixin.forge.MixinClientLevel",
|
||||
"dev.architectury.architectury.mixin.forge.ParticleEngineAccessor",
|
||||
"ParticleEngineAccessor$MutableSpriteSetAccessor"
|
||||
"MixinClientLevel"
|
||||
],
|
||||
"mixins": [
|
||||
"dev.architectury.architectury.mixin.forge.BiomeGenerationSettingsBuilderAccessor",
|
||||
"dev.architectury.architectury.mixin.forge.GameRulesAccessor",
|
||||
"GameRulesAccessor$BooleanValue",
|
||||
"GameRulesAccessor$BooleanValueSimple",
|
||||
"GameRulesAccessor$IntegerValue",
|
||||
"GameRulesAccessor$IntegerValueSimple",
|
||||
"dev.architectury.architectury.mixin.forge.MixinBlockEntity",
|
||||
"dev.architectury.architectury.mixin.forge.MixinBlockEntityExtension",
|
||||
"dev.architectury.architectury.mixin.forge.MixinChunkSerializer",
|
||||
"dev.architectury.architectury.mixin.forge.MixinItemExtension",
|
||||
"dev.architectury.architectury.mixin.forge.MixinRegistryEntry",
|
||||
"dev.architectury.architectury.mixin.forge.MixinWorldEvent",
|
||||
"dev.architectury.architectury.mixin.forge.MobSpawnSettingsBuilderAccessor"
|
||||
"MixinBlockEntity",
|
||||
"MixinBlockEntityExtension",
|
||||
"MixinChunkSerializer",
|
||||
"MixinFallingBlockEntity",
|
||||
"MixinItemExtension",
|
||||
"MixinRegistryEntry",
|
||||
"MixinWorldEvent"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in New Issue
Block a user