mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-12 10:20:28 +00:00
Revert a couple of changes to be backwards compatible
- Restore ComputerState to the previous location - Add a stub constructor for GuiComputer
This commit is contained in:
parent
ca334e7e5c
commit
8422a40c69
@ -11,6 +11,7 @@ import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.computer.core.ClientComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
@ -43,6 +44,12 @@ public class GuiComputer extends GuiContainer
|
||||
m_terminal = null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public GuiComputer( Container container, ComputerFamily family, IComputer computer, int termWidth, int termHeight )
|
||||
{
|
||||
this( container, family, (ClientComputer) computer, termWidth, termHeight );
|
||||
}
|
||||
|
||||
public GuiComputer( TileComputer computer )
|
||||
{
|
||||
this(
|
||||
|
@ -676,6 +676,7 @@ public class Computer
|
||||
m_apis.add( api );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "deprecation" )
|
||||
public void addAPI( dan200.computercraft.core.apis.ILuaAPI api )
|
||||
{
|
||||
addAPI( (ILuaAPI) api );
|
||||
|
@ -8,7 +8,6 @@ package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
@ -46,7 +45,7 @@ public class BlockCommandComputer extends BlockComputerBase
|
||||
setCreativeTab( ComputerCraft.mainCreativeTab );
|
||||
setDefaultState( this.blockState.getBaseState()
|
||||
.withProperty( Properties.FACING, EnumFacing.NORTH )
|
||||
.withProperty( Properties.STATE, ComputerState.OFF )
|
||||
.withProperty( Properties.STATE, ComputerState.Off )
|
||||
);
|
||||
}
|
||||
|
||||
@ -82,7 +81,7 @@ public class BlockCommandComputer extends BlockComputerBase
|
||||
public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
return state.withProperty( Properties.STATE, tile instanceof TileComputer ? ((TileComputer) tile).getState() : ComputerState.OFF );
|
||||
return state.withProperty( Properties.STATE, tile instanceof TileComputer ? ((TileComputer) tile).getState() : ComputerState.Off );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,7 +8,6 @@ package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItemFactory;
|
||||
import dan200.computercraft.shared.computer.items.ItemComputer;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
@ -52,7 +51,7 @@ public class BlockComputer extends BlockComputerBase
|
||||
setDefaultState( this.blockState.getBaseState()
|
||||
.withProperty( Properties.FACING, EnumFacing.NORTH )
|
||||
.withProperty( Properties.ADVANCED, false )
|
||||
.withProperty( Properties.STATE, ComputerState.OFF )
|
||||
.withProperty( Properties.STATE, ComputerState.Off )
|
||||
);
|
||||
}
|
||||
|
||||
@ -126,7 +125,7 @@ public class BlockComputer extends BlockComputerBase
|
||||
public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
return state.withProperty( Properties.STATE, tile instanceof TileComputer ? ((TileComputer) tile).getState() : ComputerState.OFF );
|
||||
return state.withProperty( Properties.STATE, tile instanceof TileComputer ? ((TileComputer) tile).getState() : ComputerState.Off );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.computer.core;
|
||||
package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
@ -12,12 +12,15 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public enum ComputerState implements IStringSerializable
|
||||
{
|
||||
OFF( "off" ),
|
||||
ON( "on" ),
|
||||
BLINKING( "blinking" );
|
||||
Off( "off" ),
|
||||
On( "on" ),
|
||||
Blinking( "blinking" );
|
||||
|
||||
private static final ComputerState[] VALUES = ComputerState.values();
|
||||
|
||||
// TODO: Move to dan200.computercraft.shared.computer.core in the future. We can't do it now
|
||||
// as Plethora depends on it.
|
||||
|
||||
private String m_name;
|
||||
|
||||
ComputerState( String name )
|
||||
@ -40,7 +43,7 @@ public enum ComputerState implements IStringSerializable
|
||||
|
||||
public static ComputerState valueOf( int ordinal )
|
||||
{
|
||||
return ordinal < 0 || ordinal >= VALUES.length ? ComputerState.OFF : VALUES[ordinal];
|
||||
return ordinal < 0 || ordinal >= VALUES.length ? ComputerState.Off : VALUES[ordinal];
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItemFactory;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@ -25,7 +24,7 @@ public class TileComputer extends TileComputerBase
|
||||
private static final String TAG_STATE = "state";
|
||||
|
||||
private ComputerProxy m_proxy;
|
||||
private ComputerState state = ComputerState.OFF;
|
||||
private ComputerState state = ComputerState.Off;
|
||||
|
||||
@Override
|
||||
protected ServerComputer createComputer( int instanceID, int id )
|
||||
@ -100,7 +99,7 @@ public class TileComputer extends TileComputerBase
|
||||
if( !world.isRemote )
|
||||
{
|
||||
ServerComputer computer = getServerComputer();
|
||||
state = computer == null ? ComputerState.OFF : computer.getState();
|
||||
state = computer == null ? ComputerState.Off : computer.getState();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ package dan200.computercraft.shared.computer.core;
|
||||
import com.google.common.base.Objects;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.common.ClientTerminal;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerState;
|
||||
import dan200.computercraft.shared.network.server.ComputerActionServerMessage;
|
||||
import dan200.computercraft.shared.network.server.QueueEventServerMessage;
|
||||
import dan200.computercraft.shared.network.server.RequestComputerMessage;
|
||||
@ -109,8 +110,8 @@ public class ClientComputer extends ClientTerminal implements IComputer
|
||||
boolean oldBlinking = m_blinking;
|
||||
NBTTagCompound oldUserData = m_userData;
|
||||
|
||||
m_on = state != ComputerState.OFF;
|
||||
m_blinking = state == ComputerState.BLINKING;
|
||||
m_on = state != ComputerState.Off;
|
||||
m_blinking = state == ComputerState.Blinking;
|
||||
m_userData = userData;
|
||||
|
||||
m_changed |= m_on != oldOn || m_blinking != oldBlinking || !Objects.equal( m_userData, oldUserData );
|
||||
|
@ -7,6 +7,7 @@
|
||||
package dan200.computercraft.shared.computer.core;
|
||||
|
||||
import dan200.computercraft.shared.common.ITerminal;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerState;
|
||||
|
||||
public interface IComputer extends ITerminal
|
||||
{
|
||||
@ -31,7 +32,7 @@ public interface IComputer extends ITerminal
|
||||
|
||||
default ComputerState getState()
|
||||
{
|
||||
if( !isOn() ) return ComputerState.OFF;
|
||||
return isCursorDisplayed() ? ComputerState.BLINKING : ComputerState.ON;
|
||||
if( !isOn() ) return ComputerState.Off;
|
||||
return isCursorDisplayed() ? ComputerState.Blinking : ComputerState.On;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
package dan200.computercraft.shared.network.client;
|
||||
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerState;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.network.NetworkMessages;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -16,7 +16,7 @@ import dan200.computercraft.shared.PocketUpgrades;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.computer.core.ClientComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ComputerState;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerState;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
import dan200.computercraft.shared.pocket.apis.PocketAPI;
|
||||
@ -454,7 +454,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
public ComputerState getState( @Nonnull ItemStack stack )
|
||||
{
|
||||
ClientComputer computer = getClientComputer( stack );
|
||||
return computer == null ? ComputerState.OFF : computer.getState();
|
||||
return computer == null ? ComputerState.Off : computer.getState();
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
|
Loading…
Reference in New Issue
Block a user