Files
ForestryMC/src/main/java/forestry/mail/gui/ContainerTradeName.java
T

64 lines
2.0 KiB
Java
Raw Normal View History

2014-05-02 21:31:20 +02:00
/*******************************************************************************
2014-08-07 08:29:25 +02:00
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
2014-08-07 02:56:58 -07:00
* http://www.gnu.org/licenses/lgpl-3.0.txt
2014-05-02 21:31:20 +02:00
*
2014-08-07 08:29:25 +02:00
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
2014-05-02 21:31:20 +02:00
******************************************************************************/
package forestry.mail.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.server.MinecraftServer;
import com.mojang.authlib.GameProfile;
2014-05-02 21:31:20 +02:00
import forestry.core.gui.ContainerForestry;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketPayload;
import forestry.core.network.PacketUpdate;
import forestry.core.proxy.Proxies;
import forestry.core.utils.InventoryAdapter;
import forestry.mail.gadgets.MachineTrader;
public class ContainerTradeName extends ContainerForestry {
boolean isLinked;
MachineTrader machine;
public ContainerTradeName(InventoryPlayer player, MachineTrader tile) {
super(new InventoryAdapter(0, "Empty"));
machine = tile;
isLinked = machine.isLinked();
}
public GameProfile getMoniker() {
2014-05-02 21:31:20 +02:00
return machine.getMoniker();
}
public void setMoniker(String moniker) {
if (moniker == null)
2014-05-02 21:31:20 +02:00
return;
PacketPayload payload = new PacketPayload(0, 0, 1);
payload.stringPayload[0] = moniker;
PacketUpdate packet = new PacketUpdate(PacketIds.TRADING_MONIKER_SET, payload);
Proxies.net.sendToServer(packet);
}
public void handleSetMoniker(PacketUpdate packet) {
GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(packet.payload.stringPayload[0]);
machine.setMoniker(profile);
2014-05-02 21:31:20 +02:00
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
}
}