mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-12 10:20:28 +00:00
A whole bunch of refomatting
- Remove redundant constructors and super calls - Standardise naming of texture fields - Always use postfix notations for loops - Cleanup several peripheral classes
This commit is contained in:
parent
27aaec9a82
commit
ee3347afbd
@ -268,10 +268,6 @@ public class ComputerCraft
|
||||
@SidedProxy( clientSide = "dan200.computercraft.client.proxy.CCTurtleProxyClient", serverSide = "dan200.computercraft.server.proxy.CCTurtleProxyServer" )
|
||||
public static ICCTurtleProxy turtleProxy;
|
||||
|
||||
public ComputerCraft()
|
||||
{
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit( FMLPreInitializationEvent event )
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ public class FixedWidthFontRenderer
|
||||
return instance = new FixedWidthFontRenderer();
|
||||
}
|
||||
|
||||
private TextureManager m_textureManager;
|
||||
private final TextureManager m_textureManager;
|
||||
|
||||
private FixedWidthFontRenderer()
|
||||
{
|
||||
|
@ -24,9 +24,9 @@ import java.io.IOException;
|
||||
|
||||
public class GuiComputer extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/corners.png" );
|
||||
private static final ResourceLocation backgroundAdvanced = new ResourceLocation( "computercraft", "textures/gui/corners_advanced.png" );
|
||||
private static final ResourceLocation backgroundCommand = new ResourceLocation( "computercraft", "textures/gui/corners_command.png" );
|
||||
private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/corners.png" );
|
||||
private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( "computercraft", "textures/gui/corners_advanced.png" );
|
||||
private static final ResourceLocation BACKGROUND_COMMAND = new ResourceLocation( "computercraft", "textures/gui/corners_command.png" );
|
||||
|
||||
private final ComputerFamily m_family;
|
||||
private final ClientComputer m_computer;
|
||||
@ -165,17 +165,17 @@ public class GuiComputer extends GuiContainer
|
||||
case Normal:
|
||||
default:
|
||||
{
|
||||
this.mc.getTextureManager().bindTexture( background );
|
||||
this.mc.getTextureManager().bindTexture( BACKGROUND );
|
||||
break;
|
||||
}
|
||||
case Advanced:
|
||||
{
|
||||
this.mc.getTextureManager().bindTexture( backgroundAdvanced );
|
||||
this.mc.getTextureManager().bindTexture( BACKGROUND_ADVANCED );
|
||||
break;
|
||||
}
|
||||
case Command:
|
||||
{
|
||||
this.mc.getTextureManager().bindTexture( backgroundCommand );
|
||||
this.mc.getTextureManager().bindTexture( BACKGROUND_COMMAND );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiDiskDrive extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/diskdrive.png" );
|
||||
private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/diskdrive.png" );
|
||||
|
||||
private final ContainerDiskDrive m_container;
|
||||
|
||||
@ -36,7 +36,7 @@ public class GuiDiskDrive extends GuiContainer
|
||||
protected void drawGuiContainerBackgroundLayer( float f, int i, int j )
|
||||
{
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
this.mc.getTextureManager().bindTexture( background );
|
||||
this.mc.getTextureManager().bindTexture( BACKGROUND );
|
||||
int l = (width - xSize) / 2;
|
||||
int i1 = (height - ySize) / 2;
|
||||
drawTexturedModalRect( l, i1, 0, 0, xSize, ySize );
|
||||
|
@ -14,7 +14,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiPrinter extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/printer.png" );
|
||||
private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/printer.png" );
|
||||
|
||||
private final ContainerPrinter m_container;
|
||||
|
||||
@ -36,7 +36,7 @@ public class GuiPrinter extends GuiContainer
|
||||
protected void drawGuiContainerBackgroundLayer( float f, int i, int j )
|
||||
{
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
this.mc.getTextureManager().bindTexture( background );
|
||||
this.mc.getTextureManager().bindTexture( BACKGROUND );
|
||||
int startX = (width - xSize) / 2;
|
||||
int startY = (height - ySize) / 2;
|
||||
drawTexturedModalRect( startX, startY, 0, 0, xSize, ySize );
|
||||
|
@ -42,30 +42,12 @@ public class GuiPrintout extends GuiContainer
|
||||
m_book = ItemPrintout.getType( container.getStack() ) == ItemPrintout.Type.Book;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed()
|
||||
{
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
super.updateScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( char c, int k ) throws IOException
|
||||
{
|
||||
|
@ -23,8 +23,8 @@ import java.io.IOException;
|
||||
|
||||
public class GuiTurtle extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/turtle.png" );
|
||||
private static final ResourceLocation backgroundAdvanced = new ResourceLocation( "computercraft", "textures/gui/turtle_advanced.png" );
|
||||
private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/turtle.png" );
|
||||
private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( "computercraft", "textures/gui/turtle_advanced.png" );
|
||||
|
||||
private ContainerTurtle m_container;
|
||||
|
||||
@ -122,7 +122,7 @@ public class GuiTurtle extends GuiContainer
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
int slotX = (slot % 4);
|
||||
int slotY = (slot / 4);
|
||||
this.mc.getTextureManager().bindTexture( advanced ? backgroundAdvanced : background );
|
||||
this.mc.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND );
|
||||
drawTexturedModalRect( x + m_container.m_turtleInvStartX - 2 + slotX * 18, y + m_container.m_playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24 );
|
||||
}
|
||||
}
|
||||
@ -136,7 +136,7 @@ public class GuiTurtle extends GuiContainer
|
||||
|
||||
// Draw border/inventory
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
this.mc.getTextureManager().bindTexture( advanced ? backgroundAdvanced : background );
|
||||
this.mc.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND );
|
||||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
drawTexturedModalRect( x, y, 0, 0, xSize, ySize );
|
||||
|
@ -18,15 +18,15 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ChatAllowedCharacters;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.BACKGROUND;
|
||||
|
||||
public class WidgetTerminal extends Widget
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/term_background.png" );
|
||||
private static final float TERMINATE_TIME = 0.5f;
|
||||
|
||||
private final IComputerContainer m_computer;
|
||||
@ -409,7 +409,7 @@ public class WidgetTerminal extends Widget
|
||||
}
|
||||
|
||||
// Draw lines
|
||||
for( int line = 0; line < th; ++line )
|
||||
for( int line = 0; line < th; line++ )
|
||||
{
|
||||
TextBuffer text = terminal.getLine( line );
|
||||
TextBuffer colour = terminal.getTextColourLine( line );
|
||||
@ -437,7 +437,7 @@ public class WidgetTerminal extends Widget
|
||||
else
|
||||
{
|
||||
// Draw a black background
|
||||
mc.getTextureManager().bindTexture( background );
|
||||
mc.getTextureManager().bindTexture( BACKGROUND );
|
||||
Colour black = Colour.Black;
|
||||
GlStateManager.color( black.getR(), black.getG(), black.getB(), 1.0f );
|
||||
try
|
||||
|
@ -32,7 +32,7 @@ public abstract class ItemMapLikeRenderer
|
||||
GlStateManager.pushMatrix();
|
||||
if( hand == EnumHand.MAIN_HAND && player.getHeldItemOffhand().isEmpty() )
|
||||
{
|
||||
renderItemFirstCentre( pitch, equipProgress, swingProgress, stack );
|
||||
renderItemFirstPersonCenter( pitch, equipProgress, swingProgress, stack );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -95,7 +95,7 @@ public abstract class ItemMapLikeRenderer
|
||||
* @param stack The stack to render
|
||||
* @see ItemRenderer#renderMapFirstPerson(float, float, float)
|
||||
*/
|
||||
private void renderItemFirstCentre( float pitch, float equipProgress, float swingProgress, ItemStack stack )
|
||||
private void renderItemFirstPersonCenter( float pitch, float equipProgress, float swingProgress, ItemStack stack )
|
||||
{
|
||||
ItemRenderer itemRenderer = Minecraft.getMinecraft().getItemRenderer();
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
package dan200.computercraft.client.render;
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.FrameInfo;
|
||||
@ -127,7 +132,7 @@ public class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
Palette palette = terminal.getPalette();
|
||||
|
||||
// Render the actual text
|
||||
for( int line = 0; line < th; ++line )
|
||||
for( int line = 0; line < th; line++ )
|
||||
{
|
||||
TextBuffer text = terminal.getLine( line );
|
||||
TextBuffer colour = terminal.getTextColourLine( line );
|
||||
|
@ -1,3 +1,9 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@ -56,7 +56,7 @@ public class PrintoutRenderer
|
||||
{
|
||||
FixedWidthFontRenderer fontRenderer = FixedWidthFontRenderer.instance();
|
||||
|
||||
for( int line = 0; line < LINES_PER_PAGE && line < text.length; ++line )
|
||||
for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ )
|
||||
{
|
||||
fontRenderer.drawString( text[start + line], x, y + line * FONT_HEIGHT, colours[start + line], null, 0, 0, false, Palette.DEFAULT );
|
||||
}
|
||||
@ -70,7 +70,7 @@ public class PrintoutRenderer
|
||||
|
||||
FixedWidthFontRenderer fontRenderer = FixedWidthFontRenderer.instance();
|
||||
|
||||
for( int line = 0; line < LINES_PER_PAGE && line < text.length; ++line )
|
||||
for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ )
|
||||
{
|
||||
fontRenderer.drawString( new TextBuffer( text[start + line] ), x, y + line * FONT_HEIGHT, new TextBuffer( colours[start + line] ), null, 0, 0, false, Palette.DEFAULT );
|
||||
}
|
||||
|
@ -1,3 +1,9 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@ -28,10 +28,6 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMonitor>
|
||||
{
|
||||
public TileEntityMonitorRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render( TileMonitor tileEntity, double posX, double posY, double posZ, float f, int i, float f2 )
|
||||
{
|
||||
|
@ -47,10 +47,6 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
private static final ModelResourceLocation COLOUR_TURTLE_MODEL = new ModelResourceLocation( "computercraft:turtle_white", "inventory" );
|
||||
private static final ModelResourceLocation ELF_OVERLAY_MODEL = new ModelResourceLocation( "computercraft:turtle_elf_overlay", "inventory" );
|
||||
|
||||
public TileEntityTurtleRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render( TileTurtle tileEntity, double posX, double posY, double posZ, float f, int i, float f2 )
|
||||
{
|
||||
|
@ -16,12 +16,6 @@ import java.util.List;
|
||||
|
||||
public class EmptyMount implements IMount
|
||||
{
|
||||
public EmptyMount()
|
||||
{
|
||||
}
|
||||
|
||||
// IMount implementation
|
||||
|
||||
@Override
|
||||
public boolean exists( @Nonnull String path )
|
||||
{
|
||||
|
@ -1,3 +1,9 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -1,5 +1,12 @@
|
||||
package dan200.computercraft.shared.command.framework;
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.command;
|
||||
|
||||
import dan200.computercraft.shared.command.framework.CommandContext;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
@ -1,5 +1,7 @@
|
||||
package dan200.computercraft.shared.command.framework;
|
||||
|
||||
import dan200.computercraft.shared.command.UserLevel;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -77,7 +77,7 @@ public class ColourableRecipe extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return ((IColouredItem) colourable.getItem()).setColour( colourable, tracker.getColour() );
|
||||
return ((IColouredItem) colourable.getItem()).withColour( colourable, tracker.getColour() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,10 +16,6 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider
|
||||
{
|
||||
public DefaultBundledRedstoneProvider()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
|
||||
{
|
||||
|
@ -6,5 +6,5 @@ public interface IColouredItem
|
||||
{
|
||||
int getColour( ItemStack stack );
|
||||
|
||||
ItemStack setColour( ItemStack stack, int colour );
|
||||
ItemStack withColour( ItemStack stack, int colour );
|
||||
}
|
||||
|
@ -56,14 +56,7 @@ public abstract class ComputerProxy
|
||||
{
|
||||
TileComputerBase tile = getTile();
|
||||
ServerComputer computer = tile.getServerComputer();
|
||||
if( computer == null )
|
||||
{
|
||||
return tile.m_computerID;
|
||||
}
|
||||
else
|
||||
{
|
||||
return computer.getID();
|
||||
}
|
||||
return computer == null ? tile.getComputerID() : computer.getID();
|
||||
}
|
||||
|
||||
public boolean isOn()
|
||||
@ -76,6 +69,6 @@ public abstract class ComputerProxy
|
||||
{
|
||||
TileComputerBase tile = getTile();
|
||||
ServerComputer computer = tile.getServerComputer();
|
||||
return computer == null ? tile.m_label : computer.getLabel();
|
||||
return computer == null ? tile.getLabel() : computer.getLabel();
|
||||
}
|
||||
}
|
||||
|
@ -32,10 +32,10 @@ import java.util.Objects;
|
||||
public abstract class TileComputerBase extends TileGeneric implements IComputerTile, IDirectionalTile, ITickable
|
||||
{
|
||||
private int m_instanceID = -1;
|
||||
protected int m_computerID = -1;
|
||||
private int m_computerID = -1;
|
||||
protected String m_label = null;
|
||||
private boolean m_on = false;
|
||||
protected boolean m_startOn = false;
|
||||
boolean m_startOn = false;
|
||||
private boolean m_fresh = false;
|
||||
|
||||
@Override
|
||||
@ -138,16 +138,10 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
public int getRedstoneOutput( EnumFacing side )
|
||||
{
|
||||
int localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) );
|
||||
if( !isRedstoneBlockedOnSide( localDir ) )
|
||||
if( !isRedstoneBlockedOnSide( localDir ) && getWorld() != null && !getWorld().isRemote )
|
||||
{
|
||||
if( getWorld() != null && !getWorld().isRemote )
|
||||
{
|
||||
ServerComputer computer = getServerComputer();
|
||||
if( computer != null )
|
||||
{
|
||||
return computer.getRedstoneOutput( localDir );
|
||||
}
|
||||
}
|
||||
ServerComputer computer = getServerComputer();
|
||||
if( computer != null ) return computer.getRedstoneOutput( localDir );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -383,28 +377,23 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
@Override
|
||||
public void setComputerID( int id )
|
||||
{
|
||||
if( !getWorld().isRemote && m_computerID != id )
|
||||
{
|
||||
m_computerID = id;
|
||||
ServerComputer computer = getServerComputer();
|
||||
if( computer != null )
|
||||
{
|
||||
computer.setID( m_computerID );
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
if( getWorld().isRemote || m_computerID == id ) return;
|
||||
|
||||
m_computerID = id;
|
||||
ServerComputer computer = getServerComputer();
|
||||
if( computer != null ) computer.setID( m_computerID );
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel( String label )
|
||||
{
|
||||
if( !getWorld().isRemote && !Objects.equals( m_label, label ) )
|
||||
{
|
||||
m_label = label;
|
||||
ServerComputer computer = getServerComputer();
|
||||
if( computer != null ) computer.setLabel( label );
|
||||
markDirty();
|
||||
}
|
||||
if( getWorld().isRemote || Objects.equals( m_label, label ) ) return;
|
||||
|
||||
m_label = label;
|
||||
ServerComputer computer = getServerComputer();
|
||||
if( computer != null ) computer.setLabel( label );
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -420,63 +409,48 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
|
||||
public ServerComputer createServerComputer()
|
||||
{
|
||||
if( !getWorld().isRemote )
|
||||
if( getWorld().isRemote ) return null;
|
||||
|
||||
boolean changed = false;
|
||||
if( m_instanceID < 0 )
|
||||
{
|
||||
boolean changed = false;
|
||||
if( m_instanceID < 0 )
|
||||
{
|
||||
m_instanceID = ComputerCraft.serverComputerRegistry.getUnusedInstanceID();
|
||||
changed = true;
|
||||
}
|
||||
if( !ComputerCraft.serverComputerRegistry.contains( m_instanceID ) )
|
||||
{
|
||||
ServerComputer computer = createComputer( m_instanceID, m_computerID );
|
||||
ComputerCraft.serverComputerRegistry.add( m_instanceID, computer );
|
||||
m_fresh = true;
|
||||
changed = true;
|
||||
}
|
||||
if( changed )
|
||||
{
|
||||
updateBlock();
|
||||
updateInput();
|
||||
}
|
||||
return ComputerCraft.serverComputerRegistry.get( m_instanceID );
|
||||
m_instanceID = ComputerCraft.serverComputerRegistry.getUnusedInstanceID();
|
||||
changed = true;
|
||||
}
|
||||
return null;
|
||||
if( !ComputerCraft.serverComputerRegistry.contains( m_instanceID ) )
|
||||
{
|
||||
ServerComputer computer = createComputer( m_instanceID, m_computerID );
|
||||
ComputerCraft.serverComputerRegistry.add( m_instanceID, computer );
|
||||
m_fresh = true;
|
||||
changed = true;
|
||||
}
|
||||
if( changed )
|
||||
{
|
||||
updateBlock();
|
||||
updateInput();
|
||||
}
|
||||
return ComputerCraft.serverComputerRegistry.get( m_instanceID );
|
||||
}
|
||||
|
||||
public ServerComputer getServerComputer()
|
||||
{
|
||||
if( !getWorld().isRemote )
|
||||
{
|
||||
return ComputerCraft.serverComputerRegistry.get( m_instanceID );
|
||||
}
|
||||
return null;
|
||||
return getWorld().isRemote ? null : ComputerCraft.serverComputerRegistry.get( m_instanceID );
|
||||
}
|
||||
|
||||
public ClientComputer createClientComputer()
|
||||
{
|
||||
if( getWorld().isRemote )
|
||||
if( !getWorld().isRemote || m_instanceID < 0 ) return null;
|
||||
|
||||
if( !ComputerCraft.clientComputerRegistry.contains( m_instanceID ) )
|
||||
{
|
||||
if( m_instanceID >= 0 )
|
||||
{
|
||||
if( !ComputerCraft.clientComputerRegistry.contains( m_instanceID ) )
|
||||
{
|
||||
ComputerCraft.clientComputerRegistry.add( m_instanceID, new ClientComputer( m_instanceID ) );
|
||||
}
|
||||
return ComputerCraft.clientComputerRegistry.get( m_instanceID );
|
||||
}
|
||||
ComputerCraft.clientComputerRegistry.add( m_instanceID, new ClientComputer( m_instanceID ) );
|
||||
}
|
||||
return null;
|
||||
return ComputerCraft.clientComputerRegistry.get( m_instanceID );
|
||||
}
|
||||
|
||||
public ClientComputer getClientComputer()
|
||||
{
|
||||
if( getWorld().isRemote )
|
||||
{
|
||||
return ComputerCraft.clientComputerRegistry.get( m_instanceID );
|
||||
}
|
||||
return null;
|
||||
return getWorld().isRemote ? ComputerCraft.clientComputerRegistry.get( m_instanceID ) : null;
|
||||
}
|
||||
|
||||
// Networking stuff
|
||||
|
@ -8,10 +8,6 @@ package dan200.computercraft.shared.computer.core;
|
||||
|
||||
public class ClientComputerRegistry extends ComputerRegistry<ClientComputer>
|
||||
{
|
||||
public ClientComputerRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
for( ClientComputer computer : getComputers() )
|
||||
@ -23,25 +19,7 @@ public class ClientComputerRegistry extends ComputerRegistry<ClientComputer>
|
||||
@Override
|
||||
public void add( int instanceID, ClientComputer computer )
|
||||
{
|
||||
//System.out.println( "ADD CLIENT COMPUTER " + instanceID );
|
||||
super.add( instanceID, computer );
|
||||
computer.requestState();
|
||||
//System.out.println( getComputers().size() + " CLIENT COMPUTERS" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove( int instanceID )
|
||||
{
|
||||
//System.out.println( "REMOVE CLIENT COMPUTER " + instanceID );
|
||||
super.remove( instanceID );
|
||||
//System.out.println( getComputers().size() + " CLIENT COMPUTERS" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
//System.out.println( "RESET CLIENT COMPUTERS" );
|
||||
super.reset();
|
||||
//System.out.println( getComputers().size() + " CLIENT COMPUTERS" );
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public abstract class ComputerConvertRecipe extends ShapedRecipes
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract ItemStack convert( @Nonnull ItemStack stack );
|
||||
protected abstract ItemStack convert( IComputerItem item, @Nonnull ItemStack stack );
|
||||
|
||||
@Override
|
||||
public boolean matches( @Nonnull InventoryCrafting inventory, @Nonnull World world )
|
||||
@ -54,10 +54,13 @@ public abstract class ComputerConvertRecipe extends ShapedRecipes
|
||||
{
|
||||
for( int x = 0; x < 3; x++ )
|
||||
{
|
||||
ItemStack item = inventory.getStackInRowAndColumn( x, y );
|
||||
ItemStack stack = inventory.getStackInRowAndColumn( x, y );
|
||||
|
||||
// If we're a computer, convert!
|
||||
if( item.getItem() instanceof IComputerItem ) return convert( item );
|
||||
if( stack.getItem() instanceof IComputerItem )
|
||||
{
|
||||
return convert( ((IComputerItem) stack.getItem()), stack );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,9 @@ public class ComputerFamilyRecipe extends ComputerConvertRecipe
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ItemStack convert( @Nonnull ItemStack stack )
|
||||
protected ItemStack convert( IComputerItem item, @Nonnull ItemStack stack )
|
||||
{
|
||||
return ((IComputerItem) stack.getItem()).withFamily( stack, family );
|
||||
return item.withFamily( stack, family );
|
||||
}
|
||||
|
||||
public static class Factory implements IRecipeFactory
|
||||
|
@ -1,3 +1,9 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.media.common;
|
||||
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
|
@ -15,10 +15,6 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemDiskExpanded extends ItemDiskLegacy
|
||||
{
|
||||
public ItemDiskExpanded()
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ItemStack createFromIDAndColour( int id, String label, int colour )
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ public class ItemDiskLegacy extends Item
|
||||
public void getSubItems( @Nonnull CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
for( int colour = 0; colour < 16; ++colour )
|
||||
for( int colour = 0; colour < 16; colour++ )
|
||||
{
|
||||
ItemStack stack = createFromIDAndColour( -1, null, Colour.values()[colour].getHex() );
|
||||
if( stack.getItem() == this )
|
||||
@ -142,7 +142,7 @@ public class ItemDiskLegacy extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setColour( ItemStack stack, int colour )
|
||||
public ItemStack withColour( ItemStack stack, int colour )
|
||||
{
|
||||
return ItemDiskExpanded.createFromIDAndColour( getDiskID( stack ), getLabel( stack ), colour );
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements
|
||||
String[] colours = new String[numPages * ItemPrintout.LINES_PER_PAGE];
|
||||
int line = 0;
|
||||
|
||||
for( int printout = 0; printout < numPrintouts; ++printout )
|
||||
for( int printout = 0; printout < numPrintouts; printout++ )
|
||||
{
|
||||
ItemStack stack = printouts[printout];
|
||||
if( stack.getItem() instanceof ItemPrintout )
|
||||
@ -121,7 +121,7 @@ public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements
|
||||
// Add a printout
|
||||
String[] pageText = ItemPrintout.getText( printouts[printout] );
|
||||
String[] pageColours = ItemPrintout.getColours( printouts[printout] );
|
||||
for( int pageLine = 0; pageLine < pageText.length; ++pageLine )
|
||||
for( int pageLine = 0; pageLine < pageText.length; pageLine++ )
|
||||
{
|
||||
text[line] = pageText[pageLine];
|
||||
colours[line] = pageColours[pageLine];
|
||||
@ -131,7 +131,7 @@ public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements
|
||||
else
|
||||
{
|
||||
// Add a blank page
|
||||
for( int pageLine = 0; pageLine < ItemPrintout.LINES_PER_PAGE; ++pageLine )
|
||||
for( int pageLine = 0; pageLine < ItemPrintout.LINES_PER_PAGE; pageLine++ )
|
||||
{
|
||||
text[line] = "";
|
||||
colours[line] = "";
|
||||
|
@ -9,12 +9,11 @@ package dan200.computercraft.shared.network.client;
|
||||
import dan200.computercraft.shared.command.text.TableBuilder;
|
||||
import dan200.computercraft.shared.network.NetworkMessage;
|
||||
import dan200.computercraft.shared.network.NetworkMessages;
|
||||
import dan200.computercraft.shared.util.NBTUtil;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
public class ChatTableClientMessage implements NetworkMessage
|
||||
{
|
||||
@ -62,34 +61,27 @@ public class ChatTableClientMessage implements NetworkMessage
|
||||
@Override
|
||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
||||
{
|
||||
try
|
||||
int id = buf.readVarInt();
|
||||
int columns = buf.readVarInt();
|
||||
TableBuilder table;
|
||||
if( buf.readBoolean() )
|
||||
{
|
||||
int id = buf.readVarInt();
|
||||
int columns = buf.readVarInt();
|
||||
TableBuilder table;
|
||||
if( buf.readBoolean() )
|
||||
{
|
||||
ITextComponent[] headers = new ITextComponent[columns];
|
||||
for( int i = 0; i < columns; i++ ) headers[i] = buf.readTextComponent();
|
||||
table = new TableBuilder( id, headers );
|
||||
}
|
||||
else
|
||||
{
|
||||
table = new TableBuilder( id );
|
||||
}
|
||||
ITextComponent[] headers = new ITextComponent[columns];
|
||||
for( int i = 0; i < columns; i++ ) headers[i] = NBTUtil.readTextComponent( buf );
|
||||
table = new TableBuilder( id, headers );
|
||||
}
|
||||
else
|
||||
{
|
||||
table = new TableBuilder( id );
|
||||
}
|
||||
|
||||
int rows = buf.readVarInt();
|
||||
for( int i = 0; i < rows; i++ )
|
||||
{
|
||||
ITextComponent[] row = new ITextComponent[columns];
|
||||
for( int j = 0; j < columns; j++ ) row[j] = buf.readTextComponent();
|
||||
table.row( row );
|
||||
}
|
||||
this.table = table;
|
||||
}
|
||||
catch( IOException e )
|
||||
int rows = buf.readVarInt();
|
||||
for( int i = 0; i < rows; i++ )
|
||||
{
|
||||
throw new UncheckedIOException( e );
|
||||
ITextComponent[] row = new ITextComponent[columns];
|
||||
for( int j = 0; j < columns; j++ ) row[j] = NBTUtil.readTextComponent( buf );
|
||||
table.row( row );
|
||||
}
|
||||
this.table = table;
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,11 @@ package dan200.computercraft.shared.network.client;
|
||||
import dan200.computercraft.shared.computer.blocks.ComputerState;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.network.NetworkMessages;
|
||||
import dan200.computercraft.shared.util.NBTUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
/**
|
||||
* Provides additional data about a client computer, such as its ID and current state.
|
||||
@ -64,13 +63,6 @@ public class ComputerDataClientMessage extends ComputerClientMessage
|
||||
{
|
||||
super.fromBytes( buf );
|
||||
state = buf.readEnumValue( ComputerState.class );
|
||||
try
|
||||
{
|
||||
userData = buf.readCompoundTag();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new UncheckedIOException( e );
|
||||
}
|
||||
userData = NBTUtil.readCompoundTag( buf );
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,11 @@
|
||||
package dan200.computercraft.shared.network.client;
|
||||
|
||||
import dan200.computercraft.shared.network.NetworkMessages;
|
||||
import dan200.computercraft.shared.util.NBTUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
public class ComputerTerminalClientMessage extends ComputerClientMessage
|
||||
{
|
||||
@ -50,13 +49,6 @@ public class ComputerTerminalClientMessage extends ComputerClientMessage
|
||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
||||
{
|
||||
super.fromBytes( buf );
|
||||
try
|
||||
{
|
||||
tag = buf.readCompoundTag();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new UncheckedIOException( e );
|
||||
}
|
||||
tag = NBTUtil.readCompoundTag( buf );
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
/**
|
||||
* Queue an event on a {@link dan200.computercraft.shared.computer.core.ServerComputer}.
|
||||
@ -70,14 +68,7 @@ public class QueueEventServerMessage extends ComputerServerMessage
|
||||
super.fromBytes( buf );
|
||||
event = buf.readString( Short.MAX_VALUE );
|
||||
|
||||
try
|
||||
{
|
||||
NBTTagCompound args = buf.readCompoundTag();
|
||||
this.args = args == null ? null : NBTUtil.decodeObjects( args );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new UncheckedIOException( e );
|
||||
}
|
||||
NBTTagCompound args = NBTUtil.readCompoundTag( buf );
|
||||
this.args = args == null ? null : NBTUtil.decodeObjects( args );
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,6 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class DefaultPeripheralProvider implements IPeripheralProvider
|
||||
{
|
||||
public DefaultPeripheralProvider()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
|
||||
{
|
||||
|
@ -23,17 +23,17 @@ public class ContainerDiskDrive extends Container
|
||||
m_diskDrive = diskDrive;
|
||||
addSlotToContainer( new Slot( m_diskDrive, 0, 8 + 4 * 18, 35 ) );
|
||||
|
||||
for( int j = 0; j < 3; j++ )
|
||||
for( int y = 0; y < 3; y++ )
|
||||
{
|
||||
for( int i1 = 0; i1 < 9; i1++ )
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
addSlotToContainer( new Slot( playerInventory, i1 + j * 9 + 9, 8 + i1 * 18, 84 + j * 18 ) );
|
||||
addSlotToContainer( new Slot( playerInventory, x + y * 9 + 9, 8 + x * 18, 84 + y * 18 ) );
|
||||
}
|
||||
}
|
||||
|
||||
for( int k = 0; k < 9; k++ )
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
addSlotToContainer( new Slot( playerInventory, k, 8 + k * 18, 142 ) );
|
||||
addSlotToContainer( new Slot( playerInventory, x, 8 + x * 18, 142 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,44 +50,38 @@ public class ContainerDiskDrive extends Container
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( EntityPlayer player, int i )
|
||||
public ItemStack transferStackInSlot( EntityPlayer player, int slotIndex )
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = inventorySlots.get( i );
|
||||
if( slot != null && slot.getHasStack() )
|
||||
ItemStack extract = ItemStack.EMPTY;
|
||||
Slot slot = inventorySlots.get( slotIndex );
|
||||
if( slot == null || !slot.getHasStack() ) return extract;
|
||||
|
||||
ItemStack existing = slot.getStack().copy();
|
||||
extract = existing.copy();
|
||||
if( slotIndex == 0 )
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack().copy();
|
||||
itemstack = itemstack1.copy();
|
||||
if( i == 0 )
|
||||
{
|
||||
if( !mergeItemStack( itemstack1, 1, 37, true ) )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if( !mergeItemStack( itemstack1, 0, 1, false ) )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( itemstack1.isEmpty() )
|
||||
{
|
||||
slot.putStack( ItemStack.EMPTY );
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if( itemstack1.getCount() != itemstack.getCount() )
|
||||
{
|
||||
slot.onTake( player, itemstack1 );
|
||||
}
|
||||
else
|
||||
if( !mergeItemStack( existing, 1, 37, true ) )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
return itemstack;
|
||||
else if( !mergeItemStack( existing, 0, 1, false ) )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( existing.isEmpty() )
|
||||
{
|
||||
slot.putStack( ItemStack.EMPTY );
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if( existing.getCount() == extract.getCount() ) return ItemStack.EMPTY;
|
||||
|
||||
slot.onTake( player, existing );
|
||||
return extract;
|
||||
}
|
||||
}
|
||||
|
@ -61,21 +61,13 @@ public class DiskDrivePeripheral implements IPeripheral
|
||||
switch( method )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
// isDiskPresent
|
||||
return new Object[] {
|
||||
!m_diskDrive.getDiskStack().isEmpty()
|
||||
};
|
||||
}
|
||||
return new Object[] { !m_diskDrive.getDiskStack().isEmpty() };
|
||||
case 1:
|
||||
{
|
||||
// getDiskLabel
|
||||
IMedia media = m_diskDrive.getDiskMedia();
|
||||
if( media != null )
|
||||
{
|
||||
return new Object[] { media.getLabel( m_diskDrive.getDiskStack() ) };
|
||||
}
|
||||
return null;
|
||||
return media == null ? null : new Object[] { media.getLabel( m_diskDrive.getDiskStack() ) };
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
@ -83,91 +75,55 @@ public class DiskDrivePeripheral implements IPeripheral
|
||||
String label = optString( arguments, 0, null );
|
||||
|
||||
IMedia media = m_diskDrive.getDiskMedia();
|
||||
if( media != null )
|
||||
{
|
||||
ItemStack disk = m_diskDrive.getDiskStack();
|
||||
label = StringUtil.normaliseLabel( label );
|
||||
if( media.setLabel( disk, label ) )
|
||||
{
|
||||
m_diskDrive.setDiskStack( disk );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new LuaException( "Disk label cannot be changed" );
|
||||
}
|
||||
}
|
||||
if( media == null ) return null;
|
||||
|
||||
ItemStack disk = m_diskDrive.getDiskStack();
|
||||
label = StringUtil.normaliseLabel( label );
|
||||
if( !media.setLabel( disk, label ) ) throw new LuaException( "Disk label cannot be changed" );
|
||||
m_diskDrive.setDiskStack( disk );
|
||||
return null;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
// hasData
|
||||
return new Object[] {
|
||||
m_diskDrive.getDiskMountPath( computer ) != null
|
||||
};
|
||||
}
|
||||
return new Object[] { m_diskDrive.getDiskMountPath( computer ) != null };
|
||||
case 4:
|
||||
{
|
||||
// getMountPath
|
||||
return new Object[] {
|
||||
m_diskDrive.getDiskMountPath( computer )
|
||||
};
|
||||
return new Object[] { m_diskDrive.getDiskMountPath( computer ) };
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
// hasAudio
|
||||
IMedia media = m_diskDrive.getDiskMedia();
|
||||
if( media != null )
|
||||
{
|
||||
return new Object[] { media.getAudio( m_diskDrive.getDiskStack() ) != null };
|
||||
}
|
||||
return new Object[] { false };
|
||||
return new Object[] { media != null && media.getAudio( m_diskDrive.getDiskStack() ) != null };
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
// getAudioTitle
|
||||
IMedia media = m_diskDrive.getDiskMedia();
|
||||
if( media != null )
|
||||
{
|
||||
return new Object[] { media.getAudioTitle( m_diskDrive.getDiskStack() ) };
|
||||
}
|
||||
return new Object[] { false };
|
||||
return new Object[] { media != null ? media.getAudioTitle( m_diskDrive.getDiskStack() ) : false };
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
// playAudio
|
||||
m_diskDrive.playDiskAudio();
|
||||
return null;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
// stopAudio
|
||||
m_diskDrive.stopDiskAudio();
|
||||
return null;
|
||||
}
|
||||
case 9:
|
||||
{
|
||||
// eject
|
||||
m_diskDrive.ejectDisk();
|
||||
return null;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
// getDiskID
|
||||
ItemStack disk = m_diskDrive.getDiskStack();
|
||||
if( disk != null )
|
||||
{
|
||||
Item item = disk.getItem();
|
||||
if( item instanceof ItemDiskLegacy )
|
||||
{
|
||||
return new Object[] { ((ItemDiskLegacy) item).getDiskID( disk ) };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
Item item = disk.getItem();
|
||||
return item instanceof ItemDiskLegacy ? new Object[] { ((ItemDiskLegacy) item).getDiskID( disk ) } : null;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,15 +142,9 @@ public class DiskDrivePeripheral implements IPeripheral
|
||||
@Override
|
||||
public boolean equals( IPeripheral other )
|
||||
{
|
||||
if( other instanceof DiskDrivePeripheral )
|
||||
{
|
||||
DiskDrivePeripheral otherDiskDrive = (DiskDrivePeripheral) other;
|
||||
if( otherDiskDrive.m_diskDrive == this.m_diskDrive )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if( this == other ) return true;
|
||||
if( !(other instanceof DiskDrivePeripheral) ) return false;
|
||||
return ((DiskDrivePeripheral) other).m_diskDrive == this.m_diskDrive;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -129,10 +129,7 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
@Override
|
||||
public void setDirection( EnumFacing dir )
|
||||
{
|
||||
if( dir.getAxis() == EnumFacing.Axis.Y )
|
||||
{
|
||||
dir = EnumFacing.NORTH;
|
||||
}
|
||||
if( dir.getAxis() == EnumFacing.Axis.Y ) dir = EnumFacing.NORTH;
|
||||
setBlockState( getBlockState().withProperty( BlockPeripheral.Properties.FACING, dir ) );
|
||||
}
|
||||
|
||||
@ -239,10 +236,7 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
@Override
|
||||
public ItemStack decrStackSize( int i, int j )
|
||||
{
|
||||
if( m_diskStack.isEmpty() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if( m_diskStack.isEmpty() ) return ItemStack.EMPTY;
|
||||
|
||||
if( m_diskStack.getCount() <= j )
|
||||
{
|
||||
@ -252,14 +246,7 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
}
|
||||
|
||||
ItemStack part = m_diskStack.splitStack( j );
|
||||
if( m_diskStack.isEmpty() )
|
||||
{
|
||||
setInventorySlotContents( 0, ItemStack.EMPTY );
|
||||
}
|
||||
else
|
||||
{
|
||||
setInventorySlotContents( 0, m_diskStack );
|
||||
}
|
||||
setInventorySlotContents( 0, m_diskStack.isEmpty() ? ItemStack.EMPTY : m_diskStack );
|
||||
return part;
|
||||
}
|
||||
|
||||
@ -331,28 +318,14 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
public String getName()
|
||||
{
|
||||
String label = getLabel();
|
||||
if( label != null )
|
||||
{
|
||||
return label;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "tile.computercraft:drive.name";
|
||||
}
|
||||
return label != null ? label : "tile.computercraft:drive.name";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
if( hasCustomName() )
|
||||
{
|
||||
return new TextComponentString( getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TextComponentTranslation( getName() );
|
||||
}
|
||||
return hasCustomName() ? new TextComponentString( getName() ) : new TextComponentTranslation( getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -448,10 +421,7 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
{
|
||||
synchronized( this )
|
||||
{
|
||||
if( !m_ejectQueued )
|
||||
{
|
||||
m_ejectQueued = true;
|
||||
}
|
||||
m_ejectQueued = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,14 +491,7 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
if( !m_diskStack.isEmpty() )
|
||||
{
|
||||
IMedia contents = getDiskMedia();
|
||||
if( contents != null )
|
||||
{
|
||||
setAnim( 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
setAnim( 1 );
|
||||
}
|
||||
setAnim( contents != null ? 2 : 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -424,20 +424,14 @@ public class TileMonitor extends TilePeripheralBase
|
||||
if( pos.equals( getPos() ) ) return this;
|
||||
|
||||
World world = getWorld();
|
||||
if( world != null && world.isBlockLoaded( pos ) )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile instanceof TileMonitor )
|
||||
{
|
||||
TileMonitor monitor = (TileMonitor) tile;
|
||||
if( monitor.getDir() == getDir() && monitor.m_advanced == m_advanced &&
|
||||
!monitor.m_destroyed && !monitor.m_ignoreMe )
|
||||
{
|
||||
return monitor;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
if( world == null || !world.isBlockLoaded( pos ) ) return null;
|
||||
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( !(tile instanceof TileMonitor) ) return null;
|
||||
|
||||
TileMonitor monitor = (TileMonitor) tile;
|
||||
return monitor.getDir() == getDir() && monitor.m_advanced == m_advanced &&
|
||||
!monitor.m_destroyed && !monitor.m_ignoreMe ? monitor : null;
|
||||
}
|
||||
|
||||
private TileMonitor getNeighbour( int x, int y )
|
||||
@ -447,9 +441,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
EnumFacing down = getDown();
|
||||
int xOffset = -m_xIndex + x;
|
||||
int yOffset = -m_yIndex + y;
|
||||
return getSimilarMonitorAt(
|
||||
pos.offset( right, xOffset ).offset( down, yOffset )
|
||||
);
|
||||
return getSimilarMonitorAt( pos.offset( right, xOffset ).offset( down, yOffset ) );
|
||||
}
|
||||
|
||||
public TileMonitor getOrigin()
|
||||
@ -520,88 +512,62 @@ public class TileMonitor extends TilePeripheralBase
|
||||
private boolean mergeLeft()
|
||||
{
|
||||
TileMonitor left = getNeighbour( -1, 0 );
|
||||
if( left != null && left.m_yIndex == 0 && left.m_height == m_height )
|
||||
{
|
||||
int width = left.m_width + m_width;
|
||||
if( width <= MAX_WIDTH )
|
||||
{
|
||||
TileMonitor origin = left.getOrigin();
|
||||
if( origin != null )
|
||||
{
|
||||
origin.resize( width, m_height );
|
||||
}
|
||||
left.expand();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if( left == null || left.m_yIndex != 0 || left.m_height != m_height ) return false;
|
||||
|
||||
int width = left.m_width + m_width;
|
||||
if( width > MAX_WIDTH ) return false;
|
||||
|
||||
TileMonitor origin = left.getOrigin();
|
||||
if( origin != null ) origin.resize( width, m_height );
|
||||
left.expand();
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean mergeRight()
|
||||
{
|
||||
TileMonitor right = getNeighbour( m_width, 0 );
|
||||
if( right != null && right.m_yIndex == 0 && right.m_height == m_height )
|
||||
{
|
||||
int width = m_width + right.m_width;
|
||||
if( width <= MAX_WIDTH )
|
||||
{
|
||||
TileMonitor origin = getOrigin();
|
||||
if( origin != null )
|
||||
{
|
||||
origin.resize( width, m_height );
|
||||
}
|
||||
expand();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if( right == null || right.m_yIndex != 0 || right.m_height != m_height ) return false;
|
||||
|
||||
int width = m_width + right.m_width;
|
||||
if( width > MAX_WIDTH ) return false;
|
||||
|
||||
TileMonitor origin = getOrigin();
|
||||
if( origin != null ) origin.resize( width, m_height );
|
||||
expand();
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean mergeUp()
|
||||
{
|
||||
TileMonitor above = getNeighbour( 0, m_height );
|
||||
if( above != null && above.m_xIndex == 0 && above.m_width == m_width )
|
||||
{
|
||||
int height = above.m_height + m_height;
|
||||
if( height <= MAX_HEIGHT )
|
||||
{
|
||||
TileMonitor origin = getOrigin();
|
||||
if( origin != null )
|
||||
{
|
||||
origin.resize( m_width, height );
|
||||
}
|
||||
expand();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if( above == null || above.m_xIndex != 0 || above.m_width != m_width ) return false;
|
||||
|
||||
int height = above.m_height + m_height;
|
||||
if( height > MAX_HEIGHT ) return false;
|
||||
|
||||
TileMonitor origin = getOrigin();
|
||||
if( origin != null ) origin.resize( m_width, height );
|
||||
expand();
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean mergeDown()
|
||||
{
|
||||
TileMonitor below = getNeighbour( 0, -1 );
|
||||
if( below != null && below.m_xIndex == 0 && below.m_width == m_width )
|
||||
{
|
||||
int height = m_height + below.m_height;
|
||||
if( height <= MAX_HEIGHT )
|
||||
{
|
||||
TileMonitor origin = below.getOrigin();
|
||||
if( origin != null )
|
||||
{
|
||||
origin.resize( m_width, height );
|
||||
}
|
||||
below.expand();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if( below == null || below.m_xIndex != 0 || below.m_width != m_width ) return false;
|
||||
|
||||
int height = m_height + below.m_height;
|
||||
if( height > MAX_HEIGHT ) return false;
|
||||
|
||||
TileMonitor origin = below.getOrigin();
|
||||
if( origin != null ) origin.resize( m_width, height );
|
||||
below.expand();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void expand()
|
||||
{
|
||||
while( mergeLeft() || mergeRight() || mergeUp() || mergeDown() )
|
||||
{
|
||||
}
|
||||
while( mergeLeft() || mergeRight() || mergeUp() || mergeDown() ) ;
|
||||
}
|
||||
|
||||
public void contractNeighbours()
|
||||
@ -610,34 +576,22 @@ public class TileMonitor extends TilePeripheralBase
|
||||
if( m_xIndex > 0 )
|
||||
{
|
||||
TileMonitor left = getNeighbour( m_xIndex - 1, m_yIndex );
|
||||
if( left != null )
|
||||
{
|
||||
left.contract();
|
||||
}
|
||||
if( left != null ) left.contract();
|
||||
}
|
||||
if( m_xIndex + 1 < m_width )
|
||||
{
|
||||
TileMonitor right = getNeighbour( m_xIndex + 1, m_yIndex );
|
||||
if( right != null )
|
||||
{
|
||||
right.contract();
|
||||
}
|
||||
if( right != null ) right.contract();
|
||||
}
|
||||
if( m_yIndex > 0 )
|
||||
{
|
||||
TileMonitor below = getNeighbour( m_xIndex, m_yIndex - 1 );
|
||||
if( below != null )
|
||||
{
|
||||
below.contract();
|
||||
}
|
||||
if( below != null ) below.contract();
|
||||
}
|
||||
if( m_yIndex + 1 < m_height )
|
||||
{
|
||||
TileMonitor above = getNeighbour( m_xIndex, m_yIndex + 1 );
|
||||
if( above != null )
|
||||
{
|
||||
above.contract();
|
||||
}
|
||||
if( above != null ) above.contract();
|
||||
}
|
||||
m_ignoreMe = false;
|
||||
}
|
||||
@ -650,32 +604,13 @@ public class TileMonitor extends TilePeripheralBase
|
||||
TileMonitor origin = getOrigin();
|
||||
if( origin == null )
|
||||
{
|
||||
TileMonitor right = null;
|
||||
TileMonitor below = null;
|
||||
if( width > 1 )
|
||||
{
|
||||
right = getNeighbour( 1, 0 );
|
||||
}
|
||||
if( height > 1 )
|
||||
{
|
||||
below = getNeighbour( 0, 1 );
|
||||
}
|
||||
if( right != null )
|
||||
{
|
||||
right.resize( width - 1, 1 );
|
||||
}
|
||||
if( below != null )
|
||||
{
|
||||
below.resize( width, height - 1 );
|
||||
}
|
||||
if( right != null )
|
||||
{
|
||||
right.expand();
|
||||
}
|
||||
if( below != null )
|
||||
{
|
||||
below.expand();
|
||||
}
|
||||
TileMonitor right = width > 1 ? getNeighbour( 1, 0 ) : null;
|
||||
TileMonitor below = height > 1 ? getNeighbour( 0, 1 ) : null;
|
||||
|
||||
if( right != null ) right.resize( width - 1, 1 );
|
||||
if( below != null ) below.resize( width, height - 1 );
|
||||
if( right != null ) right.expand();
|
||||
if( below != null ) below.expand();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -684,54 +619,41 @@ public class TileMonitor extends TilePeripheralBase
|
||||
for( int x = 0; x < width; x++ )
|
||||
{
|
||||
TileMonitor monitor = origin.getNeighbour( x, y );
|
||||
if( monitor == null )
|
||||
if( monitor != null ) continue;
|
||||
|
||||
// Decompose
|
||||
TileMonitor above = null;
|
||||
TileMonitor left = null;
|
||||
TileMonitor right = null;
|
||||
TileMonitor below = null;
|
||||
|
||||
if( y > 0 )
|
||||
{
|
||||
// Decompose
|
||||
TileMonitor above = null;
|
||||
TileMonitor left = null;
|
||||
TileMonitor right = null;
|
||||
TileMonitor below = null;
|
||||
|
||||
if( y > 0 )
|
||||
{
|
||||
above = origin;
|
||||
above.resize( width, y );
|
||||
}
|
||||
if( x > 0 )
|
||||
{
|
||||
left = origin.getNeighbour( 0, y );
|
||||
left.resize( x, 1 );
|
||||
}
|
||||
if( x + 1 < width )
|
||||
{
|
||||
right = origin.getNeighbour( x + 1, y );
|
||||
right.resize( width - (x + 1), 1 );
|
||||
}
|
||||
if( y + 1 < height )
|
||||
{
|
||||
below = origin.getNeighbour( 0, y + 1 );
|
||||
below.resize( width, height - (y + 1) );
|
||||
}
|
||||
|
||||
// Re-expand
|
||||
if( above != null )
|
||||
{
|
||||
above.expand();
|
||||
}
|
||||
if( left != null )
|
||||
{
|
||||
left.expand();
|
||||
}
|
||||
if( right != null )
|
||||
{
|
||||
right.expand();
|
||||
}
|
||||
if( below != null )
|
||||
{
|
||||
below.expand();
|
||||
}
|
||||
return;
|
||||
above = origin;
|
||||
above.resize( width, y );
|
||||
}
|
||||
if( x > 0 )
|
||||
{
|
||||
left = origin.getNeighbour( 0, y );
|
||||
left.resize( x, 1 );
|
||||
}
|
||||
if( x + 1 < width )
|
||||
{
|
||||
right = origin.getNeighbour( x + 1, y );
|
||||
right.resize( width - (x + 1), 1 );
|
||||
}
|
||||
if( y + 1 < height )
|
||||
{
|
||||
below = origin.getNeighbour( 0, y + 1 );
|
||||
below.resize( width, height - (y + 1) );
|
||||
}
|
||||
|
||||
// Re-expand
|
||||
if( above != null ) above.expand();
|
||||
if( left != null ) left.expand();
|
||||
if( right != null ) right.expand();
|
||||
if( below != null ) below.expand();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -739,7 +661,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
public void monitorTouched( float xPos, float yPos, float zPos )
|
||||
{
|
||||
int side = getDir();
|
||||
XYPair pair = convertToXY( xPos, yPos, zPos, side );
|
||||
XYPair pair = XYPair.of( xPos, yPos, zPos, side );
|
||||
pair = new XYPair( pair.x + m_xIndex, pair.y + m_height - m_yIndex - 1 );
|
||||
|
||||
if( pair.x > (m_width - RENDER_BORDER) || pair.y > (m_height - RENDER_BORDER) || pair.x < (RENDER_BORDER) || pair.y < (RENDER_BORDER) )
|
||||
@ -776,39 +698,6 @@ public class TileMonitor extends TilePeripheralBase
|
||||
}
|
||||
}
|
||||
|
||||
private XYPair convertToXY( float xPos, float yPos, float zPos, int side )
|
||||
{
|
||||
switch( side )
|
||||
{
|
||||
case 2:
|
||||
return new XYPair( 1 - xPos, 1 - yPos );
|
||||
case 3:
|
||||
return new XYPair( xPos, 1 - yPos );
|
||||
case 4:
|
||||
return new XYPair( zPos, 1 - yPos );
|
||||
case 5:
|
||||
return new XYPair( 1 - zPos, 1 - yPos );
|
||||
case 8:
|
||||
return new XYPair( 1 - xPos, zPos );
|
||||
case 9:
|
||||
return new XYPair( xPos, 1 - zPos );
|
||||
case 10:
|
||||
return new XYPair( zPos, xPos );
|
||||
case 11:
|
||||
return new XYPair( 1 - zPos, 1 - xPos );
|
||||
case 14:
|
||||
return new XYPair( 1 - xPos, 1 - zPos );
|
||||
case 15:
|
||||
return new XYPair( xPos, zPos );
|
||||
case 16:
|
||||
return new XYPair( zPos, 1 - xPos );
|
||||
case 17:
|
||||
return new XYPair( 1 - zPos, xPos );
|
||||
default:
|
||||
return new XYPair( xPos, zPos );
|
||||
}
|
||||
}
|
||||
|
||||
public void addComputer( IComputerAccess computer )
|
||||
{
|
||||
synchronized( this )
|
||||
@ -825,18 +714,6 @@ public class TileMonitor extends TilePeripheralBase
|
||||
}
|
||||
}
|
||||
|
||||
public static class XYPair
|
||||
{
|
||||
public final float x;
|
||||
public final float y;
|
||||
|
||||
private XYPair( float x, float y )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.peripheral.monitor;
|
||||
|
||||
public class XYPair
|
||||
{
|
||||
public final float x;
|
||||
public final float y;
|
||||
|
||||
public XYPair( float x, float y )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public XYPair add( float x, float y )
|
||||
{
|
||||
return new XYPair( this.x + x, this.y + y );
|
||||
}
|
||||
|
||||
public static XYPair of( float xPos, float yPos, float zPos, int side )
|
||||
{
|
||||
switch( side )
|
||||
{
|
||||
case 2:
|
||||
return new XYPair( 1 - xPos, 1 - yPos );
|
||||
case 3:
|
||||
return new XYPair( xPos, 1 - yPos );
|
||||
case 4:
|
||||
return new XYPair( zPos, 1 - yPos );
|
||||
case 5:
|
||||
return new XYPair( 1 - zPos, 1 - yPos );
|
||||
case 8:
|
||||
return new XYPair( 1 - xPos, zPos );
|
||||
case 9:
|
||||
return new XYPair( xPos, 1 - zPos );
|
||||
case 10:
|
||||
return new XYPair( zPos, xPos );
|
||||
case 11:
|
||||
return new XYPair( 1 - zPos, 1 - xPos );
|
||||
case 14:
|
||||
return new XYPair( 1 - xPos, 1 - zPos );
|
||||
case 15:
|
||||
return new XYPair( xPos, zPos );
|
||||
case 16:
|
||||
return new XYPair( zPos, 1 - xPos );
|
||||
case 17:
|
||||
return new XYPair( 1 - zPos, xPos );
|
||||
default:
|
||||
return new XYPair( xPos, zPos );
|
||||
}
|
||||
}
|
||||
}
|
@ -341,18 +341,9 @@ public class TilePrinter extends TilePeripheralBase implements DefaultSidedInven
|
||||
{
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
if( canInputPage() )
|
||||
{
|
||||
if( m_printing && !outputPage() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( inputPage() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if( !canInputPage() ) return false;
|
||||
if( m_printing && !outputPage() ) return false;
|
||||
return inputPage();
|
||||
}
|
||||
}
|
||||
|
||||
@ -373,12 +364,8 @@ public class TilePrinter extends TilePeripheralBase implements DefaultSidedInven
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
ItemStack inkStack = m_inventory.get( 0 );
|
||||
if( !inkStack.isEmpty() && isInk( inkStack ) )
|
||||
{
|
||||
return inkStack.getCount();
|
||||
}
|
||||
return isInk( inkStack ) ? inkStack.getCount() : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getPaperLevel()
|
||||
@ -431,10 +418,7 @@ public class TilePrinter extends TilePeripheralBase implements DefaultSidedInven
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
ItemStack inkStack = m_inventory.get( 0 );
|
||||
if( inkStack.isEmpty() || !isInk( inkStack ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( !isInk( inkStack ) ) return false;
|
||||
|
||||
for( int i = 1; i < 7; i++ )
|
||||
{
|
||||
|
@ -538,7 +538,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setColour( ItemStack stack, int colour )
|
||||
public ItemStack withColour( ItemStack stack, int colour )
|
||||
{
|
||||
ItemStack copy = stack.copy();
|
||||
setColourDirect( copy, colour );
|
||||
|
@ -24,10 +24,6 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class PocketComputerUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
{
|
||||
public PocketComputerUpgradeRecipe()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit( int x, int y )
|
||||
{
|
||||
|
@ -212,14 +212,14 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
// Impostor Disk recipes (to fool NEI)
|
||||
ItemStack paper = new ItemStack( Items.PAPER, 1 );
|
||||
ItemStack redstone = new ItemStack( Items.REDSTONE, 1 );
|
||||
for( int colour = 0; colour < 16; ++colour )
|
||||
for( int colour = 0; colour < 16; colour++ )
|
||||
{
|
||||
ItemStack disk = ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.values()[colour].getHex() );
|
||||
ItemStack dye = new ItemStack( Items.DYE, 1, colour );
|
||||
|
||||
int diskIdx = 0;
|
||||
ItemStack[] disks = new ItemStack[15];
|
||||
for( int otherColour = 0; otherColour < 16; ++otherColour )
|
||||
for( int otherColour = 0; otherColour < 16; otherColour++ )
|
||||
{
|
||||
if( colour != otherColour )
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ public abstract class ItemTurtleBase extends ItemComputerBase implements ITurtle
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setColour( ItemStack stack, int colour )
|
||||
public ItemStack withColour( ItemStack stack, int colour )
|
||||
{
|
||||
return TurtleItemFactory.create(
|
||||
getComputerID( stack ), getLabel( stack ), colour, getFamily( stack ),
|
||||
|
@ -33,9 +33,8 @@ public class TurtleRecipe extends ComputerConvertRecipe
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ItemStack convert( @Nonnull ItemStack stack )
|
||||
protected ItemStack convert( IComputerItem item, @Nonnull ItemStack stack )
|
||||
{
|
||||
IComputerItem item = (IComputerItem) stack.getItem();
|
||||
int computerID = item.getComputerID( stack );
|
||||
String label = item.getLabel( stack );
|
||||
|
||||
|
@ -40,12 +40,6 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade
|
||||
this.turtle = turtle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
super.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
|
@ -7,8 +7,12 @@
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -135,4 +139,28 @@ public class NBTUtil
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static NBTTagCompound readCompoundTag( PacketBuffer buf )
|
||||
{
|
||||
try
|
||||
{
|
||||
return buf.readCompoundTag();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new UncheckedIOException( e );
|
||||
}
|
||||
}
|
||||
|
||||
public static ITextComponent readTextComponent( PacketBuffer buf )
|
||||
{
|
||||
try
|
||||
{
|
||||
return buf.readTextComponent();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new UncheckedIOException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user