-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
147 additions
and
32 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
src/main/java/hunternif/mc/impl/atlas/mixin/VolatileMixinPlugin.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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package hunternif.mc.impl.atlas.mixin; | ||
|
||
/** | ||
* This file was copied from https://github.com/Hephaestus-Dev/TinyTweaks/blob/master/src/main/java/dev/hephaestus/tweaks/mixin/VolatileMixinPlugin.java | ||
* | ||
* Copyright: https://github.com/Hephaestus-Dev | ||
* License: MIT | ||
*/ | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class VolatileMixinPlugin implements IMixinConfigPlugin { | ||
@Override | ||
public void onLoad(String mixinPackage) { | ||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
boolean isDevelopmentEnvironment = FabricLoader.getInstance().isDevelopmentEnvironment(); | ||
if (mixinClassName.contains("mixin.dev") && !isDevelopmentEnvironment) | ||
return false; | ||
else return !mixinClassName.contains("mixin.prod") || !isDevelopmentEnvironment; | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
|
||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/hunternif/mc/impl/atlas/mixin/dev/MixinCartographyTableHandlerSlot.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package hunternif.mc.impl.atlas.mixin.dev; | ||
|
||
import hunternif.mc.impl.atlas.api.AtlasAPI; | ||
import hunternif.mc.impl.atlas.mixinhooks.CartographyTableHooks; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.inventory.Inventory; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.screen.CartographyTableScreenHandler; | ||
import net.minecraft.screen.ScreenHandlerContext; | ||
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.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(targets = "net.minecraft.screen.CartographyTableScreenHandler$4") | ||
class MixinCartographyTableScreenHandlerSlot { | ||
|
||
@Inject(method = "canInsert", at = @At("RETURN"), cancellable = true) | ||
void antiqueatlas_canInsert(ItemStack stack, CallbackInfoReturnable<Boolean> info) { | ||
info.setReturnValue(stack.getItem() == AtlasAPI.getAtlasItem() || info.getReturnValueZ()); | ||
} | ||
} | ||
|
||
@Mixin(targets = "net.minecraft.screen.CartographyTableScreenHandler$5") | ||
class MixinCartographyTableScreenHandlerResultSlot { | ||
|
||
CartographyTableScreenHandler antiqueatlas_handler; | ||
|
||
@Inject(method = "<init>", at = @At("TAIL")) | ||
void antiqueatlas_init(CartographyTableScreenHandler handler, Inventory inv, int a, int b, int c, ScreenHandlerContext context, CallbackInfo info) { | ||
antiqueatlas_handler = handler; | ||
} | ||
|
||
@Inject(method = "onTakeItem", at = @At("HEAD")) | ||
void antiqueatlas_onTakeItem(PlayerEntity player, ItemStack atlas, CallbackInfoReturnable<ItemStack> info) { | ||
if (atlas.getItem() == AtlasAPI.getAtlasItem()) { | ||
ItemStack map = antiqueatlas_handler.slots.get(0).getStack(); | ||
|
||
CartographyTableHooks.onTakeItem(player, map, atlas); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/hunternif/mc/impl/atlas/mixin/prod/MixinCartographyTableHandlerSlot.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package hunternif.mc.impl.atlas.mixin.prod; | ||
|
||
import hunternif.mc.impl.atlas.api.AtlasAPI; | ||
import hunternif.mc.impl.atlas.mixinhooks.CartographyTableHooks; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.inventory.Inventory; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.screen.CartographyTableScreenHandler; | ||
import net.minecraft.screen.ScreenHandlerContext; | ||
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.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(targets = "net.minecraft.screen.CartographyTableScreenHandler$4") | ||
class MixinCartographyTableScreenHandlerSlot { | ||
|
||
@Inject(method = "method_7680", at = @At("RETURN"), cancellable = true) | ||
void antiqueatlas_canInsert(ItemStack stack, CallbackInfoReturnable<Boolean> info) { | ||
info.setReturnValue(stack.getItem() == AtlasAPI.getAtlasItem() || info.getReturnValueZ()); | ||
} | ||
} | ||
|
||
@Mixin(targets = "net.minecraft.screen.CartographyTableScreenHandler$5") | ||
class MixinCartographyTableScreenHandlerResultSlot { | ||
|
||
CartographyTableScreenHandler antiqueatlas_handler; | ||
|
||
@Inject(method = "<init>", at = @At("TAIL")) | ||
void antiqueatlas_init(CartographyTableScreenHandler handler, Inventory inv, int a, int b, int c, ScreenHandlerContext context, CallbackInfo info) { | ||
antiqueatlas_handler = handler; | ||
} | ||
|
||
@Inject(method = "method_7667", at = @At("HEAD")) | ||
void antiqueatlas_onTakeItem(PlayerEntity player, ItemStack atlas, CallbackInfoReturnable<ItemStack> info) { | ||
if (atlas.getItem() == AtlasAPI.getAtlasItem()) { | ||
ItemStack map = antiqueatlas_handler.slots.get(0).getStack(); | ||
|
||
CartographyTableHooks.onTakeItem(player, map, atlas); | ||
} | ||
} | ||
} |
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