mirror of
https://github.com/GTNewHorizons/EnderCore.git
synced 2026-11-21 12:32:15 +00:00
Convert ASM code to mixin; Move void fog and Anvil max XP config tweak to Hodgepodge (#28)
Co-authored-by: Wilhelm Schuster <[email protected]>
This commit is contained in:
1 parent
120722e831
commit
ec259693d9
17 files changed
+166
-529
No files matched your search
+3
-3
@@ -1,10 +1,10 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.7.0:dev')
|
||||
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.0-GTNH:dev")
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.9.0:dev')
|
||||
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.50-GTNH:dev")
|
||||
compileOnly("curse.maven:cofh-core-69162:2388750-dev:dev")
|
||||
|
||||
// for testing
|
||||
//runtimeOnlyNonPublishable("com.github.GTNewHorizons:EnderIO:2.9.26:dev") { transitive = false }
|
||||
//runtimeOnlyNonPublishable("com.github.GTNewHorizons:EnderIO:2.10.12:dev") { transitive = false }
|
||||
}
|
||||
+41
-6
@@ -39,10 +39,34 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
# Enables modern Java syntax support. Valid values:
|
||||
# - false: No modern syntax, Java 8 only
|
||||
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
|
||||
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
|
||||
# - modern: Native modern Java bytecode, no downgrading
|
||||
enableModernJavaSyntax = false
|
||||
|
||||
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
|
||||
# and should *not* be used in most situations. -1 disables this.
|
||||
# forceToolchainVersion = -1
|
||||
|
||||
# Target JVM version for JVM Downgrader bytecode downgrading.
|
||||
# Only used when enableModernJavaSyntax = jvmDowngrader
|
||||
# downgradeTargetVersion = 8
|
||||
|
||||
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
|
||||
# Classes will be available in META-INF/versions/N/ for each version N in this list.
|
||||
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
|
||||
# jvmDowngraderMultiReleaseVersions = 21,25
|
||||
|
||||
# Specifies how JVM Downgrader API stubs are provided. Options:
|
||||
# - shade: Shade minimized stubs into the jar
|
||||
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
|
||||
# - external: Another dependency provides stubs (no constraint, no warning)
|
||||
# - (empty): Warning reminding you to configure stubs
|
||||
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
|
||||
# jvmDowngraderStubsProvider =
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
enableGenericInjection = false
|
||||
@@ -74,7 +98,7 @@ apiPackage = api
|
||||
accessTransformersFile =
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = false
|
||||
usesMixins = true
|
||||
|
||||
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
|
||||
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
|
||||
@@ -82,13 +106,15 @@ usesMixins = false
|
||||
separateMixinSourceSet =
|
||||
|
||||
# Adds some debug arguments like verbose output and class export.
|
||||
usesMixinDebug = false
|
||||
usesMixinDebug = true
|
||||
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
mixinsPackage =
|
||||
# Specify the package that contains all of your Mixins. The package must exist or
|
||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
||||
# it must match with this or the build will fail.
|
||||
mixinsPackage = common.mixins
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
# This parameter is for legacy compatibility only
|
||||
@@ -163,6 +189,12 @@ curseForgeRelations =
|
||||
# projects. New projects should not use this parameter.
|
||||
# customArchiveBaseName =
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
||||
# runClientWorkingDirectory = run/client
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
||||
# runServerWorkingDirectory = run/server
|
||||
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
@@ -192,3 +224,6 @@ curseForgeRelations =
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# ideaCheckSpotlessOnBuild = true
|
||||
|
||||
# Non-GTNH properties
|
||||
org.gradle.configuration-cache = true
|
||||
org.gradle.parallel = true
|
||||
@@ -0,0 +1,12 @@
|
||||
#This file is generated by updateDaemonJvm
|
||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
|
||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
|
||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
|
||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
|
||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/46949723aaa20c7b64d7ecfed7207034/redirect
|
||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d6690dfd71c4c91e08577437b5b2beb0/redirect
|
||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
|
||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
|
||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3cd7045fca9a72cd9bc7d14a385e594c/redirect
|
||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/552c7bffe0370c66410a51c55985b511/redirect
|
||||
toolchainVersion=25
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -172,7 +171,6 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -212,8 +210,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+1
-2
@@ -70,11 +70,10 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.43'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.13'
|
||||
}
|
||||
|
||||
|
||||
@@ -44,16 +44,6 @@ public class ConfigHandler extends AbstractConfigHandler implements ITweakConfig
|
||||
@NoSync
|
||||
public static int showDurabilityTooltips = 1;
|
||||
|
||||
@Config
|
||||
@Comment({ "Removes all void fog.", "0 = off", "1 = DEFAULT worldtype only", "2 = all world types" })
|
||||
@NoSync
|
||||
@Range(min = 0, max = 2)
|
||||
public static int disableVoidFog = 1;
|
||||
|
||||
@Config
|
||||
@Comment("The max amount of XP levels an anvil recipe can use.")
|
||||
public static int anvilMaxLevel = 40;
|
||||
|
||||
@Config
|
||||
@Comment("The way the game should have been made (Yes this is the fireworks thing).")
|
||||
public static boolean betterAchievements = true;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.enderio.core.common.mixins.early;
|
||||
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
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 com.enderio.core.common.event.ArrowUpdateEvent;
|
||||
|
||||
@Mixin(EntityArrow.class)
|
||||
public class MixinEntityArrow_UpdateEvent {
|
||||
|
||||
@Inject(
|
||||
method = "onUpdate",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;onUpdate()V", shift = At.Shift.AFTER))
|
||||
private void fireUpdateEvent(CallbackInfo ci) {
|
||||
MinecraftForge.EVENT_BUS.post(new ArrowUpdateEvent((EntityArrow) (Object) this));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.enderio.core.common.mixins.early;
|
||||
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import com.enderio.core.common.event.ItemStackEvent;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
|
||||
@Mixin(ItemStack.class)
|
||||
public class MixinItemStack_RarityEvent {
|
||||
|
||||
@ModifyReturnValue(method = "getRarity", at = @At("RETURN"))
|
||||
private EnumRarity fireItemRarityEvent(EnumRarity original) {
|
||||
ItemStackEvent.ItemRarityEvent event = new ItemStackEvent.ItemRarityEvent((ItemStack) (Object) this, original);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.rarity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.enderio.core.common.mixins.early;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import com.enderio.core.common.event.ItemStackEvent;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
|
||||
@Mixin(Item.class)
|
||||
public class MixinItem_EnchantabilityEvent {
|
||||
|
||||
@ModifyReturnValue(
|
||||
method = "getItemEnchantability(Lnet/minecraft/item/ItemStack;)I",
|
||||
at = @At("RETURN"),
|
||||
remap = false)
|
||||
private int fireItemEnchantabilityEvent(int original, ItemStack stack) {
|
||||
ItemStackEvent.ItemEnchantabilityEvent event = new ItemStackEvent.ItemEnchantabilityEvent(stack, original);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.enchantability;
|
||||
}
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
package com.enderio.core.common.transform;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ContainerFurnace;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.enderio.core.common.config.ConfigHandler;
|
||||
import com.enderio.core.common.event.ArrowUpdateEvent;
|
||||
import com.enderio.core.common.event.ItemStackEvent.ItemEnchantabilityEvent;
|
||||
import com.enderio.core.common.event.ItemStackEvent.ItemRarityEvent;
|
||||
|
||||
public class EnderCoreMethods {
|
||||
|
||||
public static boolean hasVoidParticles(WorldType type, boolean hasSky) {
|
||||
if (ConfigHandler.disableVoidFog == 0) {
|
||||
return type != WorldType.FLAT && !hasSky;
|
||||
} else if (ConfigHandler.disableVoidFog == 1) {
|
||||
return type != WorldType.FLAT && type != WorldType.DEFAULT && !hasSky;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getMaxAnvilCost() {
|
||||
return ConfigHandler.anvilMaxLevel;
|
||||
}
|
||||
|
||||
public static int getItemEnchantability(ItemStack stack, int base) {
|
||||
ItemEnchantabilityEvent event = new ItemEnchantabilityEvent(stack, base);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.enchantability;
|
||||
}
|
||||
|
||||
public static EnumRarity getItemRarity(ItemStack stack) {
|
||||
ItemRarityEvent event = new ItemRarityEvent(stack, stack.getItem().getRarity(stack));
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.rarity;
|
||||
}
|
||||
|
||||
public static void onArrowUpdate(EntityArrow entity) {
|
||||
MinecraftForge.EVENT_BUS.post(new ArrowUpdateEvent(entity));
|
||||
}
|
||||
|
||||
// mostly copied from ContainerFurnace
|
||||
public static ItemStack transferStackInSlot(ContainerFurnace inv, EntityPlayer p_82846_1_, int p_82846_2_) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot) inv.inventorySlots.get(p_82846_2_);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (p_82846_2_ == 2) {
|
||||
if (!mergeItemStack(inv, itemstack1, 3, 39, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
} else if (p_82846_2_ != 1 && p_82846_2_ != 0) {
|
||||
// I have moved this check to the beginning
|
||||
if (TileEntityFurnace.isItemFuel(itemstack1)) {
|
||||
if (!mergeItemStack(inv, itemstack1, 1, 2, false)) {
|
||||
// Nest this inside so that if the above fails it will
|
||||
// attempt to do the input slot
|
||||
if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null) {
|
||||
if (!mergeItemStack(inv, itemstack1, 0, 1, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null) {
|
||||
if (!mergeItemStack(inv, itemstack1, 0, 1, false)) {
|
||||
return null;
|
||||
}
|
||||
} else if (p_82846_2_ >= 3 && p_82846_2_ < 30) {
|
||||
if (!mergeItemStack(inv, itemstack1, 30, 39, false)) {
|
||||
return null;
|
||||
}
|
||||
} else if (p_82846_2_ >= 30 && p_82846_2_ < 39 && !mergeItemStack(inv, itemstack1, 3, 30, false)) {
|
||||
return null;
|
||||
}
|
||||
} else if (!mergeItemStack(inv, itemstack1, 3, 39, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(p_82846_1_, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
// copied from Container
|
||||
private static boolean mergeItemStack(Container inv, ItemStack p_75135_1_, int p_75135_2_, int p_75135_3_,
|
||||
boolean p_75135_4_) {
|
||||
boolean flag1 = false;
|
||||
int k = p_75135_2_;
|
||||
|
||||
if (p_75135_4_) {
|
||||
k = p_75135_3_ - 1;
|
||||
}
|
||||
|
||||
Slot slot;
|
||||
ItemStack itemstack1;
|
||||
|
||||
if (p_75135_1_.isStackable()) {
|
||||
while (p_75135_1_.stackSize > 0 && (!p_75135_4_ && k < p_75135_3_ || p_75135_4_ && k >= p_75135_2_)) {
|
||||
slot = (Slot) inv.inventorySlots.get(k);
|
||||
itemstack1 = slot.getStack();
|
||||
|
||||
if (itemstack1 != null && itemstack1.getItem() == p_75135_1_.getItem()
|
||||
&& (!p_75135_1_.getHasSubtypes() || p_75135_1_.getItemDamage() == itemstack1.getItemDamage())
|
||||
&& ItemStack.areItemStackTagsEqual(p_75135_1_, itemstack1)) {
|
||||
int l = itemstack1.stackSize + p_75135_1_.stackSize;
|
||||
|
||||
if (l <= p_75135_1_.getMaxStackSize()) {
|
||||
p_75135_1_.stackSize = 0;
|
||||
itemstack1.stackSize = l;
|
||||
slot.onSlotChanged();
|
||||
flag1 = true;
|
||||
} else if (itemstack1.stackSize < p_75135_1_.getMaxStackSize()) {
|
||||
p_75135_1_.stackSize -= p_75135_1_.getMaxStackSize() - itemstack1.stackSize;
|
||||
itemstack1.stackSize = p_75135_1_.getMaxStackSize();
|
||||
slot.onSlotChanged();
|
||||
flag1 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_75135_4_) {
|
||||
--k;
|
||||
} else {
|
||||
++k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p_75135_1_.stackSize > 0) {
|
||||
if (p_75135_4_) {
|
||||
k = p_75135_3_ - 1;
|
||||
} else {
|
||||
k = p_75135_2_;
|
||||
}
|
||||
|
||||
while (!p_75135_4_ && k < p_75135_3_ || p_75135_4_ && k >= p_75135_2_) {
|
||||
slot = (Slot) inv.inventorySlots.get(k);
|
||||
itemstack1 = slot.getStack();
|
||||
|
||||
if (itemstack1 == null) {
|
||||
slot.putStack(p_75135_1_.copy());
|
||||
slot.onSlotChanged();
|
||||
p_75135_1_.stackSize = 0;
|
||||
flag1 = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (p_75135_4_) {
|
||||
--k;
|
||||
} else {
|
||||
++k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flag1;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,21 @@
|
||||
package com.enderio.core.common.transform;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
|
||||
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@MCVersion("1.7.10")
|
||||
@IFMLLoadingPlugin.SortingIndex(Integer.MAX_VALUE)
|
||||
// we want deobf no matter what
|
||||
public class EnderCorePlugin implements IFMLLoadingPlugin {
|
||||
|
||||
public static boolean runtimeDeobfEnabled = false;
|
||||
public static final Logger logger = LogManager.getLogger("EnderCore");
|
||||
public class EnderCorePlugin implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[] { "com.enderio.core.common.transform.EnderCoreTransformer" };
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,12 +29,24 @@ public class EnderCorePlugin implements IFMLLoadingPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
runtimeDeobfEnabled = (Boolean) data.get("runtimeDeobfuscationEnabled");
|
||||
}
|
||||
public void injectData(Map<String, Object> data) {}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMixinConfig() {
|
||||
return "mixins.endercore.early.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins(Set<String> loadedCoreMods) {
|
||||
final List<String> mixins = new ArrayList<>();
|
||||
mixins.add("MixinItem_EnchantabilityEvent");
|
||||
mixins.add("MixinItemStack_RarityEvent");
|
||||
mixins.add("MixinEntityArrow_UpdateEvent");
|
||||
return mixins;
|
||||
}
|
||||
}
|
||||
@@ -1,305 +0,0 @@
|
||||
package com.enderio.core.common.transform;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.ALOAD;
|
||||
import static org.objectweb.asm.Opcodes.ARETURN;
|
||||
import static org.objectweb.asm.Opcodes.ILOAD;
|
||||
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
|
||||
import static org.objectweb.asm.Opcodes.IRETURN;
|
||||
import static org.objectweb.asm.Opcodes.ISTORE;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.IntInsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
|
||||
@MCVersion(value = "1.7.10")
|
||||
public class EnderCoreTransformer implements IClassTransformer {
|
||||
|
||||
protected static class ObfSafeName {
|
||||
|
||||
private String deobf, srg;
|
||||
|
||||
public ObfSafeName(String deobf, String srg) {
|
||||
this.deobf = deobf;
|
||||
this.srg = srg;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return EnderCorePlugin.runtimeDeobfEnabled ? srg : deobf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof String) {
|
||||
return obj.equals(deobf) || obj.equals(srg);
|
||||
} else if (obj instanceof ObfSafeName) {
|
||||
return ((ObfSafeName) obj).deobf.equals(deobf) && ((ObfSafeName) obj).srg.equals(srg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// no hashcode because I'm naughty
|
||||
}
|
||||
|
||||
protected static abstract class Transform {
|
||||
|
||||
abstract void transform(Iterator<MethodNode> methods);
|
||||
}
|
||||
|
||||
private static final String worldTypeClass = "net.minecraft.world.WorldType";
|
||||
private static final ObfSafeName voidFogMethod = new ObfSafeName("hasVoidParticles", "func_76564_j");
|
||||
private static final String voidFogMethodSig = "(Lnet/minecraft/world/WorldType;Z)Z";
|
||||
|
||||
private static final String anvilContainerClass = "net.minecraft.inventory.ContainerRepair";
|
||||
private static final ObfSafeName anvilContainerMethod = new ObfSafeName("updateRepairOutput", "func_82848_d");
|
||||
|
||||
private static final String anvilGuiClass = "net.minecraft.client.gui.GuiRepair";
|
||||
private static final ObfSafeName anvilGuiMethod = new ObfSafeName(
|
||||
"drawGuiContainerForegroundLayer",
|
||||
"func_146979_b");
|
||||
|
||||
private static final String enchantHelperClass = "net.minecraft.enchantment.EnchantmentHelper";
|
||||
private static final String enchantHelperMethodSig = "(Lnet/minecraft/item/ItemStack;I)I";
|
||||
private static final ObfSafeName buildEnchantListMethod = new ObfSafeName("buildEnchantmentList", "func_77513_b");
|
||||
private static final ObfSafeName calcEnchantabilityMethod = new ObfSafeName(
|
||||
"calcItemStackEnchantability",
|
||||
"func_77514_a");
|
||||
|
||||
private static final String itemStackClass = "net.minecraft.item.ItemStack";
|
||||
private static final ObfSafeName itemStackMethod = new ObfSafeName("getRarity", "func_77953_t");
|
||||
private static final String itemStackMethodSig = "(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/EnumRarity;";
|
||||
|
||||
private static final String entityArrowClass = "net.minecraft.entity.projectile.EntityArrow";
|
||||
private static final ObfSafeName entityArrowMethod = new ObfSafeName("onUpdate", "func_70071_h_");
|
||||
private static final String entityArrowMethodSig = "(Lnet/minecraft/entity/projectile/EntityArrow;)V";
|
||||
|
||||
private static final String containerFurnaceClass = "net.minecraft.inventory.ContainerFurnace";
|
||||
private static final ObfSafeName containerFurnaceMethod = new ObfSafeName("transferStackInSlot", "func_82846_b");
|
||||
private static final String containerFurnaceMethodSig = "(Lnet/minecraft/inventory/ContainerFurnace;Lnet/minecraft/entity/player/EntityPlayer;I)Lnet/minecraft/item/ItemStack;";
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
// Void fog removal
|
||||
if (transformedName.equals(worldTypeClass)) {
|
||||
basicClass = transform(basicClass, worldTypeClass, voidFogMethod, new Transform() {
|
||||
|
||||
@Override
|
||||
void transform(Iterator<MethodNode> methods) {
|
||||
while (methods.hasNext()) {
|
||||
MethodNode m = methods.next();
|
||||
if (voidFogMethod.equals(m.name)) {
|
||||
m.localVariables.clear();
|
||||
m.instructions.clear();
|
||||
|
||||
m.instructions.add(new VarInsnNode(ALOAD, 0));
|
||||
m.instructions.add(new VarInsnNode(ILOAD, 1));
|
||||
m.instructions.add(
|
||||
new MethodInsnNode(
|
||||
INVOKESTATIC,
|
||||
"com/enderio/core/common/transform/EnderCoreMethods",
|
||||
"hasVoidParticles",
|
||||
voidFogMethodSig,
|
||||
false));
|
||||
m.instructions.add(new InsnNode(IRETURN));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Anvil max level
|
||||
else if (transformedName.equals(anvilContainerClass) || transformedName.equals(anvilGuiClass)) {
|
||||
basicClass = transform(basicClass, anvilContainerClass, anvilContainerMethod, new Transform() {
|
||||
|
||||
@Override
|
||||
void transform(Iterator<MethodNode> methods) {
|
||||
while (methods.hasNext()) {
|
||||
MethodNode m = methods.next();
|
||||
if (anvilContainerMethod.equals(m.name) || anvilGuiMethod.equals(m.name)) {
|
||||
for (int i = 0; i < m.instructions.size(); i++) {
|
||||
AbstractInsnNode next = m.instructions.get(i);
|
||||
|
||||
next = m.instructions.get(i);
|
||||
if (next instanceof IntInsnNode && ((IntInsnNode) next).operand == 40) {
|
||||
m.instructions.set(
|
||||
next,
|
||||
new MethodInsnNode(
|
||||
INVOKESTATIC,
|
||||
"com/enderio/core/common/transform/EnderCoreMethods",
|
||||
"getMaxAnvilCost",
|
||||
"()I",
|
||||
false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Item Enchantability Event
|
||||
else if (transformedName.equals(enchantHelperClass)) {
|
||||
final Map<String, int[]> data = new HashMap<String, int[]>();
|
||||
data.put(buildEnchantListMethod.getName(), new int[] { 1, 4 });
|
||||
data.put(calcEnchantabilityMethod.getName(), new int[] { 3, 5 });
|
||||
Transform transformer = new Transform() {
|
||||
|
||||
@Override
|
||||
void transform(Iterator<MethodNode> methods) {
|
||||
while (methods.hasNext()) {
|
||||
MethodNode m = methods.next();
|
||||
if (data.keySet().contains(m.name)) {
|
||||
int[] indeces = data.get(m.name);
|
||||
for (int i = 0; i < m.instructions.size(); i++) {
|
||||
AbstractInsnNode next = m.instructions.get(i);
|
||||
if (next instanceof VarInsnNode) {
|
||||
VarInsnNode varNode = (VarInsnNode) next;
|
||||
if (varNode.getOpcode() == ISTORE && varNode.var == indeces[1]) {
|
||||
InsnList toAdd = new InsnList();
|
||||
toAdd.add(new VarInsnNode(ALOAD, indeces[0]));
|
||||
toAdd.add(new VarInsnNode(ILOAD, indeces[1]));
|
||||
toAdd.add(
|
||||
new MethodInsnNode(
|
||||
INVOKESTATIC,
|
||||
"com/enderio/core/common/transform/EnderCoreMethods",
|
||||
"getItemEnchantability",
|
||||
enchantHelperMethodSig,
|
||||
false));
|
||||
toAdd.add(new VarInsnNode(ISTORE, indeces[1]));
|
||||
m.instructions.insert(next, toAdd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
basicClass = transform(basicClass, enchantHelperClass, buildEnchantListMethod, transformer);
|
||||
}
|
||||
// ItemRarity Event
|
||||
else if (transformedName.equals(itemStackClass)) {
|
||||
basicClass = transform(basicClass, itemStackClass, itemStackMethod, new Transform() {
|
||||
|
||||
@Override
|
||||
void transform(Iterator<MethodNode> methods) {
|
||||
while (methods.hasNext()) {
|
||||
MethodNode m = methods.next();
|
||||
if (itemStackMethod.equals(m.name)) {
|
||||
m.instructions.clear();
|
||||
|
||||
m.instructions.add(new VarInsnNode(ALOAD, 0));
|
||||
m.instructions.add(
|
||||
new MethodInsnNode(
|
||||
INVOKESTATIC,
|
||||
"com/enderio/core/common/transform/EnderCoreMethods",
|
||||
"getItemRarity",
|
||||
itemStackMethodSig,
|
||||
false));
|
||||
m.instructions.add(new InsnNode(ARETURN));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// ArrowUpdate Event
|
||||
else if (transformedName.equals(entityArrowClass)) {
|
||||
basicClass = transform(basicClass, entityArrowClass, entityArrowMethod, new Transform() {
|
||||
|
||||
@Override
|
||||
void transform(Iterator<MethodNode> methods) {
|
||||
while (methods.hasNext()) {
|
||||
MethodNode m = methods.next();
|
||||
if (entityArrowMethod.equals(m.name)) {
|
||||
for (int i = 0; i < m.instructions.size(); i++) {
|
||||
AbstractInsnNode next = m.instructions.get(i);
|
||||
if (next instanceof MethodInsnNode) {
|
||||
InsnList toAdd = new InsnList();
|
||||
toAdd.add(new VarInsnNode(ALOAD, 0));
|
||||
toAdd.add(
|
||||
new MethodInsnNode(
|
||||
INVOKESTATIC,
|
||||
"com/enderio/core/common/transform/EnderCoreMethods",
|
||||
"onArrowUpdate",
|
||||
entityArrowMethodSig,
|
||||
false));
|
||||
m.instructions.insert(next, toAdd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Furnace Shift Click Fix
|
||||
else if (transformedName.equals(containerFurnaceClass)) {
|
||||
basicClass = transform(basicClass, containerFurnaceClass, containerFurnaceMethod, new Transform() {
|
||||
|
||||
@Override
|
||||
void transform(Iterator<MethodNode> methods) {
|
||||
while (methods.hasNext()) {
|
||||
MethodNode m = methods.next();
|
||||
if (containerFurnaceMethod.equals(m.name)) {
|
||||
m.instructions.clear();
|
||||
|
||||
m.instructions.add(new VarInsnNode(ALOAD, 0));
|
||||
m.instructions.add(new VarInsnNode(ALOAD, 1));
|
||||
m.instructions.add(new VarInsnNode(ILOAD, 2));
|
||||
m.instructions.add(
|
||||
new MethodInsnNode(
|
||||
INVOKESTATIC,
|
||||
"com/enderio/core/common/transform/EnderCoreMethods",
|
||||
"transferStackInSlot",
|
||||
containerFurnaceMethodSig,
|
||||
false));
|
||||
m.instructions.add(new InsnNode(ARETURN));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
protected final byte[] transform(byte[] classBytes, String className, ObfSafeName methodName,
|
||||
Transform transformer) {
|
||||
EnderCorePlugin.logger.info("Transforming Class [" + className + "], Method [" + methodName.getName() + "]");
|
||||
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader(classBytes);
|
||||
classReader.accept(classNode, 0);
|
||||
|
||||
Iterator<MethodNode> methods = classNode.methods.iterator();
|
||||
|
||||
transformer.transform(methods);
|
||||
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
classNode.accept(cw);
|
||||
EnderCorePlugin.logger.info("Transforming " + className + " Finished.");
|
||||
return cw.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.5-GTNH",
|
||||
"package": "com.enderio.core.common.mixins.early",
|
||||
"refmap": "mixins.endercore.refmap.json",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.5-GTNH",
|
||||
"refmap": "mixins.endercore.refmap.json",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
}
|
||||
Reference in new issue
Block a user