AS 0.1.9 Release

This commit is contained in:
Henry Mao 2012-12-28 14:30:11 +08:00
parent c4105e06bf
commit 790fbb3e9c
31 changed files with 398 additions and 538 deletions

View file

@ -1 +1 @@
32 35

View file

@ -28,3 +28,6 @@ Minecraft 1.4.5
* AssemblyLine_v0.1.8.30.jar AssemblyLine_v0.1.8.30_api.zip * AssemblyLine_v0.1.8.30.jar AssemblyLine_v0.1.8.30_api.zip
@ AssemblyLine_v0.1.8.31.jar AssemblyLine_v0.1.8.31_api.zip @ AssemblyLine_v0.1.8.31.jar AssemblyLine_v0.1.8.31_api.zip
@ AssemblyLine_v0.1.9.32.jar AssemblyLine_v0.1.9.32_api.zip @ AssemblyLine_v0.1.9.32.jar AssemblyLine_v0.1.9.32_api.zip
@ AssemblyLine_v0.1.9.33.jar AssemblyLine_v0.1.9.33_api.zip
@ AssemblyLine_v0.1.9.34.jar AssemblyLine_v0.1.9.34_api.zip
* AssemblyLine_v0.1.9.35.jar AssemblyLine_v0.1.9.35_api.zip

View file

@ -1 +1 @@
0.1.8 0.1.9

View file

@ -4,7 +4,6 @@
# Gui # Gui
assemblyline.gui.crafting=Crafting assemblyline.gui.crafting=Crafting
# Blocks # Blocks
tile.crate.name=Crate tile.crate.name=Crate
tile.conveyorBelt.name=Conveyor Belt tile.conveyorBelt.name=Conveyor Belt
@ -12,6 +11,8 @@ tile.stamper.name=Stamper
tile.engineerTable.name=Engineer's Table tile.engineerTable.name=Engineer's Table
tile.detector.name=Detector tile.detector.name=Detector
tile.armbot.name=Armbot tile.armbot.name=Armbot
tile.manipulator.name=Manipulator
tile.rejector.name=Rejector
# Items # Items
item.filter.name=Filter item.filter.name=Filter

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

View file

@ -0,0 +1,16 @@
package assemblyline.api;
import net.minecraft.item.ItemStack;
/**
* Applied to TileEntities that can accept a filter.
*
* @author Calclavia
*
*/
public interface IFilterable
{
public void setFilter(ItemStack filter);
public ItemStack getFilter();
}

View file

@ -1,6 +1,5 @@
package assemblyline.api; package assemblyline.api;
/** /**
* Interface applied to the manipulator. * Interface applied to the manipulator.
* *

View file

@ -6,7 +6,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import assemblyline.client.gui.GuiRejector;
import assemblyline.client.gui.GuiStamper; import assemblyline.client.gui.GuiStamper;
import assemblyline.client.render.BlockRenderingHandler; import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.client.render.RenderConveyorBelt; import assemblyline.client.render.RenderConveyorBelt;
@ -49,8 +48,6 @@ public class ClientProxy extends CommonProxy
switch (ID) switch (ID)
{ {
case GUI_REJECTOR:
return new GuiRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_STAMPER: case GUI_STAMPER:
return new GuiStamper(player.inventory, world, new Vector3(x, y, z)); return new GuiStamper(player.inventory, world, new Vector3(x, y, z));
} }

View file

@ -28,7 +28,7 @@ public class GuiStamper extends GuiContainer
protected void drawGuiContainerForegroundLayer(int par1, int par2) protected void drawGuiContainerForegroundLayer(int par1, int par2)
{ {
this.fontRenderer.drawString(TranslationHelper.getLocal("tile.stamper.name"), 68, 6, 4210752); this.fontRenderer.drawString(TranslationHelper.getLocal("tile.stamper.name"), 68, 6, 4210752);
this.fontRenderer.drawString(TranslationHelper.getLocal("assemblyline.gui.crafting")+":", 25, 55, 4210752); this.fontRenderer.drawString(TranslationHelper.getLocal("assemblyline.gui.crafting") + ":", 25, 55, 4210752);
} }
/** /**

View file

@ -11,7 +11,6 @@ import assemblyline.client.model.ModelConveyorBelt;
import assemblyline.client.model.ModelManipulator; import assemblyline.client.model.ModelManipulator;
import assemblyline.client.model.ModelSorter; import assemblyline.client.model.ModelSorter;
import assemblyline.common.AssemblyLine; import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.BlockMulti.MachineType;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
@ -39,33 +38,30 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
modelConveyorBelt.render(0.0625F, 0, false, false, false); modelConveyorBelt.render(0.0625F, 0, false, false, false);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
if (block.blockID == AssemblyLine.blockDetector.blockID) else if (block.blockID == AssemblyLine.blockDetector.blockID)
{ {
RenderDetector.render(false, new Vector3()); RenderDetector.render(false, new Vector3());
} }
else if (block.blockID == AssemblyLine.blockMulti.blockID) else if (block.blockID == AssemblyLine.blockRejector.blockID)
{ {
if (metadata == MachineType.REJECTOR.metadata) GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "sorter.png"));
{ GL11.glPushMatrix();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "sorter.png")); GL11.glTranslatef((float) 0.6F, (float) 1.5F, (float) 0.6F);
GL11.glPushMatrix(); GL11.glRotatef(180f, 0f, 0f, 1f);
GL11.glTranslatef((float) 0.6F, (float) 1.5F, (float) 0.6F); GL11.glRotatef(-90f, 0f, 1f, 0f);
GL11.glRotatef(180f, 0f, 0f, 1f); modelEjector.renderMain(0.0625F);
GL11.glRotatef(-90f, 0f, 1f, 0f); modelEjector.renderPiston(0.0625F, 1);
modelEjector.renderMain(0.0625F); GL11.glPopMatrix();
modelEjector.renderPiston(0.0625F, 1); }
GL11.glPopMatrix(); else if (block.blockID == AssemblyLine.blockManipulator.blockID)
} {
else if (metadata == MachineType.MANIPULATOR.metadata) GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "manipulator1.png"));
{ GL11.glPushMatrix();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "manipulator1.png")); GL11.glTranslatef((float) 0.6F, (float) 1.5F, (float) 0.6F);
GL11.glPushMatrix(); GL11.glRotatef(180f, 0f, 0f, 1f);
GL11.glTranslatef((float) 0.6F, (float) 1.5F, (float) 0.6F); GL11.glRotatef(-90f, 0f, 1f, 0f);
GL11.glRotatef(180f, 0f, 0f, 1f); modelInjector.render(0.0625F, true, 0);
GL11.glRotatef(-90f, 0f, 1f, 0f); GL11.glPopMatrix();
modelInjector.render(0.0625F, true, 0);
GL11.glPopMatrix();
}
} }
} }

View file

@ -151,7 +151,6 @@ public class RenderCrate extends TileEntitySpecialRenderer
// Find Center // Find Center
GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2);
GL11.glRotatef(-90, 1, 0, 0); GL11.glRotatef(-90, 1, 0, 0);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
FontRenderer fontRenderer = this.getFontRenderer(); FontRenderer fontRenderer = this.getFontRenderer();
int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1); int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1);
@ -166,7 +165,7 @@ public class RenderCrate extends TileEntitySpecialRenderer
{ {
scale = Math.min(scale, maxScale); scale = Math.min(scale, maxScale);
} }
GL11.glScalef(scale, -scale, scale); GL11.glScalef(scale, -scale, scale);
GL11.glDepthMask(false); GL11.glDepthMask(false);
@ -179,11 +178,9 @@ public class RenderCrate extends TileEntitySpecialRenderer
offsetY = (realHeight - requiredHeight) / 2; offsetY = (realHeight - requiredHeight) / 2;
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);
fontRenderer.drawString(text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1); fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1);
GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDepthMask(true); GL11.glDepthMask(true);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPopMatrix(); GL11.glPopMatrix();

View file

@ -16,8 +16,9 @@ public class RenderSorter extends TileEntitySpecialRenderer
private void renderAModelAt(TileEntityRejector tileEntity, double x, double y, double z, float f) private void renderAModelAt(TileEntityRejector tileEntity, double x, double y, double z, float f)
{ {
boolean fire = tileEntity.firePiston; boolean fire = tileEntity.firePiston;
int face = tileEntity.getDirection(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord)); int face = tileEntity.getDirection().ordinal();
int pos = 0; int pos = 0;
if (fire) if (fire)
{ {
pos = 8; pos = 8;

View file

@ -3,8 +3,6 @@ package assemblyline.common;
import java.io.File; import java.io.File;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
@ -18,14 +16,12 @@ import universalelectricity.prefab.network.PacketManager;
import assemblyline.common.block.BlockCrate; import assemblyline.common.block.BlockCrate;
import assemblyline.common.block.BlockEngineerTable; import assemblyline.common.block.BlockEngineerTable;
import assemblyline.common.block.ItemBlockCrate; import assemblyline.common.block.ItemBlockCrate;
import assemblyline.common.machine.BlockMulti; import assemblyline.common.machine.BlockManipulator;
import assemblyline.common.machine.BlockMulti.MachineType;
import assemblyline.common.machine.ItemBlockMulti;
import assemblyline.common.machine.belt.BlockConveyorBelt; import assemblyline.common.machine.belt.BlockConveyorBelt;
import assemblyline.common.machine.detector.BlockDetector; import assemblyline.common.machine.detector.BlockDetector;
import assemblyline.common.machine.filter.BlockStamper; import assemblyline.common.machine.filter.BlockStamper;
import assemblyline.common.machine.filter.ItemFilter; import assemblyline.common.machine.filter.ItemFilter;
import cpw.mods.fml.common.ICraftingHandler; import assemblyline.common.machine.machine.BlockRejector;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Init;
@ -37,7 +33,6 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = AssemblyLine.CHANNEL, name = AssemblyLine.NAME, version = AssemblyLine.VERSION, dependencies = "required-after:BasicComponents") @Mod(modid = AssemblyLine.CHANNEL, name = AssemblyLine.NAME, version = AssemblyLine.VERSION, dependencies = "required-after:BasicComponents")
@NetworkMod(channels = { AssemblyLine.CHANNEL }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class) @NetworkMod(channels = { AssemblyLine.CHANNEL }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class)
@ -67,11 +62,12 @@ public class AssemblyLine
public static final int BLOCK_ID_PREFIX = 3030; public static final int BLOCK_ID_PREFIX = 3030;
public static Block blockConveyorBelt; public static Block blockConveyorBelt;
public static Block blockMulti; public static Block blockManipulator;
public static Block blockEngineerTable; public static Block blockEngineerTable;
public static Block blockCrate; public static Block blockCrate;
public static Block blockStamper; public static Block blockStamper;
public static Block blockDetector; public static Block blockDetector;
public static Block blockRejector;
public static final int ITEM_ID_PREFIX = 3030; public static final int ITEM_ID_PREFIX = 3030;
public static Item itemFilter; public static Item itemFilter;
@ -84,11 +80,12 @@ public class AssemblyLine
CONFIGURATION.load(); CONFIGURATION.load();
blockConveyorBelt = new BlockConveyorBelt(CONFIGURATION.getBlock("Conveyor Belt", BLOCK_ID_PREFIX).getInt()); blockConveyorBelt = new BlockConveyorBelt(CONFIGURATION.getBlock("Conveyor Belt", BLOCK_ID_PREFIX).getInt());
blockMulti = new BlockMulti(CONFIGURATION.getBlock("Machine", BLOCK_ID_PREFIX + 1).getInt()); blockManipulator = new BlockManipulator(CONFIGURATION.getBlock("Manipulator", BLOCK_ID_PREFIX + 1).getInt());
blockEngineerTable = new BlockEngineerTable(CONFIGURATION.getBlock("Architect's Table", BLOCK_ID_PREFIX + 2).getInt()); blockEngineerTable = new BlockEngineerTable(CONFIGURATION.getBlock("Architect's Table", BLOCK_ID_PREFIX + 2).getInt());
blockCrate = new BlockCrate(CONFIGURATION.getBlock("Crate", BLOCK_ID_PREFIX + 3).getInt(), 0); blockCrate = new BlockCrate(CONFIGURATION.getBlock("Crate", BLOCK_ID_PREFIX + 3).getInt(), 0);
blockStamper = new BlockStamper(CONFIGURATION.getBlock("Stamper", BLOCK_ID_PREFIX + 4).getInt(), 0); blockStamper = new BlockStamper(CONFIGURATION.getBlock("Stamper", BLOCK_ID_PREFIX + 4).getInt(), 0);
blockDetector = new BlockDetector(CONFIGURATION.getBlock("Detector", BLOCK_ID_PREFIX + 5).getInt(), 1); blockDetector = new BlockDetector(CONFIGURATION.getBlock("Detector", BLOCK_ID_PREFIX + 5).getInt(), 1);
blockRejector = new BlockRejector(CONFIGURATION.getBlock("Rejector", BLOCK_ID_PREFIX + 6).getInt());
itemFilter = new ItemFilter(CONFIGURATION.getBlock("Filter", ITEM_ID_PREFIX).getInt()); itemFilter = new ItemFilter(CONFIGURATION.getBlock("Filter", ITEM_ID_PREFIX).getInt());
CONFIGURATION.save(); CONFIGURATION.save();
@ -96,29 +93,14 @@ public class AssemblyLine
NetworkRegistry.instance().registerGuiHandler(this, this.proxy); NetworkRegistry.instance().registerGuiHandler(this, this.proxy);
GameRegistry.registerBlock(blockConveyorBelt, "Conveyor Belt"); GameRegistry.registerBlock(blockConveyorBelt, "Conveyor Belt");
GameRegistry.registerBlock(blockCrate, ItemBlockCrate.class, "Crate"); GameRegistry.registerBlock(blockCrate, ItemBlockCrate.class, "Crate");
GameRegistry.registerBlock(blockMulti, ItemBlockMulti.class, "Machine"); GameRegistry.registerBlock(blockManipulator, "Manipulator");
GameRegistry.registerBlock(blockEngineerTable, "Engineer's Table"); // GameRegistry.registerBlock(blockEngineerTable, "Engineer's Table");
GameRegistry.registerBlock(blockStamper, "Stamper"); GameRegistry.registerBlock(blockStamper, "Stamper");
GameRegistry.registerBlock(blockDetector, "Detector"); GameRegistry.registerBlock(blockDetector, "Detector");
GameRegistry.registerBlock(blockRejector, "Rejector");
UpdateNotifier.INSTANCE.checkUpdate(NAME, VERSION, "http://calclavia.com/downloads/al/recommendedversion.txt"); UpdateNotifier.INSTANCE.checkUpdate(NAME, VERSION, "http://calclavia.com/downloads/al/recommendedversion.txt");
GameRegistry.registerCraftingHandler(new ICraftingHandler()
{
@Override
public void onCrafting(EntityPlayer player, ItemStack itemStack, IInventory craftMatrix)
{
// TODO Make this work for the filter
System.out.println("TEST: " + craftMatrix.getSizeInventory());
}
@Override
public void onSmelting(EntityPlayer player, ItemStack item)
{
}
});
proxy.preInit(); proxy.preInit();
} }
@ -129,12 +111,6 @@ public class AssemblyLine
System.out.println(NAME + " Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " languages."); System.out.println(NAME + " Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " languages.");
// Add Names
for (MachineType type : MachineType.values())
{
LanguageRegistry.addName(new ItemStack(blockMulti, 1, type.metadata), type.name);
}
// Filter // Filter
GameRegistry.addRecipe(new ShapedOreRecipe(itemFilter, new Object[] { "R", "P", "I", 'P', Item.paper, 'R', Item.redstone, 'I', new ItemStack(Item.dyePowder, 1, 0) })); GameRegistry.addRecipe(new ShapedOreRecipe(itemFilter, new Object[] { "R", "P", "I", 'P', Item.paper, 'R', Item.redstone, 'I', new ItemStack(Item.dyePowder, 1, 0) }));
@ -151,10 +127,10 @@ public class AssemblyLine
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), new Object[] { "III", "WMW", 'I', "ingotSteel", 'W', Block.wood, 'M', "motor" })); GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), new Object[] { "III", "WMW", 'I', "ingotSteel", 'W', Block.wood, 'M', "motor" }));
// Rejector // Rejector
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockMulti, 1, MachineType.REJECTOR.metadata), new Object[] { "WPW", "@R@", '@', "plateSteel", 'R', Item.redstone, 'P', Block.pistonBase, 'C', "basicCircuit", 'W', "copperWire" })); GameRegistry.addRecipe(new ShapedOreRecipe(blockRejector, new Object[] { "WPW", "@R@", '@', "plateSteel", 'R', Item.redstone, 'P', Block.pistonBase, 'C', "basicCircuit", 'W', "copperWire" }));
// Manipulator // Manipulator
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockMulti, 1, MachineType.MANIPULATOR.metadata), new Object[] { Block.dispenser, "basicCircuit" })); GameRegistry.addRecipe(new ShapelessOreRecipe(blockManipulator, new Object[] { Block.dispenser, "basicCircuit" }));
UETab.setItemStack(new ItemStack(blockConveyorBelt)); UETab.setItemStack(new ItemStack(blockConveyorBelt));
} }

View file

@ -5,7 +5,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import assemblyline.common.block.TileEntityCrate; import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.ContainerRejector;
import assemblyline.common.machine.TileEntityManipulator; import assemblyline.common.machine.TileEntityManipulator;
import assemblyline.common.machine.TileEntityRejector; import assemblyline.common.machine.TileEntityRejector;
import assemblyline.common.machine.belt.TileEntityConveyorBelt; import assemblyline.common.machine.belt.TileEntityConveyorBelt;
@ -16,7 +15,6 @@ import cpw.mods.fml.common.registry.GameRegistry;
public class CommonProxy implements IGuiHandler public class CommonProxy implements IGuiHandler
{ {
public static final int GUI_REJECTOR = 0;
public static final int GUI_STAMPER = 1; public static final int GUI_STAMPER = 1;
public static final int GUI_ARCHITECHT_TABLE = 2; public static final int GUI_ARCHITECHT_TABLE = 2;
@ -41,8 +39,6 @@ public class CommonProxy implements IGuiHandler
switch (ID) switch (ID)
{ {
case GUI_REJECTOR:
return new ContainerRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_STAMPER: case GUI_STAMPER:
return new ContainerStamper(player.inventory, world, new Vector3(x, y, z)); return new ContainerStamper(player.inventory, world, new Vector3(x, y, z));
} }

View file

@ -46,7 +46,7 @@ public class ItemBlockCrate extends ItemBlock
if (containingStack != null) if (containingStack != null)
{ {
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, (int)((float) containingStack.stackSize / (float) TileEntityCrate.MAX_LIMIT) * 5)); player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, (int) ((float) containingStack.stackSize / (float) TileEntityCrate.MAX_LIMIT) * 5));
} }
} }
} }

View file

@ -0,0 +1,85 @@
package assemblyline.common.machine;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.UETab;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.machine.detector.BlockFilterable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* A block that manipulates item movement between inventories.
*
* @author Calclavia
*
*/
public class BlockManipulator extends BlockFilterable
{
public BlockManipulator(int id)
{
super("manipulator", id, UniversalElectricity.machine, UETab.INSTANCE);
this.setBlockBounds(0, 0, 0, 1, 0.3f, 1);
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) par2, (double) par3, (double) par4, (double) par2 + 1, (double) par3 + 1, (double) par4 + 1);
}
@Override
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileEntityManipulator)
{
((TileEntityManipulator) tileEntity).selfPulse = !((TileEntityManipulator) tileEntity).selfPulse;
}
return true;
}
@Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileEntityManipulator)
{
((TileEntityManipulator) tileEntity).toggleOutput();
return true;
}
return false;
}
@Override
public TileEntity createNewTileEntity(World var1, int metadata)
{
return new TileEntityManipulator();
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
}

View file

@ -1,254 +0,0 @@
package assemblyline.common.machine;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.UETab;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import universalelectricity.prefab.multiblock.IBlockActivate;
import assemblyline.client.render.BlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* A metadata block containing a bunch of machines with direction.
*
* @author Darkguardsman, Calclavia
*
*/
public class BlockMulti extends BlockMachine
{
public static enum MachineType
{
REJECTOR("Rejector", 0, 0, TileEntityRejector.class), MANIPULATOR("Manipulator", 4, -1, TileEntityManipulator.class), INVALID_1("Invalid", 8, -1, null), INVALID_2("Invalid", 12, -1, null);
public String name;
public int metadata;
public int guiID;
public Class<? extends TileEntity> tileEntity;
MachineType(String name, int metadata, int guiID, Class<? extends TileEntity> tileEntity)
{
this.name = name;
this.metadata = metadata;
this.guiID = guiID;
this.tileEntity = tileEntity;
}
public static MachineType get(int metadata)
{
for (MachineType value : MachineType.values())
{
if (metadata >= value.metadata && metadata < value.metadata + 4) { return value; }
}
return null;
}
/**
* Gets the direction based on the metadata
*
* @return A direction value from 0 to 4.
*/
public static int getDirection(int metadata)
{
return metadata - MachineType.get(metadata).metadata;
}
/**
* @param currentDirection - An integer from 0 to 4.
* @return The metadata this block should change into.
*/
public int getNextDirectionMeta(int currentDirection)
{
currentDirection++;
if (currentDirection >= 4)
{
currentDirection = 0;
}
return currentDirection + this.metadata;
}
/**
* Creates a new TIleEntity.
*/
public TileEntity instantiateTileEntity()
{
try
{
return this.tileEntity.newInstance();
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
}
public BlockMulti(int id)
{
super("AssemblyLineMachine", id, UniversalElectricity.machine);
this.setCreativeTab(UETab.INSTANCE);
}
@Override
public int damageDropped(int metadata)
{
return MachineType.get(metadata).metadata;
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IBlockActivate)
{
((IBlockActivate) tileEntity).onActivated(entityPlayer);
}
}
return true;
}
@Override
public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLiving par5EntityLiving)
{
int metadata = par1World.getBlockMetadata(x, y, z);
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
switch (angle)
{
case 0:
par1World.setBlockMetadataWithNotify(x, y, z, metadata + 0);
break;
case 1:
par1World.setBlockMetadataWithNotify(x, y, z, metadata + 3);
break;
case 2:
par1World.setBlockMetadataWithNotify(x, y, z, metadata + 1);
break;
case 3:
par1World.setBlockMetadataWithNotify(x, y, z, metadata + 2);
break;
}
}
@Override
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
int metadata = par1World.getBlockMetadata(x, y, z);
MachineType machineType = MachineType.get(metadata);
par1World.setBlockAndMetadataWithNotify(x, y, z, this.blockID, machineType.getNextDirectionMeta(MachineType.getDirection(metadata)));
return true;
}
@Override
public boolean onSneakUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
int metadata = par1World.getBlockMetadata(x, y, z);
if (MachineType.get(metadata) == MachineType.MANIPULATOR)
{
TileEntityManipulator tileEntity = (TileEntityManipulator) par1World.getBlockTileEntity(x, y, z);
tileEntity.toggleOutput();
return true;
}
else
{
return this.onUseWrench(par1World, x, y, z, par5EntityPlayer, side, hitX, hitY, hitZ);
}
}
@Override
public void onNeighborBlockChange(World par1World, int x, int y, int z, int side)
{
super.onNeighborBlockChange(par1World, x, y, z, side);
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneReceptor)
{
if (par1World.isBlockIndirectlyGettingPowered(x, y, z))
{
((IRedstoneReceptor) par1World.getBlockTileEntity(x, y, z)).onPowerOn();
}
}
}
/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int x, int y, int z)
{
return this.getCollisionBoundingBoxFromPool(par1World, x, y, z);
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after
* the pool has been cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int x, int y, int z)
{
int metadata = par1World.getBlockMetadata(x, y, z);
if (MachineType.get(metadata) == MachineType.MANIPULATOR) { return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + 0.3f, (double) z + this.maxZ); }
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
}
@Override
public TileEntity createNewTileEntity(World var1, int metadata)
{
return MachineType.get(metadata).instantiateTileEntity();
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (MachineType type : MachineType.values())
{
if (type.tileEntity != null)
{
par3List.add(new ItemStack(par1, 1, type.metadata));
}
}
}
}

