Some cleanup
This commit is contained in:
parent
9c1f76c0e5
commit
362e18bb94
1 changed files with 27 additions and 26 deletions
|
@ -26,27 +26,6 @@ import java.util.Iterator;
|
||||||
@ModOnly("thaumcraft")
|
@ModOnly("thaumcraft")
|
||||||
public class DustTrigger {
|
public class DustTrigger {
|
||||||
|
|
||||||
private static final Field simpleTriggerResult;
|
|
||||||
private static final Field oredictTriggerResult;
|
|
||||||
|
|
||||||
static {
|
|
||||||
|
|
||||||
Field A = null;
|
|
||||||
Field B = null;
|
|
||||||
try {
|
|
||||||
A = DustTriggerSimple.class.getDeclaredField("result");
|
|
||||||
A.setAccessible(true);
|
|
||||||
|
|
||||||
B = DustTriggerOre.class.getDeclaredField("result");
|
|
||||||
B.setAccessible(true);
|
|
||||||
} catch(NoSuchFieldException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
simpleTriggerResult = A;
|
|
||||||
oredictTriggerResult = B;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DustTrigger() {
|
private DustTrigger() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,25 +45,25 @@ public class DustTrigger {
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class ActionAddTrigger implements IAction {
|
static final class ActionAddTrigger implements IAction {
|
||||||
|
|
||||||
private final IItemStack output;
|
private final IItemStack output;
|
||||||
private final IDustTrigger trigger;
|
private final IDustTrigger trigger;
|
||||||
|
|
||||||
ActionAddTrigger(IBlock in, IItemStack output, String research) {
|
ActionAddTrigger(IBlock in, IItemStack output, String research) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
this.trigger = new DustTriggerSimple(research, CraftTweakerMC.getBlock(in), CraftTweakerMC.getItemStack(output));
|
this.trigger = new DustTriggerSimple(research, CraftTweakerMC.getBlock(in), CraftTweakerMC.getItemStack(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionAddTrigger(IOreDictEntry in, IItemStack output, String research) {
|
ActionAddTrigger(IOreDictEntry in, IItemStack output, String research) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
this.trigger = new DustTriggerOre(research, in.getName(), CraftTweakerMC.getItemStack(output));
|
this.trigger = new DustTriggerOre(research, in.getName(), CraftTweakerMC.getItemStack(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() {
|
public void apply() {
|
||||||
IDustTrigger.registerDustTrigger(this.trigger);
|
IDustTrigger.registerDustTrigger(this.trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String describe() {
|
public String describe() {
|
||||||
return "Adding Salis mundus Conversion with output " + output.toCommandString();
|
return "Adding Salis mundus Conversion with output " + output.toCommandString();
|
||||||
|
@ -93,14 +72,36 @@ public class DustTrigger {
|
||||||
|
|
||||||
static final class ActionRemoveTrigger implements IAction {
|
static final class ActionRemoveTrigger implements IAction {
|
||||||
|
|
||||||
|
private static Field simpleTriggerResult;
|
||||||
|
private static Field oredictTriggerResult;
|
||||||
|
private static boolean didReflection = false;
|
||||||
|
|
||||||
private final IIngredient output;
|
private final IIngredient output;
|
||||||
|
|
||||||
ActionRemoveTrigger(IIngredient output) {
|
ActionRemoveTrigger(IIngredient output) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void doDirtyReflection() {
|
||||||
|
if(didReflection)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
simpleTriggerResult = DustTriggerSimple.class.getDeclaredField("result");
|
||||||
|
simpleTriggerResult.setAccessible(true);
|
||||||
|
|
||||||
|
oredictTriggerResult = DustTriggerOre.class.getDeclaredField("result");
|
||||||
|
oredictTriggerResult.setAccessible(true);
|
||||||
|
|
||||||
|
didReflection = true;
|
||||||
|
} catch(NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() {
|
public void apply() {
|
||||||
|
doDirtyReflection();
|
||||||
final Iterator<IDustTrigger> iterator = IDustTrigger.triggers.iterator();
|
final Iterator<IDustTrigger> iterator = IDustTrigger.triggers.iterator();
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
final IDustTrigger trigger = iterator.next();
|
final IDustTrigger trigger = iterator.next();
|
||||||
|
|
Loading…
Reference in a new issue