diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-09-28 12:52:31 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-09-28 12:52:31 +1000 |
commit | 19749c79884682301e292b52d0ddb15e6d35a580 (patch) | |
tree | d34cc6f5ffe3aebb2354761ca9a9e2a53b853b38 /src/Java/gtPlusPlus/core/tileentities/base | |
parent | 4ab32e96512efaccb63fc2024e44dbc675afc5f0 (diff) | |
download | GT5-Unofficial-19749c79884682301e292b52d0ddb15e6d35a580.tar.gz GT5-Unofficial-19749c79884682301e292b52d0ddb15e6d35a580.tar.bz2 GT5-Unofficial-19749c79884682301e292b52d0ddb15e6d35a580.zip |
+ Added Base Tile Entity Class.
% Changed Trade Table to inherit from the base class.
+ Added functionality to the base TE to store the owners name and UUID.
+ Added Base NBT Block Class.
$ Fixed ItemBlockNBT handling of NBT.
Diffstat (limited to 'src/Java/gtPlusPlus/core/tileentities/base')
-rw-r--r-- | src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java new file mode 100644 index 0000000000..9b0e8dee64 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -0,0 +1,89 @@ +package gtPlusPlus.core.tileentities.base; + +import java.util.UUID; + +import gtPlusPlus.core.util.Utils; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityBase extends TileEntity { + + public String mOwnerName = "null"; + public String mOwnerUUID = "null"; + private boolean mIsOwnerOP = false; + + @SuppressWarnings("static-method") + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag){ + if(!nbt.hasKey(tag)) + { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt){ + super.writeToNBT(nbt); + nbt.setBoolean("mIsOwnerOP", this.mIsOwnerOP); + nbt.setString("mOwnerName", this.mOwnerName); + nbt.setString("mOwnerUUID", this.mOwnerUUID); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt){ + this.mIsOwnerOP = nbt.getBoolean("mIsOwnerOP"); + this.mOwnerName = nbt.getString("mOwnerName"); + this.mOwnerUUID = nbt.getString("mOwnerUUID"); + super.readFromNBT(nbt); + } + + @Override + public void updateEntity() { + super.updateEntity(); + } + + @Override + public boolean canUpdate() { + return true; + } + + public String getOwner(){ + if (this.mOwnerName == null){ + return "null"; + } + return this.mOwnerName; + } + + public UUID getOwnerUUID(){ + return UUID.fromString(this.mOwnerUUID); + } + + public boolean isOwnerOP() { + return mIsOwnerOP; + } + + public void setOwnerInformation(String mName, String mUUID, boolean mOP){ + if (isServerSide()){ + if (this.mOwnerName.equals("null") || this.mOwnerUUID.equals("null") + || this.mOwnerName == null || this.mOwnerUUID == null){ + this.mOwnerName = mName; + this.mOwnerUUID = mUUID; + this.mIsOwnerOP = mOP; + Utils.LOG_INFO("Finished setting TE information. owner: "+this.mOwnerName+" | UUID: "+this.mOwnerUUID+" | OP: "+this.mIsOwnerOP); + } + } + } + + public boolean isServerSide(){ + if (this.hasWorldObj()){ + if (this.getWorldObj().isRemote){ + return false; + } + else { + return true; + } + } + return false; + } + +}
\ No newline at end of file |