generated from tilera/1710mod
fix: markDirty abstract method exception
This commit is contained in:
parent
a367fe8f6c
commit
244ca15f40
|
@ -1,17 +1,26 @@
|
|||
package dev.tilera.auracore.api.research;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class ResearchTableExtension {
|
||||
|
||||
public WeakReference<IResearchTable> researchTable;
|
||||
private Method markDirty;
|
||||
|
||||
public ResearchTableExtension(IResearchTable researchTable) {
|
||||
this.researchTable = new WeakReference<>(researchTable);
|
||||
Class<? extends ResearchTableExtension> impl = this.getClass();
|
||||
try {
|
||||
markDirty = impl.getDeclaredMethod("markDirty", new Class[0]);
|
||||
} catch (Exception e) {
|
||||
markDirty = null;
|
||||
}
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
|
@ -44,7 +53,17 @@ public abstract class ResearchTableExtension {
|
|||
|
||||
public abstract void onTick();
|
||||
|
||||
public abstract void markDirty();
|
||||
public void extMarkDirty() {
|
||||
if (this instanceof IInventory) {
|
||||
((IInventory)this).markDirty();
|
||||
} else if (markDirty != null) {
|
||||
try {
|
||||
markDirty.invoke(this);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean openGUI(EntityPlayer player);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public abstract class MixinTileResearchTable extends TileThaumcraft implements I
|
|||
@Inject(method = "markDirty", at = @At("TAIL"))
|
||||
public void onMarkDirty(CallbackInfo ci) {
|
||||
if (extension != null) {
|
||||
extension.markDirty();
|
||||
extension.extMarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue