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