mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-11-17 23:34:51 +00:00
Move several methods out of the proxy
Some methods act the same on both sides, and so can be in utility classes. Others are only needed on one side, and so do not really need to be part of the proxy. - Remove TurtleVisionCamera. It would be possible to add this back in the future, but for now it is unused and so should be removed. - Move frame info (cursor blink, current render frame) into a FrameInfo class. - Move record methods (name, playing a record) into a RecordUtil class.
This commit is contained in:
parent
2c87e66db8
commit
26ba61097b
@ -23,6 +23,7 @@ import dan200.computercraft.api.pocket.IPocketUpgrade;
|
|||||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||||
import dan200.computercraft.api.turtle.event.TurtleAction;
|
import dan200.computercraft.api.turtle.event.TurtleAction;
|
||||||
|
import dan200.computercraft.client.FrameInfo;
|
||||||
import dan200.computercraft.core.apis.AddressPredicate;
|
import dan200.computercraft.core.apis.AddressPredicate;
|
||||||
import dan200.computercraft.core.filesystem.ComboMount;
|
import dan200.computercraft.core.filesystem.ComboMount;
|
||||||
import dan200.computercraft.core.filesystem.FileMount;
|
import dan200.computercraft.core.filesystem.FileMount;
|
||||||
@ -61,6 +62,7 @@ import dan200.computercraft.shared.turtle.upgrades.*;
|
|||||||
import dan200.computercraft.shared.util.CreativeTabMain;
|
import dan200.computercraft.shared.util.CreativeTabMain;
|
||||||
import dan200.computercraft.shared.util.IDAssigner;
|
import dan200.computercraft.shared.util.IDAssigner;
|
||||||
import dan200.computercraft.shared.util.InventoryUtil;
|
import dan200.computercraft.shared.util.InventoryUtil;
|
||||||
|
import dan200.computercraft.shared.util.RecordUtil;
|
||||||
import dan200.computercraft.shared.wired.CapabilityWiredElement;
|
import dan200.computercraft.shared.wired.CapabilityWiredElement;
|
||||||
import dan200.computercraft.shared.wired.WiredNode;
|
import dan200.computercraft.shared.wired.WiredNode;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
@ -498,36 +500,6 @@ public class ComputerCraft
|
|||||||
return "${version}";
|
return "${version}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isClient()
|
|
||||||
{
|
|
||||||
return proxy.isClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getGlobalCursorBlink()
|
|
||||||
{
|
|
||||||
return proxy.getGlobalCursorBlink();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long getRenderFrame()
|
|
||||||
{
|
|
||||||
return proxy.getRenderFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object getFixedWidthFontRenderer()
|
|
||||||
{
|
|
||||||
return proxy.getFixedWidthFontRenderer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
|
|
||||||
{
|
|
||||||
proxy.playRecord( record, recordInfo, world, pos );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getRecordInfo( @Nonnull ItemStack recordStack )
|
|
||||||
{
|
|
||||||
return proxy.getRecordInfo( recordStack );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void openDiskDriveGUI( EntityPlayer player, TileDiskDrive drive )
|
public static void openDiskDriveGUI( EntityPlayer player, TileDiskDrive drive )
|
||||||
{
|
{
|
||||||
BlockPos pos = drive.getPos();
|
BlockPos pos = drive.getPos();
|
||||||
|
50
src/main/java/dan200/computercraft/client/FrameInfo.java
Normal file
50
src/main/java/dan200/computercraft/client/FrameInfo.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
|
|
||||||
|
public class FrameInfo
|
||||||
|
{
|
||||||
|
private static FrameInfo instance;
|
||||||
|
|
||||||
|
public static FrameInfo instance()
|
||||||
|
{
|
||||||
|
if( instance != null ) return instance;
|
||||||
|
return instance = new FrameInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int tick;
|
||||||
|
private long renderFrame;
|
||||||
|
|
||||||
|
private FrameInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getGlobalCursorBlink()
|
||||||
|
{
|
||||||
|
return (tick / 8) % 2 == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getRenderFrame()
|
||||||
|
{
|
||||||
|
return renderFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onTick( TickEvent.ClientTickEvent event )
|
||||||
|
{
|
||||||
|
if( event.phase == TickEvent.Phase.START ) tick++;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onRenderTick( TickEvent.RenderTickEvent event )
|
||||||
|
{
|
||||||
|
if( event.phase == TickEvent.Phase.START ) renderFrame++;
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ package dan200.computercraft.client.gui;
|
|||||||
|
|
||||||
import dan200.computercraft.core.terminal.TextBuffer;
|
import dan200.computercraft.core.terminal.TextBuffer;
|
||||||
import dan200.computercraft.shared.util.Palette;
|
import dan200.computercraft.shared.util.Palette;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
@ -20,17 +21,25 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class FixedWidthFontRenderer
|
public class FixedWidthFontRenderer
|
||||||
{
|
{
|
||||||
private static ResourceLocation font = new ResourceLocation( "computercraft", "textures/gui/term_font.png" );
|
private static final ResourceLocation FONT = new ResourceLocation( "computercraft", "textures/gui/term_font.png" );
|
||||||
public static ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/term_background.png" );
|
public static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/term_background.png" );
|
||||||
|
|
||||||
public static int FONT_HEIGHT = 9;
|
public static final int FONT_HEIGHT = 9;
|
||||||
public static int FONT_WIDTH = 6;
|
public static final int FONT_WIDTH = 6;
|
||||||
|
|
||||||
|
private static FixedWidthFontRenderer instance;
|
||||||
|
|
||||||
|
public static FixedWidthFontRenderer instance()
|
||||||
|
{
|
||||||
|
if( instance != null ) return instance;
|
||||||
|
return instance = new FixedWidthFontRenderer();
|
||||||
|
}
|
||||||
|
|
||||||
private TextureManager m_textureManager;
|
private TextureManager m_textureManager;
|
||||||
|
|
||||||
public FixedWidthFontRenderer( TextureManager textureManager )
|
private FixedWidthFontRenderer()
|
||||||
{
|
{
|
||||||
m_textureManager = textureManager;
|
m_textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void greyscaleify( double[] rgb )
|
private static void greyscaleify( double[] rgb )
|
||||||
@ -157,7 +166,7 @@ public class FixedWidthFontRenderer
|
|||||||
if( backgroundColour != null )
|
if( backgroundColour != null )
|
||||||
{
|
{
|
||||||
// Bind the background texture
|
// Bind the background texture
|
||||||
m_textureManager.bindTexture( background );
|
m_textureManager.bindTexture( BACKGROUND );
|
||||||
|
|
||||||
// Draw the quads
|
// Draw the quads
|
||||||
drawStringBackgroundPart( x, y, backgroundColour, leftMarginSize, rightMarginSize, greyScale, p );
|
drawStringBackgroundPart( x, y, backgroundColour, leftMarginSize, rightMarginSize, greyScale, p );
|
||||||
@ -185,7 +194,7 @@ public class FixedWidthFontRenderer
|
|||||||
|
|
||||||
public void bindFont()
|
public void bindFont()
|
||||||
{
|
{
|
||||||
m_textureManager.bindTexture( font );
|
m_textureManager.bindTexture( FONT );
|
||||||
GlStateManager.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP );
|
GlStateManager.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
package dan200.computercraft.client.gui.widgets;
|
package dan200.computercraft.client.gui.widgets;
|
||||||
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.client.FrameInfo;
|
||||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
||||||
import dan200.computercraft.core.terminal.Terminal;
|
import dan200.computercraft.core.terminal.Terminal;
|
||||||
import dan200.computercraft.core.terminal.TextBuffer;
|
import dan200.computercraft.core.terminal.TextBuffer;
|
||||||
@ -387,8 +387,8 @@ public class WidgetTerminal extends Widget
|
|||||||
|
|
||||||
// Get the data from the terminal first
|
// Get the data from the terminal first
|
||||||
// Unfortunately we have to keep the lock for the whole of drawing, so the text doesn't change under us.
|
// Unfortunately we have to keep the lock for the whole of drawing, so the text doesn't change under us.
|
||||||
FixedWidthFontRenderer fontRenderer = (FixedWidthFontRenderer) ComputerCraft.getFixedWidthFontRenderer();
|
FixedWidthFontRenderer fontRenderer = FixedWidthFontRenderer.instance();
|
||||||
boolean tblink = m_focus && terminal.getCursorBlink() && ComputerCraft.getGlobalCursorBlink();
|
boolean tblink = m_focus && terminal.getCursorBlink() && FrameInfo.instance().getGlobalCursorBlink();
|
||||||
int tw = terminal.getWidth();
|
int tw = terminal.getWidth();
|
||||||
int th = terminal.getHeight();
|
int th = terminal.getHeight();
|
||||||
int tx = terminal.getCursorX();
|
int tx = terminal.getCursorX();
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
package dan200.computercraft.client.proxy;
|
package dan200.computercraft.client.proxy;
|
||||||
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.ComputerCraft;
|
||||||
|
import dan200.computercraft.client.FrameInfo;
|
||||||
import dan200.computercraft.client.gui.*;
|
import dan200.computercraft.client.gui.*;
|
||||||
import dan200.computercraft.client.render.*;
|
import dan200.computercraft.client.render.*;
|
||||||
import dan200.computercraft.shared.command.CommandCopy;
|
import dan200.computercraft.shared.command.CommandCopy;
|
||||||
@ -28,7 +29,6 @@ import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
|
|||||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||||
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
|
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
|
||||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||||
import dan200.computercraft.shared.turtle.entity.TurtleVisionCamera;
|
|
||||||
import dan200.computercraft.shared.util.Colour;
|
import dan200.computercraft.shared.util.Colour;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
@ -52,15 +52,11 @@ import net.minecraft.util.text.ITextComponent;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.ClientCommandHandler;
|
import net.minecraftforge.client.ClientCommandHandler;
|
||||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
|
||||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@ -73,18 +69,12 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
|||||||
{
|
{
|
||||||
private static Int2IntOpenHashMap lastCounts = new Int2IntOpenHashMap();
|
private static Int2IntOpenHashMap lastCounts = new Int2IntOpenHashMap();
|
||||||
|
|
||||||
private long m_tick;
|
|
||||||
private long m_renderFrame;
|
|
||||||
private FixedWidthFontRenderer m_fixedWidthFontRenderer;
|
|
||||||
|
|
||||||
// IComputerCraftProxy implementation
|
// IComputerCraftProxy implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preInit()
|
public void preInit()
|
||||||
{
|
{
|
||||||
super.preInit();
|
super.preInit();
|
||||||
m_tick = 0;
|
|
||||||
m_renderFrame = 0;
|
|
||||||
|
|
||||||
// Setup client forge handlers
|
// Setup client forge handlers
|
||||||
registerForgeHandlers();
|
registerForgeHandlers();
|
||||||
@ -126,7 +116,6 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
|||||||
|
|
||||||
// Load textures
|
// Load textures
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
m_fixedWidthFontRenderer = new FixedWidthFontRenderer( mc.getTextureManager() );
|
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
mc.getItemColors().registerItemColorHandler( new DiskColorHandler( ComputerCraft.Items.disk ), ComputerCraft.Items.disk );
|
mc.getItemColors().registerItemColorHandler( new DiskColorHandler( ComputerCraft.Items.disk ), ComputerCraft.Items.disk );
|
||||||
@ -191,45 +180,6 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isClient()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getGlobalCursorBlink()
|
|
||||||
{
|
|
||||||
return (m_tick / 8) % 2 == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getRenderFrame()
|
|
||||||
{
|
|
||||||
return m_renderFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getFixedWidthFontRenderer()
|
|
||||||
{
|
|
||||||
return m_fixedWidthFontRenderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRecordInfo( @Nonnull ItemStack recordStack )
|
|
||||||
{
|
|
||||||
List<String> info = new ArrayList<>( 1 );
|
|
||||||
recordStack.getItem().addInformation( recordStack, null, info, ITooltipFlag.TooltipFlags.NORMAL );
|
|
||||||
if( info.size() > 0 )
|
|
||||||
{
|
|
||||||
return info.get( 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return super.getRecordInfo( recordStack );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive )
|
public Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive )
|
||||||
{
|
{
|
||||||
@ -402,98 +352,15 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
|||||||
|
|
||||||
private void registerForgeHandlers()
|
private void registerForgeHandlers()
|
||||||
{
|
{
|
||||||
ForgeHandlers handlers = new ForgeHandlers();
|
MinecraftForge.EVENT_BUS.register( new ForgeHandlers() );
|
||||||
MinecraftForge.EVENT_BUS.register( handlers );
|
|
||||||
MinecraftForge.EVENT_BUS.register( new RenderOverlayCable() );
|
MinecraftForge.EVENT_BUS.register( new RenderOverlayCable() );
|
||||||
MinecraftForge.EVENT_BUS.register( new ItemPocketRenderer() );
|
MinecraftForge.EVENT_BUS.register( new ItemPocketRenderer() );
|
||||||
MinecraftForge.EVENT_BUS.register( new ItemPrintoutRenderer() );
|
MinecraftForge.EVENT_BUS.register( new ItemPrintoutRenderer() );
|
||||||
|
MinecraftForge.EVENT_BUS.register( FrameInfo.instance() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ForgeHandlers
|
public class ForgeHandlers
|
||||||
{
|
{
|
||||||
public ForgeHandlers()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onRenderHand( RenderHandEvent event )
|
|
||||||
{
|
|
||||||
// Don't draw the player arm when in turtle vision
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
if( mc.getRenderViewEntity() instanceof TurtleVisionCamera )
|
|
||||||
{
|
|
||||||
event.setCanceled( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onRenderPlayer( RenderPlayerEvent.Pre event )
|
|
||||||
{
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
if( event.getEntityPlayer().isUser() && mc.getRenderViewEntity() instanceof TurtleVisionCamera )
|
|
||||||
{
|
|
||||||
// HACK: Force the 'livingPlayer' variable to the player, this ensures the entity is drawn
|
|
||||||
//event.getRenderer().getRenderManager().livingPlayer = event.getEntityPlayer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onRenderPlayer( RenderPlayerEvent.Post event )
|
|
||||||
{
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
if( event.getEntityPlayer().isUser() && mc.getRenderViewEntity() instanceof TurtleVisionCamera )
|
|
||||||
{
|
|
||||||
// HACK: Restore the 'livingPlayer' variable to what it was before the RenderPlayerEvent.Pre hack
|
|
||||||
//event.getRenderer().getRenderManager().livingPlayer = mc.getRenderViewEntity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPreRenderGameOverlay( RenderGameOverlayEvent.Pre event )
|
|
||||||
{
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
if( mc.getRenderViewEntity() instanceof TurtleVisionCamera )
|
|
||||||
{
|
|
||||||
switch( event.getType() )
|
|
||||||
{
|
|
||||||
case HELMET:
|
|
||||||
case PORTAL:
|
|
||||||
//case CROSSHAIRS:
|
|
||||||
case BOSSHEALTH:
|
|
||||||
case ARMOR:
|
|
||||||
case HEALTH:
|
|
||||||
case FOOD:
|
|
||||||
case AIR:
|
|
||||||
case HOTBAR:
|
|
||||||
case EXPERIENCE:
|
|
||||||
case HEALTHMOUNT:
|
|
||||||
case JUMPBAR:
|
|
||||||
{
|
|
||||||
event.setCanceled( true );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onTick( TickEvent.ClientTickEvent event )
|
|
||||||
{
|
|
||||||
if( event.phase == TickEvent.Phase.START )
|
|
||||||
{
|
|
||||||
m_tick++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onRenderTick( TickEvent.RenderTickEvent event )
|
|
||||||
{
|
|
||||||
if( event.phase == TickEvent.Phase.START )
|
|
||||||
{
|
|
||||||
m_renderFrame++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onWorldUnload( WorldEvent.Unload event )
|
public void onWorldUnload( WorldEvent.Unload event )
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ package dan200.computercraft.client.render;
|
|||||||
|
|
||||||
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.ComputerCraft;
|
||||||
|
import dan200.computercraft.client.FrameInfo;
|
||||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
||||||
import dan200.computercraft.core.terminal.Terminal;
|
import dan200.computercraft.core.terminal.Terminal;
|
||||||
import dan200.computercraft.core.terminal.TextBuffer;
|
import dan200.computercraft.core.terminal.TextBuffer;
|
||||||
@ -153,7 +154,7 @@ public class ItemPocketRenderer
|
|||||||
int startX = (max - width) / 2 + margin;
|
int startX = (max - width) / 2 + margin;
|
||||||
int startY = (max - height) / 2 + margin;
|
int startY = (max - height) / 2 + margin;
|
||||||
|
|
||||||
FixedWidthFontRenderer fontRenderer = (FixedWidthFontRenderer) ComputerCraft.getFixedWidthFontRenderer();
|
FixedWidthFontRenderer fontRenderer = FixedWidthFontRenderer.instance();
|
||||||
boolean greyscale = !computer.isColour();
|
boolean greyscale = !computer.isColour();
|
||||||
Palette palette = terminal.getPalette();
|
Palette palette = terminal.getPalette();
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ public class ItemPocketRenderer
|
|||||||
|
|
||||||
// And render the cursor;
|
// And render the cursor;
|
||||||
int tx = terminal.getCursorX(), ty = terminal.getCursorY();
|
int tx = terminal.getCursorX(), ty = terminal.getCursorY();
|
||||||
if( terminal.getCursorBlink() && ComputerCraft.getGlobalCursorBlink() &&
|
if( terminal.getCursorBlink() && FrameInfo.instance().getGlobalCursorBlink() &&
|
||||||
tx >= 0 && ty >= 0 && tx < tw && ty < th )
|
tx >= 0 && ty >= 0 && tx < tw && ty < th )
|
||||||
{
|
{
|
||||||
TextBuffer cursorColour = new TextBuffer( "0123456789abcdef".charAt( terminal.getTextColour() ), 1 );
|
TextBuffer cursorColour = new TextBuffer( "0123456789abcdef".charAt( terminal.getTextColour() ), 1 );
|
||||||
|
@ -55,7 +55,7 @@ public class PrintoutRenderer
|
|||||||
|
|
||||||
public static void drawText( int x, int y, int start, TextBuffer[] text, TextBuffer[] colours )
|
public static void drawText( int x, int y, int start, TextBuffer[] text, TextBuffer[] colours )
|
||||||
{
|
{
|
||||||
FixedWidthFontRenderer fontRenderer = (FixedWidthFontRenderer) ComputerCraft.getFixedWidthFontRenderer();
|
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 )
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ public class PrintoutRenderer
|
|||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
|
|
||||||
FixedWidthFontRenderer fontRenderer = (FixedWidthFontRenderer) ComputerCraft.getFixedWidthFontRenderer();
|
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 )
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
package dan200.computercraft.client.render;
|
package dan200.computercraft.client.render;
|
||||||
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.client.FrameInfo;
|
||||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
||||||
import dan200.computercraft.core.terminal.Terminal;
|
import dan200.computercraft.core.terminal.Terminal;
|
||||||
import dan200.computercraft.core.terminal.TextBuffer;
|
import dan200.computercraft.core.terminal.TextBuffer;
|
||||||
@ -53,7 +53,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
|||||||
// Ensure each monitor terminal is rendered only once. We allow rendering a specific tile
|
// Ensure each monitor terminal is rendered only once. We allow rendering a specific tile
|
||||||
// multiple times in a single frame to ensure compatibility with shaders which may run a
|
// multiple times in a single frame to ensure compatibility with shaders which may run a
|
||||||
// pass multiple times.
|
// pass multiple times.
|
||||||
long renderFrame = ComputerCraft.getRenderFrame();
|
long renderFrame = FrameInfo.instance().getRenderFrame();
|
||||||
if( originTerminal.lastRenderFrame == renderFrame && !monitorPos.equals( originTerminal.lastRenderPos ) )
|
if( originTerminal.lastRenderFrame == renderFrame && !monitorPos.equals( originTerminal.lastRenderPos ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -121,7 +121,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
|||||||
int height = terminal.getHeight();
|
int height = terminal.getHeight();
|
||||||
int cursorX = terminal.getCursorX();
|
int cursorX = terminal.getCursorX();
|
||||||
int cursorY = terminal.getCursorY();
|
int cursorY = terminal.getCursorY();
|
||||||
FixedWidthFontRenderer fontRenderer = (FixedWidthFontRenderer) ComputerCraft.getFixedWidthFontRenderer();
|
FixedWidthFontRenderer fontRenderer = FixedWidthFontRenderer.instance();
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
try
|
try
|
||||||
@ -131,7 +131,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
|||||||
GlStateManager.scale( xScale, -yScale, 1.0 );
|
GlStateManager.scale( xScale, -yScale, 1.0 );
|
||||||
|
|
||||||
// Draw background
|
// Draw background
|
||||||
mc.getTextureManager().bindTexture( FixedWidthFontRenderer.background );
|
mc.getTextureManager().bindTexture( FixedWidthFontRenderer.BACKGROUND );
|
||||||
if( redraw )
|
if( redraw )
|
||||||
{
|
{
|
||||||
// Build background display list
|
// Build background display list
|
||||||
@ -234,7 +234,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
|||||||
GlStateManager.glEndList();
|
GlStateManager.glEndList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( ComputerCraft.getGlobalCursorBlink() )
|
if( FrameInfo.instance().getGlobalCursorBlink() )
|
||||||
{
|
{
|
||||||
GlStateManager.callList( originTerminal.renderDisplayLists[2] );
|
GlStateManager.callList( originTerminal.renderDisplayLists[2] );
|
||||||
GlStateManager.resetColor();
|
GlStateManager.resetColor();
|
||||||
@ -248,7 +248,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Draw a big black quad
|
// Draw a big black quad
|
||||||
mc.getTextureManager().bindTexture( FixedWidthFontRenderer.background );
|
mc.getTextureManager().bindTexture( FixedWidthFontRenderer.BACKGROUND );
|
||||||
final Colour colour = Colour.Black;
|
final Colour colour = Colour.Black;
|
||||||
|
|
||||||
final float r = colour.getR();
|
final float r = colour.getR();
|
||||||
@ -274,7 +274,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
|||||||
GlStateManager.colorMask( false, false, false, false );
|
GlStateManager.colorMask( false, false, false, false );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mc.getTextureManager().bindTexture( FixedWidthFontRenderer.background );
|
mc.getTextureManager().bindTexture( FixedWidthFontRenderer.BACKGROUND );
|
||||||
renderer.begin( GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION );
|
renderer.begin( GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION );
|
||||||
renderer.pos( -TileMonitor.RENDER_MARGIN, TileMonitor.RENDER_MARGIN, 0.0 ).endVertex();
|
renderer.pos( -TileMonitor.RENDER_MARGIN, TileMonitor.RENDER_MARGIN, 0.0 ).endVertex();
|
||||||
renderer.pos( -TileMonitor.RENDER_MARGIN, -ySize - TileMonitor.RENDER_MARGIN, 0.0 ).endVertex();
|
renderer.pos( -TileMonitor.RENDER_MARGIN, -ySize - TileMonitor.RENDER_MARGIN, 0.0 ).endVertex();
|
||||||
|
@ -10,7 +10,6 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
|||||||
import dan200.computercraft.api.turtle.TurtleSide;
|
import dan200.computercraft.api.turtle.TurtleSide;
|
||||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||||
import dan200.computercraft.shared.turtle.entity.TurtleVisionCamera;
|
|
||||||
import dan200.computercraft.shared.util.Holiday;
|
import dan200.computercraft.shared.util.Holiday;
|
||||||
import dan200.computercraft.shared.util.HolidayUtil;
|
import dan200.computercraft.shared.util.HolidayUtil;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
@ -28,7 +27,6 @@ import net.minecraft.client.renderer.texture.TextureMap;
|
|||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -56,22 +54,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
|||||||
@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 )
|
||||||
{
|
{
|
||||||
if( tileEntity != null )
|
if( tileEntity != null ) renderTurtleAt( tileEntity, posX, posY, posZ, f, i );
|
||||||
{
|
|
||||||
// Check the turtle isn't first person
|
|
||||||
Entity viewEntity = Minecraft.getMinecraft().getRenderViewEntity();
|
|
||||||
if( viewEntity != null && viewEntity instanceof TurtleVisionCamera )
|
|
||||||
{
|
|
||||||
TurtleVisionCamera camera = (TurtleVisionCamera) viewEntity;
|
|
||||||
if( camera.getTurtle() == tileEntity.getAccess() )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render the turtle
|
|
||||||
renderTurtleAt( tileEntity, posX, posY, posZ, f, i );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ModelResourceLocation getTurtleModel( ComputerFamily family, boolean coloured )
|
public static ModelResourceLocation getTurtleModel( ComputerFamily family, boolean coloured )
|
||||||
|
@ -23,48 +23,12 @@ import java.io.File;
|
|||||||
|
|
||||||
public class ComputerCraftProxyServer extends ComputerCraftProxyCommon
|
public class ComputerCraftProxyServer extends ComputerCraftProxyCommon
|
||||||
{
|
{
|
||||||
public ComputerCraftProxyServer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// IComputerCraftProxy implementation
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
super.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getTurtleGUI( InventoryPlayer inventory, TileTurtle turtle )
|
public Object getTurtleGUI( InventoryPlayer inventory, TileTurtle turtle )
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isClient()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getGlobalCursorBlink()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getRenderFrame()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getFixedWidthFontRenderer()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive )
|
public Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive )
|
||||||
{
|
{
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
package dan200.computercraft.shared.media.items;
|
package dan200.computercraft.shared.media.items;
|
||||||
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
|
||||||
import dan200.computercraft.api.media.IMedia;
|
import dan200.computercraft.api.media.IMedia;
|
||||||
|
import dan200.computercraft.shared.util.RecordUtil;
|
||||||
import net.minecraft.item.ItemRecord;
|
import net.minecraft.item.ItemRecord;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.SoundEvent;
|
import net.minecraft.util.SoundEvent;
|
||||||
@ -34,7 +34,7 @@ public class RecordMedia implements IMedia
|
|||||||
@Override
|
@Override
|
||||||
public String getAudioTitle( @Nonnull ItemStack stack )
|
public String getAudioTitle( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
return ComputerCraft.getRecordInfo( stack );
|
return RecordUtil.getRecordInfo( stack );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,6 +16,7 @@ import dan200.computercraft.shared.peripheral.PeripheralType;
|
|||||||
import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
|
import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
|
||||||
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
||||||
import dan200.computercraft.shared.util.InventoryUtil;
|
import dan200.computercraft.shared.util.InventoryUtil;
|
||||||
|
import dan200.computercraft.shared.util.RecordUtil;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@ -655,17 +656,17 @@ public class TileDiskDrive extends TilePeripheralBase
|
|||||||
SoundEvent record = (contents != null) ? contents.getAudio( m_diskStack ) : null;
|
SoundEvent record = (contents != null) ? contents.getAudio( m_diskStack ) : null;
|
||||||
if( record != null )
|
if( record != null )
|
||||||
{
|
{
|
||||||
ComputerCraft.playRecord( record, contents.getAudioTitle( m_diskStack ), getWorld(), getPos() );
|
RecordUtil.playRecord( record, contents.getAudioTitle( m_diskStack ), getWorld(), getPos() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ComputerCraft.playRecord( null, null, getWorld(), getPos() );
|
RecordUtil.playRecord( null, null, getWorld(), getPos() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopRecord()
|
private void stopRecord()
|
||||||
{
|
{
|
||||||
ComputerCraft.playRecord( null, null, getWorld(), getPos() );
|
RecordUtil.playRecord( null, null, getWorld(), getPos() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,7 +64,6 @@ import net.minecraft.command.CommandHandler;
|
|||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
@ -75,7 +74,10 @@ import net.minecraft.item.crafting.Ingredient;
|
|||||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.IThreadListener;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
@ -95,16 +97,9 @@ import net.minecraftforge.registries.IForgeRegistry;
|
|||||||
import pl.asie.charset.ModCharset;
|
import pl.asie.charset.ModCharset;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||||
{
|
{
|
||||||
public ComputerCraftProxyCommon()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// IComputerCraftProxy implementation
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preInit()
|
public void preInit()
|
||||||
{
|
{
|
||||||
@ -112,14 +107,6 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
|||||||
|
|
||||||
// Creative tab
|
// Creative tab
|
||||||
ComputerCraft.mainCreativeTab = new CreativeTabMain( CreativeTabs.getNextID() );
|
ComputerCraft.mainCreativeTab = new CreativeTabMain( CreativeTabs.getNextID() );
|
||||||
|
|
||||||
// Recipe types
|
|
||||||
// RecipeSorter.register( "computercraft:impostor", ImpostorRecipe.class, RecipeSorter.Category.SHAPED, "after:minecraft:shapeless" );
|
|
||||||
// RecipeSorter.register( "computercraft:impostor_shapeless", ImpostorShapelessRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless" );
|
|
||||||
// RecipeSorter.register( "computercraft:disk", DiskRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless" );
|
|
||||||
// RecipeSorter.register( "computercraft:colour", ColourableRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless" );
|
|
||||||
// RecipeSorter.register( "computercraft:printout", PrintoutRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless" );
|
|
||||||
// RecipeSorter.register( "computercraft:pocket_computer_upgrade", PocketComputerUpgradeRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -139,73 +126,6 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
|||||||
handler.registerCommand( new CommandComputerCraft() );
|
handler.registerCommand( new CommandComputerCraft() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract boolean isClient();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract boolean getGlobalCursorBlink();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract long getRenderFrame();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract Object getFixedWidthFontRenderer();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRecordInfo( @Nonnull ItemStack recordStack )
|
|
||||||
{
|
|
||||||
Item item = recordStack.getItem();
|
|
||||||
if( item instanceof ItemRecord )
|
|
||||||
{
|
|
||||||
ItemRecord record = (ItemRecord) item;
|
|
||||||
return StringUtil.translateToLocal( record.displayName );
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
|
|
||||||
{
|
|
||||||
ComputerCraftPacket packet = new ComputerCraftPacket();
|
|
||||||
packet.m_packetType = ComputerCraftPacket.PlayRecord;
|
|
||||||
if( record != null )
|
|
||||||
{
|
|
||||||
packet.m_dataInt = new int[] { pos.getX(), pos.getY(), pos.getZ(), SoundEvent.REGISTRY.getIDForObject( record ) };
|
|
||||||
packet.m_dataString = new String[] { recordInfo };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
packet.m_dataInt = new int[] { pos.getX(), pos.getY(), pos.getZ() };
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint( world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64 );
|
|
||||||
ComputerCraft.sendToAllAround( packet, point );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive );
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract Object getComputerGUI( TileComputer computer );
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract Object getPrinterGUI( InventoryPlayer inventory, TilePrinter printer );
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract Object getTurtleGUI( InventoryPlayer inventory, TileTurtle turtle );
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract Object getPrintoutGUI( EntityPlayer player, EnumHand hand );
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract Object getPocketComputerGUI( EntityPlayer player, EnumHand hand );
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract Object getComputerGUI( IComputer computer, int width, int height, ComputerFamily family );
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract File getWorldDir( World world );
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePacket( final ComputerCraftPacket packet, final EntityPlayer player )
|
public void handlePacket( final ComputerCraftPacket packet, final EntityPlayer player )
|
||||||
{
|
{
|
||||||
|
@ -15,14 +15,10 @@ import dan200.computercraft.shared.peripheral.printer.TilePrinter;
|
|||||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.SoundEvent;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public interface IComputerCraftProxy
|
public interface IComputerCraftProxy
|
||||||
@ -33,18 +29,6 @@ public interface IComputerCraftProxy
|
|||||||
|
|
||||||
void initServer( MinecraftServer server );
|
void initServer( MinecraftServer server );
|
||||||
|
|
||||||
boolean isClient();
|
|
||||||
|
|
||||||
boolean getGlobalCursorBlink();
|
|
||||||
|
|
||||||
long getRenderFrame();
|
|
||||||
|
|
||||||
Object getFixedWidthFontRenderer();
|
|
||||||
|
|
||||||
String getRecordInfo( @Nonnull ItemStack item );
|
|
||||||
|
|
||||||
void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos );
|
|
||||||
|
|
||||||
Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive );
|
Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive );
|
||||||
|
|
||||||
Object getComputerGUI( TileComputer computer );
|
Object getComputerGUI( TileComputer computer );
|
||||||
|
@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2017. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
package dan200.computercraft.shared.turtle.entity;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
|
||||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.EnumHand;
|
|
||||||
import net.minecraft.util.EnumHandSide;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class TurtleVisionCamera extends EntityLivingBase
|
|
||||||
{
|
|
||||||
private ITurtleAccess m_turtle;
|
|
||||||
private ArrayList<ItemStack> m_armor;
|
|
||||||
|
|
||||||
public TurtleVisionCamera( World world, ITurtleAccess turtle )
|
|
||||||
{
|
|
||||||
super( world );
|
|
||||||
m_turtle = turtle;
|
|
||||||
m_armor = new ArrayList<>();
|
|
||||||
applyPos();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITurtleAccess getTurtle()
|
|
||||||
{
|
|
||||||
return m_turtle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getEyeHeight()
|
|
||||||
{
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public EnumHandSide getPrimaryHand()
|
|
||||||
{
|
|
||||||
return EnumHandSide.RIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate()
|
|
||||||
{
|
|
||||||
m_turtle = ((TurtleBrain) m_turtle).getFutureSelf();
|
|
||||||
applyPos();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyPos()
|
|
||||||
{
|
|
||||||
Vec3d prevPos = m_turtle.getVisualPosition( 0.0f );
|
|
||||||
this.lastTickPosX = this.prevPosX = prevPos.x;
|
|
||||||
this.lastTickPosY = this.prevPosY = prevPos.y;
|
|
||||||
this.lastTickPosZ = this.prevPosZ = prevPos.z;
|
|
||||||
this.prevRotationPitch = 0.0f;
|
|
||||||
this.prevRotationYaw = m_turtle.getVisualYaw( 0.0f );
|
|
||||||
this.prevCameraPitch = 0.0f;
|
|
||||||
|
|
||||||
Vec3d pos = m_turtle.getVisualPosition( 1.0f );
|
|
||||||
this.posX = pos.x;
|
|
||||||
this.posY = pos.y;
|
|
||||||
this.posZ = pos.z;
|
|
||||||
this.rotationPitch = 0.0f;
|
|
||||||
this.rotationYaw = m_turtle.getVisualYaw( 1.0f );
|
|
||||||
this.cameraPitch = 0.0f;
|
|
||||||
|
|
||||||
float yawDifference = this.rotationYaw - this.prevRotationYaw;
|
|
||||||
if( yawDifference > 180.0f )
|
|
||||||
{
|
|
||||||
this.prevRotationYaw += 360.0f;
|
|
||||||
}
|
|
||||||
else if( yawDifference < -180.0f )
|
|
||||||
{
|
|
||||||
this.prevRotationYaw -= 360.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// EntityLivingBase overrides:
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public ItemStack getHeldItem( EnumHand hand )
|
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setItemStackToSlot( @Nonnull EntityEquipmentSlot slot, @Nonnull ItemStack stack )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public ItemStack getItemStackFromSlot( @Nonnull EntityEquipmentSlot slot )
|
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Iterable<ItemStack> getArmorInventoryList()
|
|
||||||
{
|
|
||||||
return m_armor;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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.util;
|
||||||
|
|
||||||
|
import dan200.computercraft.ComputerCraft;
|
||||||
|
import dan200.computercraft.shared.network.ComputerCraftPacket;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemRecord;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.SoundEvent;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class RecordUtil
|
||||||
|
{
|
||||||
|
public static void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
|
||||||
|
{
|
||||||
|
ComputerCraftPacket packet = new ComputerCraftPacket();
|
||||||
|
packet.m_packetType = ComputerCraftPacket.PlayRecord;
|
||||||
|
if( record != null )
|
||||||
|
{
|
||||||
|
packet.m_dataInt = new int[] { pos.getX(), pos.getY(), pos.getZ(), SoundEvent.REGISTRY.getIDForObject( record ) };
|
||||||
|
packet.m_dataString = new String[] { recordInfo };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packet.m_dataInt = new int[] { pos.getX(), pos.getY(), pos.getZ() };
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint( world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64 );
|
||||||
|
ComputerCraft.sendToAllAround( packet, point );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getRecordInfo( @Nonnull ItemStack recordStack )
|
||||||
|
{
|
||||||
|
Item item = recordStack.getItem();
|
||||||
|
if( !(item instanceof ItemRecord) ) return null;
|
||||||
|
|
||||||
|
ItemRecord record = (ItemRecord) item;
|
||||||
|
return StringUtil.translateToLocal( record.displayName );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user