fix: research table extension
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Timo Ley 2023-01-13 17:30:04 +01:00
parent 881e51ec6c
commit 0e909e82de
2 changed files with 22 additions and 15 deletions

View file

@ -24,7 +24,7 @@ apply from: './gradle/scripts/mixins.gradle'
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
version = "1.6.0" version = "1.6.1"
group= "dev.tilera" group= "dev.tilera"
archivesBaseName = "auracore" archivesBaseName = "auracore"

View file

@ -1,30 +1,37 @@
package dev.tilera.auracore.api.research; package dev.tilera.auracore.api.research;
import java.lang.ref.WeakReference;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
public abstract class ResearchTableExtension { public abstract class ResearchTableExtension {
public World world; public WeakReference<IResearchTable> researchTable;
public int xCoord;
public int yCoord;
public int zCoord;
public ResearchTableExtension(IResearchTable researchTable) { public ResearchTableExtension(IResearchTable researchTable) {
this.world = researchTable.getWorld(); this.researchTable = new WeakReference<>(researchTable);
this.xCoord = researchTable.getXCoord(); }
this.yCoord = researchTable.getYCoord();
this.zCoord = researchTable.getZCoord(); public World getWorld() {
return researchTable.get().getWorld();
}
public int getXCoord() {
return researchTable.get().getXCoord();
}
public int getYCoord() {
return researchTable.get().getYCoord();
}
public int getZCoord() {
return researchTable.get().getZCoord();
} }
public IResearchTable getResearchTable() { public IResearchTable getResearchTable() {
TileEntity te = this.world.getTileEntity(this.xCoord, this.yCoord, this.zCoord); return researchTable.get();
if (te instanceof IResearchTable) {
return (IResearchTable) te;
}
return null;
} }
public abstract void writeToNBT(NBTTagCompound nbt); public abstract void writeToNBT(NBTTagCompound nbt);