mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-16 06:27:39 +00:00
Compare commits
11 Commits
v1.80pr1.4
...
v1.80pr1.5
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ebb50cba48 | ||
![]() |
7c218361d9 | ||
![]() |
bb2eab0bed | ||
![]() |
e8c0cf3857 | ||
![]() |
db825a7aab | ||
![]() |
dbcae810f0 | ||
![]() |
f753513289 | ||
![]() |
7bb8efed1d | ||
![]() |
0cec4aee8c | ||
![]() |
e0c9dc24e7 | ||
![]() |
244907a39a |
@@ -21,7 +21,7 @@ plugins {
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
apply plugin: 'org.ajoberstar.grgit'
|
||||
|
||||
version = "1.80pr1.4"
|
||||
version = "1.80pr1.5"
|
||||
group = "org.squiddev"
|
||||
archivesBaseName = "cc-tweaked"
|
||||
|
||||
|
@@ -505,11 +505,6 @@ public class ComputerCraft
|
||||
return proxy.getRenderFrame();
|
||||
}
|
||||
|
||||
public static void deleteDisplayLists( int list, int range )
|
||||
{
|
||||
proxy.deleteDisplayLists( list, range );
|
||||
}
|
||||
|
||||
public static Object getFixedWidthFontRenderer()
|
||||
{
|
||||
return proxy.getFixedWidthFontRenderer();
|
||||
|
@@ -25,6 +25,7 @@ import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import dan200.computercraft.shared.network.ComputerCraftPacket;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.modem.TileCable;
|
||||
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import dan200.computercraft.shared.peripheral.printer.TilePrinter;
|
||||
import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
|
||||
@@ -35,7 +36,6 @@ import dan200.computercraft.shared.turtle.entity.TurtleVisionCamera;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
@@ -57,6 +57,7 @@ import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
@@ -297,12 +298,6 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
return m_renderFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDisplayLists( int list, int range )
|
||||
{
|
||||
GlStateManager.glDeleteLists( list, range );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getFixedWidthFontRenderer()
|
||||
{
|
||||
@@ -552,6 +547,15 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
m_renderFrame++;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldUnload( WorldEvent.Unload event )
|
||||
{
|
||||
if( event.getWorld().isRemote )
|
||||
{
|
||||
ClientMonitor.destroyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
@@ -106,9 +106,9 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
Palette palette = terminal.getPalette();
|
||||
|
||||
// Allocate display lists
|
||||
if( originTerminal.renderDisplayList < 0 )
|
||||
if( originTerminal.renderDisplayLists == null )
|
||||
{
|
||||
originTerminal.renderDisplayList = GlStateManager.glGenLists( 3 );
|
||||
originTerminal.createLists();
|
||||
redraw = true;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
if( redraw )
|
||||
{
|
||||
// Build background display list
|
||||
GlStateManager.glNewList( originTerminal.renderDisplayList, GL11.GL_COMPILE );
|
||||
GlStateManager.glNewList( originTerminal.renderDisplayLists[0], GL11.GL_COMPILE );
|
||||
try
|
||||
{
|
||||
double marginXSize = TileMonitor.RENDER_MARGIN / xScale;
|
||||
@@ -171,7 +171,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
GlStateManager.glEndList();
|
||||
}
|
||||
}
|
||||
GlStateManager.callList( originTerminal.renderDisplayList );
|
||||
GlStateManager.callList( originTerminal.renderDisplayLists[0] );
|
||||
GlStateManager.resetColor();
|
||||
|
||||
// Draw text
|
||||
@@ -179,7 +179,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
if( redraw )
|
||||
{
|
||||
// Build text display list
|
||||
GlStateManager.glNewList( originTerminal.renderDisplayList + 1, GL11.GL_COMPILE );
|
||||
GlStateManager.glNewList( originTerminal.renderDisplayLists[1], GL11.GL_COMPILE );
|
||||
try
|
||||
{
|
||||
// Lines
|
||||
@@ -199,7 +199,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
GlStateManager.glEndList();
|
||||
}
|
||||
}
|
||||
GlStateManager.callList( originTerminal.renderDisplayList + 1 );
|
||||
GlStateManager.callList( originTerminal.renderDisplayLists[1] );
|
||||
GlStateManager.resetColor();
|
||||
|
||||
// Draw cursor
|
||||
@@ -207,7 +207,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
if( redraw )
|
||||
{
|
||||
// Build cursor display list
|
||||
GlStateManager.glNewList( originTerminal.renderDisplayList + 2, GL11.GL_COMPILE );
|
||||
GlStateManager.glNewList( originTerminal.renderDisplayLists[2], GL11.GL_COMPILE );
|
||||
try
|
||||
{
|
||||
// Cursor
|
||||
@@ -233,7 +233,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
}
|
||||
if( ComputerCraft.getGlobalCursorBlink() )
|
||||
{
|
||||
GlStateManager.callList( originTerminal.renderDisplayList + 2 );
|
||||
GlStateManager.callList( originTerminal.renderDisplayLists[2] );
|
||||
GlStateManager.resetColor();
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ public class Terminal
|
||||
m_palette = new Palette();
|
||||
}
|
||||
|
||||
public void reset()
|
||||
public synchronized void reset()
|
||||
{
|
||||
m_cursorColour = 0;
|
||||
m_cursorBackgroundColour = 15;
|
||||
@@ -76,7 +76,7 @@ public class Terminal
|
||||
return m_height;
|
||||
}
|
||||
|
||||
public void resize( int width, int height )
|
||||
public synchronized void resize( int width, int height )
|
||||
{
|
||||
if( width == m_width && height == m_height )
|
||||
{
|
||||
@@ -189,7 +189,7 @@ public class Terminal
|
||||
return m_palette;
|
||||
}
|
||||
|
||||
public void blit( String text, String textColour, String backgroundColour )
|
||||
public synchronized void blit( String text, String textColour, String backgroundColour )
|
||||
{
|
||||
int x = m_cursorX;
|
||||
int y = m_cursorY;
|
||||
@@ -202,7 +202,7 @@ public class Terminal
|
||||
}
|
||||
}
|
||||
|
||||
public void write( String text )
|
||||
public synchronized void write( String text )
|
||||
{
|
||||
int x = m_cursorX;
|
||||
int y = m_cursorY;
|
||||
@@ -215,7 +215,7 @@ public class Terminal
|
||||
}
|
||||
}
|
||||
|
||||
public void scroll( int yDiff )
|
||||
public synchronized void scroll( int yDiff )
|
||||
{
|
||||
if( yDiff != 0 )
|
||||
{
|
||||
@@ -245,7 +245,7 @@ public class Terminal
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
public synchronized void clear()
|
||||
{
|
||||
for( int y = 0; y < m_height; ++y )
|
||||
{
|
||||
@@ -256,7 +256,7 @@ public class Terminal
|
||||
m_changed = true;
|
||||
}
|
||||
|
||||
public void clearLine()
|
||||
public synchronized void clearLine()
|
||||
{
|
||||
int y = m_cursorY;
|
||||
if( y >= 0 && y < m_height )
|
||||
@@ -268,7 +268,7 @@ public class Terminal
|
||||
}
|
||||
}
|
||||
|
||||
public TextBuffer getLine( int y )
|
||||
public synchronized TextBuffer getLine( int y )
|
||||
{
|
||||
if( y >= 0 && y < m_height )
|
||||
{
|
||||
@@ -277,7 +277,7 @@ public class Terminal
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setLine( int y, String text, String textColour, String backgroundColour )
|
||||
public synchronized void setLine( int y, String text, String textColour, String backgroundColour )
|
||||
{
|
||||
m_text[y].write( text );
|
||||
m_textColour[y].write( textColour );
|
||||
@@ -285,7 +285,7 @@ public class Terminal
|
||||
m_changed = true;
|
||||
}
|
||||
|
||||
public TextBuffer getTextColourLine( int y )
|
||||
public synchronized TextBuffer getTextColourLine( int y )
|
||||
{
|
||||
if( y>=0 && y<m_height )
|
||||
{
|
||||
@@ -294,7 +294,7 @@ public class Terminal
|
||||
return null;
|
||||
}
|
||||
|
||||
public TextBuffer getBackgroundColourLine( int y )
|
||||
public synchronized TextBuffer getBackgroundColourLine( int y )
|
||||
{
|
||||
if( y>=0 && y<m_height )
|
||||
{
|
||||
@@ -318,7 +318,7 @@ public class Terminal
|
||||
m_changed = false;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public synchronized NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
nbttagcompound.setInteger( "term_cursorX", m_cursorX );
|
||||
nbttagcompound.setInteger( "term_cursorY", m_cursorY );
|
||||
@@ -338,7 +338,7 @@ public class Terminal
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
public synchronized void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
m_cursorX = nbttagcompound.getInteger( "term_cursorX" );
|
||||
m_cursorY = nbttagcompound.getInteger( "term_cursorY" );
|
||||
|
@@ -16,4 +16,5 @@ public interface IComputerItem
|
||||
int getComputerID( @Nonnull ItemStack stack );
|
||||
String getLabel( @Nonnull ItemStack stack );
|
||||
ComputerFamily getFamily( @Nonnull ItemStack stack );
|
||||
ItemStack withFamily(@Nonnull ItemStack stack, @Nonnull ComputerFamily family);
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ import javax.annotation.Nullable;
|
||||
public class ItemComputer extends ItemComputerBase
|
||||
{
|
||||
public static int HIGHEST_DAMAGE_VALUE_ID = 16382;
|
||||
|
||||
|
||||
public ItemComputer( Block block )
|
||||
{
|
||||
super( block );
|
||||
@@ -87,7 +87,7 @@ public class ItemComputer extends ItemComputerBase
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof IComputerTile )
|
||||
{
|
||||
IComputerTile computer = (IComputerTile)tile;
|
||||
IComputerTile computer = (IComputerTile) tile;
|
||||
setupComputerAfterPlacement( stack, computer );
|
||||
}
|
||||
return true;
|
||||
@@ -146,10 +146,16 @@ public class ItemComputer extends ItemComputerBase
|
||||
else
|
||||
{
|
||||
int damage = stack.getItemDamage() & 0x3fff;
|
||||
return ( damage - 1 );
|
||||
return (damage - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family )
|
||||
{
|
||||
return ComputerItemFactory.create( getComputerID( stack ), getLabel( stack ), family );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComputerFamily getFamily( int damage )
|
||||
{
|
||||
|
@@ -0,0 +1,66 @@
|
||||
package dan200.computercraft.shared.computer.recipe;
|
||||
|
||||
import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Represents a recipe which converts a computer from one form into another.
|
||||
*/
|
||||
public abstract class ComputerConvertRecipe extends ShapedRecipes
|
||||
{
|
||||
public ComputerConvertRecipe( String group, @Nonnull CraftingHelper.ShapedPrimer primer, @Nonnull ItemStack result )
|
||||
{
|
||||
super( group, primer.width, primer.height, primer.input, result );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract ItemStack convert( @Nonnull ItemStack stack );
|
||||
|
||||
@Override
|
||||
public boolean matches( @Nonnull InventoryCrafting inventory, @Nonnull World world )
|
||||
{
|
||||
// See if we match the recipe, and extract the input computercraft ID
|
||||
ItemStack computerStack = null;
|
||||
for( int y = 0; y < 3; ++y )
|
||||
{
|
||||
for( int x = 0; x < 3; ++x )
|
||||
{
|
||||
ItemStack stack = inventory.getStackInRowAndColumn( x, y );
|
||||
Ingredient target = getIngredients().get( x + y * 3 );
|
||||
|
||||
// First verify we match the ingredient
|
||||
if( !target.apply( stack ) ) return false;
|
||||
|
||||
// We want to ensure we have a computer item somewhere in the recipe
|
||||
if( stack.getItem() instanceof IComputerItem ) computerStack = stack;
|
||||
}
|
||||
}
|
||||
|
||||
return computerStack != null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult( @Nonnull InventoryCrafting inventory )
|
||||
{
|
||||
for( int y = 0; y < 3; ++y )
|
||||
{
|
||||
for( int x = 0; x < 3; ++x )
|
||||
{
|
||||
ItemStack item = inventory.getStackInRowAndColumn( x, y );
|
||||
|
||||
// If we're a computer, convert!
|
||||
if( item.getItem() instanceof IComputerItem ) return convert( item );
|
||||
}
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package dan200.computercraft.shared.computer.recipe;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
import dan200.computercraft.shared.util.RecipeUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.IRecipeFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ComputerFamilyRecipe extends ComputerConvertRecipe
|
||||
{
|
||||
private final ComputerFamily family;
|
||||
|
||||
public ComputerFamilyRecipe( String group, @Nonnull CraftingHelper.ShapedPrimer primer, @Nonnull ItemStack result, ComputerFamily family )
|
||||
{
|
||||
super( group, primer, result );
|
||||
this.family = family;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ItemStack convert( @Nonnull ItemStack stack )
|
||||
{
|
||||
return ((IComputerItem) stack.getItem()).withFamily( stack, family );
|
||||
}
|
||||
|
||||
public static class Factory implements IRecipeFactory
|
||||
{
|
||||
@Override
|
||||
public IRecipe parse( JsonContext context, JsonObject json )
|
||||
{
|
||||
String group = JsonUtils.getString( json, "group", "" );
|
||||
ComputerFamily family = RecipeUtil.getFamily( json, "family" );
|
||||
|
||||
CraftingHelper.ShapedPrimer primer = RecipeUtil.getPrimer( context, json );
|
||||
ItemStack result = deserializeItem( JsonUtils.getJsonObject( json, "result" ), false );
|
||||
|
||||
return new ComputerFamilyRecipe( group, primer, result, family );
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package dan200.computercraft.shared.computer.recipe;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
import dan200.computercraft.shared.util.RecipeUtil;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.IIngredientFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an ingredient which requires an item to have a specific
|
||||
* computer family. This allows us to have operations which only work
|
||||
* on normal or
|
||||
*/
|
||||
public class ComputerIngredient extends Ingredient
|
||||
{
|
||||
private final IComputerItem item;
|
||||
private final ComputerFamily family;
|
||||
|
||||
public <T extends Item & IComputerItem> ComputerIngredient( T item, int data, ComputerFamily family )
|
||||
{
|
||||
super( new ItemStack( item, 1, data ) );
|
||||
|
||||
this.item = item;
|
||||
this.family = family;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply( @Nullable ItemStack stack )
|
||||
{
|
||||
return stack != null && stack.getItem() == item && item.getFamily( stack ) == family;
|
||||
}
|
||||
|
||||
public static class Factory implements IIngredientFactory
|
||||
{
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient parse( JsonContext context, JsonObject json )
|
||||
{
|
||||
String itemName = context.appendModId( JsonUtils.getString( json, "item" ) );
|
||||
int data = JsonUtils.getInt( json, "data", 0 );
|
||||
ComputerFamily family = RecipeUtil.getFamily( json, "family" );
|
||||
|
||||
Item item = ForgeRegistries.ITEMS.getValue( new ResourceLocation( itemName ) );
|
||||
|
||||
if( item == null ) throw new JsonSyntaxException( "Unknown item '" + itemName + "'" );
|
||||
if( !(item instanceof IComputerItem) )
|
||||
{
|
||||
throw new JsonSyntaxException( "Item '" + itemName + "' is not a computer item" );
|
||||
}
|
||||
|
||||
|
||||
return new ComputerIngredient( (Item & IComputerItem) item, data, family );
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,20 @@
|
||||
package dan200.computercraft.shared.peripheral.monitor;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.common.ClientTerminal;
|
||||
import gnu.trove.set.hash.TIntHashSet;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
public class ClientMonitor extends ClientTerminal
|
||||
{
|
||||
private static final TIntHashSet displayLists = new TIntHashSet();
|
||||
private static final Set<ClientMonitor> allMonitors = new HashSet<>();
|
||||
|
||||
private final TileMonitor origin;
|
||||
|
||||
public long lastRenderFrame = -1;
|
||||
public int renderDisplayList = -1;
|
||||
public int[] renderDisplayLists = null;
|
||||
|
||||
public ClientMonitor( boolean colour, TileMonitor origin )
|
||||
{
|
||||
@@ -24,11 +27,60 @@ public class ClientMonitor extends ClientTerminal
|
||||
return origin;
|
||||
}
|
||||
|
||||
public void createLists()
|
||||
{
|
||||
if( renderDisplayLists == null )
|
||||
{
|
||||
renderDisplayLists = new int[3];
|
||||
|
||||
for( int i = 0; i < renderDisplayLists.length; i++ )
|
||||
{
|
||||
renderDisplayLists[i] = GlStateManager.glGenLists( 1 );
|
||||
}
|
||||
|
||||
synchronized( allMonitors )
|
||||
{
|
||||
allMonitors.add( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
if( renderDisplayList != -1 )
|
||||
if( renderDisplayLists != null )
|
||||
{
|
||||
ComputerCraft.deleteDisplayLists( renderDisplayList, 3 );
|
||||
synchronized( allMonitors )
|
||||
{
|
||||
allMonitors.remove( this );
|
||||
}
|
||||
|
||||
for( int list : renderDisplayLists )
|
||||
{
|
||||
GlStateManager.glDeleteLists( list, 1 );
|
||||
}
|
||||
|
||||
renderDisplayLists = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyAll()
|
||||
{
|
||||
synchronized( allMonitors )
|
||||
{
|
||||
for( Iterator<ClientMonitor> iterator = allMonitors.iterator(); iterator.hasNext(); )
|
||||
{
|
||||
ClientMonitor monitor = iterator.next();
|
||||
if( monitor.renderDisplayLists != null )
|
||||
{
|
||||
for( int list : monitor.renderDisplayLists )
|
||||
{
|
||||
GlStateManager.glDeleteLists( list, 1 );
|
||||
}
|
||||
monitor.renderDisplayLists = null;
|
||||
}
|
||||
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -243,7 +243,7 @@ public class MonitorPeripheral implements IPeripheral
|
||||
case 24:
|
||||
{
|
||||
// getTextScale
|
||||
return new Object[] { monitor.getTextScale() };
|
||||
return new Object[] { monitor.getTextScale() / 2.0 };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@@ -371,6 +371,15 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family )
|
||||
{
|
||||
return PocketComputerItemFactory.create(
|
||||
getComputerID( stack ), getLabel( stack ), getColour( stack ),
|
||||
family, getUpgrade( stack )
|
||||
);
|
||||
}
|
||||
|
||||
// IMedia
|
||||
|
||||
@Override
|
||||
|
@@ -124,11 +124,6 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
@Override
|
||||
public abstract long getRenderFrame();
|
||||
|
||||
@Override
|
||||
public void deleteDisplayLists( int list, int range )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Object getFixedWidthFontRenderer();
|
||||
|
||||
|
@@ -32,7 +32,6 @@ public interface IComputerCraftProxy
|
||||
|
||||
boolean getGlobalCursorBlink();
|
||||
long getRenderFrame();
|
||||
void deleteDisplayLists( int list, int range );
|
||||
Object getFixedWidthFontRenderer();
|
||||
|
||||
String getRecordInfo( @Nonnull ItemStack item );
|
||||
|
@@ -27,7 +27,7 @@ public class TurtlePlayer extends FakePlayer
|
||||
{
|
||||
public final static GameProfile DEFAULT_PROFILE = new GameProfile(
|
||||
UUID.fromString( "0d0c4ca0-4ff1-11e4-916c-0800200c9a66" ),
|
||||
"ComputerCraft"
|
||||
"[ComputerCraft]"
|
||||
);
|
||||
|
||||
@Deprecated
|
||||
|
@@ -170,6 +170,17 @@ public abstract class ItemTurtleBase extends ItemComputerBase implements ITurtle
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family )
|
||||
{
|
||||
return TurtleItemFactory.create(
|
||||
getComputerID( stack ), getLabel( stack ),
|
||||
getColour( stack ), family,
|
||||
getUpgrade( stack, TurtleSide.Left ), getUpgrade( stack, TurtleSide.Right ),
|
||||
getFuelLevel( stack ), getOverlay( stack )
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setColour( ItemStack stack, int colour )
|
||||
{
|
||||
|
@@ -7,82 +7,41 @@
|
||||
package dan200.computercraft.shared.turtle.recipes;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
import dan200.computercraft.shared.computer.recipe.ComputerConvertRecipe;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
|
||||
import dan200.computercraft.shared.util.RecipeUtil;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.IRecipeFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleRecipe extends ShapedRecipes
|
||||
public class TurtleRecipe extends ComputerConvertRecipe
|
||||
{
|
||||
private final NonNullList<Ingredient> m_recipe;
|
||||
private final ComputerFamily m_family;
|
||||
private final ComputerFamily family;
|
||||
|
||||
public TurtleRecipe( String group, int width, int height, NonNullList<Ingredient> recipe, ComputerFamily family )
|
||||
public TurtleRecipe( String group, @Nonnull CraftingHelper.ShapedPrimer primer, ComputerFamily family )
|
||||
{
|
||||
super( group, width, height, recipe, TurtleItemFactory.create( -1, null, -1, family, null, null, 0, null ) );
|
||||
m_recipe = recipe;
|
||||
m_family = family;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( @Nonnull InventoryCrafting _inventory, @Nonnull World world )
|
||||
{
|
||||
return !getCraftingResult( _inventory ).isEmpty();
|
||||
super( group, primer, TurtleItemFactory.create( -1, null, -1, family, null, null, 0, null ) );
|
||||
this.family = family;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult( @Nonnull InventoryCrafting inventory )
|
||||
protected ItemStack convert( @Nonnull ItemStack stack )
|
||||
{
|
||||
// See if we match the recipe, and extract the input computercraft ID
|
||||
int computerID = -1;
|
||||
String label = null;
|
||||
for( int y = 0; y < 3; ++y )
|
||||
{
|
||||
for( int x = 0; x < 3; ++x )
|
||||
{
|
||||
ItemStack item = inventory.getStackInRowAndColumn( x, y );
|
||||
Ingredient target = m_recipe.get( x + y * 3 );
|
||||
IComputerItem item = (IComputerItem) stack.getItem();
|
||||
int computerID = item.getComputerID( stack );
|
||||
String label = item.getLabel( stack );
|
||||
|
||||
if( item.getItem() instanceof IComputerItem )
|
||||
{
|
||||
IComputerItem itemComputer = (IComputerItem) item.getItem();
|
||||
if( itemComputer.getFamily( item ) != m_family ) return ItemStack.EMPTY;
|
||||
if( family == ComputerFamily.Beginners ) computerID = -1;
|
||||
|
||||
computerID = itemComputer.getComputerID( item );
|
||||
label = itemComputer.getLabel( item );
|
||||
}
|
||||
else if( !target.apply( item ) )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build a turtle with the same ID the computer had
|
||||
// Construct the new stack
|
||||
if( m_family != ComputerFamily.Beginners )
|
||||
{
|
||||
return TurtleItemFactory.create( computerID, label, -1, m_family, null, null, 0, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
return TurtleItemFactory.create( -1, label, -1, m_family, null, null, 0, null );
|
||||
}
|
||||
return TurtleItemFactory.create( computerID, label, -1, family, null, null, 0, null );
|
||||
}
|
||||
|
||||
public static class Factory implements IRecipeFactory
|
||||
@@ -91,20 +50,10 @@ public class TurtleRecipe extends ShapedRecipes
|
||||
public IRecipe parse( JsonContext context, JsonObject json )
|
||||
{
|
||||
String group = JsonUtils.getString( json, "group", "" );
|
||||
|
||||
String familyName = JsonUtils.getString( json, "family" );
|
||||
ComputerFamily family;
|
||||
try
|
||||
{
|
||||
family = ComputerFamily.valueOf( familyName );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new JsonSyntaxException( "Unknown computer family '" + familyName + "'" );
|
||||
}
|
||||
|
||||
ComputerFamily family = RecipeUtil.getFamily( json, "family" );
|
||||
CraftingHelper.ShapedPrimer primer = RecipeUtil.getPrimer( context, json );
|
||||
return new TurtleRecipe( group, primer.width, primer.height, primer.input, family );
|
||||
|
||||
return new TurtleRecipe( group, primer, family );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ package dan200.computercraft.shared.util;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.*;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
@@ -102,4 +103,17 @@ public class RecipeUtil
|
||||
|
||||
return ings;
|
||||
}
|
||||
|
||||
public static ComputerFamily getFamily( JsonObject json, String name )
|
||||
{
|
||||
String familyName = JsonUtils.getString( json, name );
|
||||
try
|
||||
{
|
||||
return ComputerFamily.valueOf( familyName );
|
||||
}
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
throw new JsonSyntaxException( "Unknown computer family '" + familyName + "' for field " + name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,10 @@
|
||||
"recipes" : {
|
||||
"impostor_shaped" : "dan200.computercraft.shared.util.ImpostorRecipe$Factory",
|
||||
"impostor_shapeless" : "dan200.computercraft.shared.util.ImpostorShapelessRecipe$Factory",
|
||||
"turtle" : "dan200.computercraft.shared.turtle.recipes.TurtleRecipe$Factory"
|
||||
"turtle" : "dan200.computercraft.shared.turtle.recipes.TurtleRecipe$Factory",
|
||||
"computer_upgrade" : "dan200.computercraft.shared.computer.recipe.ComputerFamilyRecipe$Factory"
|
||||
},
|
||||
"ingredients": {
|
||||
"computer": "dan200.computercraft.shared.computer.recipe.ComputerIngredient$Factory"
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "computercraft:computer_upgrade",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#C#",
|
||||
"# #"
|
||||
],
|
||||
"key": {
|
||||
"#": { "type": "forge:ore_dict", "ore": "ingotGold" },
|
||||
"C": { "type": "computercraft:computer", "item": "computercraft:computer", "family": "Normal" }
|
||||
},
|
||||
"family": "Advanced",
|
||||
"result": { "item": "computercraft:computer", "data": 16384 }
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "computercraft:computer_upgrade",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#C#",
|
||||
"# #"
|
||||
],
|
||||
"key": {
|
||||
"#": { "type": "forge:ore_dict", "ore": "ingotGold" },
|
||||
"C": { "item": "computercraft:pocket_computer", "data": 0 }
|
||||
},
|
||||
"family": "Advanced",
|
||||
"result": { "item": "computercraft:pocket_computer", "data": 1 }
|
||||
}
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"key": {
|
||||
"#": { "type": "forge:ore_dict", "ore": "ingotGold" },
|
||||
"C": { "item": "computercraft:computer", "data": 16384 },
|
||||
"C": { "type": "computercraft:computer", "item": "computercraft:computer", "data": 16384, "family": "Advanced" },
|
||||
"I": { "type": "forge:ore_dict", "ore": "chestWood" }
|
||||
},
|
||||
"family": "Advanced"
|
||||
|
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"type": "computercraft:computer_upgrade",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#C#",
|
||||
" B "
|
||||
],
|
||||
"key": {
|
||||
"#": { "type": "forge:ore_dict", "ore": "ingotGold" },
|
||||
"B": { "type": "forge:ore_dict", "ore": "blockGold" },
|
||||
"C": [
|
||||
{ "type": "computercraft:computer", "item": "computercraft:turtle", "family": "Normal" },
|
||||
{ "item": "computercraft:turtle_expanded", "data": 0 }
|
||||
]
|
||||
},
|
||||
"family": "Advanced",
|
||||
"result": { "item": "computercraft:turtle_advanced", "data": 0 }
|
||||
}
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"key": {
|
||||
"#": { "type": "forge:ore_dict", "ore": "ingotIron" },
|
||||
"C": { "item": "computercraft:computer", "data": 0 },
|
||||
"C": { "type": "computercraft:computer", "item": "computercraft:computer", "family": "Normal" },
|
||||
"I": { "type": "forge:ore_dict", "ore": "chestWood" }
|
||||
},
|
||||
"family": "Normal"
|
||||
|
Reference in New Issue
Block a user