mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 03:15:28 +00:00
Save the owner NBT without gameprofile properties
This commit is contained in:
1 parent
5a901ffa36
commit
86e3ae87fd
10 files changed
+49
-27
No files matched your search
@@ -20,7 +20,6 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -63,6 +62,7 @@ import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.ColourUtil;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
|
||||
public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery, IRipeningPacketReceiver {
|
||||
|
||||
@@ -105,7 +105,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
setTree(containedTree);
|
||||
} else {
|
||||
if (nbttagcompound.hasKey("owner")) {
|
||||
setOwner(NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("owner")));
|
||||
setOwner(PlayerUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("owner")));
|
||||
}
|
||||
|
||||
ripeningTime = nbttagcompound.getShort("RT");
|
||||
@@ -149,7 +149,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
GameProfile owner = getOwner();
|
||||
if (owner != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(nbt, owner);
|
||||
PlayerUtil.writeGameProfile(nbt, owner);
|
||||
nbtTagCompound.setTag("owner", nbt);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
@@ -54,7 +53,7 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl
|
||||
containedTree = new Tree(nbttagcompound.getCompoundTag("ContainedTree"));
|
||||
}
|
||||
if (nbttagcompound.hasKey("owner")) {
|
||||
owner = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("owner"));
|
||||
owner = PlayerUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("owner"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +68,7 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl
|
||||
}
|
||||
if (this.owner != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(nbt, owner);
|
||||
PlayerUtil.writeGameProfile(nbt, owner);
|
||||
nbttagcompound.setTag("owner", nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.UUID;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -167,7 +166,7 @@ public final class AccessHandler implements IAccessHandler {
|
||||
access = EnumAccess.values()[data.getInteger("Access")];
|
||||
|
||||
if (data.hasKey("owner")) {
|
||||
owner = NBTUtil.readGameProfileFromNBT(data.getCompoundTag("owner"));
|
||||
owner = PlayerUtil.readGameProfileFromNBT(data.getCompoundTag("owner"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +176,7 @@ public final class AccessHandler implements IAccessHandler {
|
||||
|
||||
if (this.owner != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(nbt, owner);
|
||||
nbt.removeTag("Properties");
|
||||
PlayerUtil.writeGameProfile(nbt, owner);
|
||||
data.setTag("owner", nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.EnumTankLevel;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
import forestry.core.tiles.IRenderableTile;
|
||||
import forestry.core.utils.NBTUtil;
|
||||
import forestry.core.utils.NBTUtil.NBTList;
|
||||
import forestry.core.utils.NBTUtilForestry;
|
||||
import forestry.core.utils.NBTUtilForestry.NBTList;
|
||||
|
||||
/**
|
||||
* @author CovertJaguar <http://www.railcraft.info>
|
||||
@@ -106,7 +106,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
NBTList<NBTTagCompound> tagList = NBTUtil.getNBTList(data, "tanks", NBTUtil.EnumNBTType.COMPOUND);
|
||||
NBTList<NBTTagCompound> tagList = NBTUtilForestry.getNBTList(data, "tanks", NBTUtilForestry.EnumNBTType.COMPOUND);
|
||||
for (NBTTagCompound tag : tagList) {
|
||||
int slot = tag.getByte("tank");
|
||||
if (slot >= 0 && slot < tanks.size()) {
|
||||
|
||||
@@ -18,7 +18,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
@@ -34,6 +33,7 @@ import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.genetics.mutations.EnumMutateChance;
|
||||
import forestry.core.items.ItemForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class ItemResearchNote extends ItemForestry {
|
||||
@@ -216,7 +216,7 @@ public class ItemResearchNote extends ItemForestry {
|
||||
public ResearchNote(NBTTagCompound compound) {
|
||||
if (compound != null) {
|
||||
if (compound.hasKey("res")) {
|
||||
this.researcher = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("res"));
|
||||
this.researcher = PlayerUtil.readGameProfileFromNBT(compound.getCompoundTag("res"));
|
||||
} else {
|
||||
this.researcher = null;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ public class ItemResearchNote extends ItemForestry {
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
if (this.researcher != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(nbt, researcher);
|
||||
PlayerUtil.writeGameProfile(nbt, researcher);
|
||||
compound.setTag("res", nbt);
|
||||
}
|
||||
compound.setByte("TYP", (byte) type.ordinal());
|
||||
|
||||
@@ -10,11 +10,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.World;
|
||||
@@ -30,8 +32,10 @@ import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.tiles.IFilterSlotDelegate;
|
||||
import forestry.core.tiles.ILocatable;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
|
||||
public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> extends MultiblockTileEntityBase<T> implements ISidedInventory, IFilterSlotDelegate, ILocatable, IGuiHandlerTile {
|
||||
@Nullable
|
||||
private GameProfile owner;
|
||||
|
||||
public MultiblockTileEntityForestry(T multiblockLogic) {
|
||||
@@ -50,7 +54,8 @@ public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> e
|
||||
super.readFromNBT(data);
|
||||
|
||||
if (data.hasKey("owner")) {
|
||||
owner = NBTUtil.readGameProfileFromNBT(data.getCompoundTag("owner"));
|
||||
NBTTagCompound ownerNbt = data.getCompoundTag("owner");
|
||||
this.owner = PlayerUtil.readGameProfileFromNBT(ownerNbt);
|
||||
}
|
||||
|
||||
getInternalInventory().readFromNBT(data);
|
||||
@@ -62,7 +67,7 @@ public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> e
|
||||
|
||||
if (this.owner != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.removeTag("Properties");
|
||||
PlayerUtil.writeGameProfile(nbt, owner);
|
||||
data.setTag("owner", nbt);
|
||||
}
|
||||
|
||||
@@ -187,12 +192,13 @@ public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> e
|
||||
}
|
||||
|
||||
/* IMultiblockComponent */
|
||||
@Nullable
|
||||
@Override
|
||||
public final GameProfile getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public final void setOwner(GameProfile owner) {
|
||||
public final void setOwner(@Nonnull GameProfile owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
/**
|
||||
* @author CovertJaguar <http://www.railcraft.info/>
|
||||
*/
|
||||
public abstract class NBTUtil {
|
||||
public abstract class NBTUtilForestry {
|
||||
|
||||
public enum EnumNBTType {
|
||||
|
||||
@@ -10,9 +10,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.utils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
@@ -74,4 +79,19 @@ public abstract class PlayerUtil {
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
public static void writeGameProfile(@Nonnull NBTTagCompound tagCompound, @Nonnull GameProfile profile) {
|
||||
if (!StringUtils.isNullOrEmpty(profile.getName())) {
|
||||
tagCompound.setString("Name", profile.getName());
|
||||
}
|
||||
|
||||
if (profile.getId() != null) {
|
||||
tagCompound.setString("Id", profile.getId().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GameProfile readGameProfileFromNBT(@Nonnull NBTTagCompound compound) {
|
||||
return NBTUtil.readGameProfileFromNBT(compound);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
@@ -69,7 +68,7 @@ public class MailAddress implements INbtWritable, IMailAddress {
|
||||
gameProfile = invalidGameProfile;
|
||||
} else if (nbt.hasKey("profile")) {
|
||||
NBTTagCompound profileTag = nbt.getCompoundTag("profile");
|
||||
gameProfile = NBTUtil.readGameProfileFromNBT(profileTag);
|
||||
gameProfile = PlayerUtil.readGameProfileFromNBT(profileTag);
|
||||
}
|
||||
|
||||
this.type = type;
|
||||
@@ -141,7 +140,7 @@ public class MailAddress implements INbtWritable, IMailAddress {
|
||||
|
||||
if (gameProfile != null) {
|
||||
NBTTagCompound profileNbt = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(profileNbt, gameProfile);
|
||||
PlayerUtil.writeGameProfile(profileNbt, gameProfile);
|
||||
nbttagcompound.setTag("profile", profileNbt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.World;
|
||||
@@ -36,6 +35,7 @@ import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.mail.inventory.InventoryTradeStation;
|
||||
import forestry.mail.items.EnumStampDefinition;
|
||||
@@ -86,7 +86,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
if (nbttagcompound.hasKey("owner")) {
|
||||
owner = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("owner"));
|
||||
owner = PlayerUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("owner"));
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasKey("address")) {
|
||||
@@ -102,7 +102,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
if (owner != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(nbt, owner);
|
||||
PlayerUtil.writeGameProfile(nbt, owner);
|
||||
nbttagcompound.setTag("owner", nbt);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user