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() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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