Skip to content

Commit

Permalink
Fix mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
BrokenK3yboard committed Dec 9, 2024
1 parent 5f1da59 commit 8698af9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import com.mojang.serialization.Decoder;

import net.minecraft.core.Registry;
import net.minecraft.core.WritableRegistry;
import net.minecraft.resources.RegistryDataLoader;
import net.minecraft.resources.RegistryOps;
Expand All @@ -21,9 +20,8 @@
@Mixin(RegistryDataLoader.class)
public class RegistryDataLoaderMixin {

@Inject(method = "loadRegistryContents", at = @At("RETURN"))
private static <E> void zeta$onLoadRegistryContents(RegistryOps.RegistryInfoLookup registryInfoLookup, ResourceManager mgr, ResourceKey<? extends Registry<E>> registryId, WritableRegistry<E> registry, Decoder<E> whereWereGoingWeDontNeedParsers, Map<ResourceKey<?>, Exception> failed, CallbackInfo ci) {
RegisterDynamicUtil.onRegisterDynamic(registryInfoLookup, registryId, registry);
@Inject(method = "loadContentsFromManager", at = @At("RETURN"))
private static <E> void zeta$onLoadRegistryContents(ResourceManager manager, RegistryOps.RegistryInfoLookup lookup, WritableRegistry<E> registry, Decoder<E> whereWereGoingWeDontNeedParsers, Map<ResourceKey<?>, Exception> failed, CallbackInfo ci) {
RegisterDynamicUtil.onRegisterDynamic(lookup, registry.key(), registry);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
public class StructurePieceMixin {

@ModifyVariable(
method = "createChest(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/level/levelgen/structure/BoundingBox;Lnet/minecraft/util/RandomSource;Lnet/minecraft/core/BlockPos;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/level/block/state/BlockState;)Z",
at = @At(
value = "INVOKE", target = "Lnet/minecraft/world/level/ServerLevelAccessor;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z",
shift = At.Shift.BY, by = -2
),
method = "createChest(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/level/levelgen/structure/BoundingBox;Lnet/minecraft/util/RandomSource;Lnet/minecraft/core/BlockPos;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/block/state/BlockState;)Z",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ServerLevelAccessor;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z", shift = At.Shift.BY, by = -2),
argsOnly = true
)
protected BlockState modifyBlockstateForChest(BlockState state, ServerLevelAccessor accessor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.violetmoon.zetaimplforge.mixin.mixins.client;

import net.minecraft.client.DeltaTracker;
import net.minecraft.client.renderer.GameRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -8,12 +10,10 @@
import org.violetmoon.zeta.util.zetalist.ZetaClientList;
import org.violetmoon.zetaimplforge.client.event.play.ForgeZEarlyRender;

import net.minecraft.client.renderer.GameRenderer;

@Mixin(GameRenderer.class)
public class GameRenderMixin {
@Inject(method = "render", at = @At(target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", value = "INVOKE", shift = At.Shift.AFTER))
private void quark$renderEvent(float v, long l, boolean b, CallbackInfo ci) {
private void quark$renderEvent(DeltaTracker tracker, boolean bool, CallbackInfo ci) {
ZetaClientList.INSTANCE.fireEvent(new ForgeZEarlyRender(), ZEarlyRender.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@
import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.violetmoon.zeta.client.HumanoidArmorModelGetter;
import org.violetmoon.zetaimplforge.client.IZetaForgeItemStuff;

@Mixin(Item.class)
public class ItemMixin implements IZetaForgeItemStuff {
@Shadow(remap = false) private Object renderProperties;

@Unique
private Object zeta$renderProperties;

@Override
public void zeta$setBlockEntityWithoutLevelRenderer(BlockEntityWithoutLevelRenderer bewlr) {
if(renderProperties != null)
if(zeta$renderProperties != null)
throw new IllegalStateException("Cannot set both BlockEntityWithoutLevelRenderer and HumanoidArmorModel because zeta's api is bad");

renderProperties = new IClientItemExtensions() {
zeta$renderProperties = new IClientItemExtensions() {
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
return bewlr;
Expand All @@ -31,10 +34,10 @@ public BlockEntityWithoutLevelRenderer getCustomRenderer() {

@Override
public void zeta$setHumanoidArmorModel(HumanoidArmorModelGetter getter) {
if(renderProperties != null)
if(zeta$renderProperties != null)
throw new IllegalStateException("Cannot set both BlockEntityWithoutLevelRenderer and HumanoidArmorModel because zeta's api is bad");

renderProperties = new IClientItemExtensions() {
zeta$renderProperties = new IClientItemExtensions() {
@Override
public @NotNull HumanoidModel<?> getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<?> original) {
return getter.getHumanoidArmorModel(livingEntity, itemStack, equipmentSlot, original);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/zeta_forge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"package": "org.violetmoon.zetaimplforge.mixin.mixins",
"plugin": "org.violetmoon.zeta.mixin.plugin.InterfaceDelegateMixinPlugin",
"mixins": [
"AccessorConfigTracker",
"AccessorEvent",
"AccessorModConfig",
"AccessorPotionBrewing",
Expand Down

0 comments on commit 8698af9

Please sign in to comment.