Added Armbot Blocks
This commit is contained in:
parent
6fc94411b6
commit
d81c015793
7 changed files with 177 additions and 133 deletions
|
@ -9,6 +9,7 @@ import universalelectricity.core.vector.Vector3;
|
|||
import assemblyline.client.gui.GuiEncoder;
|
||||
import assemblyline.client.gui.GuiImprinter;
|
||||
import assemblyline.client.render.BlockRenderingHandler;
|
||||
import assemblyline.client.render.RenderArmbot;
|
||||
import assemblyline.client.render.RenderConveyorBelt;
|
||||
import assemblyline.client.render.RenderCrate;
|
||||
import assemblyline.client.render.RenderDetector;
|
||||
|
@ -20,6 +21,7 @@ import assemblyline.common.block.TileEntityCrate;
|
|||
import assemblyline.common.machine.TileEntityManipulator;
|
||||
import assemblyline.common.machine.TileEntityRejector;
|
||||
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
|
||||
import assemblyline.common.machine.crafter.TileEntityArmbot;
|
||||
import assemblyline.common.machine.detector.TileEntityDetector;
|
||||
import assemblyline.common.machine.encoder.TileEntityEncoder;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
|
@ -45,6 +47,7 @@ public class ClientProxy extends CommonProxy
|
|||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDetector.class, new RenderDetector());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, new RenderManipulator());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, new RenderCrate());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArmbot.class, new RenderArmbot());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
25
src/minecraft/assemblyline/client/render/RenderArmbot.java
Normal file
25
src/minecraft/assemblyline/client/render/RenderArmbot.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package assemblyline.client.render;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import assemblyline.client.model.ModelArmbot;
|
||||
|
||||
public class RenderArmbot extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static final ModelArmbot MOEDL = new ModelArmbot();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
// this.bindTextureByName(AssemblyLine.TEXTURE_PATH + "sorter.png");
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
MOEDL.render(0.0625f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
|
@ -12,12 +12,14 @@ import universalelectricity.core.UniversalElectricity;
|
|||
import universalelectricity.prefab.TranslationHelper;
|
||||
import universalelectricity.prefab.UETab;
|
||||
import universalelectricity.prefab.UpdateNotifier;
|
||||
import universalelectricity.prefab.multiblock.BlockMulti;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import assemblyline.common.block.BlockCrate;
|
||||
import assemblyline.common.block.ItemBlockCrate;
|
||||
import assemblyline.common.machine.BlockManipulator;
|
||||
import assemblyline.common.machine.BlockRejector;
|
||||
import assemblyline.common.machine.belt.BlockConveyorBelt;
|
||||
import assemblyline.common.machine.crafter.BlockArmbot;
|
||||
import assemblyline.common.machine.detector.BlockDetector;
|
||||
import assemblyline.common.machine.encoder.BlockEncoder;
|
||||
import assemblyline.common.machine.encoder.ItemDisk;
|
||||
|
@ -70,6 +72,9 @@ public class AssemblyLine
|
|||
public static Block blockEncoder;
|
||||
public static Block blockDetector;
|
||||
public static Block blockRejector;
|
||||
public static Block blockArmbot;
|
||||
|
||||
public static BlockMulti blockMulti;
|
||||
|
||||
public static final int ITEM_ID_PREFIX = 3030;
|
||||
public static Item itemImprint;
|
||||
|
@ -89,6 +94,9 @@ public class AssemblyLine
|
|||
blockDetector = new BlockDetector(CONFIGURATION.getBlock("Detector", BLOCK_ID_PREFIX + 5).getInt(), 1);
|
||||
blockRejector = new BlockRejector(CONFIGURATION.getBlock("Rejector", BLOCK_ID_PREFIX + 6).getInt());
|
||||
blockEncoder = new BlockEncoder(CONFIGURATION.getBlock("Encoder", BLOCK_ID_PREFIX + 7).getInt(), 7);
|
||||
blockArmbot = new BlockArmbot(CONFIGURATION.getBlock("Armbot", BLOCK_ID_PREFIX + 8).getInt());
|
||||
|
||||
blockMulti = new BlockMulti(CONFIGURATION.getBlock("Multiblock", BLOCK_ID_PREFIX + 9).getInt());
|
||||
|
||||
itemImprint = new ItemImprinter(CONFIGURATION.getBlock("Imprint", ITEM_ID_PREFIX).getInt());
|
||||
itemDisk = new ItemDisk(CONFIGURATION.getBlock("Disk", ITEM_ID_PREFIX + 1).getInt());
|
||||
|
@ -102,6 +110,7 @@ public class AssemblyLine
|
|||
GameRegistry.registerBlock(blockEncoder, "Encoder");
|
||||
GameRegistry.registerBlock(blockDetector, "Detector");
|
||||
GameRegistry.registerBlock(blockRejector, "Rejector");
|
||||
GameRegistry.registerBlock(blockArmbot, "Armbot");
|
||||
|
||||
TabAssemblyLine.itemStack = new ItemStack(AssemblyLine.blockConveyorBelt);
|
||||
UpdateNotifier.INSTANCE.checkUpdate(NAME, VERSION, "http://calclavia.com/downloads/al/recommendedversion.txt");
|
||||
|
|
|
@ -4,10 +4,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.multiblock.TileEntityMulti;
|
||||
import assemblyline.common.block.TileEntityCrate;
|
||||
import assemblyline.common.machine.TileEntityManipulator;
|
||||
import assemblyline.common.machine.TileEntityRejector;
|
||||
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
|
||||
import assemblyline.common.machine.crafter.TileEntityArmbot;
|
||||
import assemblyline.common.machine.detector.TileEntityDetector;
|
||||
import assemblyline.common.machine.encoder.ContainerEncoder;
|
||||
import assemblyline.common.machine.encoder.TileEntityEncoder;
|
||||
|
@ -34,6 +36,8 @@ public class CommonProxy implements IGuiHandler
|
|||
GameRegistry.registerTileEntity(TileEntityCrate.class, "ALCrate");
|
||||
GameRegistry.registerTileEntity(TileEntityDetector.class, "ALDetector");
|
||||
GameRegistry.registerTileEntity(TileEntityEncoder.class, "ALEncoder");
|
||||
GameRegistry.registerTileEntity(TileEntityArmbot.class, "ALArmbot");
|
||||
GameRegistry.registerTileEntity(TileEntityMulti.class, "ALMulti");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package assemblyline.common.machine.crafter;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.BlockMachine;
|
||||
import universalelectricity.prefab.multiblock.IMultiBlock;
|
||||
import assemblyline.common.TabAssemblyLine;
|
||||
|
||||
public class BlockArmbot extends BlockMachine
|
||||
{
|
||||
public BlockArmbot(int id)
|
||||
{
|
||||
super("armbot", id, UniversalElectricity.machine);
|
||||
this.setResistance(5.0f);
|
||||
this.setHardness(5.0f);
|
||||
this.setCreativeTab(TabAssemblyLine.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null && tileEntity instanceof IMultiBlock)
|
||||
{
|
||||
((IMultiBlock) tileEntity).onCreate(new Vector3(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null && tileEntity instanceof IMultiBlock) { return ((IMultiBlock) tileEntity).onActivated(player); }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null && tileEntity instanceof IMultiBlock)
|
||||
{
|
||||
((IMultiBlock) tileEntity).onDestroy(tileEntity);
|
||||
}
|
||||
|
||||
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
|
||||
|
||||
super.breakBlock(world, x, y, z, par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
return new TileEntityArmbot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
package assemblyline.common.machine.crafter;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.prefab.BlockMachine;
|
||||
import universalelectricity.prefab.UETab;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
|
||||
public class BlockCrafter extends BlockMachine
|
||||
{
|
||||
protected BlockCrafter(int id)
|
||||
{
|
||||
super("AutoCrafter", id, UniversalElectricity.machine);
|
||||
this.setResistance(5.0f);
|
||||
this.setHardness(5.0f);
|
||||
this.setCreativeTab(UETab.INSTANCE);
|
||||
}
|
||||
|
||||
public static enum CrafterType
|
||||
{
|
||||
CRAFTER("Crafter", 0, -1, TileEntityAutoCrafter.class);
|
||||
|
||||
public String name;
|
||||
public int metadata;
|
||||
public int guiID;
|
||||
public Class<? extends TileEntity> tileEntity;
|
||||
|
||||
CrafterType(String name, int metadata, int guiID, Class<? extends TileEntity> tileEntity)
|
||||
{
|
||||
this.name = name;
|
||||
this.metadata = metadata;
|
||||
this.guiID = guiID;
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
public static CrafterType get(int metadata)
|
||||
{
|
||||
for (CrafterType value : CrafterType.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 - CrafterType.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int metadata)
|
||||
{
|
||||
return CrafterType.get(metadata).instantiateTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
int metadata = par1World.getBlockMetadata(x, y, z);
|
||||
int guiID = CrafterType.get(metadata).metadata;
|
||||
if (guiID == -1)
|
||||
return false;
|
||||
par5EntityPlayer.openGui(AssemblyLine.instance, guiID, par1World, x, y, z);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSneakUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package assemblyline.common.machine.crafter;
|
|||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -15,13 +16,17 @@ import universalelectricity.core.electricity.ElectricityConnections;
|
|||
import universalelectricity.core.implement.IConductor;
|
||||
import universalelectricity.core.implement.IJouleStorage;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.TranslationHelper;
|
||||
import universalelectricity.prefab.multiblock.IMultiBlock;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.tile.TileEntityElectricityReceiver;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.machine.armbot.CommandManager;
|
||||
import assemblyline.common.machine.encoder.ItemDisk;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityArmbot extends TileEntityElectricityReceiver implements IInventory, IPacketReceiver, IJouleStorage
|
||||
public class TileEntityArmbot extends TileEntityElectricityReceiver implements IMultiBlock, IInventory, IPacketReceiver, IJouleStorage
|
||||
{
|
||||
/**
|
||||
* The items this container contains.
|
||||
|
@ -119,7 +124,7 @@ public class TileEntityArmbot extends TileEntityElectricityReceiver implements I
|
|||
}
|
||||
|
||||
/**
|
||||
* inventory
|
||||
* Inventory
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
|
@ -130,7 +135,7 @@ public class TileEntityArmbot extends TileEntityElectricityReceiver implements I
|
|||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return "RoboticArm";
|
||||
return TranslationHelper.getLocal("tile.armbot.name");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,7 +207,7 @@ public class TileEntityArmbot extends TileEntityElectricityReceiver implements I
|
|||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -285,4 +290,55 @@ public class TileEntityArmbot extends TileEntityElectricityReceiver implements I
|
|||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(EntityPlayer player)
|
||||
{
|
||||
ItemStack containingStack = this.getStackInSlot(0);
|
||||
|
||||
if (containingStack != null)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
EntityItem dropStack = new EntityItem(this.worldObj, player.posX, player.posY, player.posZ, containingStack);
|
||||
dropStack.delayBeforeCanPickup = 0;
|
||||
this.worldObj.spawnEntityInWorld(dropStack);
|
||||
}
|
||||
|
||||
this.setInventorySlotContents(0, null);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if (player.getCurrentEquippedItem().getItem() instanceof ItemDisk)
|
||||
{
|
||||
this.setInventorySlotContents(0, player.getCurrentEquippedItem());
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Vector3 placedPosition)
|
||||
{
|
||||
AssemblyLine.blockMulti.makeFakeBlock(this.worldObj, Vector3.add(placedPosition, new Vector3(0, 1, 0)), placedPosition);
|
||||
AssemblyLine.blockMulti.makeFakeBlock(this.worldObj, Vector3.add(placedPosition, new Vector3(0, 2, 0)), placedPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(TileEntity callingBlock)
|
||||
{
|
||||
Vector3 destroyPosition = new Vector3(callingBlock);
|
||||
destroyPosition.add(new Vector3(0, 1, 0));
|
||||
destroyPosition.setBlockWithNotify(this.worldObj, 0);
|
||||
destroyPosition.add(new Vector3(0, 1, 0));
|
||||
destroyPosition.setBlockWithNotify(this.worldObj, 0);
|
||||
this.worldObj.setBlockWithNotify(this.xCoord, this.yCoord, this.zCoord, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue