Some cleanup

This commit is contained in:
kindlich 2019-01-29 17:29:30 +01:00
parent 9c1f76c0e5
commit 362e18bb94
No known key found for this signature in database
GPG key ID: A471F355F32425FE

View file

@ -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();