Skip to content

Commit

Permalink
@ModifyConstant => @ModifyExpressionValue for compat & stackablity. F…
Browse files Browse the repository at this point in the history
…ixes #4591 and #4588
  • Loading branch information
IThundxr committed Jan 17, 2024
1 parent 7319afa commit bd777f4
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public void addAdditionalHints(ZGatherHints event) {

// The value that comes out of this is fed onto a constant for the FOR loop that
// computes the beacon segments, so we return 0 to run that code, or MAX_VALUE to not
public static int tickBeacon(BeaconBlockEntity beacon) {
public static int tickBeacon(BeaconBlockEntity beacon, int original) {
if(!staticEnabled)
return 0;
return original;

Level world = beacon.getLevel();
BlockPos beaconPos = beacon.getBlockPos();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
package org.violetmoon.quark.mixin.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.decoration.ArmorStand;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import org.spongepowered.asm.mixin.injection.At;
import org.violetmoon.quark.content.tweaks.module.ArmedArmorStandsModule;

@Mixin(ArmorStand.class)
public class ArmorStandMixin {
@ModifyConstant(method = "defineSynchedData", constant = @Constant(intValue = 0))
private int asdasld(int orig) {
@ModifyExpressionValue(method = "defineSynchedData", at = @At(value = "CONSTANT", args = "intValue=0"))
private int quark$armedArmorStands(int original) {
if(!ArmedArmorStandsModule.staticEnabled)
return orig;
return original;

//try to be careful - this is a kinda scary looking mixin, lol
SynchedEntityData data = ((Entity) (Object) this).getEntityData();
if(data.hasItem(ArmorStand.DATA_CLIENT_FLAGS))
return orig; //it's already been defined
return original; //it's already been defined

else
return orig | ArmorStand.CLIENT_FLAG_SHOW_ARMS; // | 4
return original | ArmorStand.CLIENT_FLAG_SHOW_ARMS; // | 4
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
package org.violetmoon.quark.mixin.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.world.item.crafting.BannerDuplicateRecipe;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import org.spongepowered.asm.mixin.injection.At;
import org.violetmoon.quark.content.tweaks.module.MoreBannerLayersModule;

@Mixin(BannerDuplicateRecipe.class)
public class BannerDuplicateRecipeMixin {

@ModifyConstant(method = "matches(Lnet/minecraft/world/inventory/CraftingContainer;Lnet/minecraft/world/level/Level;)Z", constant = @Constant(intValue = 6))
public int getLimitMatches(int curr) {
return MoreBannerLayersModule.getLimit(curr);
@ModifyExpressionValue(method = "matches(Lnet/minecraft/world/inventory/CraftingContainer;Lnet/minecraft/world/level/Level;)Z", at = @At(value = "CONSTANT", args = "intValue=6"))
public int getLimitMatches(int original) {
return MoreBannerLayersModule.getLimit(original);
}

@ModifyConstant(method = "assemble(Lnet/minecraft/world/inventory/CraftingContainer;Lnet/minecraft/core/RegistryAccess;)Lnet/minecraft/world/item/ItemStack;", constant = @Constant(intValue = 6))
public int getLimitAssemble(int curr) {
return MoreBannerLayersModule.getLimit(curr);
@ModifyExpressionValue(method = "assemble(Lnet/minecraft/world/inventory/CraftingContainer;Lnet/minecraft/core/RegistryAccess;)Lnet/minecraft/world/item/ItemStack;", at = @At(value = "CONSTANT", args = "intValue=6"))
public int getLimitAssemble(int original) {
return MoreBannerLayersModule.getLimit(original);
}

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
package org.violetmoon.quark.mixin.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
import net.minecraft.world.level.block.state.BlockState;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import org.spongepowered.asm.mixin.injection.At;
import org.violetmoon.quark.content.tools.module.BeaconRedirectionModule;

@Mixin(BeaconBlockEntity.class)
public class BeaconBlockEntityMixin {

// This captures the for loop inside tick that computes the beacon segments
@ModifyConstant(method = "tick", constant = @Constant(intValue = 0, ordinal = 0))
private static int tick(int val, Level level, BlockPos pos, BlockState state, BeaconBlockEntity beacon) {
return BeaconRedirectionModule.tickBeacon(beacon);
@ModifyExpressionValue(method = "tick", at = @At(value = "CONSTANT", args = "intValue=0", ordinal = 0))
private static int tick(int original, Level level, BlockPos pos, BlockState state, BeaconBlockEntity beacon) {
return BeaconRedirectionModule.tickBeacon(beacon, original);
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package org.violetmoon.quark.mixin.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.world.inventory.LoomMenu;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import org.spongepowered.asm.mixin.injection.At;
import org.violetmoon.quark.content.tweaks.module.MoreBannerLayersModule;

@Mixin(LoomMenu.class)
public class LoomMenuMixin {

@ModifyConstant(method = "slotsChanged", constant = @Constant(intValue = 6))
public int getLimit(int curr) {
return MoreBannerLayersModule.getLimit(curr);
@ModifyExpressionValue(method = "slotsChanged", at = @At(value = "CONSTANT", args = "intValue=6"))
public int getLimit(int original) {
return MoreBannerLayersModule.getLimit(original);
}

}
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package org.violetmoon.quark.mixin.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
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.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import org.violetmoon.quark.content.automation.module.PistonsMoveTileEntitiesModule;
import org.violetmoon.quark.content.experimental.module.GameNerfsModule;

Expand All @@ -24,8 +20,10 @@ private static boolean tick(Level instance, BlockPos pos, BlockState newState, i
return PistonsMoveTileEntitiesModule.setPistonBlock(instance, pos, newState, flags) || original.call(instance, pos, newState, flags);
}

@ModifyConstant(method = "tick", constant = @Constant(intValue = 84))
private static int forceNotifyBlockUpdate(int flag) {
return GameNerfsModule.stopPistonPhysicsExploits() ? (flag | 2) : flag; // paper impl comment: Paper - force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air
@ModifyExpressionValue(method = "tick", at = @At(value = "CONSTANT", args = "intValue=84"))
private static int forceNotifyBlockUpdate(int original) {
// paper impl comment: Paper - force notify (original 2),
// it's possible the set type by the piston block (which doesn't notify) to set this block to air
return GameNerfsModule.stopPistonPhysicsExploits() ? (original | 2) : original;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
package org.violetmoon.quark.mixin.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.world.level.block.SpongeBlock;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import org.spongepowered.asm.mixin.injection.At;
import org.violetmoon.quark.content.tweaks.module.ImprovedSpongesModule;

@Mixin(SpongeBlock.class)
public class SpongeBlockMixin {

@ModifyConstant(method = "removeWaterBreadthFirstSearch", constant = @Constant(intValue = 65))
public int getDrainLimit(int limit) {
return ImprovedSpongesModule.drainLimit(limit);
@ModifyExpressionValue(method = "removeWaterBreadthFirstSearch", at = @At(value = "CONSTANT", args = "intValue=65"))
public int getDrainLimit(int original) {
return ImprovedSpongesModule.drainLimit(original);
}

@ModifyConstant(method = "removeWaterBreadthFirstSearch", constant = @Constant(intValue = 6))
public int getCrawlLimit(int limit) {
return ImprovedSpongesModule.crawlLimit(limit);
@ModifyExpressionValue(method = "removeWaterBreadthFirstSearch", at = @At(value = "CONSTANT", args = "intValue=6"))
public int getCrawlLimit(int original) {
return ImprovedSpongesModule.crawlLimit(original);
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package org.violetmoon.quark.mixin.mixins.client;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.world.item.BannerItem;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import org.spongepowered.asm.mixin.injection.At;
import org.violetmoon.quark.content.tweaks.module.MoreBannerLayersModule;

@Mixin(BannerItem.class)
public class BannerItemMixin {

@ModifyConstant(method = "appendHoverTextFromBannerBlockEntityTag", constant = @Constant(intValue = 6))
private static int getLimit(int curr) {
return MoreBannerLayersModule.getLimit(curr);
@ModifyExpressionValue(method = "appendHoverTextFromBannerBlockEntityTag", at = @At(value = "CONSTANT", args = "intValue=6"))
private static int getLimit(int original) {
return MoreBannerLayersModule.getLimit(original);
}

}
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package org.violetmoon.quark.mixin.mixins.client;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraftforge.client.gui.overlay.ForgeGui;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import org.spongepowered.asm.mixin.injection.At;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.content.client.module.ElytraIndicatorModule;

@Mixin(ForgeGui.class)
public class ForgeGuiMixin {

@ModifyConstant(method = "renderArmor", constant = @Constant(intValue = 20), remap = false)
private static int renderArmor(int curr) {
@ModifyExpressionValue(method = "renderArmor", at = @At(value = "CONSTANT", args = "intValue=20"), remap = false)
private static int renderArmor(int original) {
ElytraIndicatorModule module = Quark.ZETA.modules.get(ElytraIndicatorModule.class);
return module == null ? curr : module.getArmorLimit(curr);
return module == null ? original : module.getArmorLimit(original);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import org.violetmoon.quark.content.management.module.ItemSharingModule;
import org.violetmoon.quark.content.tools.module.ColorRunesModule;

Expand Down Expand Up @@ -70,8 +65,8 @@ private static RenderType getEntityGlintDirect(RenderType prev) {
return ColorRunesModule.Client.getEntityGlintDirect();
}

@ModifyConstant(method = "renderQuadList", constant = @Constant(floatValue = 1F), require = 0) // Allow failure in case of rubidium
public float renderQuads(float constant) {
return ItemSharingModule.Client.alphaValue * constant;
@ModifyExpressionValue(method = "renderQuadList", at = @At(value = "CONSTANT", args = "floatValue=1F"), require = 0) // Allow failure in case of rubidium/embeddium
public float renderQuads(float original) {
return ItemSharingModule.Client.alphaValue * original;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package org.violetmoon.quark.mixin.mixins.client;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.client.gui.screens.inventory.LoomScreen;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import org.spongepowered.asm.mixin.injection.At;
import org.violetmoon.quark.content.tweaks.module.MoreBannerLayersModule;

@Mixin(LoomScreen.class)
public class LoomScreenMixin {

@ModifyConstant(method = "containerChanged", constant = @Constant(intValue = 6))
private static int getLimit(int curr) {
return MoreBannerLayersModule.getLimit(curr);
@ModifyExpressionValue(method = "containerChanged", at = @At(value = "CONSTANT", args = "intValue=6"))
private static int getLimit(int original) {
return MoreBannerLayersModule.getLimit(original);
}

}

0 comments on commit bd777f4

Please sign in to comment.