diff --git a/forestry_common/apiculture/forestry/apiculture/gadgets/TileAlvearyPlain.java b/forestry_common/apiculture/forestry/apiculture/gadgets/TileAlvearyPlain.java index 7fcb7063c..6a8c63fb6 100755 --- a/forestry_common/apiculture/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/forestry_common/apiculture/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -10,6 +10,8 @@ package forestry.apiculture.gadgets; import java.util.LinkedHashSet; import java.util.Set; +import com.mojang.authlib.GameProfile; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; @@ -18,11 +20,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; - import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.api.inventory.ISpecialInventory; - import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; @@ -836,4 +835,10 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS public boolean isOwnable() { return true; } + + /* IHousing */ + @Override + public GameProfile getOwnerName() { + return this.getOwnerProfile(); + } } diff --git a/forestry_common/apiculture/forestry/apiculture/gadgets/TileBeehouse.java b/forestry_common/apiculture/forestry/apiculture/gadgets/TileBeehouse.java index 031f338e5..f7c21ac13 100755 --- a/forestry_common/apiculture/forestry/apiculture/gadgets/TileBeehouse.java +++ b/forestry_common/apiculture/forestry/apiculture/gadgets/TileBeehouse.java @@ -7,6 +7,8 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import com.mojang.authlib.GameProfile; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -14,7 +16,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; - import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; @@ -435,4 +436,10 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { public boolean onEggLaid(IBee queen) { return false; } + + /* IHousing */ + @Override + public GameProfile getOwnerName() { + return this.getOwnerProfile(); + } } diff --git a/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileLeaves.java b/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileLeaves.java index 6b5ed8ed8..a0fbe393e 100755 --- a/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileLeaves.java +++ b/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileLeaves.java @@ -12,6 +12,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; +import com.mojang.authlib.GameProfile; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -19,12 +21,9 @@ import net.minecraft.network.Packet; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.EnumPlantType; - import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IFruitProvider; import forestry.api.arboriculture.ILeafTickHandler; @@ -422,4 +421,9 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru return !isDestroyed() && caterpillar == null; } + /* IHousing */ + @Override + public GameProfile getOwnerName() { + return this.getOwnerProfile(); + } } diff --git a/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileSapling.java b/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileSapling.java index 9a8646b4d..95c77af45 100755 --- a/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileSapling.java +++ b/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileSapling.java @@ -57,7 +57,7 @@ public class TileSapling extends TileTreeContainer { WorldGenerator generator = this.getTree().getTreeGenerator(worldObj, xCoord, yCoord, zCoord, bonemealed); if (generator.generate(worldObj, worldObj.rand, xCoord, yCoord, zCoord)) { - PluginArboriculture.treeInterface.getBreedingTracker(worldObj, getOwnerName()).registerBirth(getTree()); + PluginArboriculture.treeInterface.getBreedingTracker(worldObj, getOwnerProfile()).registerBirth(getTree()); return 2; } diff --git a/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileTreeContainer.java b/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileTreeContainer.java index 86eb531b5..e9400f0e1 100755 --- a/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileTreeContainer.java +++ b/forestry_common/arboriculture/forestry/arboriculture/gadgets/TileTreeContainer.java @@ -138,7 +138,7 @@ public abstract class TileTreeContainer extends TileEntity implements INetworked } @Override - public GameProfile getOwnerName() { + public GameProfile getOwnerProfile() { return owner; } diff --git a/forestry_common/arboriculture/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/forestry_common/arboriculture/forestry/arboriculture/worldgen/WorldGenArboriculture.java index fbf0da5c3..3ceb05e9b 100755 --- a/forestry_common/arboriculture/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/forestry_common/arboriculture/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -58,7 +58,7 @@ public abstract class WorldGenArboriculture extends WorldGenBase { if (!(tile instanceof TileSapling)) return Utils.getForestryPlayerProfile(); - return ((TileSapling) tile).getOwnerName(); + return ((TileSapling) tile).getOwnerProfile(); } public abstract void preGenerate(); diff --git a/forestry_common/core/forestry/core/gadgets/BlockBase.java b/forestry_common/core/forestry/core/gadgets/BlockBase.java index 66af0cede..95a7749f2 100755 --- a/forestry_common/core/forestry/core/gadgets/BlockBase.java +++ b/forestry_common/core/forestry/core/gadgets/BlockBase.java @@ -24,18 +24,16 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.IFluidHandler; - import forestry.core.interfaces.IOwnable; import forestry.core.items.ItemNBTTile; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; +import forestry.core.utils.StringUtil; public class BlockBase extends BlockForestry { @@ -176,10 +174,18 @@ public class BlockBase extends BlockForestry { if (!Proxies.common.isSimulating(world)) return true; - if (tile.allowsInteraction(player)) + if (tile.allowsInteraction(player)) { tile.openGui(player, tile); - else - player.addChatMessage(new ChatComponentTranslation("\u00A7c%s %s", new ChatComponentText(tile.getOwnerName().getName()), new ChatComponentTranslation("chat.accesslocked"))); + } + else { + String ownerName = StringUtil.localize("gui.derelict"); + + if (tile.getOwnerProfile() != null) + ownerName = tile.getOwnerProfile().getName(); + + + player.addChatMessage(new ChatComponentTranslation("\u00A7c%s %s", new ChatComponentText(ownerName), new ChatComponentTranslation("chat.accesslocked"))); + } return true; } diff --git a/forestry_common/core/forestry/core/gadgets/BlockStructure.java b/forestry_common/core/forestry/core/gadgets/BlockStructure.java index 3082cdaad..782179d8f 100755 --- a/forestry_common/core/forestry/core/gadgets/BlockStructure.java +++ b/forestry_common/core/forestry/core/gadgets/BlockStructure.java @@ -14,9 +14,9 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; - import forestry.api.core.ITileStructure; import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; public abstract class BlockStructure extends BlockForestry { @@ -68,10 +68,17 @@ public abstract class BlockStructure extends BlockForestry { if (!((ITileStructure) tile).isIntegratedIntoStructure()) return false; - if (tile.allowsInteraction(player)) + if (tile.allowsInteraction(player)) { tile.openGui(player); - else - player.addChatMessage(new ChatComponentTranslation("\u00A7c%s %s", new ChatComponentText(tile.getOwnerName().getName()), new ChatComponentTranslation("chat.accesslocked"))); + } + else { + String ownerName = StringUtil.localize("gui.derelict"); + + if (tile.getOwnerProfile() != null) + ownerName = tile.getOwnerProfile().getName(); + + player.addChatMessage(new ChatComponentTranslation("\u00A7c%s %s", new ChatComponentText(ownerName), new ChatComponentTranslation("chat.accesslocked"))); + } return true; } diff --git a/forestry_common/core/forestry/core/gadgets/TileForestry.java b/forestry_common/core/forestry/core/gadgets/TileForestry.java index 13312306d..5dee189f9 100755 --- a/forestry_common/core/forestry/core/gadgets/TileForestry.java +++ b/forestry_common/core/forestry/core/gadgets/TileForestry.java @@ -256,7 +256,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit } @Override - public GameProfile getOwnerName() { + public GameProfile getOwnerProfile() { return owner; } @@ -275,14 +275,14 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit @Override public boolean isOwner(EntityPlayer player) { if (owner != null) - return owner.equals(player.getGameProfile().getId()); + return owner.getId().compareTo(player.getPersistentID()) == 0; else return false; } @Override public boolean switchAccessRule(EntityPlayer player) { - if (owner != null && !owner.equals(player.getGameProfile())) + if (!isOwner(player)) return false; if (access.ordinal() < EnumAccess.values().length - 1) diff --git a/forestry_common/core/forestry/core/gadgets/TileMachine.java b/forestry_common/core/forestry/core/gadgets/TileMachine.java index 139b809d7..3ff9bd646 100755 --- a/forestry_common/core/forestry/core/gadgets/TileMachine.java +++ b/forestry_common/core/forestry/core/gadgets/TileMachine.java @@ -349,11 +349,6 @@ public class TileMachine extends TileForestry implements ISpecialInventory, ICli return 0; } - // @Override - // public boolean canAccess(String username) { - // return isOwned() && getOwnerName().equals(username); - // } - @Override public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { if (getAccess() == EnumAccess.PRIVATE) diff --git a/forestry_common/core/forestry/core/gui/OwnerLedger.java b/forestry_common/core/forestry/core/gui/OwnerLedger.java index 9a5946587..795176257 100755 --- a/forestry_common/core/forestry/core/gui/OwnerLedger.java +++ b/forestry_common/core/forestry/core/gui/OwnerLedger.java @@ -11,7 +11,6 @@ import java.util.Locale; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; - import forestry.core.interfaces.IOwnable; import forestry.core.network.PacketCoordinates; import forestry.core.network.PacketIds; @@ -71,11 +70,12 @@ public class OwnerLedger extends Ledger { manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.owner"), x + 22, y + 8, manager.gui.fontColor.get("ledger.owner.header")); - String owner; - if ((owner = tile.getOwnerName().getName()) == null) - owner = StringUtil.localize("gui.derelict"); - - manager.minecraft.fontRenderer.drawString(owner, x + 22, y + 20, manager.gui.fontColor.get("ledger.owner.text")); + String ownerName = StringUtil.localize("gui.derelict"); + + if (tile.getOwnerProfile() != null) + ownerName = tile.getOwnerProfile().getName(); + + manager.minecraft.fontRenderer.drawString(ownerName, x + 22, y + 20, manager.gui.fontColor.get("ledger.owner.text")); if (!playerIsOwner) return; @@ -90,8 +90,8 @@ public class OwnerLedger extends Ledger { @Override public String getTooltip() { - if (tile.getOwnerName() != null) - return StringUtil.localize("gui.owner") + ": " + tile.getOwnerName(); + if (tile.getOwnerProfile() != null) + return StringUtil.localize("gui.owner") + ": " + tile.getOwnerProfile().getName(); else return StringUtil.localize("gui.derelict"); } diff --git a/forestry_common/core/forestry/core/interfaces/IOwnable.java b/forestry_common/core/forestry/core/interfaces/IOwnable.java index 66d6df05c..a9aaa737c 100755 --- a/forestry_common/core/forestry/core/interfaces/IOwnable.java +++ b/forestry_common/core/forestry/core/interfaces/IOwnable.java @@ -19,7 +19,7 @@ public interface IOwnable { boolean isOwned(); - GameProfile getOwnerName(); + GameProfile getOwnerProfile(); void setOwner(EntityPlayer player); diff --git a/forestry_common/lepidopterology/forestry/lepidopterology/genetics/Butterfly.java b/forestry_common/lepidopterology/forestry/lepidopterology/genetics/Butterfly.java index 9fe4e8892..7e6606004 100755 --- a/forestry_common/lepidopterology/forestry/lepidopterology/genetics/Butterfly.java +++ b/forestry_common/lepidopterology/forestry/lepidopterology/genetics/Butterfly.java @@ -233,8 +233,6 @@ public class Butterfly extends IndividualLiving implements IButterfly { if ((chance = mutation.getChance(nursery, allele0, allele1, genome0, genome1)) > 0) if (world.rand.nextFloat()*100 < chance) { - //IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName()); - //breedingTracker.registerMutation(mutation); return PluginLepidopterology.butterflyInterface.templateAsChromosomes(mutation.getTemplate()); } } diff --git a/forestry_common/mail/forestry/mail/POBox.java b/forestry_common/mail/forestry/mail/POBox.java index d2bcd6353..df06356d8 100755 --- a/forestry_common/mail/forestry/mail/POBox.java +++ b/forestry_common/mail/forestry/mail/POBox.java @@ -55,7 +55,7 @@ public class POBox extends WorldSavedData implements IInventory { letters.writeToNBT(nbttagcompound); } - public GameProfile getOwnerName() { + public GameProfile getOwnerProfile() { return this.owner; } diff --git a/forestry_common/mail/forestry/mail/gadgets/MachineMailbox.java b/forestry_common/mail/forestry/mail/gadgets/MachineMailbox.java index e3d7873c3..244f35aaf 100755 --- a/forestry_common/mail/forestry/mail/gadgets/MachineMailbox.java +++ b/forestry_common/mail/forestry/mail/gadgets/MachineMailbox.java @@ -100,10 +100,10 @@ public class MachineMailbox extends TileBase implements IMailContainer, ISpecial if (!Proxies.common.isSimulating(worldObj)) return new InventoryAdapter(POBox.SLOT_SIZE, "Letters"); - if (getOwnerName() == null) + if (getOwnerProfile() == null) return new InventoryAdapter(POBox.SLOT_SIZE, "Letters"); - return PostRegistry.getOrCreatePOBox(worldObj, getOwnerName()); + return PostRegistry.getOrCreatePOBox(worldObj, getOwnerProfile()); } private IPostalState tryDispatchLetter(ItemStack letterstack, boolean dispatchLetter) { diff --git a/forestry_common/mail/forestry/mail/gadgets/MachineTrader.java b/forestry_common/mail/forestry/mail/gadgets/MachineTrader.java index b641df73f..c61250e15 100755 --- a/forestry_common/mail/forestry/mail/gadgets/MachineTrader.java +++ b/forestry_common/mail/forestry/mail/gadgets/MachineTrader.java @@ -171,7 +171,7 @@ public class MachineTrader extends TileBase implements ISpecialInventory, ISided } this.moniker = moniker; - PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerName(), this.moniker); + PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), this.moniker); setErrorState(EnumErrorCode.OK); sendNetworkUpdate(); } else @@ -188,7 +188,7 @@ public class MachineTrader extends TileBase implements ISpecialInventory, ISided if (this.moniker == null) return new InventoryAdapter(TradeStation.SLOT_SIZE, "INV"); - return PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerName(), this.moniker); + return PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), this.moniker); } /* ISPECIALINVENTORY */ diff --git a/forestry_common/mail/forestry/mail/gui/ContainerMailbox.java b/forestry_common/mail/forestry/mail/gui/ContainerMailbox.java index 6c66a7c5c..615431457 100755 --- a/forestry_common/mail/forestry/mail/gui/ContainerMailbox.java +++ b/forestry_common/mail/forestry/mail/gui/ContainerMailbox.java @@ -54,7 +54,7 @@ public class ContainerMailbox extends ContainerForestry { ItemStack stack = super.slotClick(slotIndex, button, par3, player); if (Proxies.common.isSimulating(player.worldObj) && mailinventory != null) - PluginMail.proxy.setPOBoxInfo(mailbox.getWorldObj(), mailbox.getOwnerName(), mailinventory.getPOBoxInfo()); + PluginMail.proxy.setPOBoxInfo(mailbox.getWorldObj(), mailbox.getOwnerProfile(), mailinventory.getPOBoxInfo()); return stack; }