forked from jaredlll08/ModTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tcomplement support closes jaredlll08#541
- Loading branch information
1 parent
c5a174d
commit 33c71a3
Showing
3 changed files
with
225 additions
and
0 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
103 changes: 103 additions & 0 deletions
103
src/main/java/com/blamejared/compat/tcomplement/Blacklist.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,103 @@ | ||
package com.blamejared.compat.tcomplement; | ||
|
||
import com.blamejared.ModTweaker; | ||
import com.blamejared.compat.tconstruct.recipes.MeltingRecipeTweaker; | ||
import com.blamejared.mtlib.helpers.*; | ||
import com.blamejared.mtlib.utils.BaseUndoable; | ||
import crafttweaker.CraftTweakerAPI; | ||
import crafttweaker.annotations.*; | ||
import crafttweaker.api.item.IItemStack; | ||
import crafttweaker.api.liquid.ILiquidStack; | ||
import knightminer.tcomplement.library.TCompRegistry; | ||
import knightminer.tcomplement.library.events.TCompRegisterEvent; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import slimeknights.mantle.util.RecipeMatch; | ||
import stanhebben.zenscript.annotations.*; | ||
|
||
import java.util.*; | ||
|
||
@ZenClass("mods.tcomplement.Blacklist") | ||
@ZenRegister | ||
@ModOnly("tcomplement") | ||
public class Blacklist { | ||
|
||
|
||
public static final List<IItemStack> REMOVED_RECIPES = new LinkedList<>(); | ||
private static boolean init = false; | ||
|
||
private static void init() { | ||
if(!init) { | ||
MinecraftForge.EVENT_BUS.register(new Blacklist()); | ||
init = true; | ||
} | ||
} | ||
|
||
@ZenMethod | ||
public static void addRecipe(ILiquidStack output, IItemStack input) { | ||
init(); | ||
ModTweaker.LATE_ADDITIONS.add(new Blacklist.Add(InputHelper.toFluid(output), InputHelper.toStack(input))); | ||
} | ||
|
||
@ZenMethod | ||
public static void removeRecipe(IItemStack input) { | ||
init(); | ||
CraftTweakerAPI.apply(new Blacklist.Remove(input)); | ||
} | ||
|
||
private static class Add extends BaseUndoable { | ||
|
||
private FluidStack output; | ||
private ItemStack input; | ||
|
||
public Add(FluidStack output, ItemStack input) { | ||
super("Blacklist"); | ||
this.output = output; | ||
this.input = input; | ||
} | ||
|
||
@Override | ||
public void apply() { | ||
TCompRegistry.registerMelterBlacklist(RecipeMatch.of(input, output.amount)); | ||
} | ||
|
||
@Override | ||
protected String getRecipeInfo() { | ||
return LogHelper.getStackDescription(output); | ||
} | ||
} | ||
|
||
private static class Remove extends BaseUndoable { | ||
|
||
private IItemStack input; | ||
|
||
protected Remove(IItemStack input) { | ||
super("Blacklist"); | ||
this.input = input; | ||
} | ||
|
||
@Override | ||
public void apply() { | ||
REMOVED_RECIPES.add(input); | ||
} | ||
|
||
@Override | ||
protected String getRecipeInfo() { | ||
return LogHelper.getStackDescription(input); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onTinkerRegister(TCompRegisterEvent.MelterBlackListRegisterEvent event) { | ||
if(event.getRecipe() instanceof MeltingRecipeTweaker) { | ||
return; | ||
} | ||
for(IItemStack ent : REMOVED_RECIPES) { | ||
if(event.getRecipe().matches(InputHelper.toStack(ent))) { | ||
event.setCanceled(true); | ||
} | ||
} | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
src/main/java/com/blamejared/compat/tcomplement/Overrides.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,117 @@ | ||
package com.blamejared.compat.tcomplement; | ||
|
||
import com.blamejared.ModTweaker; | ||
import com.blamejared.compat.tconstruct.recipes.MeltingRecipeTweaker; | ||
import com.blamejared.mtlib.helpers.*; | ||
import com.blamejared.mtlib.utils.BaseUndoable; | ||
import crafttweaker.CraftTweakerAPI; | ||
import crafttweaker.annotations.*; | ||
import crafttweaker.api.item.IItemStack; | ||
import crafttweaker.api.liquid.ILiquidStack; | ||
import knightminer.tcomplement.library.TCompRegistry; | ||
import knightminer.tcomplement.library.events.TCompRegisterEvent; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.NonNullList; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import slimeknights.mantle.util.RecipeMatch; | ||
import stanhebben.zenscript.annotations.Optional; | ||
import stanhebben.zenscript.annotations.*; | ||
|
||
import java.util.*; | ||
|
||
@ZenClass("mods.tcomplement.Overrides") | ||
@ZenRegister | ||
@ModOnly("tcomplement") | ||
public class Overrides { | ||
|
||
|
||
public static final Map<ILiquidStack, IItemStack> REMOVED_RECIPES = new LinkedHashMap<>(); | ||
private static boolean init = false; | ||
|
||
private static void init() { | ||
if(!init) { | ||
MinecraftForge.EVENT_BUS.register(new Overrides()); | ||
init = true; | ||
} | ||
} | ||
|
||
@ZenMethod | ||
public static void addRecipe(ILiquidStack output, IItemStack input, @Optional int temp) { | ||
init(); | ||
ModTweaker.LATE_ADDITIONS.add(new Overrides.Add(InputHelper.toFluid(output), InputHelper.toStack(input), temp)); | ||
} | ||
|
||
@ZenMethod | ||
public static void removeRecipe(ILiquidStack output, @Optional IItemStack input) { | ||
init(); | ||
CraftTweakerAPI.apply(new Overrides.Remove(output, input)); | ||
} | ||
|
||
private static class Add extends BaseUndoable { | ||
|
||
private FluidStack output; | ||
private ItemStack input; | ||
private int temp; | ||
|
||
public Add(FluidStack output, ItemStack input, int temp) { | ||
super("Overrides"); | ||
this.output = output; | ||
this.input = input; | ||
this.temp = temp; | ||
} | ||
|
||
@java.lang.Override | ||
public void apply() { | ||
if(temp != 0) | ||
TCompRegistry.registerMelterOverride(new MeltingRecipeTweaker(RecipeMatch.of(input, output.amount), output, temp)); | ||
else | ||
TCompRegistry.registerMelterOverride(new MeltingRecipeTweaker(RecipeMatch.of(input, output.amount), output)); | ||
} | ||
|
||
@java.lang.Override | ||
protected String getRecipeInfo() { | ||
return LogHelper.getStackDescription(output); | ||
} | ||
} | ||
|
||
private static class Remove extends BaseUndoable { | ||
|
||
private ILiquidStack output; | ||
private IItemStack input; | ||
|
||
protected Remove(ILiquidStack output, IItemStack input) { | ||
super("Overrides"); | ||
this.output = output; | ||
this.input = input; | ||
} | ||
|
||
@Override | ||
public void apply() { | ||
REMOVED_RECIPES.put(output, input); | ||
} | ||
|
||
@Override | ||
protected String getRecipeInfo() { | ||
return LogHelper.getStackDescription(output); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onTinkerRegister(TCompRegisterEvent.MelterOverrideRegisterEvent event) { | ||
if(event.getRecipe() instanceof MeltingRecipeTweaker) { | ||
return; | ||
} | ||
for(Map.Entry<ILiquidStack, IItemStack> ent : REMOVED_RECIPES.entrySet()) { | ||
if(event.getRecipe().getResult().isFluidEqual(((FluidStack) ent.getKey().getInternal()))) { | ||
if(ent.getValue() != null) { | ||
if(event.getRecipe().input.matches(NonNullList.withSize(1, (ItemStack) ent.getValue().getInternal())).isPresent()) { | ||
event.setCanceled(true); | ||
} | ||
} else | ||
event.setCanceled(true); | ||
} | ||
} | ||
} | ||
} |