Browse Source

Add CraftTweaker support.

tags/1.12.2-v1.4.0
primetoxinz 2 years ago
parent
commit
d012b7efdf
8 changed files with 157 additions and 1 deletions
  1. +2
    -0
      .gitignore
  2. +5
    -1
      build.gradle
  3. +6
    -0
      src/main/java/com/legacy/aether/Aether.java
  4. +38
    -0
      src/main/java/com/legacy/aether/universal/crafttweaker/Accessory.java
  5. +14
    -0
      src/main/java/com/legacy/aether/universal/crafttweaker/AetherCraftTweakerPlugin.java
  6. +36
    -0
      src/main/java/com/legacy/aether/universal/crafttweaker/Enchanter.java
  7. +31
    -0
      src/main/java/com/legacy/aether/universal/crafttweaker/Freezer.java
  8. +25
    -0
      src/main/java/com/legacy/aether/universal/crafttweaker/RegisterAction.java

+ 2
- 0
.gitignore View File

@@ -20,3 +20,5 @@ build
# other
eclipse
run

classes

+ 5
- 1
build.gradle View File

@@ -19,7 +19,7 @@ compileJava {
}

minecraft {
version = "1.12.2-14.23.1.2562"
version = "1.12.2-14.23.4.2705"
runDir = "run"

mappings = "snapshot_20171003"
@@ -30,10 +30,14 @@ repositories {
maven {
url 'http://dvs1.progwml6.com/files/maven'
}
maven {
url "http://maven.blamejared.com"
}
}

dependencies {
deobfCompile "mezz.jei:jei_1.12.2:4.8.5.138"
deobfCompile "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.8.470"
}

processResources {


+ 6
- 0
src/main/java/com/legacy/aether/Aether.java View File

@@ -1,6 +1,8 @@
package com.legacy.aether;

import com.legacy.aether.universal.crafttweaker.AetherCraftTweakerPlugin;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
@@ -44,6 +46,10 @@ public class Aether
AetherAdvancements.initialization();
AetherNetworkingManager.preInitialization();

if(Loader.isModLoaded("crafttweaker")) {
AetherCraftTweakerPlugin.preInitialization();
}

CommonProxy.registerEvent(new AetherRegistryEvent());

proxy.preInitialization();


+ 38
- 0
src/main/java/com/legacy/aether/universal/crafttweaker/Accessory.java View File

@@ -0,0 +1,38 @@
package com.legacy.aether.universal.crafttweaker;


import com.legacy.aether.Aether;
import com.legacy.aether.api.accessories.AccessoryType;
import com.legacy.aether.api.accessories.AetherAccessory;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.IForgeRegistry;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

@ZenClass("mods.aether_legacy.Accessory")
public class Accessory {

public static final IForgeRegistry<AetherAccessory> accessories = GameRegistry.findRegistry(AetherAccessory.class);

private static final AccessoryType[] VALUES = AccessoryType.values();

private static AccessoryType getFromName(String accessory) {
for (AccessoryType value : VALUES) {
if (value.getDisplayName().equalsIgnoreCase(accessory)) {
return value;
}
}
return null;
}

@ZenMethod
public static void registerAccessory(IItemStack input, String accessory) {
CraftTweakerAPI.apply(new RegisterAction<>(accessories, new AetherAccessory(CraftTweakerMC.getItemStack(input), getFromName(accessory))));
}


}

+ 14
- 0
src/main/java/com/legacy/aether/universal/crafttweaker/AetherCraftTweakerPlugin.java View File

@@ -0,0 +1,14 @@
package com.legacy.aether.universal.crafttweaker;


import crafttweaker.CraftTweakerAPI;

public class AetherCraftTweakerPlugin {

public static void preInitialization() {
CraftTweakerAPI.registerClass(Accessory.class);
CraftTweakerAPI.registerClass(Enchanter.class);
CraftTweakerAPI.registerClass(Freezer.class);
}

}

+ 36
- 0
src/main/java/com/legacy/aether/universal/crafttweaker/Enchanter.java View File

@@ -0,0 +1,36 @@
package com.legacy.aether.universal.crafttweaker;


import com.legacy.aether.api.enchantments.AetherEnchantment;
import com.legacy.aether.api.enchantments.AetherEnchantmentFuel;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.IForgeRegistry;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

@ZenClass("mods.aether_legacy.Enchanter")
public class Enchanter {

public static final IForgeRegistry<AetherEnchantment> enchantments = GameRegistry.findRegistry(AetherEnchantment.class);
public static final IForgeRegistry<AetherEnchantmentFuel> enchantmentFuels = GameRegistry.findRegistry(AetherEnchantmentFuel.class);

@ZenMethod
public static void registerEnchantment(IItemStack input, IItemStack output, int timeRequired) {
CraftTweakerAPI.apply(new RegisterAction<>(enchantments, new AetherEnchantment(CraftTweakerMC.getItemStack(input), CraftTweakerMC.getItemStack(output), timeRequired)));
}

@ZenMethod
public static void registerEnchantment(IItemStack repair, int timeRequired) {
CraftTweakerAPI.apply(new RegisterAction<>(enchantments, new AetherEnchantment(CraftTweakerMC.getItemStack(repair), CraftTweakerMC.getItemStack(repair), timeRequired)));
}


@ZenMethod
public static void registerEnchanterFuel(IItemStack input, int timeGiven) {
CraftTweakerAPI.apply(new RegisterAction<>(enchantmentFuels, new AetherEnchantmentFuel(CraftTweakerMC.getItemStack(input), timeGiven)));
}

}

+ 31
- 0
src/main/java/com/legacy/aether/universal/crafttweaker/Freezer.java View File

@@ -0,0 +1,31 @@
package com.legacy.aether.universal.crafttweaker;


import com.legacy.aether.api.freezables.AetherFreezable;
import com.legacy.aether.api.freezables.AetherFreezableFuel;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.IForgeRegistry;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

@ZenClass("mods.aether_legacy.Freezer")
public class Freezer {

public static final IForgeRegistry<AetherFreezable> freezables = GameRegistry.findRegistry(AetherFreezable.class);
public static final IForgeRegistry<AetherFreezableFuel> freezableFuels = GameRegistry.findRegistry(AetherFreezableFuel.class);

@ZenMethod
public static void registerFreezable(IItemStack input, IItemStack output, int timeRequired) {
CraftTweakerAPI.apply(new RegisterAction<>(freezables, new AetherFreezable(CraftTweakerMC.getItemStack(input), CraftTweakerMC.getItemStack(output), timeRequired)));
}

@ZenMethod
public static void registerFreezerFuel(IItemStack input, int timeGiven) {
CraftTweakerAPI.apply(new RegisterAction<>(freezableFuels, new AetherFreezableFuel(CraftTweakerMC.getItemStack(input), timeGiven)));
}


}

+ 25
- 0
src/main/java/com/legacy/aether/universal/crafttweaker/RegisterAction.java View File

@@ -0,0 +1,25 @@
package com.legacy.aether.universal.crafttweaker;

import crafttweaker.IAction;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;

public class RegisterAction<T extends IForgeRegistryEntry<T>> implements IAction {
private IForgeRegistry<T> registry;
private T t;

public RegisterAction(IForgeRegistry<T> registry, T t) {
this.registry = registry;
this.t = t;
}

@Override
public void apply() {
registry.register(t);
}

@Override
public String describe() {
return t.toString();
}
}

Loading…
Cancel
Save