forked from GL33P-0R4NG3/oreganized
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use MixinExtras for most redirects to avoid mixin conflicts
- Loading branch information
1 parent
845437a
commit 8e07c18
Showing
9 changed files
with
54 additions
and
61 deletions.
There are no files selected for viewing
15 changes: 8 additions & 7 deletions
15
src/main/java/galena/oreganized/mixin/AbstractArrowMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
package galena.oreganized.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import galena.oreganized.content.entity.LeadBoltEntity; | ||
import galena.oreganized.index.ODamageSources; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.damagesource.DamageSources; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.projectile.AbstractArrow; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(AbstractArrow.class) | ||
public class AbstractArrowMixin { | ||
|
||
@Redirect( | ||
@ModifyExpressionValue( | ||
method = "onHitEntity(Lnet/minecraft/world/phys/EntityHitResult;)V", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/damagesource/DamageSources;arrow(Lnet/minecraft/world/entity/projectile/AbstractArrow;Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/damagesource/DamageSource;") | ||
) | ||
public DamageSource injectLeadBolt(DamageSources instance, AbstractArrow arrow, Entity user) { | ||
if (arrow instanceof LeadBoltEntity) { | ||
return instance.source(ODamageSources.LEAD_BOLT, arrow, user); | ||
public DamageSource injectLeadBolt(DamageSource original, @Local(ordinal = 1) Entity user) { | ||
var self = (AbstractArrow) (Object) this; | ||
if (self instanceof LeadBoltEntity) { | ||
return self.damageSources().source(ODamageSources.LEAD_BOLT, self, user); | ||
} | ||
|
||
return instance.arrow(arrow, user); | ||
return original; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
package galena.oreganized.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import galena.oreganized.content.item.ScribeItem; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.enchantment.Enchantment; | ||
import net.minecraft.world.item.enchantment.EnchantmentHelper; | ||
import net.minecraft.world.item.enchantment.Enchantments; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.storage.loot.LootParams; | ||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(Block.class) | ||
public class BlockMixin { | ||
|
||
@ModifyVariable( | ||
@WrapOperation( | ||
method = "getDrops(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/ItemStack;)Ljava/util/List;", | ||
at = @At(value = "STORE") | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getDrops(Lnet/minecraft/world/level/storage/loot/LootParams$Builder;)Ljava/util/List;") | ||
) | ||
private static LootParams.Builder modifyLootBuilder(LootParams.Builder builder, @Local BlockState state, @Local ItemStack stack) { | ||
private static List<ItemStack> modifyLootBuilder(BlockState state, LootParams.Builder builder, Operation<List<ItemStack>> original, @Local ItemStack stack) { | ||
if (stack.getItem() instanceof ScribeItem scribe && scribe.dropsLikeSilktouch(stack, state)) { | ||
var virtual = stack.copy(); | ||
virtual.enchant(Enchantments.SILK_TOUCH, 1); | ||
return builder.withParameter(LootContextParams.TOOL, virtual); | ||
builder.withParameter(LootContextParams.TOOL, virtual); | ||
} | ||
return builder; | ||
return original.call(state, builder); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
package galena.oreganized.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import galena.oreganized.index.OEffects; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.food.FoodData; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(FoodData.class) | ||
public class FoodDataMixin { | ||
|
||
@Redirect( | ||
@ModifyExpressionValue( | ||
method = "tick(Lnet/minecraft/world/entity/player/Player;)V", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;heal(F)V") | ||
at = @At(value = "CONSTANT", args = "floatValue=6F", ordinal = 1) | ||
) | ||
private void modifyHealthAmount(Player player, float value) { | ||
if (player.hasEffect(OEffects.STUNNING.get())) player.heal(value / 2); | ||
else player.heal(value); | ||
private float modifyHealthAmount(float value, @Local Player player) { | ||
if (player.hasEffect(OEffects.STUNNING.get())) return value * 2; | ||
return value; | ||
} | ||
|
||
@ModifyExpressionValue( | ||
method = "tick(Lnet/minecraft/world/entity/player/Player;)V", | ||
at = @At(value = "CONSTANT", args = "floatValue=1F", ordinal = 1) | ||
) | ||
private float modifyHealthAmount2(float value, @Local Player player) { | ||
if (player.hasEffect(OEffects.STUNNING.get())) return value / 2; | ||
return value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
package galena.oreganized.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import galena.oreganized.content.item.ScribeItem; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.enchantment.Enchantment; | ||
import net.minecraft.world.item.enchantment.EnchantmentHelper; | ||
import net.minecraft.world.item.enchantment.Enchantments; | ||
import net.minecraft.world.level.block.IceBlock; | ||
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.Redirect; | ||
|
||
@Mixin(IceBlock.class) | ||
public class IceBlockMixin { | ||
|
||
@Redirect( | ||
@ModifyExpressionValue( | ||
method = "playerDestroy(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/item/ItemStack;)V", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/EnchantmentHelper;getItemEnchantmentLevel(Lnet/minecraft/world/item/enchantment/Enchantment;Lnet/minecraft/world/item/ItemStack;)I") | ||
) | ||
private int modifyLootBuilder(Enchantment enchantment, ItemStack stack, @Local BlockState state) { | ||
private int modifyLootBuilder(int original, @Local ItemStack stack, @Local BlockState state) { | ||
if (stack.getItem() instanceof ScribeItem scribe && scribe.isCorrectToolForDrops(stack, state)) { | ||
return 1; | ||
} | ||
return EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack); | ||
return original; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/main/java/galena/oreganized/mixin/client/GuiAccessor.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters