mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-11 18:00:29 +00:00
Initial update to 1.12
- Convert most recipes to JSON - Add JSON factories for impostor and turtle recipes. - Several mappings changes - Migrate to Forge's new registry system
This commit is contained in:
parent
bee41e7f97
commit
08099f08f2
@ -9,7 +9,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath 'org.ajoberstar:gradle-git:1.6.0'
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ group = "dan200.computercraft"
|
||||
archivesBaseName = "ComputerCraft"
|
||||
|
||||
minecraft {
|
||||
version = "1.11.2-13.20.0.2294"
|
||||
version = "1.12-14.21.1.2387"
|
||||
runDir = "run"
|
||||
replace '${version}', project.version
|
||||
|
||||
@ -37,7 +37,7 @@ minecraft {
|
||||
// stable_# stables are built at the discretion of the MCP team.
|
||||
// Use non-default mappings at your own risk. they may not allways work.
|
||||
// simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings = "snapshot_20161227"
|
||||
mappings = "snapshot_20170629"
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
}
|
||||
|
||||
|
@ -396,14 +396,6 @@ public class ComputerCraft
|
||||
turtleProxy.init();
|
||||
}
|
||||
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onMissingMappings( FMLMissingMappingsEvent event )
|
||||
{
|
||||
proxy.remap( event );
|
||||
turtleProxy.remap( event );
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onServerStarting( FMLServerStartingEvent event )
|
||||
{
|
||||
|
@ -8,9 +8,9 @@ package dan200.computercraft.client.gui;
|
||||
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@ -38,7 +38,7 @@ public class FixedWidthFontRenderer
|
||||
Arrays.fill( rgb, ( rgb[0] + rgb[1] + rgb[2] ) / 3.0f );
|
||||
}
|
||||
|
||||
private void drawChar( VertexBuffer renderer, double x, double y, int index, int color, Palette p, boolean greyscale )
|
||||
private void drawChar( BufferBuilder renderer, double x, double y, int index, int color, Palette p, boolean greyscale )
|
||||
{
|
||||
int column = index % 16;
|
||||
int row = index / 16;
|
||||
@ -63,7 +63,7 @@ public class FixedWidthFontRenderer
|
||||
renderer.pos( x + FONT_WIDTH, y + FONT_HEIGHT, 0.0 ).tex( (xStart + FONT_WIDTH) / 256.0, (yStart + FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
}
|
||||
|
||||
private void drawQuad( VertexBuffer renderer, double x, double y, int color, double width, Palette p, boolean greyscale )
|
||||
private void drawQuad( BufferBuilder renderer, double x, double y, int color, double width, Palette p, boolean greyscale )
|
||||
{
|
||||
double[] colour = p.getColour( 15 - color );
|
||||
if(greyscale)
|
||||
@ -91,7 +91,7 @@ public class FixedWidthFontRenderer
|
||||
{
|
||||
// Draw the quads
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer renderer = tessellator.getBuffer();
|
||||
BufferBuilder renderer = tessellator.getBuffer();
|
||||
renderer.begin( GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR );
|
||||
if( leftMarginSize > 0.0 )
|
||||
{
|
||||
@ -129,7 +129,7 @@ public class FixedWidthFontRenderer
|
||||
{
|
||||
// Draw the quads
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer renderer = tessellator.getBuffer();
|
||||
BufferBuilder renderer = tessellator.getBuffer();
|
||||
renderer.begin( GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_TEX_COLOR );
|
||||
for( int i = 0; i < s.length(); i++ )
|
||||
{
|
||||
|
@ -52,24 +52,10 @@ public class GuiConfigCC extends GuiConfig
|
||||
return new GuiConfigCC( parentScreen );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass()
|
||||
{
|
||||
return GuiConfigCC.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public RuntimeOptionGuiHandler getHandlerFor( RuntimeOptionCategoryElement runtimeOptionCategoryElement )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ public class GuiDiskDrive extends GuiContainer
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
String title = m_diskDrive.getDisplayName().getUnformattedText();
|
||||
fontRendererObj.drawString( title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 6, 0x404040 );
|
||||
fontRendererObj.drawString( I18n.format("container.inventory"), 8, (ySize - 96) + 2, 0x404040 );
|
||||
fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth(title)) / 2, 6, 0x404040 );
|
||||
fontRenderer.drawString( I18n.format("container.inventory"), 8, (ySize - 96) + 2, 0x404040 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,8 +32,8 @@ public class GuiPrinter extends GuiContainer
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
String title = m_printer.getDisplayName().getUnformattedText();
|
||||
fontRendererObj.drawString( title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 6, 0x404040 );
|
||||
fontRendererObj.drawString( I18n.format("container.inventory"), 8, (ySize - 96) + 2, 0x404040 );
|
||||
fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth(title)) / 2, 6, 0x404040 );
|
||||
fontRenderer.drawString( I18n.format("container.inventory"), 8, (ySize - 96) + 2, 0x404040 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -265,7 +265,7 @@ public abstract class Widget extends Gui
|
||||
protected void drawTooltip( String[] lines, int x, int y )
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
FontRenderer fontRenderer = mc.fontRendererObj;
|
||||
FontRenderer fontRenderer = mc.fontRenderer;
|
||||
|
||||
int width = 0;
|
||||
for( String line : lines )
|
||||
@ -340,7 +340,7 @@ public abstract class Widget extends Gui
|
||||
if( renderItem != null )
|
||||
{
|
||||
renderItem.renderItemAndEffectIntoGUI( stack, x, y );
|
||||
renderItem.renderItemOverlayIntoGUI( mc.fontRendererObj, stack, x, y, null );
|
||||
renderItem.renderItemOverlayIntoGUI( mc.fontRenderer, stack, x, y, null );
|
||||
}
|
||||
}
|
||||
finally
|
||||
@ -360,7 +360,7 @@ public abstract class Widget extends Gui
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
try
|
||||
{
|
||||
mc.fontRendererObj.drawString( s, x, y, color );
|
||||
mc.fontRenderer.drawString( s, x, y, color );
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -371,7 +371,7 @@ public abstract class Widget extends Gui
|
||||
protected int getStringWidth( String s )
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
return mc.fontRendererObj.getStringWidth( s );
|
||||
return mc.fontRenderer.getStringWidth( s );
|
||||
}
|
||||
|
||||
protected void playClickSound()
|
||||
|
@ -29,6 +29,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
@ -49,6 +50,13 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
|
||||
{
|
||||
super.preInit();
|
||||
|
||||
// Setup client forge handlers
|
||||
registerForgeHandlers();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerModels( ModelRegistryEvent event )
|
||||
{
|
||||
// Register item models
|
||||
ItemMeshDefinition turtleMeshDefinition = new ItemMeshDefinition()
|
||||
{
|
||||
@ -70,9 +78,6 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
|
||||
registerItemModel( ComputerCraft.Blocks.turtle, turtleMeshDefinition, turtleModelNames );
|
||||
registerItemModel( ComputerCraft.Blocks.turtleExpanded, turtleMeshDefinition, turtleModelNames );
|
||||
registerItemModel( ComputerCraft.Blocks.turtleAdvanced, turtleMeshDefinition, turtleModelNames );
|
||||
|
||||
// Setup client forge handlers
|
||||
registerForgeHandlers();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,6 +34,7 @@ import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@ -44,6 +45,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
@ -76,6 +78,13 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
m_tick = 0;
|
||||
m_renderFrame = 0;
|
||||
|
||||
// Setup client forge handlers
|
||||
registerForgeHandlers();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerModels( ModelRegistryEvent event )
|
||||
{
|
||||
// Register item models
|
||||
registerItemModel( ComputerCraft.Blocks.computer, new ItemMeshDefinition()
|
||||
{
|
||||
@ -174,9 +183,6 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
"advanced_pocket_computer", "advanced_pocket_computer_on", "advanced_pocket_computer_blinking",
|
||||
"pocket_computer_colour", "pocket_computer_colour_on", "pocket_computer_colour_blinking",
|
||||
} );
|
||||
|
||||
// Setup client forge handlers
|
||||
registerForgeHandlers();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -304,7 +310,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
public String getRecordInfo( @Nonnull ItemStack recordStack )
|
||||
{
|
||||
List<String> info = new ArrayList<String>( 1 );
|
||||
recordStack.getItem().addInformation( recordStack, null, info, false );
|
||||
recordStack.getItem().addInformation( recordStack, null, info, ITooltipFlag.TooltipFlags.NORMAL );
|
||||
if( info.size() > 0 ) {
|
||||
return info.get( 0 );
|
||||
} else {
|
||||
|
@ -16,17 +16,15 @@ import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMonitor>
|
||||
{
|
||||
public TileEntityMonitorRenderer()
|
||||
@ -34,7 +32,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt( @Nonnull TileMonitor tileEntity, double posX, double posY, double posZ, float f, int i )
|
||||
public void render( TileMonitor tileEntity, double posX, double posY, double posZ, float f, int i, float f2 )
|
||||
{
|
||||
if( tileEntity != null )
|
||||
{
|
||||
@ -93,7 +91,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
// Get renderers
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer renderer = tessellator.getBuffer();
|
||||
BufferBuilder renderer = tessellator.getBuffer();
|
||||
|
||||
// Get terminal
|
||||
ClientTerminal clientTerminal = (ClientTerminal)origin.getTerminal();
|
||||
|
@ -17,9 +17,9 @@ import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
||||
@ -40,7 +40,6 @@ import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import java.util.List;
|
||||
|
||||
@ -58,7 +57,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt( @Nonnull TileTurtle tileEntity, double posX, double posY, double posZ, float f, int i )
|
||||
public void render( TileTurtle tileEntity, double posX, double posY, double posZ, float f, int i, float f2 )
|
||||
{
|
||||
if( tileEntity != null )
|
||||
{
|
||||
@ -66,7 +65,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
Entity viewEntity = Minecraft.getMinecraft().getRenderViewEntity();
|
||||
if( viewEntity != null && viewEntity instanceof TurtleVisionCamera )
|
||||
{
|
||||
TurtleVisionCamera camera = (TurtleVisionCamera)viewEntity;
|
||||
TurtleVisionCamera camera = (TurtleVisionCamera) viewEntity;
|
||||
if( camera.getTurtle() == tileEntity.getAccess() )
|
||||
{
|
||||
return;
|
||||
@ -127,7 +126,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
offset = new Vec3d( 0.0, 0.0, 0.0 );
|
||||
yaw = 0.0f;
|
||||
}
|
||||
GlStateManager.translate( posX + offset.xCoord, posY + offset.yCoord, posZ + offset.zCoord );
|
||||
GlStateManager.translate( posX + offset.x, posY + offset.y, posZ + offset.z );
|
||||
|
||||
// Render the label
|
||||
IComputer computer = (turtle != null) ? turtle.getComputer() : null;
|
||||
@ -250,7 +249,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
|
||||
private void renderQuads( Tessellator tessellator, List<BakedQuad> quads, int[] tints )
|
||||
{
|
||||
VertexBuffer buffer = tessellator.getBuffer();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
VertexFormat format = DefaultVertexFormats.ITEM;
|
||||
buffer.begin( GL11.GL_QUADS, format );
|
||||
for (BakedQuad quad : quads)
|
||||
@ -309,7 +308,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
try
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer renderer = tessellator.getBuffer();
|
||||
BufferBuilder renderer = tessellator.getBuffer();
|
||||
renderer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR );
|
||||
renderer.pos( (double) ( -xOffset - 1 ), (double) ( -1 + yOffset ), 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
|
||||
renderer.pos( (double) ( -xOffset - 1 ), (double) ( 8 + yOffset ), 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
|
||||
|
@ -11,7 +11,6 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.turtle.items.ItemTurtleBase;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@ -90,15 +89,15 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack m_defaultItem;
|
||||
|
||||
private HashMap<TurtleModelCombination, IBakedModel> m_cachedModels;
|
||||
private ItemOverrideList m_overrides;
|
||||
private final TurtleModelCombination m_defaultCombination;
|
||||
|
||||
public TurtleSmartItemModel()
|
||||
{
|
||||
m_defaultItem = TurtleItemFactory.create( -1, null, -1, ComputerFamily.Normal, null, null, 0, null );
|
||||
m_cachedModels = new HashMap<TurtleModelCombination, IBakedModel>();
|
||||
m_defaultCombination = new TurtleModelCombination( ComputerFamily.Normal, false, null, null, null, false );
|
||||
m_overrides = new ItemOverrideList( new ArrayList<ItemOverride>() )
|
||||
{
|
||||
@Nonnull
|
||||
@ -216,6 +215,13 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
|
||||
|
||||
private IBakedModel getDefaultModel()
|
||||
{
|
||||
return m_overrides.handleItemState( this, m_defaultItem, null, null );
|
||||
IBakedModel model = m_cachedModels.get( m_defaultCombination );
|
||||
if( model == null )
|
||||
{
|
||||
model = buildModel( m_defaultCombination );
|
||||
m_cachedModels.put( m_defaultCombination, model );
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
@ -15,16 +15,18 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -46,18 +48,15 @@ public abstract class BlockGeneric extends Block implements
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final List<ItemStack> getDrops( IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune )
|
||||
public final void getDrops( @Nonnull NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune )
|
||||
{
|
||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>( 1 );
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
{
|
||||
TileGeneric generic = (TileGeneric)tile;
|
||||
TileGeneric generic = (TileGeneric) tile;
|
||||
generic.getDroppedItems( drops, false );
|
||||
}
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -85,7 +84,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
public final void dropAllItems( World world, BlockPos pos, boolean creative )
|
||||
{
|
||||
// Get items to drop
|
||||
List<ItemStack> drops = new ArrayList<ItemStack>( 1 );
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
{
|
||||
@ -170,6 +169,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final boolean isSideSolid( IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
@ -188,7 +188,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance( World world, BlockPos pos, @Nonnull Entity exploder, Explosion explosion )
|
||||
public float getExplosionResistance( World world, BlockPos pos, @Nullable Entity exploder, Explosion explosion )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric && tile.hasWorld() )
|
||||
@ -199,7 +199,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
return 2000.0f;
|
||||
}
|
||||
}
|
||||
return super.getExplosionResistance( exploder );
|
||||
return super.getExplosionResistance( world, pos, exploder, explosion );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -9,10 +9,11 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ColourableRecipe implements IRecipe
|
||||
public class ColourableRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
{
|
||||
@Override
|
||||
public boolean matches( @Nonnull InventoryCrafting inv, @Nonnull World worldIn )
|
||||
@ -79,9 +80,15 @@ public class ColourableRecipe implements IRecipe
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
public boolean canFit( int x, int y )
|
||||
{
|
||||
return 2;
|
||||
return x >= 2 && y >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@ -79,7 +80,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
getWorld().setBlockState( getPos(), newState, 3 );
|
||||
}
|
||||
|
||||
public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
|
||||
public void getDroppedItems( @Nonnull NonNullList<ItemStack> drops, boolean creative )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
@ -48,7 +49,7 @@ public class TileComputer extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
|
||||
public void getDroppedItems( @Nonnull NonNullList<ItemStack> drops, boolean creative )
|
||||
{
|
||||
IComputer computer = getComputer();
|
||||
if( !creative || (computer != null && computer.getLabel() != null) )
|
||||
|
@ -40,9 +40,12 @@ public class ItemCommandComputer extends ItemComputer
|
||||
// Build the stack
|
||||
ItemStack result = new ItemStack( this, 1, 0 );
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger( "computerID", id );
|
||||
result.setTagCompound( nbt );
|
||||
if( id >= 0 )
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger( "computerID", id );
|
||||
result.setTagCompound( nbt );
|
||||
}
|
||||
|
||||
if( label != null )
|
||||
{
|
||||
@ -53,8 +56,9 @@ public class ItemCommandComputer extends ItemComputer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Command ) );
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,9 @@ public class ItemComputer extends ItemComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Normal ) );
|
||||
list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Advanced ) );
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -18,6 +19,7 @@ import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ItemComputerBase extends ItemBlock implements IComputerItem, IMedia
|
||||
@ -36,9 +38,9 @@ public abstract class ItemComputerBase extends ItemBlock implements IComputerIte
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( @Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull List<String> list, boolean debug )
|
||||
public void addInformation( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<String> list, @Nonnull ITooltipFlag flag )
|
||||
{
|
||||
if( debug )
|
||||
if( flag.isAdvanced() )
|
||||
{
|
||||
int id = getComputerID( stack );
|
||||
if( id >= 0 )
|
||||
|
@ -12,6 +12,7 @@ import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@ -37,8 +38,9 @@ public class ItemDiskLegacy extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, CreativeTabs tabs, NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nonnull CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
for( int colour=0; colour<16; ++colour )
|
||||
{
|
||||
ItemStack stack = createFromIDAndColour( -1, null, Colour.values()[ colour ].getHex() );
|
||||
@ -83,9 +85,9 @@ public class ItemDiskLegacy extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( @Nonnull ItemStack stack, EntityPlayer player, List<String> list, boolean debug )
|
||||
public void addInformation( @Nonnull ItemStack stack, World world, List<String> list, ITooltipFlag flag )
|
||||
{
|
||||
if( debug )
|
||||
if( flag.isAdvanced() )
|
||||
{
|
||||
int id = getDiskID( stack );
|
||||
if( id >= 0 )
|
||||
|
@ -7,6 +7,7 @@
|
||||
package dan200.computercraft.shared.media.items;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@ -43,15 +44,16 @@ public class ItemPrintout extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, CreativeTabs tabs, NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nonnull CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
list.add( createSingleFromTitleAndText( null, new String[ LINES_PER_PAGE ], new String[ LINES_PER_PAGE ] ) );
|
||||
list.add( createMultipleFromTitleAndText( null, new String[ 2*LINES_PER_PAGE ], new String[ 2*LINES_PER_PAGE ] ) );
|
||||
list.add( createBookFromTitleAndText( null, new String[ 2*LINES_PER_PAGE ], new String[ 2*LINES_PER_PAGE ] ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( @Nonnull ItemStack itemstack, EntityPlayer par2EntityPlayer, List<String> list, boolean flag )
|
||||
public void addInformation( @Nonnull ItemStack itemstack, World world, List<String> list, ITooltipFlag flag )
|
||||
{
|
||||
String title = getTitle( itemstack );
|
||||
if( title != null && title.length() > 0 )
|
||||
@ -91,7 +93,7 @@ public class ItemPrintout extends Item
|
||||
{
|
||||
ComputerCraft.openPrintoutGUI( player, hand );
|
||||
}
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) );
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -11,6 +11,7 @@ import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.core.filesystem.SubMount;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@ -23,6 +24,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@ -37,12 +39,12 @@ public class ItemTreasureDisk extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, CreativeTabs tabs, NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nonnull CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( @Nonnull ItemStack stack, EntityPlayer player, List<String> list, boolean bool )
|
||||
public void addInformation( @Nonnull ItemStack stack, World world, List<String> list, ITooltipFlag flag )
|
||||
{
|
||||
String label = getTitle( stack );
|
||||
if( label != null && label.length() > 0 )
|
||||
|
@ -1,107 +1,114 @@
|
||||
/*
|
||||
* 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.media.recipes;
|
||||
|
||||
import dan200.computercraft.shared.media.items.ItemDiskLegacy;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.ColourTracker;
|
||||
import dan200.computercraft.shared.util.ColourUtils;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class DiskRecipe implements IRecipe
|
||||
{
|
||||
@Override
|
||||
public boolean matches( @Nonnull InventoryCrafting inv, @Nonnull World world )
|
||||
{
|
||||
boolean paperFound = false;
|
||||
boolean redstoneFound = false;
|
||||
|
||||
for( int i = 0; i < inv.getSizeInventory(); ++i )
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot( i );
|
||||
|
||||
if( !stack.isEmpty() )
|
||||
{
|
||||
if( stack.getItem() == Items.PAPER )
|
||||
{
|
||||
if( paperFound ) return false;
|
||||
paperFound = true;
|
||||
}
|
||||
else if( stack.getItem() == Items.REDSTONE )
|
||||
{
|
||||
if( redstoneFound ) return false;
|
||||
redstoneFound = true;
|
||||
}
|
||||
else if( ColourUtils.getStackColour( stack ) < 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return redstoneFound && paperFound;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult( @Nonnull InventoryCrafting inv )
|
||||
{
|
||||
ColourTracker tracker = new ColourTracker();
|
||||
|
||||
for( int i = 0; i < inv.getSizeInventory(); ++i )
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot( i );
|
||||
|
||||
if( stack.isEmpty() ) continue;
|
||||
|
||||
if( stack.getItem() != Items.PAPER && stack.getItem() != Items.REDSTONE )
|
||||
{
|
||||
int index = ColourUtils.getStackColour( stack );
|
||||
if( index < 0 ) continue;
|
||||
|
||||
Colour colour = Colour.values()[ index ];
|
||||
tracker.addColour( colour.getR(), colour.getG(), colour.getB() );
|
||||
}
|
||||
}
|
||||
|
||||
return ItemDiskLegacy.createFromIDAndColour( -1, null, tracker.hasColour() ? tracker.getColour() : Colour.Blue.getHex() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.Blue.getHex() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
|
||||
{
|
||||
NonNullList<ItemStack> results = NonNullList.withSize( inventoryCrafting.getSizeInventory(), ItemStack.EMPTY );
|
||||
for( int i = 0; i < results.size(); ++i )
|
||||
{
|
||||
ItemStack stack = inventoryCrafting.getStackInSlot( i );
|
||||
results.set( i, ForgeHooks.getContainerItem( stack ) );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.media.recipes;
|
||||
|
||||
import dan200.computercraft.shared.media.items.ItemDiskLegacy;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.ColourTracker;
|
||||
import dan200.computercraft.shared.util.ColourUtils;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
{
|
||||
@Override
|
||||
public boolean matches( @Nonnull InventoryCrafting inv, @Nonnull World world )
|
||||
{
|
||||
boolean paperFound = false;
|
||||
boolean redstoneFound = false;
|
||||
|
||||
for( int i = 0; i < inv.getSizeInventory(); ++i )
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot( i );
|
||||
|
||||
if( !stack.isEmpty() )
|
||||
{
|
||||
if( stack.getItem() == Items.PAPER )
|
||||
{
|
||||
if( paperFound ) return false;
|
||||
paperFound = true;
|
||||
}
|
||||
else if( stack.getItem() == Items.REDSTONE )
|
||||
{
|
||||
if( redstoneFound ) return false;
|
||||
redstoneFound = true;
|
||||
}
|
||||
else if( ColourUtils.getStackColour( stack ) < 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return redstoneFound && paperFound;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult( @Nonnull InventoryCrafting inv )
|
||||
{
|
||||
ColourTracker tracker = new ColourTracker();
|
||||
|
||||
for( int i = 0; i < inv.getSizeInventory(); ++i )
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot( i );
|
||||
|
||||
if( stack.isEmpty() ) continue;
|
||||
|
||||
if( stack.getItem() != Items.PAPER && stack.getItem() != Items.REDSTONE )
|
||||
{
|
||||
int index = ColourUtils.getStackColour( stack );
|
||||
if( index < 0 ) continue;
|
||||
|
||||
Colour colour = Colour.values()[ index ];
|
||||
tracker.addColour( colour.getR(), colour.getG(), colour.getB() );
|
||||
}
|
||||
}
|
||||
|
||||
return ItemDiskLegacy.createFromIDAndColour( -1, null, tracker.hasColour() ? tracker.getColour() : Colour.Blue.getHex() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit( int x, int y )
|
||||
{
|
||||
return x >= 2 && y >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.Blue.getHex() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
|
||||
{
|
||||
NonNullList<ItemStack> results = NonNullList.withSize( inventoryCrafting.getSizeInventory(), ItemStack.EMPTY );
|
||||
for( int i = 0; i < results.size(); ++i )
|
||||
{
|
||||
ItemStack stack = inventoryCrafting.getStackInSlot( i );
|
||||
results.set( i, ForgeHooks.getContainerItem( stack ) );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
@ -15,19 +15,26 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PrintoutRecipe implements IRecipe
|
||||
public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
{
|
||||
public PrintoutRecipe( )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
public boolean canFit( int x, int y )
|
||||
{
|
||||
return 3;
|
||||
return x >= 3 && y >= 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -35,7 +35,7 @@ public class PacketHandler
|
||||
{
|
||||
ComputerCraftPacket packet = new ComputerCraftPacket();
|
||||
packet.fromBytes( event.getPacket().payload() );
|
||||
ComputerCraft.handlePacket( packet, ((NetHandlerPlayServer)event.getHandler()).playerEntity );
|
||||
ComputerCraft.handlePacket( packet, ((NetHandlerPlayServer)event.getHandler()).player );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
|
@ -51,8 +51,9 @@ public class ItemAdvancedModem extends ItemPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.AdvancedModem, null, 1 ) );
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,9 @@ public class ItemCable extends ItemPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.WiredModem, null, 1 ) );
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.Cable, null, 1 ) );
|
||||
}
|
||||
@ -108,7 +109,7 @@ public class ItemCable extends ItemPeripheralBase
|
||||
}
|
||||
|
||||
// Try to add on the side of something
|
||||
if( !existing.isAir( existingState, world, pos ) && (type == PeripheralType.Cable || existing.isSideSolid( existingState, world, pos, side )) )
|
||||
if( !existing.isAir( existingState, world, pos ) && (type == PeripheralType.Cable || existingState.isSideSolid( world, pos, side )) )
|
||||
{
|
||||
BlockPos offset = pos.offset( side );
|
||||
Block offsetExisting = world.getBlockState( offset ).getBlock();
|
||||
|
@ -77,8 +77,9 @@ public class ItemPeripheral extends ItemPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nonnull CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.DiskDrive, null, 1 ) );
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.Printer, null, 1 ) );
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.Monitor, null, 1 ) );
|
||||
|
@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
@ -46,7 +47,7 @@ public abstract class TilePeripheralBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
|
||||
public void getDroppedItems( @Nonnull NonNullList<ItemStack> drops, boolean creative )
|
||||
{
|
||||
if( !creative )
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@ -298,7 +299,7 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
|
||||
public void getDroppedItems( @Nonnull NonNullList<ItemStack> drops, boolean creative )
|
||||
{
|
||||
if( !creative )
|
||||
{
|
||||
|
@ -46,9 +46,9 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral
|
||||
minRange = (double) ComputerCraft.modem_rangeDuringStorm;
|
||||
maxRange = (double) ComputerCraft.modem_highAltitudeRangeDuringStorm;
|
||||
}
|
||||
if( position.yCoord > 96.0 && maxRange > minRange )
|
||||
if( position.y > 96.0 && maxRange > minRange )
|
||||
{
|
||||
return minRange + ( position.yCoord - 96.0 ) * ( ( maxRange - minRange ) / ( ( world.getHeight() - 1 ) - 96.0 ) );
|
||||
return minRange + ( position.y - 96.0 ) * ( ( maxRange - minRange ) / ( ( world.getHeight() - 1 ) - 96.0 ) );
|
||||
}
|
||||
return minRange;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class ContainerPrinter extends Container
|
||||
public void addListener( IContainerListener crafting )
|
||||
{
|
||||
super.addListener( crafting );
|
||||
crafting.sendProgressBarUpdate( this, 0, m_printer.isPrinting() ? 1 : 0 );
|
||||
crafting.sendWindowProperty( this, 0, m_printer.isPrinting() ? 1 : 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,7 +81,7 @@ public class ContainerPrinter extends Container
|
||||
{
|
||||
if( printing != m_lastPrinting )
|
||||
{
|
||||
listener.sendProgressBarUpdate( this, 0, printing ? 1 : 0 );
|
||||
listener.sendWindowProperty( this, 0, printing ? 1 : 0 );
|
||||
}
|
||||
}
|
||||
m_lastPrinting = printing;
|
||||
|
@ -20,6 +20,7 @@ import dan200.computercraft.shared.computer.items.IComputerItem;
|
||||
import dan200.computercraft.shared.pocket.apis.PocketAPI;
|
||||
import dan200.computercraft.shared.pocket.core.PocketServerComputer;
|
||||
import dan200.computercraft.shared.util.StringUtil;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -86,8 +87,9 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, CreativeTabs tabs, NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nonnull CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
getSubItems( list, ComputerFamily.Normal );
|
||||
getSubItems( list, ComputerFamily.Advanced );
|
||||
}
|
||||
@ -223,9 +225,9 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( @Nonnull ItemStack stack, EntityPlayer player, List<String> list, boolean debug )
|
||||
public void addInformation( @Nonnull ItemStack stack, World world, List<String> list, ITooltipFlag flag )
|
||||
{
|
||||
if( debug )
|
||||
if( flag.isAdvanced() )
|
||||
{
|
||||
int id = getComputerID( stack );
|
||||
if( id >= 0 )
|
||||
|
@ -17,19 +17,26 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PocketComputerUpgradeRecipe implements IRecipe
|
||||
public class PocketComputerUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
{
|
||||
public PocketComputerUpgradeRecipe()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
public boolean canFit( int x, int y )
|
||||
{
|
||||
return 2;
|
||||
return x >= 2 && y >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -8,10 +8,7 @@ package dan200.computercraft.shared.proxy;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.core.computer.Computer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItemFactory;
|
||||
import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral;
|
||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtleAdvanced;
|
||||
@ -21,7 +18,6 @@ import dan200.computercraft.shared.turtle.items.ItemTurtleAdvanced;
|
||||
import dan200.computercraft.shared.turtle.items.ItemTurtleLegacy;
|
||||
import dan200.computercraft.shared.turtle.items.ItemTurtleNormal;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
|
||||
import dan200.computercraft.shared.turtle.recipes.TurtleRecipe;
|
||||
import dan200.computercraft.shared.turtle.recipes.TurtleUpgradeRecipe;
|
||||
import dan200.computercraft.shared.turtle.upgrades.*;
|
||||
import dan200.computercraft.shared.util.IEntityDropConsumer;
|
||||
@ -30,22 +26,19 @@ import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.*;
|
||||
@ -68,11 +61,18 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
@Override
|
||||
public void preInit()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
|
||||
EntityRegistry.registerModEntity(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "turtle_player" ), TurtlePlayer.class, "turtle_player",
|
||||
0, ComputerCraft.instance, Integer.MAX_VALUE, Integer.MAX_VALUE, false
|
||||
);
|
||||
registerItems();
|
||||
|
||||
registerUpgrades();
|
||||
|
||||
// Recipe types
|
||||
// RecipeSorter.register( "computercraft:turtle", TurtleRecipe.class, RecipeSorter.Category.SHAPED, "after:minecraft:shapeless" );
|
||||
// RecipeSorter.register( "computercraft:turtle_upgrade", TurtleUpgradeRecipe.class, RecipeSorter.Category.SHAPED, "after:minecraft:shapeless" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -264,12 +264,48 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
m_legacyTurtleUpgrades.put( legacyID, upgrade );
|
||||
}
|
||||
m_turtleUpgrades.put( id, upgrade );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerBlocks( RegistryEvent.Register<Block> event )
|
||||
{
|
||||
IForgeRegistry<Block> registry = event.getRegistry();
|
||||
|
||||
// Turtle
|
||||
ComputerCraft.Blocks.turtle = BlockTurtle.createTurtleBlock();
|
||||
registry.register( ComputerCraft.Blocks.turtle.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ) ) );
|
||||
|
||||
ComputerCraft.Blocks.turtleExpanded = BlockTurtle.createTurtleBlock();
|
||||
registry.register( ComputerCraft.Blocks.turtleExpanded.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_expanded" ) ) );
|
||||
|
||||
// Advanced Turtle
|
||||
ComputerCraft.Blocks.turtleAdvanced = BlockTurtle.createTurtleBlock();
|
||||
registry.register( ComputerCraft.Blocks.turtleAdvanced.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_advanced" ) ) );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerItems( RegistryEvent.Register<Item> event )
|
||||
{
|
||||
IForgeRegistry<Item> registry = event.getRegistry();
|
||||
|
||||
registry.register( new ItemTurtleLegacy( ComputerCraft.Blocks.turtle).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ) ) );
|
||||
registry.register( new ItemTurtleNormal( ComputerCraft.Blocks.turtleExpanded ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_expanded" ) ) );
|
||||
registry.register( new ItemTurtleAdvanced( ComputerCraft.Blocks.turtleAdvanced ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "turtle_advanced" ) ) );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerRecipes( RegistryEvent.Register<IRecipe> event )
|
||||
{
|
||||
IForgeRegistry<IRecipe> registry = event.getRegistry();
|
||||
registry.register( new TurtleUpgradeRecipe().setRegistryName( new ResourceLocation( "computercraft:turtle" ) ) );
|
||||
|
||||
// Add a bunch of impostor recipes
|
||||
if( isUpgradeVanilla( upgrade ) )
|
||||
// TODO: Figure out a way to do this in a "nice" way.
|
||||
for( ITurtleUpgrade upgrade : m_turtleUpgrades.values() )
|
||||
{
|
||||
if( !isUpgradeVanilla( upgrade ) ) continue;
|
||||
|
||||
// Add fake recipes to fool NEI
|
||||
List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList();
|
||||
ItemStack craftingItem = upgrade.getCraftingItem();
|
||||
|
||||
// A turtle just containing this upgrade
|
||||
@ -285,22 +321,29 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
{
|
||||
ItemStack craftedTurtle = TurtleItemFactory.create( -1, null, -1, family, upgrade, null, 0, null );
|
||||
ItemStack craftedTurtleFlipped = TurtleItemFactory.create( -1, null, -1, family, null, upgrade, 0, null );
|
||||
recipeList.add( new ImpostorRecipe( 2, 1, new ItemStack[] { baseTurtle, craftingItem }, craftedTurtle ) );
|
||||
recipeList.add( new ImpostorRecipe( 2, 1, new ItemStack[] { craftingItem, baseTurtle }, craftedTurtleFlipped ) );
|
||||
registry.register(
|
||||
new ImpostorRecipe( "computercraft:" + family.toString() + "_turtle_upgrade", 2, 1, new ItemStack[] { baseTurtle, craftingItem }, craftedTurtle )
|
||||
.setRegistryName( new ResourceLocation( "computercraft:" + family + "_turtle_upgrade_" + upgrade.getUpgradeID().toString().replace( ':', '_' ) + "_1" ) )
|
||||
);
|
||||
registry.register(
|
||||
new ImpostorRecipe( "computercraft:" + family.toString() + "_turtle_upgrade", 2, 1, new ItemStack[] { craftingItem, baseTurtle }, craftedTurtleFlipped )
|
||||
.setRegistryName( new ResourceLocation( "computercraft:" + family + "_turtle_upgrade_" + upgrade.getUpgradeID().toString().replace( ':', '_' ) + "_2" ) )
|
||||
);
|
||||
|
||||
/*
|
||||
// A turtle containing this upgrade and another upgrade
|
||||
for( ITurtleUpgrade otherUpgrade : m_turtleUpgrades.values() )
|
||||
{
|
||||
if( isUpgradeVanilla( otherUpgrade ) && isUpgradeSuitableForFamily( family, otherUpgrade ) )
|
||||
{
|
||||
ItemStack otherCraftingItem = otherUpgrade.getCraftingItem();
|
||||
|
||||
|
||||
ItemStack otherCraftedTurtle = TurtleItemFactory.create( -1, null, -1, family, null, otherUpgrade, 0, null );
|
||||
ItemStack comboCraftedTurtle = TurtleItemFactory.create( -1, null, -1, family, upgrade, otherUpgrade, 0, null );
|
||||
|
||||
|
||||
ItemStack otherCraftedTurtleFlipped = TurtleItemFactory.create( -1, null, -1, family, otherUpgrade, null, 0, null );
|
||||
ItemStack comboCraftedTurtleFlipped = TurtleItemFactory.create( -1, null, -1, family, otherUpgrade, upgrade, 0, null );
|
||||
|
||||
|
||||
recipeList.add( new ImpostorRecipe( 2, 1, new ItemStack[] { otherCraftingItem, craftedTurtle }, comboCraftedTurtle ) );
|
||||
recipeList.add( new ImpostorRecipe( 2, 1, new ItemStack[] { otherCraftedTurtle, craftingItem }, comboCraftedTurtle ) );
|
||||
recipeList.add( new ImpostorRecipe( 2, 1, new ItemStack[] { craftedTurtleFlipped, otherCraftingItem }, comboCraftedTurtleFlipped ) );
|
||||
@ -309,67 +352,14 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
recipeList.add( new ImpostorRecipe( 3, 1, new ItemStack[] { craftingItem, baseTurtle, otherCraftingItem }, comboCraftedTurtleFlipped ) );
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerItems()
|
||||
|
||||
private void registerUpgrades()
|
||||
{
|
||||
// Blocks
|
||||
// Turtle
|
||||
ComputerCraft.Blocks.turtle = BlockTurtle.createTurtleBlock();
|
||||
registerBlock( ComputerCraft.Blocks.turtle, new ItemTurtleLegacy(ComputerCraft.Blocks.turtle), "turtle" );
|
||||
|
||||
ComputerCraft.Blocks.turtleExpanded = BlockTurtle.createTurtleBlock();
|
||||
registerBlock( ComputerCraft.Blocks.turtleExpanded, new ItemTurtleNormal( ComputerCraft.Blocks.turtleExpanded ), "turtle_expanded" );
|
||||
|
||||
// Advanced Turtle
|
||||
ComputerCraft.Blocks.turtleAdvanced = BlockTurtle.createTurtleBlock();
|
||||
registerBlock( ComputerCraft.Blocks.turtleAdvanced, new ItemTurtleAdvanced( ComputerCraft.Blocks.turtleAdvanced ), "turtle_advanced" );
|
||||
|
||||
// Recipe types
|
||||
RecipeSorter.register( "computercraft:turtle", TurtleRecipe.class, RecipeSorter.Category.SHAPED, "after:minecraft:shapeless" );
|
||||
RecipeSorter.register( "computercraft:turtle_upgrade", TurtleUpgradeRecipe.class, RecipeSorter.Category.SHAPED, "after:minecraft:shapeless" );
|
||||
|
||||
// Recipes
|
||||
// Turtle
|
||||
GameRegistry.addRecipe( new TurtleRecipe( new Item[] {
|
||||
Items.IRON_INGOT, Items.IRON_INGOT, Items.IRON_INGOT,
|
||||
Items.IRON_INGOT, Item.getItemFromBlock( ComputerCraft.Blocks.computer ), Items.IRON_INGOT,
|
||||
Items.IRON_INGOT, Item.getItemFromBlock( Blocks.CHEST ), Items.IRON_INGOT,
|
||||
}, ComputerFamily.Normal ) );
|
||||
GameRegistry.addRecipe( new TurtleUpgradeRecipe() );
|
||||
|
||||
// Impostor Turtle recipe (to fool NEI)
|
||||
ItemStack iron = new ItemStack( Items.IRON_INGOT, 1 );
|
||||
GameRegistry.addRecipe( new ImpostorRecipe( 3, 3,
|
||||
new ItemStack[] {
|
||||
iron, iron, iron,
|
||||
iron, ComputerItemFactory.create( -1, null, ComputerFamily.Normal ), iron,
|
||||
iron, new ItemStack( Blocks.CHEST, 1 ), iron,
|
||||
},
|
||||
TurtleItemFactory.create( -1, null, -1, ComputerFamily.Normal, null, null, 0, null )
|
||||
) );
|
||||
|
||||
// Advanced Turtle
|
||||
GameRegistry.addRecipe( new TurtleRecipe( new Item[] {
|
||||
Items.GOLD_INGOT, Items.GOLD_INGOT, Items.GOLD_INGOT,
|
||||
Items.GOLD_INGOT, Item.getItemFromBlock( ComputerCraft.Blocks.computer ), Items.GOLD_INGOT,
|
||||
Items.GOLD_INGOT, Item.getItemFromBlock( Blocks.CHEST ), Items.GOLD_INGOT,
|
||||
}, ComputerFamily.Advanced ) );
|
||||
|
||||
// Impostor Advanced Turtle recipe (to fool NEI)
|
||||
ItemStack gold = new ItemStack( Items.GOLD_INGOT, 1 );
|
||||
GameRegistry.addRecipe( new ImpostorRecipe( 3, 3,
|
||||
new ItemStack[] {
|
||||
gold, gold, gold,
|
||||
gold, ComputerItemFactory.create( -1, null, ComputerFamily.Advanced ), gold,
|
||||
gold, new ItemStack( Blocks.CHEST, 1 ), gold,
|
||||
},
|
||||
TurtleItemFactory.create( -1, null, -1, ComputerFamily.Advanced, null, null, 0, null )
|
||||
) );
|
||||
|
||||
// Upgrades
|
||||
ComputerCraft.Upgrades.wirelessModem = new TurtleModem( false, new ResourceLocation( "computercraft", "wireless_modem" ), 1 );
|
||||
registerTurtleUpgradeInternal( ComputerCraft.Upgrades.wirelessModem );
|
||||
@ -397,63 +387,64 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
|
||||
ComputerCraft.Upgrades.turtleSpeaker = new TurtleSpeaker( new ResourceLocation( "computercraft", "speaker" ), 8 );
|
||||
registerTurtleUpgradeInternal( ComputerCraft.Upgrades.turtleSpeaker );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remap( FMLMissingMappingsEvent mappings )
|
||||
@SubscribeEvent
|
||||
public void remapItems( RegistryEvent.MissingMappings<Item> mappings )
|
||||
{
|
||||
// We have to use mappings.getAll() as the mod ID is upper case but the domain lower.
|
||||
for( FMLMissingMappingsEvent.MissingMapping mapping : mappings.getAll() )
|
||||
// We have to use mappings.getAllMappings() as the mod ID is upper case but the domain lower.
|
||||
for( RegistryEvent.MissingMappings.Mapping<Item> mapping : mappings.getAllMappings() )
|
||||
{
|
||||
String domain = mapping.resourceLocation.getResourceDomain();
|
||||
String domain = mapping.key.getResourceDomain();
|
||||
if( !domain.equalsIgnoreCase( ComputerCraft.MOD_ID ) ) continue;
|
||||
|
||||
String key = mapping.resourceLocation.getResourcePath();
|
||||
String key = mapping.key.getResourcePath();
|
||||
if( key.equalsIgnoreCase( "CC-Turtle" ) )
|
||||
{
|
||||
remap( mapping, ComputerCraft.Blocks.turtle );
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.turtle ) );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-TurtleExpanded" ) )
|
||||
{
|
||||
remap( mapping, ComputerCraft.Blocks.turtleExpanded );
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.turtleExpanded ) );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-TurtleAdvanced" ) )
|
||||
{
|
||||
remap( mapping, ComputerCraft.Blocks.turtleAdvanced );
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.turtleAdvanced ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void remap( FMLMissingMappingsEvent.MissingMapping mapping, Block block )
|
||||
@SubscribeEvent
|
||||
public void remapBlocks( RegistryEvent.MissingMappings<Block> mappings )
|
||||
{
|
||||
if( mapping.type == GameRegistry.Type.BLOCK )
|
||||
// We have to use mappings.getAllMappings() as the mod ID is upper case but the domain lower.
|
||||
for( RegistryEvent.MissingMappings.Mapping<Block> mapping : mappings.getAllMappings() )
|
||||
{
|
||||
mapping.remap( block );
|
||||
}
|
||||
else
|
||||
{
|
||||
mapping.remap( Item.getItemFromBlock( block ) );
|
||||
}
|
||||
}
|
||||
String domain = mapping.key.getResourceDomain();
|
||||
if( !domain.equalsIgnoreCase( ComputerCraft.MOD_ID ) ) continue;
|
||||
|
||||
private void registerBlock( Block block, Item item, String name )
|
||||
{
|
||||
GameRegistry.register( block.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, name ) ) );
|
||||
GameRegistry.register( item.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, name ) ) );
|
||||
}
|
||||
|
||||
private void registerTileEntity( Class<? extends TileEntity> klass, String name )
|
||||
{
|
||||
GameRegistry.registerTileEntityWithAlternatives( klass, ComputerCraft.LOWER_ID + " : " + name, name );
|
||||
String key = mapping.key.getResourcePath();
|
||||
if( key.equalsIgnoreCase( "CC-Turtle" ) )
|
||||
{
|
||||
mapping.remap( ComputerCraft.Blocks.turtle );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-TurtleExpanded" ) )
|
||||
{
|
||||
mapping.remap( ComputerCraft.Blocks.turtleExpanded );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-TurtleAdvanced" ) )
|
||||
{
|
||||
mapping.remap( ComputerCraft.Blocks.turtleAdvanced );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerTileEntities()
|
||||
{
|
||||
// TileEntities
|
||||
registerTileEntity( TileTurtle.class, "turtle" );
|
||||
registerTileEntity( TileTurtleExpanded.class, "turtleex" );
|
||||
registerTileEntity( TileTurtleAdvanced.class, "turtleadv" );
|
||||
GameRegistry.registerTileEntity( TileTurtle.class, ComputerCraft.LOWER_ID + " : " + "turtle" );
|
||||
GameRegistry.registerTileEntity( TileTurtleExpanded.class, ComputerCraft.LOWER_ID + " : " + "turtleex" );
|
||||
GameRegistry.registerTileEntity( TileTurtleAdvanced.class, ComputerCraft.LOWER_ID + " : " + "turtleadv" );
|
||||
}
|
||||
|
||||
private void registerForgeHandlers()
|
||||
@ -484,7 +475,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
// All checks have passed, lets dispatch the drops
|
||||
for(EntityItem entityItem : drops)
|
||||
{
|
||||
consumer.consumeDrop( entity, entityItem.getEntityItem() );
|
||||
consumer.consumeDrop( entity, entityItem.getItem() );
|
||||
}
|
||||
drops.clear();
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItemFactory;
|
||||
import dan200.computercraft.shared.computer.items.ItemCommandComputer;
|
||||
import dan200.computercraft.shared.computer.items.ItemComputer;
|
||||
import dan200.computercraft.shared.media.common.DefaultMediaProvider;
|
||||
@ -32,7 +31,6 @@ import dan200.computercraft.shared.media.items.ItemTreasureDisk;
|
||||
import dan200.computercraft.shared.media.recipes.DiskRecipe;
|
||||
import dan200.computercraft.shared.media.recipes.PrintoutRecipe;
|
||||
import dan200.computercraft.shared.network.ComputerCraftPacket;
|
||||
import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import dan200.computercraft.shared.peripheral.commandblock.CommandBlockPeripheralProvider;
|
||||
import dan200.computercraft.shared.peripheral.common.*;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
|
||||
@ -59,31 +57,28 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemRecord;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
@ -99,7 +94,18 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
@Override
|
||||
public void preInit()
|
||||
{
|
||||
registerItems();
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
|
||||
// Creative tab
|
||||
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
|
||||
@ -159,6 +165,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
@Override
|
||||
public abstract Object getPocketComputerGUI( EntityPlayer player, EnumHand hand );
|
||||
|
||||
@Override
|
||||
public abstract File getWorldDir( World world );
|
||||
|
||||
@Override
|
||||
@ -228,224 +235,117 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
}
|
||||
}
|
||||
|
||||
private void registerItems()
|
||||
@SubscribeEvent
|
||||
public void registerBlocks( RegistryEvent.Register<Block> event )
|
||||
{
|
||||
// Creative tab
|
||||
ComputerCraft.mainCreativeTab = new CreativeTabMain( CreativeTabs.getNextID() );
|
||||
IForgeRegistry<Block> registry = event.getRegistry();
|
||||
|
||||
// Blocks
|
||||
// Computer
|
||||
ComputerCraft.Blocks.computer = new BlockComputer();
|
||||
registerBlock( ComputerCraft.Blocks.computer, new ItemComputer( ComputerCraft.Blocks.computer ), "computer" );
|
||||
registry.register( ComputerCraft.Blocks.computer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ) );
|
||||
|
||||
// Peripheral
|
||||
ComputerCraft.Blocks.peripheral = new BlockPeripheral();
|
||||
registerBlock( ComputerCraft.Blocks.peripheral, new ItemPeripheral( ComputerCraft.Blocks.peripheral ), "peripheral" );
|
||||
registry.register( ComputerCraft.Blocks.peripheral.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "peripheral" ) ) );
|
||||
|
||||
// Cable
|
||||
ComputerCraft.Blocks.cable = new BlockCable();
|
||||
registerBlock( ComputerCraft.Blocks.cable, new ItemCable( ComputerCraft.Blocks.cable ), "cable" );
|
||||
registry.register( ComputerCraft.Blocks.cable.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "cable" ) ) );
|
||||
|
||||
// Command Computer
|
||||
ComputerCraft.Blocks.commandComputer = new BlockCommandComputer();
|
||||
registerBlock( ComputerCraft.Blocks.commandComputer, new ItemCommandComputer( ComputerCraft.Blocks.commandComputer ), "command_computer" );
|
||||
registry.register( ComputerCraft.Blocks.commandComputer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "command_computer" ) ) );
|
||||
|
||||
// Command Computer
|
||||
ComputerCraft.Blocks.advancedModem = new BlockAdvancedModem();
|
||||
registerBlock( ComputerCraft.Blocks.advancedModem, new ItemAdvancedModem( ComputerCraft.Blocks.advancedModem ), "advanced_modem" );
|
||||
registry.register( ComputerCraft.Blocks.advancedModem.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "advanced_modem" ) ) );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerItems( RegistryEvent.Register<Item> event )
|
||||
{
|
||||
IForgeRegistry<Item> registry = event.getRegistry();
|
||||
|
||||
// Computer
|
||||
registry.register( new ItemComputer( ComputerCraft.Blocks.computer ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ) );
|
||||
|
||||
// Peripheral
|
||||
registry.register( new ItemPeripheral( ComputerCraft.Blocks.peripheral ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "peripheral" ) ) );
|
||||
|
||||
// Cable
|
||||
registry.register( new ItemCable( ComputerCraft.Blocks.cable ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "cable" ) ) );
|
||||
|
||||
// Command Computer
|
||||
registry.register( new ItemCommandComputer( ComputerCraft.Blocks.commandComputer ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "command_computer" ) ) );
|
||||
|
||||
// Command Computer
|
||||
registry.register( new ItemAdvancedModem( ComputerCraft.Blocks.advancedModem ).setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "advanced_modem" ) ) );
|
||||
|
||||
// Items
|
||||
// Floppy Disk
|
||||
ComputerCraft.Items.disk = new ItemDiskLegacy();
|
||||
GameRegistry.register( ComputerCraft.Items.disk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk" ) ) );
|
||||
registry.register( ComputerCraft.Items.disk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk" ) ) );
|
||||
|
||||
ComputerCraft.Items.diskExpanded = new ItemDiskExpanded();
|
||||
GameRegistry.register( ComputerCraft.Items.diskExpanded.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk_expanded" ) ) );
|
||||
registry.register( ComputerCraft.Items.diskExpanded.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "disk_expanded" ) ) );
|
||||
|
||||
// Treasure Disk
|
||||
ComputerCraft.Items.treasureDisk = new ItemTreasureDisk();
|
||||
GameRegistry.register( ComputerCraft.Items.treasureDisk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "treasure_disk" ) ) );
|
||||
registry.register( ComputerCraft.Items.treasureDisk.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "treasure_disk" ) ) );
|
||||
|
||||
// Printout
|
||||
ComputerCraft.Items.printout = new ItemPrintout();
|
||||
GameRegistry.register( ComputerCraft.Items.printout.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printout" ) ) );
|
||||
registry.register( ComputerCraft.Items.printout.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "printout" ) ) );
|
||||
|
||||
// Pocket computer
|
||||
ComputerCraft.Items.pocketComputer = new ItemPocketComputer();
|
||||
GameRegistry.register( ComputerCraft.Items.pocketComputer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer" ) ) );
|
||||
registry.register( ComputerCraft.Items.pocketComputer.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, "pocket_computer" ) ) );
|
||||
}
|
||||
|
||||
// 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" );
|
||||
|
||||
// Recipes
|
||||
// Computer
|
||||
ItemStack computer = ComputerItemFactory.create( -1, null, ComputerFamily.Normal );
|
||||
GameRegistry.addRecipe( computer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Advanced Computer
|
||||
ItemStack advancedComputer = ComputerItemFactory.create( -1, null, ComputerFamily.Advanced );
|
||||
GameRegistry.addRecipe( advancedComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.REDSTONE,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Disk Drive
|
||||
ItemStack diskDrive = PeripheralItemFactory.create( PeripheralType.DiskDrive, null, 1 );
|
||||
GameRegistry.addRecipe( diskDrive,
|
||||
"XXX", "XYX", "XYX",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE
|
||||
);
|
||||
|
||||
// Speaker
|
||||
ItemStack speaker = PeripheralItemFactory.create( PeripheralType.Speaker, null, 1);
|
||||
GameRegistry.addRecipe( speaker,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Blocks.NOTEBLOCK,
|
||||
'Z', Items.REDSTONE
|
||||
);
|
||||
|
||||
// Wireless Modem
|
||||
ItemStack wirelessModem = PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 );
|
||||
GameRegistry.addRecipe( wirelessModem,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.ENDER_PEARL
|
||||
);
|
||||
|
||||
// Monitor
|
||||
ItemStack monitor = PeripheralItemFactory.create( PeripheralType.Monitor, null, 1 );
|
||||
GameRegistry.addRecipe( monitor,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// PrinterEmpty
|
||||
ItemStack printer = PeripheralItemFactory.create( PeripheralType.Printer, null, 1 );
|
||||
GameRegistry.addRecipe( printer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE,
|
||||
'Z', new ItemStack( Items.DYE, 1, 0 ) // 0 = Black
|
||||
);
|
||||
|
||||
// Advanced Monitor
|
||||
ItemStack advancedMonitors = PeripheralItemFactory.create( PeripheralType.AdvancedMonitor, null, 4 );
|
||||
GameRegistry.addRecipe( advancedMonitors,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Networking Cable
|
||||
ItemStack cable = PeripheralItemFactory.create( PeripheralType.Cable, null, 6 );
|
||||
GameRegistry.addRecipe( cable,
|
||||
" X ", "XYX", " X ",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE
|
||||
);
|
||||
|
||||
// Wired Modem
|
||||
ItemStack wiredModem = PeripheralItemFactory.create( PeripheralType.WiredModem, null, 1 );
|
||||
GameRegistry.addRecipe( wiredModem,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.REDSTONE
|
||||
);
|
||||
|
||||
// Computer
|
||||
ItemStack commandComputer = ComputerItemFactory.create( -1, null, ComputerFamily.Command );
|
||||
GameRegistry.addRecipe( commandComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Blocks.COMMAND_BLOCK,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Advanced Modem
|
||||
ItemStack advancedModem = PeripheralItemFactory.create( PeripheralType.AdvancedModem, null, 1 );
|
||||
GameRegistry.addRecipe( advancedModem,
|
||||
"XXX", "XYX", "XXX",
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.ENDER_EYE
|
||||
);
|
||||
@SubscribeEvent
|
||||
public void registerRecipes( RegistryEvent.Register<IRecipe> event )
|
||||
{
|
||||
IForgeRegistry<IRecipe> registry = event.getRegistry();
|
||||
|
||||
// Disk
|
||||
GameRegistry.addRecipe( new DiskRecipe() );
|
||||
registry.register( new DiskRecipe().setRegistryName( new ResourceLocation( "computercraft:disk" ) ) );
|
||||
|
||||
// Colourable items (turtles, disks)
|
||||
GameRegistry.addRecipe( new ColourableRecipe() );
|
||||
registry.register( new ColourableRecipe().setRegistryName( new ResourceLocation( "computercraft:colour" ) ) );
|
||||
|
||||
// Impostor Disk recipes (to fool NEI)
|
||||
ItemStack paper = new ItemStack( Items.PAPER, 1 );
|
||||
ItemStack redstone = new ItemStack( Items.REDSTONE, 1 );
|
||||
ItemStack basicDisk = ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.Blue.getHex() );
|
||||
GameRegistry.addRecipe( new ImpostorShapelessRecipe( basicDisk, new ItemStack[]{redstone, paper} ) );
|
||||
|
||||
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 );
|
||||
for (int otherColour = 0; otherColour < 16; ++otherColour)
|
||||
|
||||
int diskIdx = 0;
|
||||
ItemStack[] disks = new ItemStack[ 15 ];
|
||||
for( int otherColour = 0; otherColour < 16; ++otherColour )
|
||||
{
|
||||
if (colour != otherColour)
|
||||
if( colour != otherColour )
|
||||
{
|
||||
ItemStack otherDisk = ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.values()[colour].getHex() );
|
||||
GameRegistry.addRecipe( new ImpostorShapelessRecipe( disk, new ItemStack[]{
|
||||
otherDisk, dye
|
||||
} ) );
|
||||
disks[ diskIdx++ ] = ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.values()[ otherColour ].getHex() );
|
||||
}
|
||||
}
|
||||
GameRegistry.addRecipe( new ImpostorShapelessRecipe( disk, new ItemStack[]{
|
||||
redstone, paper, dye
|
||||
} ) );
|
||||
|
||||
// Normal recipe
|
||||
registry.register(
|
||||
new ImpostorShapelessRecipe( "computercraft:disk", disk, new ItemStack[] { redstone, paper, dye } )
|
||||
.setRegistryName( new ResourceLocation( "computercraft:disk_imposter_" + colour ) )
|
||||
);
|
||||
|
||||
// Conversion recipe
|
||||
registry.register(
|
||||
new ImpostorShapelessRecipe( "computercraft:disk", disk, NonNullList.from( Ingredient.EMPTY, Ingredient.fromStacks( disks ), Ingredient.fromStacks( dye ) ) )
|
||||
.setRegistryName( new ResourceLocation( "computercraft:disk_imposter_convert_" + colour ) )
|
||||
);
|
||||
}
|
||||
|
||||
// Printout
|
||||
GameRegistry.addRecipe( new PrintoutRecipe() );
|
||||
|
||||
ItemStack singlePrintout = ItemPrintout.createSingleFromTitleAndText( null, null, null );
|
||||
ItemStack multiplePrintout = ItemPrintout.createMultipleFromTitleAndText( null, null, null );
|
||||
ItemStack bookPrintout = ItemPrintout.createBookFromTitleAndText( null, null, null );
|
||||
|
||||
// Impostor Printout recipes (to fool NEI)
|
||||
ItemStack string = new ItemStack( Items.STRING, 1, 0 );
|
||||
GameRegistry.addRecipe( new ImpostorShapelessRecipe( multiplePrintout, new ItemStack[]{singlePrintout, singlePrintout, string} ) );
|
||||
|
||||
ItemStack leather = new ItemStack( Items.LEATHER, 1, 0 );
|
||||
GameRegistry.addRecipe( new ImpostorShapelessRecipe( bookPrintout, new ItemStack[]{leather, singlePrintout, string} ) );
|
||||
|
||||
// Pocket Computer
|
||||
ItemStack pocketComputer = PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Normal, null );
|
||||
GameRegistry.addRecipe( pocketComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Blocks.STONE,
|
||||
'Y', Items.GOLDEN_APPLE,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
|
||||
// Advanced Pocket Computer
|
||||
ItemStack advancedPocketComputer = PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Advanced, null );
|
||||
GameRegistry.addRecipe( advancedPocketComputer,
|
||||
"XXX", "XYX", "XZX",
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.GOLDEN_APPLE,
|
||||
'Z', Blocks.GLASS_PANE
|
||||
);
|
||||
registry.register( new PrintoutRecipe().setRegistryName( new ResourceLocation( "computercraft:printout" ) ) );
|
||||
|
||||
// Register pocket upgrades
|
||||
ComputerCraft.PocketUpgrades.wirelessModem = new PocketModem( false );
|
||||
@ -457,61 +357,52 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
ComputerCraftAPI.registerPocketUpgrade( ComputerCraft.PocketUpgrades.pocketSpeaker );
|
||||
|
||||
// Wireless Pocket Computer
|
||||
GameRegistry.addRecipe( new PocketComputerUpgradeRecipe() );
|
||||
registry.register( new PocketComputerUpgradeRecipe().setRegistryName( new ResourceLocation( "computercraft:pocket_computer_upgrade" ) ) );
|
||||
|
||||
// Impostor Pocket Computer recipes (to fool NEI)
|
||||
for (IPocketUpgrade upgrade : ComputerCraft.getVanillaPocketUpgrades())
|
||||
ItemStack pocketComputer = PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Normal, null );
|
||||
ItemStack advancedPocketComputer = PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Advanced, null );
|
||||
for( IPocketUpgrade upgrade : ComputerCraft.getVanillaPocketUpgrades() )
|
||||
{
|
||||
GameRegistry.addRecipe( new ImpostorRecipe(
|
||||
1, 2,
|
||||
new ItemStack[]{ upgrade.getCraftingItem(), pocketComputer },
|
||||
PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Normal, upgrade )
|
||||
) );
|
||||
registry.register( new ImpostorRecipe(
|
||||
"computercraft:normal_pocket_upgrade",
|
||||
1, 2,
|
||||
new ItemStack[] { upgrade.getCraftingItem(), pocketComputer },
|
||||
PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Normal, upgrade )
|
||||
).setRegistryName( new ResourceLocation( "computercraft:normal_pocket_upgrade_" + upgrade.getUpgradeID().toString().replace( ':', '_' ) ) )
|
||||
);
|
||||
|
||||
GameRegistry.addRecipe( new ImpostorRecipe(
|
||||
1, 2,
|
||||
new ItemStack[]{ upgrade.getCraftingItem(), advancedPocketComputer },
|
||||
PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Advanced, upgrade )
|
||||
) );
|
||||
registry.register(
|
||||
new ImpostorRecipe( "computercraft:advanced_pocket_upgrade",
|
||||
1, 2,
|
||||
new ItemStack[] { upgrade.getCraftingItem(), advancedPocketComputer },
|
||||
PocketComputerItemFactory.create( -1, null, -1, ComputerFamily.Advanced, upgrade )
|
||||
).setRegistryName( new ResourceLocation( "computercraft:advanced_pocket_upgrade_" + upgrade.getUpgradeID().toString().replace( ':', '_' ) ) )
|
||||
);
|
||||
}
|
||||
|
||||
// Skulls (Easter Egg)
|
||||
// Dan
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString( "SkullOwner", "dan200" );
|
||||
ItemStack danHead = new ItemStack( Items.SKULL, 1, 3 );
|
||||
danHead.setTagCompound( tag );
|
||||
GameRegistry.addShapelessRecipe( danHead, computer, new ItemStack( Items.SKULL, 1, 1 ) );
|
||||
|
||||
// Cloudy
|
||||
tag = new NBTTagCompound();
|
||||
tag.setString( "SkullOwner", "Cloudhunter" );
|
||||
ItemStack cloudyHead = new ItemStack( Items.SKULL, 1, 3 );
|
||||
cloudyHead.setTagCompound( tag );
|
||||
GameRegistry.addShapelessRecipe( cloudyHead, monitor, new ItemStack( Items.SKULL, 1, 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remap( FMLMissingMappingsEvent mappings )
|
||||
@SubscribeEvent
|
||||
public void remapItems( RegistryEvent.MissingMappings<Item> mappings )
|
||||
{
|
||||
// We have to use mappings.getAll() as the mod ID is upper case but the domain lower.
|
||||
for( FMLMissingMappingsEvent.MissingMapping mapping : mappings.getAll() )
|
||||
// We have to use mappings.getAllMappings() as the mod ID is upper case but the domain lower.
|
||||
for( RegistryEvent.MissingMappings.Mapping<Item> mapping : mappings.getAllMappings() )
|
||||
{
|
||||
String domain = mapping.resourceLocation.getResourceDomain();
|
||||
String domain = mapping.key.getResourceDomain();
|
||||
if( !domain.equalsIgnoreCase( ComputerCraft.MOD_ID ) ) continue;
|
||||
|
||||
String key = mapping.resourceLocation.getResourcePath();
|
||||
String key = mapping.key.getResourcePath();
|
||||
if( key.equalsIgnoreCase( "CC-Computer" ) )
|
||||
{
|
||||
remap( mapping, ComputerCraft.Blocks.computer );
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.computer ) );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-Peripheral" ) )
|
||||
{
|
||||
remap( mapping, ComputerCraft.Blocks.peripheral );
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.peripheral ) );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-Cable" ) )
|
||||
{
|
||||
remap( mapping, ComputerCraft.Blocks.cable );
|
||||
mapping.remap( Item.getItemFromBlock( ComputerCraft.Blocks.cable ) );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "diskExpanded" ) )
|
||||
{
|
||||
@ -528,41 +419,43 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
}
|
||||
}
|
||||
|
||||
private static void remap( FMLMissingMappingsEvent.MissingMapping mapping, Block block )
|
||||
@SubscribeEvent
|
||||
public void remapBlocks( RegistryEvent.MissingMappings<Block> mappings )
|
||||
{
|
||||
if( mapping.type == GameRegistry.Type.BLOCK )
|
||||
// We have to use mappings.getAllMappings() as the mod ID is upper case but the domain lower.
|
||||
for( RegistryEvent.MissingMappings.Mapping<Block> mapping : mappings.getAllMappings() )
|
||||
{
|
||||
mapping.remap( block );
|
||||
}
|
||||
else
|
||||
{
|
||||
mapping.remap( Item.getItemFromBlock( block ) );
|
||||
}
|
||||
}
|
||||
String domain = mapping.key.getResourceDomain();
|
||||
if( !domain.equalsIgnoreCase( ComputerCraft.MOD_ID ) ) continue;
|
||||
|
||||
private void registerBlock( Block block, Item item, String name )
|
||||
{
|
||||
GameRegistry.register( block.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, name ) ) );
|
||||
GameRegistry.register( item.setRegistryName( new ResourceLocation( ComputerCraft.MOD_ID, name ) ) );
|
||||
}
|
||||
|
||||
private void registerTileEntity( Class<? extends TileEntity> klass, String name )
|
||||
{
|
||||
GameRegistry.registerTileEntityWithAlternatives( klass, ComputerCraft.LOWER_ID + " : " + name, name );
|
||||
String key = mapping.key.getResourcePath();
|
||||
if( key.equalsIgnoreCase( "CC-Computer" ) )
|
||||
{
|
||||
mapping.remap( ComputerCraft.Blocks.computer );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-Peripheral" ) )
|
||||
{
|
||||
mapping.remap( ComputerCraft.Blocks.peripheral );
|
||||
}
|
||||
else if( key.equalsIgnoreCase( "CC-Cable" ) )
|
||||
{
|
||||
mapping.remap( ComputerCraft.Blocks.cable );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerTileEntities()
|
||||
{
|
||||
// Tile Entities
|
||||
registerTileEntity( TileComputer.class, "computer" );
|
||||
registerTileEntity( TileDiskDrive.class, "diskdrive" );
|
||||
registerTileEntity( TileWirelessModem.class, "wirelessmodem" );
|
||||
registerTileEntity( TileMonitor.class, "monitor" );
|
||||
registerTileEntity( TilePrinter.class, "ccprinter" );
|
||||
registerTileEntity( TileCable.class, "wiredmodem" );
|
||||
registerTileEntity( TileCommandComputer.class, "command_computer" );
|
||||
registerTileEntity( TileAdvancedModem.class, "advanced_modem" );
|
||||
registerTileEntity( TileSpeaker.class, "speaker" );
|
||||
GameRegistry.registerTileEntity( TileComputer.class, ComputerCraft.LOWER_ID + " : " + "computer" );
|
||||
GameRegistry.registerTileEntity( TileDiskDrive.class, ComputerCraft.LOWER_ID + " : " + "diskdrive" );
|
||||
GameRegistry.registerTileEntity( TileWirelessModem.class, ComputerCraft.LOWER_ID + " : " + "wirelessmodem" );
|
||||
GameRegistry.registerTileEntity( TileMonitor.class, ComputerCraft.LOWER_ID + " : " + "monitor" );
|
||||
GameRegistry.registerTileEntity( TilePrinter.class, ComputerCraft.LOWER_ID + " : " + "ccprinter" );
|
||||
GameRegistry.registerTileEntity( TileCable.class, ComputerCraft.LOWER_ID + " : " + "wiredmodem" );
|
||||
GameRegistry.registerTileEntity( TileCommandComputer.class, ComputerCraft.LOWER_ID + " : " + "command_computer" );
|
||||
GameRegistry.registerTileEntity( TileAdvancedModem.class, ComputerCraft.LOWER_ID + " : " + "advanced_modem" );
|
||||
GameRegistry.registerTileEntity( TileSpeaker.class, ComputerCraft.LOWER_ID + " : " + "speaker" );
|
||||
|
||||
// Register peripheral providers
|
||||
ComputerCraftAPI.registerPeripheralProvider( new DefaultPeripheralProvider() );
|
||||
|
@ -10,7 +10,6 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.shared.util.IEntityDropConsumer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -19,7 +18,6 @@ public interface ICCTurtleProxy
|
||||
{
|
||||
void preInit();
|
||||
void init();
|
||||
void remap( FMLMissingMappingsEvent mappings);
|
||||
|
||||
void registerTurtleUpgrade( ITurtleUpgrade upgrade );
|
||||
ITurtleUpgrade getTurtleUpgrade( String id );
|
||||
|
@ -18,7 +18,6 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
@ -27,7 +26,6 @@ public interface IComputerCraftProxy
|
||||
{
|
||||
void preInit();
|
||||
void init();
|
||||
void remap( FMLMissingMappingsEvent mappings);
|
||||
boolean isClient();
|
||||
|
||||
boolean getGlobalCursorBlink();
|
||||
|
@ -156,7 +156,7 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
|
||||
public void getDroppedItems( @Nonnull NonNullList<ItemStack> drops, boolean creative )
|
||||
{
|
||||
IComputer computer = getComputer();
|
||||
if( !creative || (computer != null && computer.getLabel() != null) )
|
||||
@ -258,8 +258,8 @@ public class TileTurtle extends TileComputerBase
|
||||
{
|
||||
Vec3d offset = getRenderOffset( 1.0f );
|
||||
return new AxisAlignedBB(
|
||||
offset.xCoord + 0.125, offset.yCoord + 0.125, offset.zCoord + 0.125,
|
||||
offset.xCoord + 0.875, offset.yCoord + 0.875, offset.zCoord + 0.875
|
||||
offset.x + 0.125, offset.y + 0.125, offset.z + 0.125,
|
||||
offset.x + 0.875, offset.y + 0.875, offset.z + 0.875
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -553,9 +553,9 @@ public class TurtleBrain implements ITurtleAccess
|
||||
Vec3d offset = getRenderOffset( f );
|
||||
BlockPos pos = m_owner.getPos();
|
||||
return new Vec3d(
|
||||
pos.getX() + 0.5 + offset.xCoord,
|
||||
pos.getY() + 0.5 + offset.yCoord,
|
||||
pos.getZ() + 0.5 + offset.zCoord
|
||||
pos.getX() + 0.5 + offset.x,
|
||||
pos.getY() + 0.5 + offset.y,
|
||||
pos.getZ() + 0.5 + offset.z
|
||||
);
|
||||
}
|
||||
|
||||
@ -1177,9 +1177,9 @@ public class TurtleBrain implements ITurtleAccess
|
||||
Vec3d position = getVisualPosition( 1.0f );
|
||||
if( position != null )
|
||||
{
|
||||
double x = position.xCoord + world.rand.nextGaussian() * 0.1;
|
||||
double y = position.yCoord + 0.5 + world.rand.nextGaussian() * 0.1;
|
||||
double z = position.zCoord + world.rand.nextGaussian() * 0.1;
|
||||
double x = position.x + world.rand.nextGaussian() * 0.1;
|
||||
double y = position.y + 0.5 + world.rand.nextGaussian() * 0.1;
|
||||
double z = position.z + world.rand.nextGaussian() * 0.1;
|
||||
world.spawnParticle(
|
||||
EnumParticleTypes.HEART, x, y, z,
|
||||
world.rand.nextGaussian() * 0.02,
|
||||
|
@ -15,13 +15,13 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
public class TurtleCompareCommand implements ITurtleCommand
|
||||
{
|
||||
@ -77,8 +77,9 @@ public class TurtleCompareCommand implements ITurtleCommand
|
||||
// (try 5 times to try and beat random number generators)
|
||||
for( int i=0; (i<5) && lookAtStack.isEmpty(); ++i )
|
||||
{
|
||||
List<ItemStack> drops = lookAtBlock.getDrops( world, newPosition, lookAtState, 0 );
|
||||
if( drops != null && drops.size() > 0 )
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
lookAtBlock.getDrops( drops, world, newPosition, lookAtState, 0 );
|
||||
if( drops.size() > 0 )
|
||||
{
|
||||
for( ItemStack drop : drops )
|
||||
{
|
||||
|
@ -240,7 +240,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Place on the entity
|
||||
boolean placed = false;
|
||||
EnumActionResult cancelResult = ForgeHooks.onInteractEntityAtAction( turtlePlayer, hitEntity, hitPos, EnumHand.MAIN_HAND );
|
||||
EnumActionResult cancelResult = ForgeHooks.onInteractEntityAt( turtlePlayer, hitEntity, hitPos, EnumHand.MAIN_HAND );
|
||||
if( cancelResult == null )
|
||||
{
|
||||
cancelResult = hitEntity.applyPlayerInteraction( turtlePlayer, hitPos, EnumHand.MAIN_HAND );
|
||||
@ -253,7 +253,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
else
|
||||
{
|
||||
// See EntityPlayer.interactOn
|
||||
cancelResult = ForgeHooks.onInteractEntityAction( turtlePlayer, hitEntity, EnumHand.MAIN_HAND );
|
||||
cancelResult = ForgeHooks.onInteractEntity( turtlePlayer, hitEntity, EnumHand.MAIN_HAND );
|
||||
if( cancelResult == EnumActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
@ -391,7 +391,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
if( !placed && (item instanceof ItemBucket || item instanceof ItemBoat || item instanceof ItemLilyPad || item instanceof ItemGlassBottle) )
|
||||
{
|
||||
EnumActionResult actionResult = ForgeHooks.onItemRightClickAction( turtlePlayer, EnumHand.MAIN_HAND );
|
||||
EnumActionResult actionResult = ForgeHooks.onItemRightClick( turtlePlayer, EnumHand.MAIN_HAND );
|
||||
if( actionResult == EnumActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
|
@ -102,7 +102,7 @@ public class TurtleSuckCommand implements ITurtleCommand
|
||||
// Suck up the item
|
||||
foundItems = true;
|
||||
EntityItem entityItem = (EntityItem) entity;
|
||||
ItemStack stack = entityItem.getEntityItem().copy();
|
||||
ItemStack stack = entityItem.getItem().copy();
|
||||
ItemStack storeStack;
|
||||
ItemStack leaveStack;
|
||||
if( stack.getCount() > m_quantity )
|
||||
@ -125,16 +125,16 @@ public class TurtleSuckCommand implements ITurtleCommand
|
||||
}
|
||||
else if( remainder.isEmpty() )
|
||||
{
|
||||
entityItem.setEntityItemStack( leaveStack );
|
||||
entityItem.setItem( leaveStack );
|
||||
}
|
||||
else if( leaveStack.isEmpty() )
|
||||
{
|
||||
entityItem.setEntityItemStack( remainder );
|
||||
entityItem.setItem( remainder );
|
||||
}
|
||||
else
|
||||
{
|
||||
leaveStack.grow( remainder.getCount() );
|
||||
entityItem.setEntityItemStack( leaveStack );
|
||||
entityItem.setItem( leaveStack );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -60,17 +60,17 @@ public class TurtleVisionCamera extends EntityLivingBase
|
||||
private void applyPos()
|
||||
{
|
||||
Vec3d prevPos = m_turtle.getVisualPosition( 0.0f );
|
||||
this.lastTickPosX = this.prevPosX = prevPos.xCoord;
|
||||
this.lastTickPosY = this.prevPosY = prevPos.yCoord;
|
||||
this.lastTickPosZ = this.prevPosZ = prevPos.zCoord;
|
||||
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.xCoord;
|
||||
this.posY = pos.yCoord;
|
||||
this.posZ = pos.zCoord;
|
||||
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;
|
||||
|
@ -92,7 +92,7 @@ public class ContainerTurtle extends Container
|
||||
private void sendStateToPlayer( IContainerListener icrafting )
|
||||
{
|
||||
int selectedSlot = m_turtle.getSelectedSlot();
|
||||
icrafting.sendProgressBarUpdate( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot );
|
||||
icrafting.sendWindowProperty( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -112,7 +112,7 @@ public class ContainerTurtle extends Container
|
||||
{
|
||||
if( m_selectedSlot != selectedSlot )
|
||||
{
|
||||
listener.sendProgressBarUpdate( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot );
|
||||
listener.sendWindowProperty( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot );
|
||||
}
|
||||
}
|
||||
m_selectedSlot = selectedSlot;
|
||||
|
@ -42,8 +42,9 @@ public abstract class ItemTurtleBase extends ItemComputerBase implements ITurtle
|
||||
public abstract ItemStack create( int id, String label, int colour, ITurtleUpgrade leftUpgrade, ITurtleUpgrade rightUpgrade, int fuelLevel, ResourceLocation overlay );
|
||||
|
||||
@Override
|
||||
public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
public void getSubItems( @Nullable CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
|
||||
{
|
||||
if( !isInCreativeTab( tabs ) ) return;
|
||||
NonNullList<ItemStack> all = NonNullList.create();
|
||||
ComputerCraft.addAllUpgradedTurtles( all );
|
||||
for( ItemStack stack : all )
|
||||
|
@ -6,43 +6,38 @@
|
||||
|
||||
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.turtle.items.TurtleItemFactory;
|
||||
import dan200.computercraft.shared.util.RecipeUtil;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
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.ForgeHooks;
|
||||
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 implements IRecipe
|
||||
public class TurtleRecipe extends ShapedRecipes
|
||||
{
|
||||
private final Item[] m_recipe;
|
||||
private final NonNullList<Ingredient> m_recipe;
|
||||
private final ComputerFamily m_family;
|
||||
|
||||
public TurtleRecipe( Item[] recipe, ComputerFamily family )
|
||||
|
||||
public TurtleRecipe( String group, int width, int height, NonNullList<Ingredient> recipe, 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 int getRecipeSize()
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return TurtleItemFactory.create( -1, null, -1, m_family, null, null, 0, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( @Nonnull InventoryCrafting _inventory, @Nonnull World world )
|
||||
{
|
||||
@ -56,34 +51,28 @@ public class TurtleRecipe implements IRecipe
|
||||
// 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 y = 0; y < 3; ++y )
|
||||
{
|
||||
for( int x=0; x<3; ++x )
|
||||
for( int x = 0; x < 3; ++x )
|
||||
{
|
||||
ItemStack item = inventory.getStackInRowAndColumn(x, y);
|
||||
if( !item.isEmpty() && item.getItem() == m_recipe[ x + y*3 ] )
|
||||
ItemStack item = inventory.getStackInRowAndColumn( x, y );
|
||||
Ingredient target = m_recipe.get( x + y * 3 );
|
||||
|
||||
if( item.getItem() instanceof IComputerItem )
|
||||
{
|
||||
if( item.getItem() instanceof IComputerItem )
|
||||
{
|
||||
IComputerItem itemComputer = (IComputerItem)item.getItem();
|
||||
if( m_family == ComputerFamily.Beginners || itemComputer.getFamily( item ) == m_family )
|
||||
{
|
||||
computerID = itemComputer.getComputerID( item );
|
||||
label = itemComputer.getLabel( item );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
IComputerItem itemComputer = (IComputerItem) item.getItem();
|
||||
if( itemComputer.getFamily( item ) != m_family ) return ItemStack.EMPTY;
|
||||
|
||||
computerID = itemComputer.getComputerID( item );
|
||||
label = itemComputer.getLabel( item );
|
||||
}
|
||||
else
|
||||
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 )
|
||||
@ -96,16 +85,26 @@ public class TurtleRecipe implements IRecipe
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
|
||||
public static class Factory implements IRecipeFactory
|
||||
{
|
||||
NonNullList<ItemStack> results = NonNullList.withSize( inventoryCrafting.getSizeInventory(), ItemStack.EMPTY );
|
||||
for( int i = 0; i < results.size(); ++i )
|
||||
@Override
|
||||
public IRecipe parse( JsonContext context, JsonObject json )
|
||||
{
|
||||
ItemStack stack = inventoryCrafting.getStackInSlot( i );
|
||||
results.set( i, ForgeHooks.getContainerItem( stack ) );
|
||||
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 + "'" );
|
||||
}
|
||||
|
||||
CraftingHelper.ShapedPrimer primer = RecipeUtil.getPrimer( context, json );
|
||||
return new TurtleRecipe( group, primer.width, primer.height, primer.input, family );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.proxy.CCTurtleProxyCommon;
|
||||
import dan200.computercraft.shared.turtle.items.ITurtleItem;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
@ -21,19 +20,26 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleUpgradeRecipe implements IRecipe
|
||||
public class TurtleUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
{
|
||||
public TurtleUpgradeRecipe()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
public boolean canFit( int x, int y )
|
||||
{
|
||||
return 3;
|
||||
return x >= 3 && y >= 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -59,7 +59,7 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
}
|
||||
|
||||
// Check the actual crafting
|
||||
return CraftingManager.getInstance().findMatchingRecipe( this, m_turtle.getWorld() );
|
||||
return CraftingManager.findMatchingResult( this, m_turtle.getWorld() );
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> doCrafting( World world, int maxCount )
|
||||
@ -123,7 +123,7 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
results.add( result );
|
||||
|
||||
// Consume resources from the inventory
|
||||
NonNullList<ItemStack> remainingItems = CraftingManager.getInstance().getRemainingItems( this, world );
|
||||
NonNullList<ItemStack> remainingItems = CraftingManager.getRemainingItems( this, world );
|
||||
for( int n=0; n<size; ++n )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( n );
|
||||
|
@ -28,6 +28,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@ -315,7 +316,8 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
{
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
List<ItemStack> drops = block.getDrops( world, pos, world.getBlockState( pos ), 0 );
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
block.getDrops( drops, world, pos, world.getBlockState( pos ), 0 );
|
||||
double chance = ForgeEventFactory.fireBlockHarvesting( drops, world, pos, state, 0, 1, false, player );
|
||||
|
||||
for( int i = drops.size() - 1; i >= 0; i-- )
|
||||
|
@ -5,18 +5,39 @@
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
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 ImpostorRecipe extends ShapedRecipes
|
||||
{
|
||||
public ImpostorRecipe( int width, int height, ItemStack[] ingredients, @Nonnull ItemStack result )
|
||||
public ImpostorRecipe( @Nonnull String group, int width, int height, NonNullList<Ingredient> ingredients, @Nonnull ItemStack result )
|
||||
{
|
||||
super( width, height, ingredients, result );
|
||||
super( group, width, height, ingredients, result );
|
||||
}
|
||||
|
||||
public ImpostorRecipe( @Nonnull String group, int width, int height, ItemStack[] ingredients, @Nonnull ItemStack result )
|
||||
{
|
||||
super( group, width, height, convert( ingredients ), result );
|
||||
}
|
||||
|
||||
private static NonNullList<Ingredient> convert( ItemStack[] items )
|
||||
{
|
||||
NonNullList<Ingredient> ingredients = NonNullList.withSize( items.length, Ingredient.EMPTY );
|
||||
for( int i = 0; i < items.length; i++ ) ingredients.set( i, Ingredient.fromStacks( items[ i ] ) );
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -24,11 +45,23 @@ public class ImpostorRecipe extends ShapedRecipes
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult( @Nonnull InventoryCrafting _inventory )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static class Factory implements IRecipeFactory
|
||||
{
|
||||
@Override
|
||||
public IRecipe parse( JsonContext ctx, JsonObject json )
|
||||
{
|
||||
String group = JsonUtils.getString( json, "group", "" );
|
||||
CraftingHelper.ShapedPrimer primer = RecipeUtil.getPrimer( ctx, json );
|
||||
ItemStack result = CraftingHelper.getItemStack( JsonUtils.getJsonObject( json, "result" ), ctx );
|
||||
return new ImpostorRecipe( group, primer.width, primer.height, primer.input, result );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,20 +6,38 @@
|
||||
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
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.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.IRecipeFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ImpostorShapelessRecipe extends ShapelessRecipes
|
||||
{
|
||||
public ImpostorShapelessRecipe( @Nonnull ItemStack result, ItemStack[] ingredients )
|
||||
public ImpostorShapelessRecipe( @Nonnull String group, @Nonnull ItemStack result, NonNullList<Ingredient> ingredients )
|
||||
{
|
||||
super( result, new ArrayList<ItemStack>(Arrays.asList( ingredients )));
|
||||
super( group, result, ingredients );
|
||||
}
|
||||
|
||||
public ImpostorShapelessRecipe( @Nonnull String group, @Nonnull ItemStack result, ItemStack[] ingredients )
|
||||
{
|
||||
super( group, result, convert( ingredients ) );
|
||||
}
|
||||
|
||||
private static NonNullList<Ingredient> convert( ItemStack[] items )
|
||||
{
|
||||
NonNullList<Ingredient> ingredients = NonNullList.withSize( items.length, Ingredient.EMPTY );
|
||||
for( int i = 0; i < items.length; i++ ) ingredients.set( i, Ingredient.fromStacks( items[ i ] ) );
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,8 +48,20 @@ public class ImpostorShapelessRecipe extends ShapelessRecipes
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult( InventoryCrafting _inventory )
|
||||
public ItemStack getCraftingResult( InventoryCrafting inventory )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static class Factory implements IRecipeFactory
|
||||
{
|
||||
@Override
|
||||
public IRecipe parse( JsonContext context, JsonObject json )
|
||||
{
|
||||
String group = JsonUtils.getString( json, "group", "" );
|
||||
NonNullList<Ingredient> ings = RecipeUtil.getIngredients( context, json );
|
||||
ItemStack itemstack = ShapedRecipes.deserializeItem( JsonUtils.getJsonObject( json, "result" ), true );
|
||||
return new ImpostorShapelessRecipe( group, itemstack, ings );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
105
src/main/java/dan200/computercraft/shared/util/RecipeUtil.java
Normal file
105
src/main/java/dan200/computercraft/shared/util/RecipeUtil.java
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.*;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class RecipeUtil
|
||||
{
|
||||
public static CraftingHelper.ShapedPrimer getPrimer( JsonContext context, JsonObject json )
|
||||
{
|
||||
Map<Character, Ingredient> ingMap = Maps.newHashMap();
|
||||
for( Map.Entry<String, JsonElement> entry : JsonUtils.getJsonObject( json, "key" ).entrySet() )
|
||||
{
|
||||
if( entry.getKey().length() != 1 )
|
||||
{
|
||||
throw new JsonSyntaxException( "Invalid key entry: '" + entry.getKey() + "' is an invalid symbol (must be 1 character only)." );
|
||||
}
|
||||
if( " ".equals( entry.getKey() ) )
|
||||
{
|
||||
throw new JsonSyntaxException( "Invalid key entry: ' ' is a reserved symbol." );
|
||||
}
|
||||
|
||||
ingMap.put( entry.getKey().charAt( 0 ), CraftingHelper.getIngredient( entry.getValue(), context ) );
|
||||
}
|
||||
|
||||
ingMap.put( ' ', Ingredient.EMPTY );
|
||||
|
||||
JsonArray patternJ = JsonUtils.getJsonArray( json, "pattern" );
|
||||
|
||||
if( patternJ.size() == 0 )
|
||||
throw new JsonSyntaxException( "Invalid pattern: empty pattern not allowed" );
|
||||
|
||||
String[] pattern = new String[ patternJ.size() ];
|
||||
for( int x = 0; x < pattern.length; ++x )
|
||||
{
|
||||
String line = JsonUtils.getString( patternJ.get( x ), "pattern[" + x + "]" );
|
||||
if( x > 0 && pattern[ 0 ].length() != line.length() )
|
||||
{
|
||||
throw new JsonSyntaxException( "Invalid pattern: each row must be the same width" );
|
||||
}
|
||||
pattern[ x ] = line;
|
||||
}
|
||||
|
||||
CraftingHelper.ShapedPrimer primer = new CraftingHelper.ShapedPrimer();
|
||||
primer.width = pattern[ 0 ].length();
|
||||
primer.height = pattern.length;
|
||||
primer.mirrored = false;
|
||||
primer.input = NonNullList.withSize( primer.width * primer.height, Ingredient.EMPTY );
|
||||
|
||||
Set<Character> keys = Sets.newHashSet( ingMap.keySet() );
|
||||
keys.remove( ' ' );
|
||||
|
||||
int x = 0;
|
||||
for( String line : pattern )
|
||||
{
|
||||
for( char chr : line.toCharArray() )
|
||||
{
|
||||
Ingredient ing = ingMap.get( chr );
|
||||
if( ing == null )
|
||||
{
|
||||
throw new JsonSyntaxException( "Pattern references symbol '" + chr + "' but it's not defined in the key" );
|
||||
}
|
||||
primer.input.set( x++, ing );
|
||||
keys.remove( chr );
|
||||
}
|
||||
}
|
||||
|
||||
if( !keys.isEmpty() )
|
||||
{
|
||||
throw new JsonSyntaxException( "Key defines symbols that aren't used in pattern: " + keys );
|
||||
}
|
||||
|
||||
return primer;
|
||||
}
|
||||
|
||||
public static NonNullList<Ingredient> getIngredients( JsonContext context, JsonObject json )
|
||||
{
|
||||
NonNullList<Ingredient> ings = NonNullList.create();
|
||||
for( JsonElement ele : JsonUtils.getJsonArray( json, "ingredients" ) )
|
||||
{
|
||||
ings.add( CraftingHelper.getIngredient( ele, context ) );
|
||||
}
|
||||
|
||||
if( ings.isEmpty() )
|
||||
{
|
||||
throw new JsonParseException( "No ingredients for recipe" );
|
||||
}
|
||||
|
||||
return ings;
|
||||
}
|
||||
}
|
@ -36,27 +36,27 @@ public class WorldUtil
|
||||
|
||||
public static Pair<Entity, Vec3d> rayTraceEntities( World world, Vec3d vecStart, Vec3d vecDir, double distance )
|
||||
{
|
||||
Vec3d vecEnd = vecStart.addVector( vecDir.xCoord * distance, vecDir.yCoord * distance, vecDir.zCoord * distance );
|
||||
Vec3d vecEnd = vecStart.addVector( vecDir.x * distance, vecDir.y * distance, vecDir.z * distance );
|
||||
|
||||
// Raycast for blocks
|
||||
RayTraceResult result = world.rayTraceBlocks( vecStart.addVector(0.0,0.0,0.0), vecEnd.addVector(0.0,0.0,0.0) );
|
||||
if( result != null && result.typeOfHit == RayTraceResult.Type.BLOCK )
|
||||
{
|
||||
distance = vecStart.distanceTo( result.hitVec );
|
||||
vecEnd = vecStart.addVector( vecDir.xCoord * distance, vecDir.yCoord * distance, vecDir.zCoord * distance );
|
||||
vecEnd = vecStart.addVector( vecDir.x * distance, vecDir.y * distance, vecDir.z * distance );
|
||||
}
|
||||
|
||||
// Check for entities
|
||||
float xStretch = (Math.abs(vecDir.xCoord) > 0.25f) ? 0.0f : 1.0f;
|
||||
float yStretch = (Math.abs(vecDir.yCoord) > 0.25f) ? 0.0f : 1.0f;
|
||||
float zStretch = (Math.abs(vecDir.zCoord) > 0.25f) ? 0.0f : 1.0f;
|
||||
float xStretch = (Math.abs(vecDir.x) > 0.25f) ? 0.0f : 1.0f;
|
||||
float yStretch = (Math.abs(vecDir.y) > 0.25f) ? 0.0f : 1.0f;
|
||||
float zStretch = (Math.abs(vecDir.z) > 0.25f) ? 0.0f : 1.0f;
|
||||
AxisAlignedBB bigBox = new AxisAlignedBB(
|
||||
Math.min(vecStart.xCoord, vecEnd.xCoord) - 0.375f * xStretch,
|
||||
Math.min(vecStart.yCoord, vecEnd.yCoord) - 0.375f * yStretch,
|
||||
Math.min(vecStart.zCoord, vecEnd.zCoord) - 0.375f * zStretch,
|
||||
Math.max(vecStart.xCoord, vecEnd.xCoord) + 0.375f * xStretch,
|
||||
Math.max(vecStart.yCoord, vecEnd.yCoord) + 0.375f * yStretch,
|
||||
Math.max(vecStart.zCoord, vecEnd.zCoord) + 0.375f * zStretch
|
||||
Math.min(vecStart.x, vecEnd.x) - 0.375f * xStretch,
|
||||
Math.min(vecStart.y, vecEnd.y) - 0.375f * yStretch,
|
||||
Math.min(vecStart.z, vecEnd.z) - 0.375f * zStretch,
|
||||
Math.max(vecStart.x, vecEnd.x) + 0.375f * xStretch,
|
||||
Math.max(vecStart.y, vecEnd.y) + 0.375f * yStretch,
|
||||
Math.max(vecStart.z, vecEnd.z) + 0.375f * zStretch
|
||||
);
|
||||
|
||||
Entity closest = null;
|
||||
@ -79,7 +79,7 @@ public class WorldUtil
|
||||
}
|
||||
}
|
||||
|
||||
if( littleBox.isVecInside( vecStart ) )
|
||||
if( littleBox.contains( vecStart ) )
|
||||
{
|
||||
closest = entity;
|
||||
closestDist = 0.0f;
|
||||
@ -96,7 +96,7 @@ public class WorldUtil
|
||||
closestDist = dist;
|
||||
}
|
||||
}
|
||||
else if( littleBox.intersectsWith( bigBox ) )
|
||||
else if( littleBox.intersects( bigBox ) )
|
||||
{
|
||||
if( closest == null )
|
||||
{
|
||||
@ -107,7 +107,7 @@ public class WorldUtil
|
||||
}
|
||||
if( closest != null && closestDist <= distance )
|
||||
{
|
||||
Vec3d closestPos = vecStart.addVector( vecDir.xCoord * closestDist, vecDir.yCoord * closestDist, vecDir.zCoord * closestDist );
|
||||
Vec3d closestPos = vecStart.addVector( vecDir.x * closestDist, vecDir.y * closestDist, vecDir.z * closestDist );
|
||||
return Pair.of( closest, closestPos );
|
||||
}
|
||||
return null;
|
||||
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#R#",
|
||||
"#G#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:gold_ingot" },
|
||||
"R": { "item": "minecraft:redstone" },
|
||||
"G": { "item": "minecraft:glass_pane" }
|
||||
},
|
||||
"result": { "item": "computercraft:computer", "data": 16384 }
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#G#",
|
||||
"###"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:gold_ingot" },
|
||||
"G": { "item": "minecraft:glass_pane" }
|
||||
},
|
||||
"result": { "item": "computercraft:peripheral", "data": 4 }
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#A#",
|
||||
"#G#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:gold_ingot" },
|
||||
"G": { "item": "minecraft:glass_pane" },
|
||||
"A": { "item": "minecraft:golden_apple", "data": 0 }
|
||||
},
|
||||
"result": { "item": "computercraft:pocket_computer", "data": 1 }
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "computercraft:turtle",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#C#",
|
||||
"#I#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:gold_ingot" },
|
||||
"C": { "item": "computercraft:computer", "data": 16384 },
|
||||
"I": { "item": "minecraft:chest" }
|
||||
},
|
||||
"family": "Advanced"
|
||||
}
|
13
src/main/resources/assets/computercraft/recipes/cable.json
Normal file
13
src/main/resources/assets/computercraft/recipes/cable.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
" # ",
|
||||
"#R#",
|
||||
" # "
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"R": { "item": "minecraft:redstone" }
|
||||
},
|
||||
"result": { "item": "computercraft:cable", "data": 0, "count": 6 }
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#C#",
|
||||
"#G#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"C": { "item": "minecraft:command_block" },
|
||||
"G": { "item": "minecraft:glass_pane" }
|
||||
},
|
||||
"result": { "item": "computercraft:command_computer", "data": 0 }
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#R#",
|
||||
"#R#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"R": { "item": "minecraft:redstone" }
|
||||
},
|
||||
"result": { "item": "computercraft:peripheral", "data": 0 }
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"type": "computercraft:impostor_shapeless",
|
||||
"ingredients": [
|
||||
{ "item": "minecraft:redstone" },
|
||||
{ "item": "minecraft:paper" }
|
||||
],
|
||||
"result": { "item": "computercraft:disk", "data": 0 }
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#E#",
|
||||
"###"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:gold_ingot" },
|
||||
"E": { "item": "minecraft:ender_eye" }
|
||||
},
|
||||
"result": { "item": "computercraft:advanced_modem", "data": 0 }
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#R#",
|
||||
"#G#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"R": { "item": "minecraft:redstone" },
|
||||
"G": { "item": "minecraft:glass_pane" }
|
||||
},
|
||||
"result": { "item": "computercraft:computer", "data": 0 }
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#G#",
|
||||
"###"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"G": { "item": "minecraft:glass_pane" }
|
||||
},
|
||||
"result": { "item": "computercraft:peripheral", "data": 2 }
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#A#",
|
||||
"#G#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"G": { "item": "minecraft:glass_pane" },
|
||||
"A": { "item": "minecraft:golden_apple", "data": 0 }
|
||||
},
|
||||
"result": { "item": "computercraft:pocket_computer", "data": 0 }
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "computercraft:turtle",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#C#",
|
||||
"#I#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:iron_ingot" },
|
||||
"C": { "item": "computercraft:computer", "data": 0 },
|
||||
"I": { "item": "minecraft:chest" }
|
||||
},
|
||||
"family": "Normal"
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"type": "computercraft:impostor_shapeless",
|
||||
"ingredients": [
|
||||
{ "item": "minecraft:leather" },
|
||||
{ "item": "computercraft:printout", "data": 0 },
|
||||
{ "item": "minecraft:string" }
|
||||
],
|
||||
"result": { "item": "computercraft:printout", "data": 2 }
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"type": "computercraft:impostor_shapeless",
|
||||
"ingredients": [
|
||||
{ "item": "computercraft:printout", "data": 0 },
|
||||
{ "item": "computercraft:printout", "data": 0 },
|
||||
{ "item": "minecraft:string" }
|
||||
],
|
||||
"result": { "item": "computercraft:printout", "data": 1 }
|
||||
}
|
14
src/main/resources/assets/computercraft/recipes/printer.json
Normal file
14
src/main/resources/assets/computercraft/recipes/printer.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#R#",
|
||||
"#D#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"R": { "item": "minecraft:redstone" },
|
||||
"D": { "item": "minecraft:dye", "data": 0 }
|
||||
},
|
||||
"result": { "item": "computercraft:peripheral", "data": 3 }
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{ "item": "minecraft:skull", "data": 1 },
|
||||
{ "item": "computercraft:peripheral", "data": 2 }
|
||||
],
|
||||
"result": {
|
||||
"item": "minecraft:skull",
|
||||
"data": 3,
|
||||
"nbt": { "SkullOwner": "Cloudhunter" }
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{ "item": "minecraft:skull", "data": 1 },
|
||||
{ "item": "computercraft:computer", "data": 0 }
|
||||
],
|
||||
"result": {
|
||||
"item": "minecraft:skull",
|
||||
"data": 3,
|
||||
"nbt": { "SkullOwner": "dan200" }
|
||||
}
|
||||
}
|
14
src/main/resources/assets/computercraft/recipes/speaker.json
Normal file
14
src/main/resources/assets/computercraft/recipes/speaker.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#N#",
|
||||
"#R#"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"R": { "item": "minecraft:redstone" },
|
||||
"N": { "item": "minecraft:noteblock" }
|
||||
},
|
||||
"result": { "item": "computercraft:peripheral", "data": 5 }
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#R#",
|
||||
"###"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"R": { "item": "minecraft:redstone" }
|
||||
},
|
||||
"result": { "item": "computercraft:cable", "data": 1 }
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"###",
|
||||
"#E#",
|
||||
"###"
|
||||
],
|
||||
"key": {
|
||||
"#": { "item": "minecraft:stone", "data": 0 },
|
||||
"E": { "item": "minecraft:ender_pearl" }
|
||||
},
|
||||
"result": { "item": "computercraft:peripheral", "data": 1 }
|
||||
}
|
Loading…
Reference in New Issue
Block a user