Fixes #1327: Prevents crash when configuring a GUI
This commit is contained in:
@@ -31,16 +31,17 @@ import appeng.api.util.IConfigurableObject;
|
|||||||
import appeng.container.AEBaseContainer;
|
import appeng.container.AEBaseContainer;
|
||||||
import appeng.core.sync.AppEngPacket;
|
import appeng.core.sync.AppEngPacket;
|
||||||
import appeng.core.sync.network.INetworkInfo;
|
import appeng.core.sync.network.INetworkInfo;
|
||||||
|
import appeng.helpers.Reflected;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class PacketConfigButton extends AppEngPacket
|
public final class PacketConfigButton extends AppEngPacket
|
||||||
{
|
{
|
||||||
|
private final Settings option;
|
||||||
public final Settings option;
|
private final boolean rotationDirection;
|
||||||
public final boolean rotationDirection;
|
|
||||||
|
|
||||||
// automatic.
|
// automatic.
|
||||||
|
@Reflected
|
||||||
public PacketConfigButton( ByteBuf stream )
|
public PacketConfigButton( ByteBuf stream )
|
||||||
{
|
{
|
||||||
this.option = Settings.values()[stream.readInt()];
|
this.option = Settings.values()[stream.readInt()];
|
||||||
@@ -66,12 +67,15 @@ public class PacketConfigButton extends AppEngPacket
|
|||||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||||
{
|
{
|
||||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||||
AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
if ( sender.openContainer instanceof AEBaseContainer )
|
||||||
if( baseContainer.getTarget() instanceof IConfigurableObject )
|
|
||||||
{
|
{
|
||||||
IConfigManager cm = ( (IConfigurableObject) baseContainer.getTarget() ).getConfigManager();
|
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||||
Enum newState = Platform.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() );
|
if( baseContainer.getTarget() instanceof IConfigurableObject )
|
||||||
cm.putSetting( this.option, newState );
|
{
|
||||||
|
IConfigManager cm = ( (IConfigurableObject) baseContainer.getTarget() ).getConfigManager();
|
||||||
|
Enum<?> newState = Platform.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() );
|
||||||
|
cm.putSetting( this.option, newState );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user