Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ dependencies {
if (project.use_mixins.toBoolean()) {
implementation 'zone.rong:mixinbooter:7.1'
}
implementation 'com.cleanroommc:configanytime:2.0'

implementation files('libs/CraftTweaker2-MC1120-Mod-JEI-1.12-4.1.20.670-deobf.jar')

implementation rfg.deobf("curse.maven:Baubles-227083:2518667")
implementation rfg.deobf("curse.maven:zenutils-401178:5162113-sources-5162114")
implementation rfg.deobf("curse.maven:modtweaker-220954:3488553")
Expand Down
85 changes: 40 additions & 45 deletions src/main/java/ink/ikx/rt/api/mods/botania/ICocoon.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,93 @@

import com.google.common.collect.Maps;
import crafttweaker.CraftTweakerAPI;
import youyihj.zenutils.api.zenscript.SidedZenRegister;
import crafttweaker.api.entity.IEntityDefinition;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import ink.ikx.rt.Main;
import ink.ikx.rt.api.mods.botania.function.DynamicSpawnTable;
import ink.ikx.rt.api.mods.botania.function.ICocoonTileEntity;
import ink.ikx.rt.impl.mods.botania.cocoon.MCCocoon;

import java.util.Map;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.EntityEntry;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenMethod;
import youyihj.zenutils.api.zenscript.SidedZenRegister;

import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@SidedZenRegister(modDeps = "botania")
@ZenClass("mods.randomtweaker.botania.ICocoon")
public abstract class ICocoon {
public interface ICocoon {

@Nullable
@ZenMethod
public static ICocoon registerSpawn(@Nonnull String name, IItemStack stack, Map<IEntityDefinition, Double> spawnTab, @Optional DynamicSpawnTable dynamicSpawnTab) {
ICocoon cocoon;
if (!Main.CUSTOM_COCOONS_SPAWN.containsKey(name)) {
Map<EntityEntry, Double> tab = Maps.newHashMap();
spawnTab.forEach((entity, probably) -> {
if (Objects.nonNull(entity)) {
if (entity.getInternal() instanceof EntityEntry) {
tab.put((EntityEntry) entity.getInternal(), probably);
} else {
CraftTweakerAPI.logError("The internal type of " + entity.getId() + " is not EntityEntry!");
}
}
});

cocoon = MCCocoon.create(name, CraftTweakerMC.getItemStack(stack), tab, dynamicSpawnTab);
static ICocoon registerSpawn(@Nonnull String name, IItemStack stack, Map<IEntityDefinition, Double> spawnTab, @Optional DynamicSpawnTable dynamicSpawnTab) {
Map<EntityEntry, Double> tab = convertToEntityEntry(spawnTab);
ICocoon cocoon = MCCocoon.create(name, CraftTweakerMC.getItemStack(stack), tab, dynamicSpawnTab);

if (Objects.isNull(cocoon)) {
CraftTweakerAPI.logError("Registering " + name + " failed");
return null;
}
} else {
cocoon = getInstanceByName(name);

if (Objects.nonNull(dynamicSpawnTab)) {
cocoon.setDynamicSpawnTable(dynamicSpawnTab);
}
if (cocoon == null) {
CraftTweakerAPI.logError("Registering " + name + " failed");
return null;
}

Main.CUSTOM_COCOONS_SPAWN.put(name, cocoon);
return cocoon;
}

@Nullable
@ZenMethod
public static ICocoon getInstanceByStack(IItemStack stack) {
static ICocoon getSpawnWhenEmpty() {
return Main.CUSTOM_COCOONS_SPAWN.get("default");
}

@Nullable
@ZenMethod
static ICocoon getInstanceByStack(IItemStack stack) {
return getInstanceByStack(CraftTweakerMC.getItemStack(stack));
}

@ZenMethod
public static ICocoon getInstanceByName(String name) {
static ICocoon getInstanceByName(String name) {
return Main.CUSTOM_COCOONS_SPAWN.get(name);
}

@Nullable
public static ICocoon getInstanceByStack(ItemStack stack) {
static ICocoon getInstanceByStack(ItemStack stack) {
return Main.CUSTOM_COCOONS_SPAWN.values().stream().filter(cocoon -> cocoon.match(stack)).findFirst().orElse(null);
}

public abstract ItemStack getStack();
static Map<EntityEntry, Double> convertToEntityEntry(Map<IEntityDefinition, Double> originalMap) {
Map<EntityEntry, Double> tab = Maps.newHashMap();
originalMap.forEach((entity, probably) -> {
if (entity != null) {
if (entity.getInternal() instanceof EntityEntry) {
tab.put((EntityEntry) entity.getInternal(), probably);
} else {
CraftTweakerAPI.logError("The internal type of " + entity.getId() + " is not EntityEntry!");
}
}
});
return tab;
}

public abstract boolean match(ItemStack stack);
ItemStack getStack();

public abstract DynamicSpawnTable getDynamicSpawnTable();
boolean match(ItemStack stack);

public abstract Map<EntityEntry, Double> getSpawnTab();
DynamicSpawnTable getDynamicSpawnTable();

public abstract void setDynamicSpawnTable(DynamicSpawnTable dynamicSpawn);
Map<EntityEntry, Double> getSpawnTab();

public abstract double getProbablyByEntity(EntityEntry entity);
double getProbabilityByEntity(EntityEntry entity);

public abstract String getDynamicResult(ItemStack stack, EntityPlayer player, ICocoonTileEntity tile);
String getDynamicResult(ItemStack stack, EntityPlayer player, ICocoonTileEntity tile);

@ZenMethod
@ZenGetter("name")
public abstract String getName();
String getName();

}
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package ink.ikx.rt.api.mods.botania.event;

import youyihj.zenutils.api.zenscript.SidedZenRegister;
import crafttweaker.api.entity.IEntityItem;
import crafttweaker.api.event.IEventCancelable;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import ink.ikx.rt.api.mods.botania.ITileAlfPortal;
import ink.ikx.rt.impl.internal.utils.InternalUtils;
import ink.ikx.rt.impl.mods.botania.event.AlfPortalDroppedEvent;

import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenMethod;
import stanhebben.zenscript.annotations.ZenSetter;
import youyihj.zenutils.api.zenscript.SidedZenRegister;

import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;


Expand Down Expand Up @@ -51,9 +49,6 @@ public void addOutput(IItemStack output) {

@ZenMethod
public void setOutput(IItemStack[] output) {
if (Objects.isNull(output)) {
return;
}
event.setOutput(Arrays.stream(CraftTweakerMC.getItemStacks(output)).collect(Collectors.toList()));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
package ink.ikx.rt.api.mods.botania.render;

import youyihj.zenutils.api.zenscript.SidedZenRegister;

import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.common.Botania;
import youyihj.zenutils.api.zenscript.SidedZenRegister;


@SidedZenRegister(modDeps = "botania")
@ZenClass("mods.randomtweaker.botania.IBotaniaFXHelper")
public abstract class IBotaniaFXHelper {

@ZenMethod
public static void setWispFXDistanceLimit(boolean limit) {
Botania.proxy.setWispFXDistanceLimit(limit);
}

@ZenMethod
public static void setWispFXDepthTest(boolean depth) {
Botania.proxy.setWispFXDepthTest(depth);
}

@ZenMethod
public static void setSparkleFXNoClip(boolean noclip) {
Botania.proxy.setSparkleFXNoClip(noclip);
}

@ZenMethod
public static void setSparkleFXCorrupt(boolean corrupt) {
Botania.proxy.setSparkleFXCorrupt(corrupt);
}

@ZenMethod
public static void sparkleFX(double x, double y, double z, float r, float g, float b, float size, int m) {
sparkleFX(x, y, z, r, g, b, size, m, false);
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/ink/ikx/rt/api/mods/tconstruct/IBook.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package ink.ikx.rt.api.mods.tconstruct;

import com.google.common.base.Preconditions;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import youyihj.zenutils.api.zenscript.SidedZenRegister;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import ink.ikx.rt.Main;

import ink.ikx.rt.impl.internal.config.RTConfig;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import youyihj.zenutils.api.zenscript.SidedZenRegister;

/**
* Created by IntelliJ IDEA.
Expand All @@ -23,19 +24,26 @@ public abstract class IBook {

@ZenMethod
public static void addHiddenMaterial(String material) {
checkConfig();
CraftTweakerAPI.apply(new AddHiddenMaterialAction(material));
}

@ZenMethod
public static void changeMaterialItem(String material, IItemStack item) {
checkConfig();
CraftTweakerAPI.apply(new ChangeMaterialItem(material, item));
}

@ZenMethod
public static void setMaterialPriority(String material, int priority) {
checkConfig();
CraftTweakerAPI.apply(new SetMaterialPriority(material, priority));
}

private static void checkConfig() {
Preconditions.checkArgument(RTConfig.Tconstruct.iconModification, "Please change Tconstruct iconModification config to true.");
}

public static class AddHiddenMaterialAction implements IAction {

private final String material;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import crafttweaker.api.entity.attribute.IEntityAttributeModifier;
import crafttweaker.api.item.IIngredient;
import crafttweaker.util.IEventHandler;

import ink.ikx.rt.impl.internal.config.RTConfig;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenExpansion;
import stanhebben.zenscript.annotations.ZenMethod;
Expand Down Expand Up @@ -63,5 +63,17 @@ public void apply() {
public String describe() {
return "";
}

@Override
public boolean validate() {
return RTConfig.RandomTweaker.itemAttributeModification;
}

@Override
public String describeInvalid() {
return "Please change itemAttributeModification config to true";
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import ink.ikx.rt.classTransforms.mods.astralsorcery.ASMTileAttunementAltar;
import ink.ikx.rt.classTransforms.mods.tconstruct.ASMAbstractMaterialSectionTransformer;
import ink.ikx.rt.classTransforms.vanilla.ASMItemStack;
import ink.ikx.rt.impl.internal.config.RTConfig;
import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -17,7 +19,7 @@ public class RandomTweakerClassTransformer implements IClassTransformer {

private static final Logger LOGGER = LogManager.getLogger();

private static final boolean debug = true;
private static final boolean debug = FMLLaunchHandler.isDeobfuscatedEnvironment();

protected static ClassWriter createClassWriter(@SuppressWarnings("SameParameterValue") boolean debug) {
return new RandomTweakerClassWriter(debug ? 0 : ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
Expand Down Expand Up @@ -51,19 +53,21 @@ protected static byte[] tryGetAsmResult(

@Override
public byte[] transform(String name, String transformedName, byte[] basicClass) {
if (transformedName.equals("hellfirepvp.astralsorcery.common.tile.TileAttunementAltar")) {
if (transformedName.startsWith("ink.ikx.rt"))
return basicClass;
if (RTConfig.Astralsorcery.attunementModification && "hellfirepvp.astralsorcery.common.tile.TileAttunementAltar".equals(transformedName)) {
LOGGER.info("transforming class {} ({})", transformedName, name);
ClassWriter classWriter = createClassWriter(false);
ASMTileAttunementAltar asm = new ASMTileAttunementAltar(ASM5, classWriter);
return tryGetAsmResult("astral sorcery", transformedName, basicClass, asm, classWriter);
}
if (transformedName.equals("slimeknights.tconstruct.library.book.sectiontransformer.AbstractMaterialSectionTransformer")) {
if (RTConfig.Tconstruct.iconModification && "slimeknights.tconstruct.library.book.sectiontransformer.AbstractMaterialSectionTransformer".equals(transformedName)) {
LOGGER.info("transforming class {} ({})", transformedName, name);
ClassWriter classWriter = createClassWriter(false);
ASMAbstractMaterialSectionTransformer asm = new ASMAbstractMaterialSectionTransformer(ASM5, classWriter);
return tryGetAsmResult("tinkers construct", transformedName, basicClass, asm, classWriter);
}
if (transformedName.equals("net.minecraft.item.ItemStack")) {
if (RTConfig.RandomTweaker.itemAttributeModification && "net.minecraft.item.ItemStack".equals(transformedName)) {
LOGGER.info("transforming class {} ({})", transformedName, name);
ClassWriter classWriter = createDefaultClassWriter(false);
ASMItemStack asm = new ASMItemStack(ASM5, classWriter, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@
public class AttunementAltarMethodReflections {

public static void onAttunementStart(Entity entity, IConstellation constellation) {
if (!RTConfig.Astralsorcery.attunementModification || entity == null) {
if (entity == null) {
return;
}
AttunementStartEvent event = new AttunementStartEvent(entity, entity.getEntityWorld(), constellation);
event.post();
}

public static void onCraftingFinish(ItemStack itemStack, EntityItem original, IConstellation constellation) {
if (!RTConfig.Astralsorcery.attunementModification) {
return;
}
World world = original.getEntityWorld();
for (CustomAttunementRecipe recipe : CustomAttunementRecipe.allRecipes) {
if (recipe.canDoRecipe(constellation, original.getItem())) {
Expand Down Expand Up @@ -89,9 +86,6 @@ private static void resetMotion(EntityItem item) {
}

public static boolean haveRecipe(IConstellation constellation, ItemStack itemStack) {
if (!RTConfig.Astralsorcery.attunementModification) {
return false;
}
for (CustomAttunementRecipe recipe : CustomAttunementRecipe.allRecipes) {
if (recipe.canDoRecipe(constellation, itemStack)) {
return true;
Expand Down Expand Up @@ -130,7 +124,7 @@ public static void applyCrystalProperties(ItemStack itemStack, CrystalProperties
}

public static boolean logicPatch(boolean A, boolean B, boolean C) {
return RTConfig.Astralsorcery.attunementModification && ((A && B) || C);
return ((A && B) || C);
}

public static Item getTunedItemVariant(Item item, EntityItem itemStack, IConstellation constellation) {
Expand Down
Loading