View file

@ -1,26 +0,0 @@
package assemblyline.common.machine;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import assemblyline.common.machine.BlockMulti.MachineType;
public class ItemBlockMulti extends ItemBlock
{
public ItemBlockMulti(int par1)
{
super(par1);
this.setHasSubtypes(true);
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
return MachineType.get(itemstack.getItemDamage()).name;
}
@Override
public int getMetadata(int par1)
{
return MachineType.get(par1).metadata;
}
}

View file

@ -17,18 +17,16 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory; import net.minecraftforge.common.ISidedInventory;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRedstoneReceptor; import universalelectricity.prefab.implement.IRedstoneReceptor;
import universalelectricity.prefab.multiblock.IBlockActivate;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import assemblyline.api.IManipulator; import assemblyline.api.IManipulator;
import assemblyline.common.AssemblyLine; import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.BlockMulti.MachineType;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.PacketDispatcher;
public class TileEntityManipulator extends TileEntityAssemblyNetwork implements IRedstoneReceptor, IPacketReceiver, IManipulator, IBlockActivate public class TileEntityManipulator extends TileEntityAssemblyNetwork implements IRedstoneReceptor, IPacketReceiver, IManipulator
{ {
public boolean selfPulse = false; public boolean selfPulse = false;
@ -81,7 +79,7 @@ public class TileEntityManipulator extends TileEntityAssemblyNetwork implements
{ {
this.isRedstonePowered = true; this.isRedstonePowered = true;
} }
/** /**
* Finds the connected inventory and outputs the items upon a redstone pulse. * Finds the connected inventory and outputs the items upon a redstone pulse.
*/ */
@ -218,6 +216,7 @@ public class TileEntityManipulator extends TileEntityAssemblyNetwork implements
entityItem.motionX = 0; entityItem.motionX = 0;
entityItem.motionZ = 0; entityItem.motionZ = 0;
entityItem.motionY /= 5; entityItem.motionY /= 5;
entityItem.delayBeforeCanPickup = 30;
worldObj.spawnEntityInWorld(entityItem); worldObj.spawnEntityInWorld(entityItem);
} }
@ -421,7 +420,7 @@ public class TileEntityManipulator extends TileEntityAssemblyNetwork implements
public ForgeDirection getBeltDirection() public ForgeDirection getBeltDirection()
{ {
return ForgeDirection.getOrientation(MachineType.getDirection(this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)) + 2); return ForgeDirection.getOrientation(this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
} }
@Override @Override
@ -452,11 +451,4 @@ public class TileEntityManipulator extends TileEntityAssemblyNetwork implements
{ {
this.isRedstonePowered = false; this.isRedstonePowered = false;
} }
@Override
public boolean onActivated(EntityPlayer entityPlayer)
{
this.selfPulse = !this.selfPulse;
return true;
}
} }

