Changed to EntityPlayer instead of Player, also new Set Value Packet.
This commit is contained in:
@@ -5,6 +5,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import appeng.api.config.Settings;
|
||||
@@ -13,43 +14,45 @@ import appeng.api.util.IConfigureableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class PacketConfigButton extends AppEngPacket
|
||||
{
|
||||
|
||||
final public Settings option;
|
||||
final public boolean rotationDirection;
|
||||
|
||||
// automatic.
|
||||
public PacketConfigButton(DataInputStream stream) throws IOException {
|
||||
option = Settings.values()[stream.readInt()];
|
||||
rotationDirection = stream.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkManager manager, AppEngPacket packet, Player player)
|
||||
public void serverPacketData(INetworkManager manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
AEBaseContainer aebc = (AEBaseContainer) sender.openContainer;
|
||||
if ( aebc.getTarget() instanceof IConfigureableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigureableObject) aebc.getTarget()).getConfigManager();
|
||||
Enum newState = Platform.nextEnum( cm.getSetting( option ) );
|
||||
Enum newState = Platform.rotateEnum( cm.getSetting( option ), rotationDirection, option.getPossibleValues() );
|
||||
cm.putSetting( option, newState );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketConfigButton(Settings option) throws IOException {
|
||||
public PacketConfigButton(Settings option, boolean rotationDirection) throws IOException {
|
||||
this.option = option;
|
||||
this.rotationDirection = rotationDirection;
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( option.ordinal() );
|
||||
data.writeBoolean( rotationDirection );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user