View file

@ -1,5 +1,6 @@
package assemblyline.common.machine; package assemblyline.common.machine;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -16,12 +17,13 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.multiblock.IBlockActivate; import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import assemblyline.api.IFilterable;
import assemblyline.common.AssemblyLine; import assemblyline.common.AssemblyLine;
import assemblyline.common.CommonProxy; import assemblyline.common.machine.filter.ItemFilter;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
@ -32,12 +34,12 @@ import cpw.mods.fml.common.network.PacketDispatcher;
* @author Darkguardsman * @author Darkguardsman
* *
*/ */
public class TileEntityRejector extends TileEntityAssemblyNetwork implements IPacketReceiver, IInventory, IBlockActivate public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRotatable, IFilterable, IPacketReceiver, IInventory
{ {
/** /**
* The items this container contains. * The items this container contains.
*/ */
protected ItemStack[] containingItems = new ItemStack[this.getSizeInventory()]; protected ItemStack[] containingItems = new ItemStack[1];
/** /**
* Used to id the packet types * Used to id the packet types
@ -55,10 +57,6 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IPa
* on/off value for the GUI buttons * on/off value for the GUI buttons
*/ */
public boolean[] guiButtons = new boolean[] { true, true, true, true, true }; public boolean[] guiButtons = new boolean[] { true, true, true, true, true };
/**
* the belt found in the search area
*/
public TileEntityConveyorBelt beltSide = null;
private int playerUsing = 0; private int playerUsing = 0;
@ -74,45 +72,36 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IPa
this.firePiston = false; this.firePiston = false;
// area to search for items // area to search for items
ForgeDirection searchPosition = Vector3.getOrientationFromSide(ForgeDirection.getOrientation(getDirection(meta)), ForgeDirection.SOUTH); Vector3 searchPosition = new Vector3(this);
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord + searchPosition.offsetX, yCoord + searchPosition.offsetY, zCoord + searchPosition.offsetZ); searchPosition.modifyPositionFromSide(this.getDirection());
TileEntity tileEntity = searchPosition.getTileEntity(this.worldObj);
// find the belt in that search area
if (tileEntity instanceof TileEntityConveyorBelt)
{
this.beltSide = (TileEntityConveyorBelt) tileEntity;
}
else
{
this.beltSide = null;
}
try try
{ {
// search area bound box
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(xCoord + searchPosition.offsetX, yCoord + searchPosition.offsetY, zCoord + searchPosition.offsetZ, xCoord + searchPosition.offsetX + 1, yCoord + searchPosition.offsetY + 1, zCoord + searchPosition.offsetZ + 1);
// EntityItem list
List<EntityItem> itemsBehind = worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
boolean flag = false; boolean flag = false;
if (itemsBehind.size() > 0 && this.isRunning()) if (this.isRunning())
{ {
// for every item found check /**
// if can be thrown then throw * Find all entities in the position in which this block is facing and attempt
// item off belt if it can * to push it out of the way.
for (EntityItem entity : itemsBehind) */
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(searchPosition.x, searchPosition.y, searchPosition.z, searchPosition.x + 1, searchPosition.y + 1, searchPosition.z + 1);
List<Entity> entitiesInFront = this.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : entitiesInFront)
{ {
if (this.canItemBeThrow(entity)) if (this.canEntityBeThrow(entity))
{ {
this.throwItem(searchPosition, entity); this.throwItem(this.getDirection(), entity);
flag = true; flag = true;
} }
} }
} }
// send packet with animation data
// if an item was rejected from /**
// the area * If a push happened, send a packet to the client to notify it for an animation.
*/
if (!this.worldObj.isRemote && flag) if (!this.worldObj.isRemote && flag)
{ {
Packet packet = PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.getPacketData(PacketTypes.ANIMATION)); Packet packet = PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.getPacketData(PacketTypes.ANIMATION));
@ -148,65 +137,37 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IPa
{ {
this.firePiston = true; this.firePiston = true;
entity.motionX = (double) side.offsetX * 0.15; entity.motionX = (double) side.offsetX * 0.1;
entity.motionY += 0.10000000298023224D; entity.motionY += 0.10000000298023224D;
entity.motionZ = (double) side.offsetZ * 0.15; entity.motionZ = (double) side.offsetZ * 0.1;
} }
public boolean canItemBeThrow(Entity entity) public boolean canEntityBeThrow(Entity entity)
{ {
// TODO Add other things than items // TODO Add other things than items
if (entity instanceof EntityItem) if (entity instanceof EntityItem)
{ {
EntityItem itemE = (EntityItem) entity; EntityItem entityItem = (EntityItem) entity;
ItemStack item = itemE.func_92014_d(); ItemStack itemStack = entityItem.func_92014_d();
if (this.guiButtons[4]) if (this.containingItems[0] != null)
{ {
// reject matching items ArrayList<ItemStack> checkStacks = ItemFilter.getFilters(this.containingItems[0]);
for (int i = 0; i < this.containingItems.length; i++)
// Reject matching items
for (int i = 0; i < checkStacks.size(); i++)
{ {
if (containingItems[i] != null && guiButtons[i]) if (checkStacks.get(i) != null)
{ {
if (containingItems[i].itemID == item.itemID && containingItems[i].getItemDamage() == item.getItemDamage()) { return true; } if (checkStacks.get(i).isItemEqual(itemStack)) { return true; }
} }
} }
return false;
}
else if (!this.guiButtons[4])
{
// reject all but matching items
for (int i = 0; i < this.containingItems.length; i++)
{
if (containingItems[i] != null && guiButtons[i])
{
if (containingItems[i].itemID == item.itemID && containingItems[i].getItemDamage() == item.getItemDamage()) { return false; }
}
}
return true;
} }
} }
return false; return false;
} }
public byte getDirection(int meta)
{
switch (meta)
{
case 0:
return 2;
case 1:
return 5;
case 2:
return 3;
case 3:
return 4;
}
return 0;
}
/** /**
* Used to change any one of the boolean value of on/off array After changing the value if it * Used to change any one of the boolean value of on/off array After changing the value if it
* was changed client side it will send a packet server side with the changes * was changed client side it will send a packet server side with the changes
@ -290,13 +251,13 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IPa
@Override @Override
public String getInvName() public String getInvName()
{ {
return "Sorter"; return TranslationHelper.getLocal("tile.rejector.name");
} }
@Override @Override
public int getSizeInventory() public int getSizeInventory()
{ {
return 4; return this.containingItems.length;
} }
/** /**
@ -454,9 +415,26 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IPa
} }
@Override @Override
public boolean onActivated(EntityPlayer entityPlayer) public void setFilter(ItemStack filter)
{ {
entityPlayer.openGui(AssemblyLine.instance, CommonProxy.GUI_REJECTOR, this.worldObj, this.xCoord, this.yCoord, this.zCoord); this.setInventorySlotContents(0, filter);
return true; }
@Override
public ItemStack getFilter()
{
return this.getStackInSlot(0);
}
@Override
public ForgeDirection getDirection()
{
return ForgeDirection.getOrientation(this.getBlockMetadata());
}
@Override
public void setDirection(ForgeDirection facingDirection)
{
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, facingDirection.ordinal());
} }
} }

View file

@ -64,17 +64,18 @@ public class BlockConveyorBelt extends BlockMachine
switch (original) switch (original)
{ {
case 2: case 2:
change = 5;
break;
case 5:
change = 4; change = 4;
break; break;
case 3:
change = 5;
break;
case 4: case 4:
change = 3; change = 3;
break; break;
case 3: case 5:
change = 2; change = 2;
break; break;
} }
world.setBlockMetadataWithNotify(x, y, z, change); world.setBlockMetadataWithNotify(x, y, z, change);
@ -123,29 +124,36 @@ public class BlockConveyorBelt extends BlockMachine
// Move the entity based on the conveyor belt's direction. // Move the entity based on the conveyor belt's direction.
entity.addVelocity(direction.offsetX * tileEntity.acceleration * modifier, 0, direction.offsetZ * tileEntity.acceleration * modifier); entity.addVelocity(direction.offsetX * tileEntity.acceleration * modifier, 0, direction.offsetZ * tileEntity.acceleration * modifier);
if (direction.offsetX != 0 && Math.abs(entity.motionX) > Math.abs(direction.offsetX * tileEntity.maxSpeed)) if (direction.offsetX != 0 && Math.abs(entity.motionX) > tileEntity.maxSpeed)
{ {
entity.motionX = direction.offsetX * tileEntity.maxSpeed; entity.motionX = direction.offsetX * tileEntity.maxSpeed;
entity.motionZ = 0;
} }
if (direction.offsetZ != 0 && Math.abs(entity.motionZ) > Math.abs(direction.offsetZ * tileEntity.maxSpeed)) if (direction.offsetZ != 0 && Math.abs(entity.motionZ) > tileEntity.maxSpeed)
{ {
entity.motionZ = direction.offsetZ * tileEntity.maxSpeed; entity.motionZ = direction.offsetZ * tileEntity.maxSpeed;
entity.motionX = 0;
} }
// Attempt to move entity to the center of the belt to prevent them if (entity instanceof EntityItem)
// from flying off.
if (direction.offsetX != 0)
{ {
double difference = (z + 0.5) - entity.posZ; if (direction.offsetX != 0)
entity.motionZ += difference * 0.015; {
// entity.posZ = z + 0.5; double difference = (z + 0.5) - entity.posZ;
} entity.motionZ += difference * 0.006;
else if (direction.offsetZ != 0) // entity.posZ = z + 0.5;
{ }
double difference = (x + 0.5) - entity.posX; else if (direction.offsetZ != 0)
entity.motionX += difference * 0.015; {
// entity.posX = z + 0.5; double difference = (x + 0.5) - entity.posX;
entity.motionX += difference * 0.006;
// /entity.posX = x + 0.5;
}
((EntityItem) entity).age++;
((EntityItem) entity).delayBeforeCanPickup = 2;
entity.onGround = false;
} }
if (slantType == SlantType.UP) if (slantType == SlantType.UP)
@ -163,12 +171,6 @@ public class BlockConveyorBelt extends BlockMachine
} }
} }
if (entity instanceof EntityItem)
{
((EntityItem) entity).age++;
((EntityItem) entity).delayBeforeCanPickup = 2;
entity.onGround = false;
}
} }
} }

View file

@ -33,8 +33,8 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
/** /**
* Joules required to run this thing. * Joules required to run this thing.
*/ */
public float acceleration = 0.01f; public final float acceleration = 0.01f;
public float maxSpeed = 0.3f; public final float maxSpeed = 0.1f;
public float wheelRotation = 0; public float wheelRotation = 0;
private SlantType slantType = SlantType.NONE; private SlantType slantType = SlantType.NONE;

View file

@ -124,21 +124,6 @@ public class BlockDetector extends BlockFilterable
return false; return false;
} }
@Override
public boolean canBlockStay(World world, int x, int y, int z)
{
if (world.isBlockSolidOnSide(x, y + 1, z, ForgeDirection.DOWN))
return true;
return false;
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return canBlockStay(world, x, y, z);
}
@Override @Override
public TileEntity createNewTileEntity(World world) public TileEntity createNewTileEntity(World world)
{ {

View file

@ -2,12 +2,16 @@ package assemblyline.common.machine.detector;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import universalelectricity.prefab.BlockMachine; import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import assemblyline.api.IFilterable;
import assemblyline.common.machine.filter.ItemFilter; import assemblyline.common.machine.filter.ItemFilter;
/** /**
@ -32,9 +36,9 @@ public abstract class BlockFilterable extends BlockMachine
if (tileEntity != null) if (tileEntity != null)
{ {
if (tileEntity instanceof TileEntityDetector) if (tileEntity instanceof IFilterable)
{ {
ItemStack containingStack = ((TileEntityDetector) tileEntity).getStackInSlot(0); ItemStack containingStack = ((IFilterable) tileEntity).getFilter();
if (containingStack != null) if (containingStack != null)
{ {
@ -45,7 +49,7 @@ public abstract class BlockFilterable extends BlockMachine
world.spawnEntityInWorld(dropStack); world.spawnEntityInWorld(dropStack);
} }
((TileEntityDetector) tileEntity).setInventorySlotContents(0, null); ((IFilterable) tileEntity).setFilter(null);
return true; return true;
} }
else else
@ -54,7 +58,7 @@ public abstract class BlockFilterable extends BlockMachine
{ {
if (player.getCurrentEquippedItem().getItem() instanceof ItemFilter) if (player.getCurrentEquippedItem().getItem() instanceof ItemFilter)
{ {
((TileEntityDetector) tileEntity).setInventorySlotContents(0, player.getCurrentEquippedItem()); ((IFilterable) tileEntity).setFilter(player.getCurrentEquippedItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null); player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
return true; return true;
} }
@ -67,4 +71,72 @@ public abstract class BlockFilterable extends BlockMachine
return false; return false;
} }
@Override
public void onNeighborBlockChange(World par1World, int x, int y, int z, int side)
{
super.onNeighborBlockChange(par1World, x, y, z, side);
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneReceptor)
{
if (par1World.isBlockIndirectlyGettingPowered(x, y, z))
{
((IRedstoneReceptor) par1World.getBlockTileEntity(x, y, z)).onPowerOn();
}
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving)
{
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int change = 2;
switch (angle)
{
case 0:
change = 2;
break;
case 1:
change = 5;
break;
case 2:
change = 3;
break;
case 3:
change = 4;
break;
}
world.setBlockMetadataWithNotify(x, y, z, change);
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
int original = world.getBlockMetadata(x, y, z);
int change = 2;
switch (original)
{
case 2:
change = 4;
break;
case 3:
change = 5;
break;
case 4:
change = 3;
break;
case 5:
change = 2;
break;
}
world.setBlockMetadataWithNotify(x, y, z, change);
return true;
}
} }

View file

@ -19,12 +19,13 @@ import universalelectricity.prefab.implement.IRedstoneProvider;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import universalelectricity.prefab.tile.TileEntityAdvanced; import universalelectricity.prefab.tile.TileEntityAdvanced;
import assemblyline.api.IFilterable;
import assemblyline.common.AssemblyLine; import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.filter.ItemFilter; import assemblyline.common.machine.filter.ItemFilter;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
public class TileEntityDetector extends TileEntityAdvanced implements IInventory, IRedstoneProvider, IPacketReceiver public class TileEntityDetector extends TileEntityAdvanced implements IFilterable, IInventory, IRedstoneProvider, IPacketReceiver
{ {
private boolean powering = false; private boolean powering = false;
private boolean isInverted = false; private boolean isInverted = false;
@ -327,4 +328,16 @@ public class TileEntityDetector extends TileEntityAdvanced implements IInventory
return this.isPoweringTo(side); return this.isPoweringTo(side);
} }
@Override
public void setFilter(ItemStack filter)
{
this.setInventorySlotContents(0, filter);
}
@Override
public ItemStack getFilter()
{
return this.getStackInSlot(0);
}
} }

View file

@ -165,7 +165,10 @@ public class ContainerStamper extends Container implements IInventory
@Override @Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{ {
this.containingItems[par1] = par2ItemStack; if (par1 < this.containingItems.length)
{
this.containingItems[par1] = par2ItemStack;
}
} }
@Override @Override
@ -221,36 +224,22 @@ public class ContainerStamper extends Container implements IInventory
} }
/** /**
* TODO WORK IN PROGRESS. Make filters able to autocraft into its item based on what is in the player's inventory * TODO WORK IN PROGRESS. Make filters able to autocraft into its item based on what is in
* the player's inventory
boolean didCraft = false; *
* boolean didCraft = false;
if (this.getStackInSlot(3) != null) *
{ * if (this.getStackInSlot(3) != null) { if (this.getStackInSlot(3).getItem() instanceof
if (this.getStackInSlot(3).getItem() instanceof ItemFilter) * ItemFilter) { ArrayList<ItemStack> filters =
{ * ItemFilter.getFilters(this.getStackInSlot(3));
ArrayList<ItemStack> filters = ItemFilter.getFilters(this.getStackInSlot(3)); *
* if (filters.size() > 0) { ItemStack outputStack = filters.get(0);
if (filters.size() > 0) *
{ * if (outputStack != null) { if (this.getIdealRecipe(outputStack) != null) {
ItemStack outputStack = filters.get(0); * this.setInventorySlotContents(4, outputStack); didCraft = true; } } } } }
*
if (outputStack != null) * if (!didCraft) { this.setInventorySlotContents(4, null); }
{ */
if (this.getIdealRecipe(outputStack) != null)
{
this.setInventorySlotContents(4, outputStack);
didCraft = true;
}
}
}
}
}
if (!didCraft)
{
this.setInventorySlotContents(4, null);
} */
} }
/** /**

View file

@ -16,7 +16,7 @@ public class ItemFilter extends Item
{ {
super(id); super(id);
this.setItemName("filter"); this.setItemName("filter");
this.setIconIndex(Item.paper.getIconFromDamage(0)); this.setIconIndex(58);
this.setCreativeTab(UETab.INSTANCE); this.setCreativeTab(UETab.INSTANCE);
this.setHasSubtypes(true); this.setHasSubtypes(true);
} }

View file

@ -33,13 +33,10 @@ public class SlotFilterResult extends Slot
} }
} }
/* /*
if (this.inventory.getStackInSlot(1) != null) * if (this.inventory.getStackInSlot(1) != null) {
{ * this.inventory.getStackInSlot(1).stackSize--; if
this.inventory.getStackInSlot(1).stackSize--; * (this.inventory.getStackInSlot(1).stackSize <= 1) {
if (this.inventory.getStackInSlot(1).stackSize <= 1) * this.inventory.setInventorySlotContents(1, null); } }
{ */
this.inventory.setInventorySlotContents(1, null);
}
}*/
} }
} }

View file

@ -0,0 +1,45 @@
package assemblyline.common.machine.machine;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.UETab;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.machine.TileEntityRejector;
import assemblyline.common.machine.detector.BlockFilterable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockRejector extends BlockFilterable
{
public BlockRejector(int id)
{
super("rejector", id, UniversalElectricity.machine, UETab.INSTANCE);
}
@Override
public TileEntity createNewTileEntity(World var1, int metadata)
{
return new TileEntityRejector();
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
}