feat: initial port

This commit is contained in:
Timo Ley 2022-10-26 19:42:44 +02:00
parent c5adeede0a
commit 1b692b6dfc
206 changed files with 11422 additions and 1 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
.idea
build
run
bin
off

View File

@ -17,6 +17,9 @@ buildscript {
apply plugin: 'forge'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
version = "1.0"
group= "modgroup"
archivesBaseName = "modid"
@ -26,8 +29,12 @@ minecraft {
runDir = "run"
}
dependencies {
repositories {
maven { url = "https://maven.tilera.xyz" }
}
dependencies {
compile "universalelectricity:basiccomponents:1.0.2-dirty:deobf"
}
processResources

0
gradlew vendored Normal file → Executable file
View File

View File

@ -0,0 +1,22 @@
package assemblyline.api;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
public interface IArmbot {
public void grabEntity(Entity var1);
public void grabItem(ItemStack var1);
public void dropEntity(Entity var1);
public void dropItem(ItemStack var1);
public void dropAll();
public List getGrabbedEntities();
public List getGrabbedItems();
}

View File

@ -0,0 +1,8 @@
package assemblyline.api;
import assemblyline.api.IArmbot;
public interface IArmbotUseable {
public boolean onUse(IArmbot var1, String[] var2);
}

View File

@ -0,0 +1,11 @@
package assemblyline.api;
import java.util.List;
import net.minecraft.entity.Entity;
public interface IBelt {
public List getAffectedEntities();
public void IgnoreEntity(Entity var1);
}

View File

@ -0,0 +1,5 @@
package assemblyline.api;
public interface IBotArm {
}

View File

@ -0,0 +1,8 @@
package assemblyline.api;
import net.minecraftforge.common.util.ForgeDirection;
public interface ICraneConnectable {
public boolean canFrameConnectTo(ForgeDirection var1);
}

View File

@ -0,0 +1,8 @@
package assemblyline.api;
import assemblyline.api.ICraneConnectable;
public interface ICraneStructure
extends ICraneConnectable {
}

View File

@ -0,0 +1,10 @@
package assemblyline.api;
import net.minecraft.item.ItemStack;
public interface IFilterable {
public void setFilter(ItemStack var1);
public ItemStack getFilter();
}

View File

@ -0,0 +1,8 @@
package assemblyline.api;
public interface IManipulator {
public void eject();
public void inject();
}

View File

@ -0,0 +1,77 @@
package assemblyline.client;
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.RenderCraneController;
import assemblyline.client.render.RenderCraneFrame;
import assemblyline.client.render.RenderCrate;
import assemblyline.client.render.RenderDetector;
import assemblyline.client.render.RenderManipulator;
import assemblyline.client.render.RenderRejector;
import assemblyline.common.CommonProxy;
import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.TileEntityManipulator;
import assemblyline.common.machine.TileEntityRejector;
import assemblyline.common.machine.armbot.TileEntityArmbot;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import assemblyline.common.machine.crane.TileEntityCraneController;
import assemblyline.common.machine.crane.TileEntityCraneRail;
import assemblyline.common.machine.detector.TileEntityDetector;
import assemblyline.common.machine.encoder.TileEntityEncoder;
import assemblyline.common.machine.imprinter.TileEntityImprinter;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
public class ClientProxy
extends CommonProxy {
@Override
public void preInit() {
RenderingRegistry.registerBlockHandler(new BlockRenderingHandler());
}
@Override
public void init() {
super.init();
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConveyorBelt.class, (TileEntitySpecialRenderer)new RenderConveyorBelt());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, (TileEntitySpecialRenderer)new RenderRejector());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, (TileEntitySpecialRenderer)new RenderManipulator());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, (TileEntitySpecialRenderer)new RenderCrate());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArmbot.class, (TileEntitySpecialRenderer)new RenderArmbot());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDetector.class, (TileEntitySpecialRenderer)new RenderDetector());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCraneController.class, (TileEntitySpecialRenderer)new RenderCraneController());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCraneRail.class, (TileEntitySpecialRenderer)new RenderCraneFrame());
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
switch (ID) {
case 1: {
return new GuiImprinter(player.inventory, (TileEntityImprinter)tileEntity);
}
case 2: {
if (tileEntity == null || !(tileEntity instanceof TileEntityEncoder)) break;
return new GuiEncoder(player.inventory, (TileEntityEncoder)tileEntity);
}
}
}
return null;
}
@Override
public boolean isCtrKeyDown() {
return GuiScreen.isCtrlKeyDown();
}
}

View File

@ -0,0 +1,34 @@
package assemblyline.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerWorkbench;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
@SideOnly(value=Side.CLIENT)
public class GuiAutoCrafting
extends GuiContainer {
public GuiAutoCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) {
super((Container)new ContainerWorkbench(par1InventoryPlayer, par2World, par3, par4, par5));
}
protected void drawGuiContainerForegroundLayer() {
this.fontRendererObj.drawString(StatCollector.translateToLocal((String)"AutoCrafter"), 28, 6, 0x404040);
this.fontRendererObj.drawString(StatCollector.translateToLocal((String)"container.inventory"), 8, this.ySize - 96 + 2, 0x404040);
}
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
this.mc.renderEngine.getTexture(new ResourceLocation("assemblyline", "textures/gui/gui_crafting.png"));
GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
int var5 = (this.width - this.xSize) / 2;
int var6 = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
}
}

View File

@ -0,0 +1,37 @@
package assemblyline.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(value=Side.CLIENT)
@Deprecated
public class GuiButtonImage
extends GuiButton {
private int type = 0;
public GuiButtonImage(int par1, int par2, int par3, int type) {
super(par1, par2, par3, 12, 12, "");
this.type = type;
}
@Override
public void drawButton(Minecraft par1Minecraft, int width, int hight) {
if (this.visible) {
par1Minecraft.getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/gui@.png"));
GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
boolean var4 = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
int var5 = 106;
int var6 = 0;
if (var4) {
var5 += this.height;
}
this.drawTexturedModalRect(this.xPosition, this.yPosition, var6, var5, this.width, this.height);
}
}
}

View File

@ -0,0 +1,93 @@
package assemblyline.client.gui;
import cpw.mods.fml.client.GuiScrollingList;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
public class GuiCommandList
extends GuiScrollingList {
private ArrayList commands = new ArrayList();
private int selIndex = -1;
private Minecraft mc;
public GuiCommandList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight) {
super(client, width, height, top, bottom, left, entryHeight);
this.mc = client;
}
public void setCommands(ArrayList commands) {
this.commands = (ArrayList)commands.clone();
}
protected int getSize() {
return this.commands.size();
}
protected void elementClicked(int index, boolean doubleClick) {
this.selIndex = index;
}
protected boolean isSelected(int index) {
return this.selIndex == index;
}
protected void drawBackground() {
GuiCommandList.drawOutlineRect(this.left, this.left + this.listWidth, this.top, this.top + this.listHeight, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f);
}
public static void drawOutlineRect(int x1, int y1, int x2, int y2, float rR, float rG, float rB, float lR, float lG, float lB) {
Tessellator tesselator = Tessellator.instance;
GL11.glEnable((int)3042);
GL11.glDisable((int)3553);
GL11.glBlendFunc((int)770, (int)771);
GL11.glColor4f((float)rR, (float)rG, (float)rB, (float)1.0f);
if (rR > 0.0f && rG > 0.0f && rB > 0.0f) {
tesselator.startDrawingQuads();
tesselator.addVertex((double)x1, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y1, 0.0);
tesselator.addVertex((double)x1, (double)y1, 0.0);
tesselator.draw();
}
GL11.glColor4f((float)lR, (float)lG, (float)lB, (float)1.0f);
tesselator.startDrawingQuads();
tesselator.addVertex((double)x1, (double)y1, 0.0);
tesselator.addVertex((double)x1, (double)y2, 0.0);
tesselator.addVertex((double)x1 + 1.0, (double)y2, 0.0);
tesselator.addVertex((double)x1 + 1.0, (double)y1, 0.0);
tesselator.draw();
tesselator.startDrawingQuads();
tesselator.addVertex((double)x2 - 1.0, (double)y1, 0.0);
tesselator.addVertex((double)x2 - 1.0, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y1, 0.0);
tesselator.draw();
tesselator.startDrawingQuads();
tesselator.addVertex((double)x1, (double)y1, 0.0);
tesselator.addVertex((double)x1, (double)y1 + 1.0, 0.0);
tesselator.addVertex((double)x2, (double)y1 + 1.0, 0.0);
tesselator.addVertex((double)x2, (double)y1, 0.0);
tesselator.draw();
tesselator.startDrawingQuads();
tesselator.addVertex((double)x1, (double)y2 - 1.0, 0.0);
tesselator.addVertex((double)x1, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y2 - 1.0, 0.0);
tesselator.draw();
GL11.glEnable((int)3553);
GL11.glDisable((int)3042);
}
protected void drawSlot(int slotID, int width, int slotY, int slotHeight, Tessellator tessellator) {
if (slotID < this.commands.size()) {
String command = (String)this.commands.get(slotID);
if (this.isSelected(slotID)) {
GuiCommandList.drawOutlineRect(this.left, this.left + width, this.top + slotY, this.top + slotY + slotHeight, -1.0f, -1.0f, -1.0f, 0.5f, 0.5f, 0.5f);
}
this.mc.fontRenderer.drawString(command, this.left + 4, slotY + 4, 0xAAAAAA, false);
}
}
}

View File

@ -0,0 +1,305 @@
package assemblyline.client.gui;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.encoder.ContainerEncoder;
import assemblyline.common.machine.encoder.IInventoryWatcher;
import assemblyline.common.machine.encoder.ItemDisk;
import assemblyline.common.machine.encoder.TileEntityEncoder;
import assemblyline.common.network.MessageEncoder;
import java.util.ArrayList;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
public class GuiEncoder
extends GuiContainer
implements IInventoryWatcher {
private static final int MAX_COMMANDS = 6;
private int containerWidth;
private int containerHeight;
private TileEntityEncoder tileEntity;
private ArrayList commands;
private int minCommand;
private int selCommand;
private GuiButton addButton;
private GuiButton delButton;
private GuiButton pUpButton;
private GuiButton pDnButton;
private GuiTextField commandField;
public GuiEncoder(InventoryPlayer playerInventory, TileEntityEncoder tileEntity) {
super((Container)new ContainerEncoder(playerInventory, tileEntity));
this.ySize = 237;
this.tileEntity = tileEntity;
tileEntity.setWatcher(this);
}
public void initGui() {
super.initGui();
this.allowUserInput = true;
Keyboard.enableRepeatEvents((boolean)true);
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.addButton = new GuiButton(0, this.containerWidth + (this.xSize - 25), this.containerHeight + 128 + 0, 18, 20, "+");
this.delButton = new GuiButton(1, this.containerWidth + (this.xSize - 43), this.containerHeight + 128 + 0, 18, 20, "-");
this.pUpButton = new GuiButton(2, this.containerWidth + (this.xSize - 25), this.containerHeight + 46 + 0, 18, 20, "");
this.pDnButton = new GuiButton(3, this.containerWidth + (this.xSize - 25), this.containerHeight + 106 + 0, 18, 20, "");
this.commandField = new GuiTextField(this.fontRendererObj, 8, 129, this.xSize - 52, 18);
this.buttonList.add(this.addButton);
this.buttonList.add(this.delButton);
this.buttonList.add(this.pUpButton);
this.buttonList.add(this.pDnButton);
this.commands = new ArrayList();
this.minCommand = 0;
this.selCommand = -1;
}
@Override
protected void actionPerformed(GuiButton button) {
switch (button.id) {
case 0: {
ItemStack disk;
if (this.commandField.getText().equals("")) break;
if (this.tileEntity != null && (disk = this.tileEntity.getStackInSlot(0)) != null) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("create", true);
nbt.setString("newCommand", this.commandField.getText());
AssemblyLine.NETWORK.sendToServer(new MessageEncoder(new Vector3(this.tileEntity), nbt));
}
this.minCommand = this.commands.size() - 6 + 1;
if (this.minCommand < 0) {
this.minCommand = 0;
}
this.selCommand = -1;
this.commandField.setText("");
break;
}
case 1: {
if (this.tileEntity == null) break;
ItemStack disk = this.tileEntity.getStackInSlot(0);
if (disk != null && this.selCommand >= 0 && this.selCommand < this.commands.size()) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("create", false);
nbt.setInteger("commandToRemove", this.selCommand);
AssemblyLine.NETWORK.sendToServer(new MessageEncoder(new Vector3(this.tileEntity), nbt));
}
this.selCommand = -1;
break;
}
case 2: {
if (this.minCommand <= 0) break;
--this.minCommand;
break;
}
case 3: {
if (this.minCommand + 6 >= this.commands.size()) break;
++this.minCommand;
}
}
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
GL11.glDisable((int)2896);
this.fontRendererObj.drawString(TranslationHelper.getLocal("tile.encoder.name"), 68, 8, 0x404040);
this.fontRendererObj.drawString("Disk:", 56, 28, 0x404040);
GL11.glPushMatrix();
GL11.glTranslatef((float)(this.pUpButton.xPosition - this.containerWidth + 6), (float)(this.pUpButton.yPosition - this.containerHeight + 7), (float)0.0f);
this.fontRendererObj.drawString("^", 1, 1, 0x444444);
this.fontRendererObj.drawString("^", 0, 0, 0xFFFFFF);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslatef((float)(this.pDnButton.xPosition - this.containerWidth + 6), (float)(this.pDnButton.yPosition - this.containerHeight + 7), (float)0.0f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
GL11.glTranslatef((float)-5.0f, (float)-4.0f, (float)0.0f);
this.fontRendererObj.drawString("^", -1, -1, 0x444444);
this.fontRendererObj.drawString("^", 0, 0, 0xFFFFFF);
GL11.glPopMatrix();
if (this.commands != null) {
this.drawCommands();
}
this.commandField.drawTextBox();
}
private void drawCommands() {
for (int i = this.minCommand; i < this.minCommand + 6; ++i) {
if (i < 0 || i >= this.commands.size()) continue;
int relativeCommand = i - this.minCommand;
String command = ((String)this.commands.get(i)).toUpperCase();
this.drawCommand(command, 8, 47 + relativeCommand * (this.fontRendererObj.FONT_HEIGHT + 4), this.selCommand == i);
}
}
private void drawCommand(String command, int x, int y, boolean selected) {
if (selected) {
GuiEncoder.drawOutlineRect(x, y, x + 142, y + this.fontRendererObj.FONT_HEIGHT + 4, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
}
this.fontRendererObj.drawString(command, x + 3, y + this.fontRendererObj.FONT_HEIGHT / 2 - 1, 0xFFFFFF, false);
}
@Override
protected void mouseClicked(int x, int y, int button) {
super.mouseClicked(x, y, button);
this.commandField.mouseClicked(x - this.containerWidth, y - this.containerHeight, button);
if (button == 0) {
if (x >= this.containerWidth + 8) {
if (y >= this.containerHeight + 47 + 0) {
if (x <= this.containerWidth + (this.xSize - 25)) {
if (y <= this.containerHeight + 46 + 80 + 0) {
this.listClicked(x - (this.containerWidth + 8), y - (this.containerHeight + 47 + 0));
} else {
this.selCommand = -1;
}
} else {
this.selCommand = -1;
}
} else {
this.selCommand = -1;
}
} else {
this.selCommand = -1;
}
}
}
private void listClicked(int relativeX, int relativeY) {
int itemClicked = relativeY / 13;
this.selCommand = itemClicked + this.minCommand;
}
@Override
protected void keyTyped(char character, int keycode) {
if (character != 'e' && character != 'E') {
super.keyTyped(character, keycode);
}
this.commandField.textboxKeyTyped(character, keycode);
if (keycode == 1) {
this.mc.thePlayer.closeScreen();
} else if (keycode == 28) {
if (this.commandField.isFocused()) {
this.actionPerformed(this.addButton);
}
} else if (keycode == 211) {
this.actionPerformed(this.delButton);
} else if (keycode == 201) {
this.actionPerformed(this.pUpButton);
} else if (keycode == 209) {
this.actionPerformed(this.pDnButton);
} else if (keycode == 200) {
--this.selCommand;
if (this.selCommand < -1) {
this.selCommand = this.commands.size() - 1;
}
if (this.selCommand < this.minCommand && this.selCommand >= 0) {
this.minCommand = this.selCommand;
}
if (this.selCommand >= this.minCommand + 6 && this.selCommand < this.commands.size()) {
this.minCommand = this.selCommand - 6 + 1;
}
} else if (keycode == 208) {
++this.selCommand;
if (this.selCommand >= this.commands.size()) {
this.selCommand = -1;
}
if (this.selCommand >= this.minCommand + 6 && this.selCommand < this.commands.size()) {
this.minCommand = this.selCommand - 6 + 1;
}
if (this.selCommand < this.minCommand && this.selCommand >= 0) {
this.minCommand = this.selCommand;
}
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
this.mc.renderEngine.bindTexture(new ResourceLocation("assemblyline", "textures/gui/gui_encoder.png"));
GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
this.drawTexturedModalRect(this.containerWidth, this.containerHeight + 0, 0, 0, this.xSize, this.ySize);
GuiEncoder.drawOutlineRect(this.containerWidth + 7, this.containerHeight + 46 + 0, this.containerWidth + (this.xSize - 25), this.containerHeight + 46 + 80 + 0, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f);
}
public static void drawOutlineRect(int x1, int y1, int x2, int y2, float rR, float rG, float rB, float lR, float lG, float lB) {
Tessellator tesselator = Tessellator.instance;
GL11.glEnable((int)3042);
GL11.glDisable((int)3553);
GL11.glBlendFunc((int)770, (int)771);
GL11.glColor4f((float)rR, (float)rG, (float)rB, (float)1.0f);
if (rR >= 0.0f && rG >= 0.0f && rB >= 0.0f) {
tesselator.startDrawingQuads();
tesselator.addVertex((double)x1, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y1, 0.0);
tesselator.addVertex((double)x1, (double)y1, 0.0);
tesselator.draw();
}
GL11.glColor4f((float)lR, (float)lG, (float)lB, (float)1.0f);
tesselator.startDrawingQuads();
tesselator.addVertex((double)x1, (double)y1, 0.0);
tesselator.addVertex((double)x1, (double)y2, 0.0);
tesselator.addVertex((double)x1 + 1.0, (double)y2, 0.0);
tesselator.addVertex((double)x1 + 1.0, (double)y1, 0.0);
tesselator.draw();
tesselator.startDrawingQuads();
tesselator.addVertex((double)x2 - 1.0, (double)y1, 0.0);
tesselator.addVertex((double)x2 - 1.0, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y1, 0.0);
tesselator.draw();
tesselator.startDrawingQuads();
tesselator.addVertex((double)x1, (double)y1, 0.0);
tesselator.addVertex((double)x1, (double)y1 + 1.0, 0.0);
tesselator.addVertex((double)x2, (double)y1 + 1.0, 0.0);
tesselator.addVertex((double)x2, (double)y1, 0.0);
tesselator.draw();
tesselator.startDrawingQuads();
tesselator.addVertex((double)x1, (double)y2 - 1.0, 0.0);
tesselator.addVertex((double)x1, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y2, 0.0);
tesselator.addVertex((double)x2, (double)y2 - 1.0, 0.0);
tesselator.draw();
GL11.glEnable((int)3553);
GL11.glDisable((int)3042);
}
private void updateCommands() {
if (this.commands != null) {
ItemStack disk;
this.commands.clear();
if (this.tileEntity != null && (disk = this.tileEntity.getStackInSlot(0)) != null) {
this.commands = ItemDisk.getCommands(disk);
}
if (this.minCommand + 6 >= this.commands.size()) {
this.minCommand = this.commands.size() - 6;
}
if (this.minCommand < 0) {
this.minCommand = 0;
}
}
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Keyboard.enableRepeatEvents((boolean)false);
}
@Override
public void inventoryChanged() {
this.updateCommands();
}
}

View File

@ -0,0 +1,41 @@
package assemblyline.client.gui;
import assemblyline.common.machine.imprinter.ContainerImprinter;
import assemblyline.common.machine.imprinter.TileEntityImprinter;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import universalelectricity.prefab.TranslationHelper;
public class GuiImprinter
extends GuiContainer {
private int containerWidth;
private int containerHeight;
private TileEntityImprinter tileEntity;
public GuiImprinter(InventoryPlayer par1InventoryPlayer, TileEntityImprinter tileEntity) {
super((Container)new ContainerImprinter(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
this.ySize = 201;
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
this.fontRendererObj.drawString("Use Inventories:", 70, 58, 0x404040);
this.fontRendererObj.drawString("" + this.tileEntity.searchInventories, 105, 67, 0x404040);
this.fontRendererObj.drawString(TranslationHelper.getLocal("tile.imprinter.name"), 68, 6, 0x404040);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
this.mc.renderEngine.bindTexture(new ResourceLocation("assemblyline", "textures/gui/gui_imprinter.png"));
GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0, this.xSize, this.ySize);
}
}

View File

@ -0,0 +1,68 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelAngledBelt
extends ModelBase {
ModelRenderer MRoller1;
ModelRenderer bBELT;
ModelRenderer MRoller2;
ModelRenderer tBELT;
ModelRenderer MRoller3;
public ModelAngledBelt() {
this.textureWidth = 128;
this.textureHeight = 128;
this.MRoller1 = new ModelRenderer((ModelBase)this, 0, 26);
this.MRoller1.addBox(-7.0f, -1.0f, -1.0f, 14, 2, 2);
this.MRoller1.setRotationPoint(0.0f, 14.0f, 0.0f);
this.MRoller1.setTextureSize(128, 128);
this.MRoller1.mirror = true;
this.setRotation(this.MRoller1, 0.7853982f, 0.0f, 0.0f);
this.bBELT = new ModelRenderer((ModelBase)this, 0, 0);
this.bBELT.addBox(0.0f, 0.0f, 0.0f, 14, 1, 23);
this.bBELT.setRotationPoint(-7.0f, 23.5f, -8.0f);
this.bBELT.setTextureSize(128, 128);
this.bBELT.mirror = true;
this.setRotation(this.bBELT, 0.7853982f, 0.0f, 0.0f);
this.MRoller2 = new ModelRenderer((ModelBase)this, 0, 26);
this.MRoller2.addBox(-7.0f, -1.0f, -1.0f, 14, 2, 2);
this.MRoller2.setRotationPoint(0.0f, 9.0f, 5.0f);
this.MRoller2.setTextureSize(128, 128);
this.MRoller2.mirror = true;
this.setRotation(this.MRoller2, 0.7853982f, 0.0f, 0.0f);
this.tBELT = new ModelRenderer((ModelBase)this, 0, 0);
this.tBELT.addBox(0.0f, 0.0f, 0.0f, 14, 1, 23);
this.tBELT.setRotationPoint(-7.0f, 19.0f, -8.0f);
this.tBELT.setTextureSize(128, 128);
this.tBELT.mirror = true;
this.setRotation(this.tBELT, 0.7853982f, 0.0f, 0.0f);
this.MRoller3 = new ModelRenderer((ModelBase)this, 0, 26);
this.MRoller3.addBox(-7.0f, -1.0f, -1.0f, 14, 2, 2);
this.MRoller3.setRotationPoint(0.0f, 19.0f, -5.0f);
this.MRoller3.setTextureSize(128, 128);
this.MRoller3.mirror = true;
this.setRotation(this.MRoller3, 0.7853982f, 0.0f, 0.0f);
}
public void render(float f5, boolean slantAdjust) {
if (slantAdjust) {
this.bBELT.setRotationPoint(-7.0f, 21.5f, -7.0f);
} else {
this.bBELT.setRotationPoint(-7.0f, 23.5f, -8.0f);
}
this.MRoller1.render(f5);
this.bBELT.render(f5);
this.MRoller2.render(f5);
this.tBELT.render(f5);
this.MRoller3.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,154 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
public class ModelArmbot
extends ModelBase {
ModelRenderer baseTop;
ModelRenderer base;
ModelRenderer armMountRight;
ModelRenderer armMountLeft;
ModelRenderer armLower;
ModelRenderer armLower2;
ModelRenderer armLower3;
ModelRenderer armUpper;
ModelRenderer baseRotation;
ModelRenderer clampBody;
ModelRenderer clampBody2;
ModelRenderer clampClawLower;
ModelRenderer clampClawLower2;
ModelRenderer clampClawLower3;
public ModelArmbot() {
this.textureWidth = 128;
this.textureHeight = 128;
this.baseTop = new ModelRenderer((ModelBase)this, 0, 94);
this.baseTop.addBox(-6.0f, 0.0f, -6.0f, 12, 3, 12);
this.baseTop.setRotationPoint(0.0f, 18.0f, 0.0f);
this.baseTop.setTextureSize(64, 32);
this.baseTop.mirror = true;
this.setRotation(this.baseTop, 0.0f, 0.0f, 0.0f);
this.base = new ModelRenderer((ModelBase)this, 0, 109);
this.base.addBox(-8.0f, 0.0f, -8.0f, 16, 3, 16);
this.base.setRotationPoint(0.0f, 21.0f, 0.0f);
this.base.setTextureSize(64, 32);
this.base.mirror = true;
this.setRotation(this.base, 0.0f, 0.0f, 0.0f);
this.armMountRight = new ModelRenderer((ModelBase)this, 24, 85);
this.armMountRight.addBox(-3.8f, -5.0f, -2.0f, 4, 5, 4);
this.armMountRight.setRotationPoint(0.0f, 17.0f, 0.0f);
this.armMountRight.setTextureSize(128, 128);
this.armMountRight.mirror = true;
this.setRotation(this.armMountRight, 0.0f, 0.0f, 0.0f);
this.armMountLeft = new ModelRenderer((ModelBase)this, 0, 85);
this.armMountLeft.addBox(2.0f, -5.0f, -2.0f, 2, 5, 4);
this.armMountLeft.setRotationPoint(0.0f, 17.0f, 0.0f);
this.armMountLeft.setTextureSize(64, 32);
this.armMountLeft.mirror = true;
this.setRotation(this.armMountLeft, 0.0f, 0.0f, 0.0f);
this.armLower = new ModelRenderer((ModelBase)this, 116, 0);
this.armLower.addBox(0.3f, -15.0f, -1.5f, 2, 16, 4);
this.armLower.setRotationPoint(0.0f, 14.0f, 0.0f);
this.armLower.setTextureSize(64, 32);
this.armLower.mirror = true;
this.setRotation(this.armLower, 0.5235988f, 0.0f, 0.0f);
this.armLower2 = new ModelRenderer((ModelBase)this, 104, 0);
this.armLower2.addBox(-2.3f, -15.0f, -1.5f, 2, 16, 4);
this.armLower2.setRotationPoint(0.0f, 14.0f, 0.0f);
this.armLower2.setTextureSize(64, 32);
this.armLower2.mirror = true;
this.setRotation(this.armLower2, 0.5235988f, 0.0f, 0.0f);
this.armLower3 = new ModelRenderer((ModelBase)this, 92, 0);
this.armLower3.addBox(-1.0f, -14.0f, -2.0f, 2, 14, 4);
this.armLower3.setRotationPoint(0.0f, 14.0f, 0.0f);
this.armLower3.setTextureSize(64, 32);
this.armLower3.mirror = true;
this.setRotation(this.armLower3, 0.5235988f, 0.0f, 0.0f);
this.armUpper = new ModelRenderer((ModelBase)this, 0, 70);
this.armUpper.addBox(-1.0f, -10.0f, -1.5f, 2, 12, 3);
this.armUpper.setRotationPoint(0.0f, 2.0f, -7.0f);
this.armUpper.setTextureSize(64, 32);
this.armUpper.mirror = true;
this.setRotation(this.armUpper, 2.513274f, 0.0f, 0.0f);
this.baseRotation = new ModelRenderer((ModelBase)this, 0, 60);
this.baseRotation.addBox(-4.5f, 0.0f, -4.5f, 9, 1, 9);
this.baseRotation.setRotationPoint(0.0f, 17.0f, 0.0f);
this.baseRotation.setTextureSize(64, 32);
this.baseRotation.mirror = true;
this.setRotation(this.baseRotation, 0.0f, 0.0f, 0.0f);
this.clampBody = new ModelRenderer((ModelBase)this, 0, 7);
this.clampBody.addBox(-1.5f, -12.0f, -2.5f, 3, 2, 5);
this.clampBody.setRotationPoint(0.0f, 2.0f, -7.0f);
this.clampBody.setTextureSize(64, 32);
this.clampBody.mirror = true;
this.setRotation(this.clampBody, 2.513274f, 0.0f, 0.0f);
this.clampBody2 = new ModelRenderer((ModelBase)this, 0, 56);
this.clampBody2.addBox(-1.0f, -14.0f, -1.0f, 2, 2, 2);
this.clampBody2.setRotationPoint(0.0f, 2.0f, -7.0f);
this.clampBody2.setTextureSize(64, 32);
this.clampBody2.mirror = true;
this.setRotation(this.clampBody2, 2.513274f, 0.0f, 0.0f);
this.clampClawLower = new ModelRenderer((ModelBase)this, 0, 25);
this.clampClawLower.addBox(-1.0f, -4.0f, -1.0f, 2, 5, 1);
this.clampClawLower.setRotationPoint(0.0f, 13.0f, -15.0f);
this.clampClawLower.setTextureSize(64, 32);
this.clampClawLower.mirror = true;
this.setRotation(this.clampClawLower, 2.9147f, 0.0f, 0.0f);
this.clampClawLower2 = new ModelRenderer((ModelBase)this, 0, 31);
this.clampClawLower2.addBox(-1.2f, -3.5f, 0.0f, 1, 6, 1);
this.clampClawLower2.setRotationPoint(0.0f, 14.0f, -16.0f);
this.clampClawLower2.setTextureSize(64, 32);
this.clampClawLower2.mirror = true;
this.setRotation(this.clampClawLower2, 2.897247f, 0.0f, 0.0f);
this.clampClawLower3 = new ModelRenderer((ModelBase)this, 0, 0);
this.clampClawLower3.addBox(0.2f, -3.5f, 0.0f, 1, 6, 1);
this.clampClawLower3.setRotationPoint(0.0f, 14.0f, -16.0f);
this.clampClawLower3.setTextureSize(64, 32);
this.clampClawLower3.mirror = true;
this.setRotation(this.clampClawLower3, 2.897247f, 0.0f, 0.0f);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.render(f5, entity.rotationYaw, entity.rotationPitch);
}
public void render(float f5, float rotationYaw, float rotationPitch) {
this.baseTop.render(f5);
this.base.render(f5);
GL11.glPushMatrix();
GL11.glRotatef((float)rotationYaw, (float)0.0f, (float)1.0f, (float)0.0f);
this.armMountRight.render(f5);
this.armMountLeft.render(f5);
this.baseRotation.render(f5);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotatef((float)rotationYaw, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glTranslatef((float)0.0f, (float)0.9f, (float)0.0f);
GL11.glRotatef((float)(-rotationPitch), (float)1.0f, (float)0.0f, (float)0.0f);
GL11.glTranslatef((float)0.0f, (float)-0.9f, (float)0.0f);
this.armLower.render(f5);
GL11.glPushMatrix();
GL11.glTranslatef((float)0.0f, (float)0.1f, (float)-0.35f);
GL11.glRotatef((float)(-rotationPitch), (float)1.0f, (float)0.0f, (float)0.0f);
GL11.glTranslatef((float)0.0f, (float)-0.05f, (float)0.35f);
this.armUpper.render(f5);
this.clampBody.render(f5);
this.clampBody2.render(f5);
this.clampClawLower.render(f5);
this.clampClawLower2.render(f5);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,217 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelConveyorBelt
extends ModelBase {
ModelRenderer bBELTLong;
ModelRenderer FBELT;
ModelRenderer BacBELT;
ModelRenderer BBelt;
ModelRenderer FRL;
ModelRenderer MRL;
ModelRenderer FLL;
ModelRenderer BLL;
ModelRenderer MRoller;
ModelRenderer BRoller;
ModelRenderer tBELT;
ModelRenderer FRoller;
ModelRenderer BRL;
ModelRenderer BML;
ModelRenderer tBELTLong;
ModelRenderer tBELT15;
ModelRenderer bBELT15;
ModelRenderer c4;
ModelRenderer c3;
ModelRenderer c2;
ModelRenderer c1;
public ModelConveyorBelt() {
this.textureWidth = 128;
this.textureHeight = 128;
this.bBELTLong = new ModelRenderer((ModelBase)this, 0, 66);
this.bBELTLong.addBox(0.0f, 0.0f, 0.0f, 14, 1, 16);
this.bBELTLong.setRotationPoint(-7.0f, 22.0f, -8.0f);
this.bBELTLong.setTextureSize(128, 128);
this.bBELTLong.mirror = true;
this.setRotation(this.bBELTLong, 0.0f, 0.0f, 0.0f);
this.FBELT = new ModelRenderer((ModelBase)this, 0, 16);
this.FBELT.addBox(0.0f, 0.0f, 0.0f, 14, 2, 1);
this.FBELT.setRotationPoint(-7.0f, 20.0f, -8.0f);
this.FBELT.setTextureSize(128, 128);
this.FBELT.mirror = true;
this.setRotation(this.FBELT, 0.0f, 0.0f, 0.0f);
this.BacBELT = new ModelRenderer((ModelBase)this, 0, 16);
this.BacBELT.addBox(0.0f, 0.0f, 0.0f, 14, 2, 1);
this.BacBELT.setRotationPoint(-7.0f, 20.0f, 7.0f);
this.BacBELT.setTextureSize(128, 128);
this.BacBELT.mirror = true;
this.setRotation(this.BacBELT, 0.0f, 0.0f, 0.0f);
this.BBelt = new ModelRenderer((ModelBase)this, 0, 31);
this.BBelt.addBox(0.0f, 0.0f, 0.0f, 14, 1, 14);
this.BBelt.setRotationPoint(-7.0f, 22.0f, -7.0f);
this.BBelt.setTextureSize(128, 128);
this.BBelt.mirror = true;
this.setRotation(this.BBelt, 0.0f, 0.0f, 0.0f);
this.FRL = new ModelRenderer((ModelBase)this, 0, 20);
this.FRL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.FRL.setRotationPoint(-8.0f, 21.0f, -6.0f);
this.FRL.setTextureSize(128, 128);
this.FRL.mirror = true;
this.setRotation(this.FRL, 0.0f, 0.0f, 0.0f);
this.MRL = new ModelRenderer((ModelBase)this, 0, 20);
this.MRL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.MRL.setRotationPoint(-8.0f, 21.0f, -1.0f);
this.MRL.setTextureSize(128, 128);
this.MRL.mirror = true;
this.setRotation(this.MRL, 0.0f, 0.0f, 0.0f);
this.FLL = new ModelRenderer((ModelBase)this, 0, 20);
this.FLL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.FLL.setRotationPoint(7.0f, 21.0f, -6.0f);
this.FLL.setTextureSize(128, 128);
this.FLL.mirror = true;
this.setRotation(this.FLL, 0.0f, 0.0f, 0.0f);
this.BLL = new ModelRenderer((ModelBase)this, 0, 20);
this.BLL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.BLL.setRotationPoint(7.0f, 21.0f, 4.0f);
this.BLL.setTextureSize(128, 128);
this.BLL.mirror = true;
this.setRotation(this.BLL, 0.0f, 0.0f, 0.0f);
this.MRoller = new ModelRenderer((ModelBase)this, 0, 26);
this.MRoller.addBox(-7.0f, -1.0f, -1.0f, 14, 2, 2);
this.MRoller.setRotationPoint(0.0f, 21.0f, 0.0f);
this.MRoller.setTextureSize(128, 128);
this.MRoller.mirror = true;
this.setRotation(this.MRoller, 0.0f, 0.0f, 0.0f);
this.BRoller = new ModelRenderer((ModelBase)this, 0, 26);
this.BRoller.addBox(-7.0f, -1.0f, -1.0f, 14, 2, 2);
this.BRoller.setRotationPoint(0.0f, 21.0f, 5.0f);
this.BRoller.setTextureSize(128, 128);
this.BRoller.mirror = true;
this.setRotation(this.BRoller, 0.0f, 0.0f, 0.0f);
this.tBELT = new ModelRenderer((ModelBase)this, 0, 0);
this.tBELT.addBox(0.0f, 0.0f, 0.0f, 14, 1, 14);
this.tBELT.setRotationPoint(-7.0f, 19.0f, -7.0f);
this.tBELT.setTextureSize(128, 128);
this.tBELT.mirror = true;
this.setRotation(this.tBELT, 0.0f, 0.0f, 0.0f);
this.FRoller = new ModelRenderer((ModelBase)this, 0, 26);
this.FRoller.addBox(-7.0f, -1.0f, -1.0f, 14, 2, 2);
this.FRoller.setRotationPoint(0.0f, 21.0f, -5.0f);
this.FRoller.setTextureSize(128, 128);
this.FRoller.mirror = true;
this.setRotation(this.FRoller, 0.0f, 0.0f, 0.0f);
this.BRL = new ModelRenderer((ModelBase)this, 0, 20);
this.BRL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.BRL.setRotationPoint(-8.0f, 21.0f, 4.0f);
this.BRL.setTextureSize(128, 128);
this.BRL.mirror = true;
this.setRotation(this.BRL, 0.0f, 0.0f, 0.0f);
this.BML = new ModelRenderer((ModelBase)this, 0, 20);
this.BML.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.BML.setRotationPoint(7.0f, 21.0f, -1.0f);
this.BML.setTextureSize(128, 128);
this.BML.mirror = true;
this.setRotation(this.BML, 0.0f, 0.0f, 0.0f);
this.tBELTLong = new ModelRenderer((ModelBase)this, 0, 48);
this.tBELTLong.addBox(0.0f, 0.0f, 0.0f, 14, 1, 16);
this.tBELTLong.setRotationPoint(-7.0f, 19.0f, -8.0f);
this.tBELTLong.setTextureSize(128, 128);
this.tBELTLong.mirror = true;
this.setRotation(this.tBELTLong, 0.0f, 0.0f, 0.0f);
this.tBELT15 = new ModelRenderer((ModelBase)this, 0, 84);
this.tBELT15.addBox(0.0f, 0.0f, 0.0f, 14, 1, 15);
this.tBELT15.setRotationPoint(-7.0f, 19.0f, -8.0f);
this.tBELT15.setTextureSize(128, 128);
this.tBELT15.mirror = true;
this.setRotation(this.tBELT15, 0.0f, 0.0f, 0.0f);
this.bBELT15 = new ModelRenderer((ModelBase)this, 0, 84);
this.bBELT15.addBox(0.0f, 0.0f, 0.0f, 14, 1, 15);
this.bBELT15.setRotationPoint(-7.0f, 22.0f, -8.0f);
this.bBELT15.setTextureSize(128, 128);
this.bBELT15.mirror = true;
this.setRotation(this.bBELT15, 0.0f, 0.0f, 0.0f);
this.c4 = new ModelRenderer((ModelBase)this, 60, 20);
this.c4.addBox(0.0f, 0.0f, 0.0f, 1, 16, 1);
this.c4.setRotationPoint(7.0f, 8.0f, 7.0f);
this.c4.setTextureSize(128, 128);
this.c4.mirror = true;
this.setRotation(this.c4, 0.0f, 0.0f, 0.0f);
this.c3 = new ModelRenderer((ModelBase)this, 60, 20);
this.c3.addBox(0.0f, 0.0f, 0.0f, 1, 16, 1);
this.c3.setRotationPoint(7.0f, 8.0f, -8.0f);
this.c3.setTextureSize(128, 128);
this.c3.mirror = true;
this.setRotation(this.c3, 0.0f, 0.0f, 0.0f);
this.c2 = new ModelRenderer((ModelBase)this, 60, 20);
this.c2.addBox(0.0f, 0.0f, 0.0f, 1, 16, 1);
this.c2.setRotationPoint(-8.0f, 8.0f, 7.0f);
this.c2.setTextureSize(128, 128);
this.c2.mirror = true;
this.setRotation(this.c2, 0.0f, 0.0f, 0.0f);
this.c1 = new ModelRenderer((ModelBase)this, 60, 20);
this.c1.addBox(0.0f, 0.0f, 0.0f, 1, 16, 1);
this.c1.setRotationPoint(-8.0f, 8.0f, -8.0f);
this.c1.setTextureSize(128, 128);
this.c1.mirror = true;
this.setRotation(this.c1, 0.0f, 0.0f, 0.0f);
}
public void render(float f5, float radians, boolean front, boolean back, boolean above, boolean legs) {
boolean rightCap;
boolean mid = front && back;
boolean leftCap = !front && back;
boolean bl = rightCap = front && !back;
if (back || front) {
if (leftCap) {
this.FBELT.render(f5);
this.tBELT15.setRotationPoint(-7.0f, 19.0f, -7.0f);
this.bBELT15.setRotationPoint(-7.0f, 22.0f, -7.0f);
this.tBELT15.render(f5);
this.bBELT15.render(f5);
} else if (rightCap) {
this.BacBELT.render(f5);
this.tBELT15.setRotationPoint(-7.0f, 19.0f, -8.0f);
this.bBELT15.setRotationPoint(-7.0f, 22.0f, -8.0f);
this.tBELT15.render(f5);
this.bBELT15.render(f5);
} else {
this.bBELTLong.render(f5);
this.tBELTLong.render(f5);
}
} else {
this.FBELT.render(f5);
this.BacBELT.render(f5);
this.BBelt.render(f5);
this.tBELT.render(f5);
}
if (above) {
this.c1.render(f5);
this.c2.render(f5);
this.c3.render(f5);
this.c4.render(f5);
}
this.MRoller.rotateAngleX = radians;
this.BRoller.rotateAngleX = radians;
this.FRoller.rotateAngleX = radians;
this.MRoller.render(f5);
this.BRoller.render(f5);
this.FRoller.render(f5);
if (legs) {
this.BRL.render(f5);
this.BML.render(f5);
this.FLL.render(f5);
this.BLL.render(f5);
this.FRL.render(f5);
this.MRL.render(f5);
}
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,87 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelCraneArmMount
extends ModelBase {
private ModelRenderer RailGuard1;
private ModelRenderer ArmMount;
private ModelRenderer RailGuard2;
private ModelRenderer Base;
private ModelRenderer WheelMount1;
private ModelRenderer Wheel2;
private ModelRenderer WheelMount2;
private ModelRenderer Wheel1;
public ModelCraneArmMount() {
this.textureWidth = 64;
this.textureHeight = 64;
this.RailGuard1 = new ModelRenderer((ModelBase)this, 0, 20);
this.RailGuard1.addBox(0.0f, 0.0f, 0.0f, 16, 8, 2);
this.RailGuard1.setRotationPoint(-8.0f, 12.0f, 4.0f);
this.RailGuard1.setTextureSize(64, 32);
this.RailGuard1.mirror = true;
this.setRotation(this.RailGuard1, 0.0f, 0.0f, 0.0f);
this.ArmMount = new ModelRenderer((ModelBase)this, 36, 26);
this.ArmMount.addBox(0.0f, 0.0f, 0.0f, 8, 4, 2);
this.ArmMount.setRotationPoint(-4.0f, 4.0f, -8.0f);
this.ArmMount.setTextureSize(64, 32);
this.ArmMount.mirror = true;
this.setRotation(this.ArmMount, 0.0f, 0.0f, 0.0f);
this.RailGuard2 = new ModelRenderer((ModelBase)this, 0, 20);
this.RailGuard2.addBox(0.0f, 0.0f, 0.0f, 16, 8, 2);
this.RailGuard2.setRotationPoint(-8.0f, 12.0f, -6.0f);
this.RailGuard2.setTextureSize(64, 32);
this.RailGuard2.mirror = true;
this.setRotation(this.RailGuard2, 0.0f, 0.0f, 0.0f);
this.Base = new ModelRenderer((ModelBase)this, 0, 0);
this.Base.addBox(0.0f, 0.0f, 0.0f, 16, 4, 16);
this.Base.setRotationPoint(-8.0f, 8.0f, -8.0f);
this.Base.setTextureSize(64, 32);
this.Base.mirror = true;
this.setRotation(this.Base, 0.0f, 0.0f, 0.0f);
this.WheelMount1 = new ModelRenderer((ModelBase)this, 0, 30);
this.WheelMount1.addBox(0.0f, 0.0f, 0.0f, 14, 4, 4);
this.WheelMount1.setRotationPoint(-7.0f, 4.0f, 2.0f);
this.WheelMount1.setTextureSize(64, 32);
this.WheelMount1.mirror = true;
this.setRotation(this.WheelMount1, 0.0f, 0.0f, 0.0f);
this.Wheel2 = new ModelRenderer((ModelBase)this, 36, 20);
this.Wheel2.addBox(0.0f, 0.0f, 0.0f, 5, 4, 2);
this.Wheel2.setRotationPoint(1.0f, 6.0f, -1.0f);
this.Wheel2.setTextureSize(64, 32);
this.Wheel2.mirror = true;
this.setRotation(this.Wheel2, 0.0f, 0.0f, 0.0f);
this.WheelMount2 = new ModelRenderer((ModelBase)this, 0, 30);
this.WheelMount2.addBox(0.0f, 0.0f, 0.0f, 14, 4, 4);
this.WheelMount2.setRotationPoint(-7.0f, 4.0f, -6.0f);
this.WheelMount2.setTextureSize(64, 32);
this.WheelMount2.mirror = true;
this.setRotation(this.WheelMount2, 0.0f, 0.0f, 0.0f);
this.Wheel1 = new ModelRenderer((ModelBase)this, 36, 20);
this.Wheel1.addBox(0.0f, 0.0f, 0.0f, 5, 4, 2);
this.Wheel1.setRotationPoint(-6.0f, 6.0f, -1.0f);
this.Wheel1.setTextureSize(64, 32);
this.Wheel1.mirror = true;
this.setRotation(this.Wheel1, 0.0f, 0.0f, 0.0f);
}
public void render(float scale) {
this.RailGuard1.render(scale);
this.ArmMount.render(scale);
this.RailGuard2.render(scale);
this.Base.render(scale);
this.WheelMount1.render(scale);
this.Wheel2.render(scale);
this.WheelMount2.render(scale);
this.Wheel1.render(scale);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,117 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelCraneController
extends ModelBase {
ModelRenderer Base2;
ModelRenderer Base;
ModelRenderer ConnectorFront;
ModelRenderer Decoration1;
ModelRenderer Decoration2;
ModelRenderer Decoration3;
ModelRenderer Decoration4;
ModelRenderer ConnectorTop;
ModelRenderer ConnectorRight;
public ModelCraneController() {
this.textureWidth = 128;
this.textureHeight = 64;
this.Base2 = new ModelRenderer((ModelBase)this, 0, 24);
this.Base2.addBox(0.0f, 0.0f, 0.0f, 12, 4, 12);
this.Base2.setRotationPoint(-6.0f, 12.0f, -6.0f);
this.Base2.setTextureSize(128, 64);
this.Base2.mirror = true;
this.setRotation(this.Base2, 0.0f, 0.0f, 0.0f);
this.Base = new ModelRenderer((ModelBase)this, 0, 0);
this.Base.addBox(0.0f, 0.0f, 0.0f, 16, 8, 16);
this.Base.setRotationPoint(-8.0f, 16.0f, -8.0f);
this.Base.setTextureSize(128, 64);
this.Base.mirror = true;
this.setRotation(this.Base, 0.0f, 0.0f, 0.0f);
this.ConnectorFront = new ModelRenderer((ModelBase)this, 64, 0);
this.ConnectorFront.addBox(0.0f, 0.0f, 0.0f, 8, 8, 8);
this.ConnectorFront.setRotationPoint(-4.0f, 12.0f, 0.0f);
this.ConnectorFront.setTextureSize(128, 64);
this.ConnectorFront.mirror = true;
this.setRotation(this.ConnectorFront, 0.0f, 1.570796f, 0.0f);
this.Decoration1 = new ModelRenderer((ModelBase)this, 54, 24);
this.Decoration1.addBox(0.0f, 0.0f, 0.0f, 2, 1, 1);
this.Decoration1.setRotationPoint(2.0f, 15.0f, 6.0f);
this.Decoration1.setTextureSize(128, 64);
this.Decoration1.mirror = true;
this.setRotation(this.Decoration1, 0.0f, 0.0f, 0.0f);
this.Decoration2 = new ModelRenderer((ModelBase)this, 54, 24);
this.Decoration2.addBox(0.0f, 0.0f, 0.0f, 2, 1, 1);
this.Decoration2.setRotationPoint(-4.0f, 15.0f, 6.0f);
this.Decoration2.setTextureSize(128, 64);
this.Decoration2.mirror = true;
this.setRotation(this.Decoration2, 0.0f, 0.0f, 0.0f);
this.Decoration3 = new ModelRenderer((ModelBase)this, 48, 24);
this.Decoration3.addBox(0.0f, 0.0f, 0.0f, 1, 1, 2);
this.Decoration3.setRotationPoint(-7.0f, 15.0f, 2.0f);
this.Decoration3.setTextureSize(128, 64);
this.Decoration3.mirror = true;
this.setRotation(this.Decoration3, 0.0f, 0.0f, 0.0f);
this.Decoration4 = new ModelRenderer((ModelBase)this, 48, 24);
this.Decoration4.addBox(0.0f, 0.0f, 0.0f, 1, 1, 2);
this.Decoration4.setRotationPoint(-7.0f, 15.0f, -4.0f);
this.Decoration4.setTextureSize(128, 64);
this.Decoration4.mirror = true;
this.setRotation(this.Decoration4, 0.0f, 0.0f, 0.0f);
this.ConnectorTop = new ModelRenderer((ModelBase)this, 64, 0);
this.ConnectorTop.addBox(0.0f, 0.0f, 0.0f, 8, 8, 8);
this.ConnectorTop.setRotationPoint(-4.0f, 16.0f, -4.0f);
this.ConnectorTop.setTextureSize(128, 64);
this.ConnectorTop.mirror = true;
this.setRotation(this.ConnectorTop, 0.0f, 0.0f, -1.570796f);
this.ConnectorRight = new ModelRenderer((ModelBase)this, 64, 0);
this.ConnectorRight.addBox(0.0f, 0.0f, 0.0f, 8, 8, 8);
this.ConnectorRight.setRotationPoint(0.0f, 12.0f, -4.0f);
this.ConnectorRight.setTextureSize(128, 64);
this.ConnectorRight.mirror = true;
this.setRotation(this.ConnectorRight, 0.0f, 0.0f, 0.0f);
}
public void render(float scale, boolean connectEast, boolean connectNorth) {
this.Base2.setRotationPoint(-6.0f, 12.0f, -6.0f);
this.setRotation(this.Base2, 0.0f, 0.0f, 0.0f);
this.Base.setRotationPoint(-8.0f, 16.0f, -8.0f);
this.setRotation(this.Base, 0.0f, 0.0f, 0.0f);
this.Decoration1.setRotationPoint(2.0f, 15.0f, 6.0f);
this.setRotation(this.Decoration1, 0.0f, 0.0f, 0.0f);
this.Decoration2.setRotationPoint(-4.0f, 15.0f, 6.0f);
this.setRotation(this.Decoration2, 0.0f, 0.0f, 0.0f);
this.Decoration3.setRotationPoint(-7.0f, 15.0f, 2.0f);
this.setRotation(this.Decoration3, 0.0f, 0.0f, 0.0f);
this.Decoration4.setRotationPoint(-7.0f, 15.0f, -4.0f);
this.setRotation(this.Decoration4, 0.0f, 0.0f, 0.0f);
this.ConnectorTop.setRotationPoint(-4.0f, 16.0f, -4.0f);
this.setRotation(this.ConnectorTop, 0.0f, 0.0f, -1.570796f);
this.ConnectorFront.setRotationPoint(-4.0f, 11.99f, -0.01f);
this.setRotation(this.ConnectorFront, 0.0f, 1.570796f, 0.0f);
this.ConnectorRight.setRotationPoint(0.01f, 11.99f, -4.0f);
this.setRotation(this.ConnectorRight, 0.0f, 0.0f, 0.0f);
this.Base2.render(scale);
this.Base.render(scale);
this.ConnectorTop.render(scale);
if (connectEast) {
this.ConnectorFront.render(scale);
this.Decoration1.render(scale);
this.Decoration2.render(scale);
}
if (connectNorth) {
this.ConnectorRight.render(scale);
this.Decoration3.render(scale);
this.Decoration4.render(scale);
}
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,454 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelCraneRail
extends ModelBase {
ModelRenderer SegmentUBLeft;
ModelRenderer SegmentUFLeft;
ModelRenderer SegmentBFLeft;
ModelRenderer SegmentBBLeft;
ModelRenderer SegmentBLBack;
ModelRenderer SegmentLUBack;
ModelRenderer SegmentRUBack;
ModelRenderer SegmentBRBack;
ModelRenderer SegmentBLFront;
ModelRenderer SegmentLUFront;
ModelRenderer SegmentRUFront;
ModelRenderer SegmentBRFront;
ModelRenderer SegmentLBUp;
ModelRenderer SegmentRBUp;
ModelRenderer SegmentLFUp;
ModelRenderer SegmentRFUp;
ModelRenderer SegmentUBRight;
ModelRenderer SegmentBFRight;
ModelRenderer SegmentUFRight;
ModelRenderer SegmentBBRight;
ModelRenderer SegmentLFDown;
ModelRenderer SegmentLBDown;
ModelRenderer SegmentRBDown;
ModelRenderer SegmentRFDown;
ModelRenderer SegmentBFMid;
ModelRenderer SegmentUBMid;
ModelRenderer SegmentBBMid;
ModelRenderer SegmentUFMid;
ModelRenderer SegmentLBMid;
ModelRenderer SegmentLFMid;
ModelRenderer SegmentRBMid;
ModelRenderer SegmentRFMid;
ModelRenderer SegmentRUMid;
ModelRenderer SegmentBRMid;
ModelRenderer SegmentBLMid;
ModelRenderer SegmentLUMid;
ModelRenderer SegmentMidDiag1;
ModelRenderer SegmentMidDiag2;
ModelRenderer SegmentMidDiag3;
ModelRenderer SegmentMidDiag4;
ModelRenderer SegmentMidDiag5;
ModelRenderer SegmentMidDiag6;
ModelRenderer SegmentMidDiag7;
ModelRenderer SegmentMidDiag8;
ModelRenderer FootBottom;
ModelRenderer FootTop;
public ModelCraneRail() {
this.textureWidth = 64;
this.textureHeight = 32;
this.SegmentBLBack = new ModelRenderer((ModelBase)this, 10, 13);
this.SegmentBLBack.addBox(0.0f, 0.0f, 0.0f, 1, 1, 4);
this.SegmentBLBack.setRotationPoint(3.0f, 19.0f, 4.0f);
this.SegmentBLBack.setTextureSize(64, 32);
this.SegmentBLBack.mirror = true;
this.setRotation(this.SegmentBLBack, 0.0f, 0.0f, 0.0f);
this.SegmentLUBack = new ModelRenderer((ModelBase)this, 10, 13);
this.SegmentLUBack.addBox(0.0f, 0.0f, 0.0f, 1, 1, 4);
this.SegmentLUBack.setRotationPoint(3.0f, 12.0f, 4.0f);
this.SegmentLUBack.setTextureSize(64, 32);
this.SegmentLUBack.mirror = true;
this.setRotation(this.SegmentLUBack, 0.0f, 0.0f, 0.0f);
this.SegmentRUBack = new ModelRenderer((ModelBase)this, 10, 13);
this.SegmentRUBack.addBox(0.0f, 0.0f, 0.0f, 1, 1, 4);
this.SegmentRUBack.setRotationPoint(-4.0f, 12.0f, 4.0f);
this.SegmentRUBack.setTextureSize(64, 32);
this.SegmentRUBack.mirror = true;
this.setRotation(this.SegmentRUBack, 0.0f, 0.0f, 0.0f);
this.SegmentBRBack = new ModelRenderer((ModelBase)this, 10, 13);
this.SegmentBRBack.addBox(0.0f, 0.0f, 0.0f, 1, 1, 4);
this.SegmentBRBack.setRotationPoint(-4.0f, 19.0f, 4.0f);
this.SegmentBRBack.setTextureSize(64, 32);
this.SegmentBRBack.mirror = true;
this.setRotation(this.SegmentBRBack, 0.0f, 0.0f, 0.0f);
this.SegmentBLFront = new ModelRenderer((ModelBase)this, 10, 13);
this.SegmentBLFront.addBox(0.0f, 0.0f, 0.0f, 1, 1, 4);
this.SegmentBLFront.setRotationPoint(3.0f, 19.0f, -8.0f);
this.SegmentBLFront.setTextureSize(64, 32);
this.SegmentBLFront.mirror = true;
this.setRotation(this.SegmentBLFront, 0.0f, 0.0f, 0.0f);
this.SegmentLUFront = new ModelRenderer((ModelBase)this, 10, 13);
this.SegmentLUFront.addBox(0.0f, 0.0f, 0.0f, 1, 1, 4);
this.SegmentLUFront.setRotationPoint(3.0f, 12.0f, -8.0f);
this.SegmentLUFront.setTextureSize(64, 32);
this.SegmentLUFront.mirror = true;
this.setRotation(this.SegmentLUFront, 0.0f, 0.0f, 0.0f);
this.SegmentRUFront = new ModelRenderer((ModelBase)this, 10, 13);
this.SegmentRUFront.addBox(0.0f, 0.0f, 0.0f, 1, 1, 4);
this.SegmentRUFront.setRotationPoint(-4.0f, 12.0f, -8.0f);
this.SegmentRUFront.setTextureSize(64, 32);
this.SegmentRUFront.mirror = true;
this.setRotation(this.SegmentRUFront, 0.0f, 0.0f, 0.0f);
this.SegmentBRFront = new ModelRenderer((ModelBase)this, 10, 13);
this.SegmentBRFront.addBox(0.0f, 0.0f, 0.0f, 1, 1, 4);
this.SegmentBRFront.setRotationPoint(-4.0f, 19.0f, -8.0f);
this.SegmentBRFront.setTextureSize(64, 32);
this.SegmentBRFront.mirror = true;
this.setRotation(this.SegmentBRFront, 0.0f, 0.0f, 0.0f);
this.SegmentLBUp = new ModelRenderer((ModelBase)this, 20, 13);
this.SegmentLBUp.addBox(0.0f, 0.0f, 0.0f, 1, 4, 1);
this.SegmentLBUp.setRotationPoint(3.0f, 8.0f, 3.0f);
this.SegmentLBUp.setTextureSize(64, 32);
this.SegmentLBUp.mirror = true;
this.setRotation(this.SegmentLBUp, 0.0f, 0.0f, 0.0f);
this.SegmentRBUp = new ModelRenderer((ModelBase)this, 20, 13);
this.SegmentRBUp.addBox(0.0f, 0.0f, 0.0f, 1, 4, 1);
this.SegmentRBUp.setRotationPoint(-4.0f, 8.0f, 3.0f);
this.SegmentRBUp.setTextureSize(64, 32);
this.SegmentRBUp.mirror = true;
this.setRotation(this.SegmentRBUp, 0.0f, 0.0f, 0.0f);
this.SegmentLFUp = new ModelRenderer((ModelBase)this, 20, 13);
this.SegmentLFUp.addBox(0.0f, 0.0f, 0.0f, 1, 4, 1);
this.SegmentLFUp.setRotationPoint(3.0f, 8.0f, -4.0f);
this.SegmentLFUp.setTextureSize(64, 32);
this.SegmentLFUp.mirror = true;
this.setRotation(this.SegmentLFUp, 0.0f, 0.0f, 0.0f);
this.SegmentRFUp = new ModelRenderer((ModelBase)this, 20, 13);
this.SegmentRFUp.addBox(0.0f, 0.0f, 0.0f, 1, 4, 1);
this.SegmentRFUp.setRotationPoint(-4.0f, 8.0f, -4.0f);
this.SegmentRFUp.setTextureSize(64, 32);
this.SegmentRFUp.mirror = true;
this.setRotation(this.SegmentRFUp, 0.0f, 0.0f, 0.0f);
this.SegmentUBRight = new ModelRenderer((ModelBase)this, 0, 13);
this.SegmentUBRight.addBox(0.0f, 0.0f, 0.0f, 4, 1, 1);
this.SegmentUBRight.setRotationPoint(-8.0f, 12.0f, 3.0f);
this.SegmentUBRight.setTextureSize(64, 32);
this.SegmentUBRight.mirror = true;
this.setRotation(this.SegmentUBRight, 0.0f, 0.0f, 0.0f);
this.SegmentBFRight = new ModelRenderer((ModelBase)this, 0, 13);
this.SegmentBFRight.addBox(0.0f, 0.0f, 0.0f, 4, 1, 1);
this.SegmentBFRight.setRotationPoint(-8.0f, 19.0f, -4.0f);
this.SegmentBFRight.setTextureSize(64, 32);
this.SegmentBFRight.mirror = true;
this.setRotation(this.SegmentBFRight, 0.0f, 0.0f, 0.0f);
this.SegmentUFRight = new ModelRenderer((ModelBase)this, 0, 13);
this.SegmentUFRight.addBox(0.0f, 0.0f, 0.0f, 4, 1, 1);
this.SegmentUFRight.setRotationPoint(-8.0f, 12.0f, -4.0f);
this.SegmentUFRight.setTextureSize(64, 32);
this.SegmentUFRight.mirror = true;
this.setRotation(this.SegmentUFRight, 0.0f, 0.0f, 0.0f);
this.SegmentBBRight = new ModelRenderer((ModelBase)this, 0, 13);
this.SegmentBBRight.addBox(0.0f, 0.0f, 0.0f, 4, 1, 1);
this.SegmentBBRight.setRotationPoint(-8.0f, 19.0f, 3.0f);
this.SegmentBBRight.setTextureSize(64, 32);
this.SegmentBBRight.mirror = true;
this.setRotation(this.SegmentBBRight, 0.0f, 0.0f, 0.0f);
this.SegmentLFDown = new ModelRenderer((ModelBase)this, 20, 13);
this.SegmentLFDown.addBox(0.0f, 0.0f, 0.0f, 1, 4, 1);
this.SegmentLFDown.setRotationPoint(3.0f, 20.0f, -4.0f);
this.SegmentLFDown.setTextureSize(64, 32);
this.SegmentLFDown.mirror = true;
this.setRotation(this.SegmentLFDown, 0.0f, 0.0f, 0.0f);
this.SegmentLBDown = new ModelRenderer((ModelBase)this, 20, 13);
this.SegmentLBDown.addBox(0.0f, 0.0f, 0.0f, 1, 4, 1);
this.SegmentLBDown.setRotationPoint(3.0f, 20.0f, 3.0f);
this.SegmentLBDown.setTextureSize(64, 32);
this.SegmentLBDown.mirror = true;
this.setRotation(this.SegmentLBDown, 0.0f, 0.0f, 0.0f);
this.SegmentRBDown = new ModelRenderer((ModelBase)this, 20, 13);
this.SegmentRBDown.addBox(0.0f, 0.0f, 0.0f, 1, 4, 1);
this.SegmentRBDown.setRotationPoint(-4.0f, 20.0f, 3.0f);
this.SegmentRBDown.setTextureSize(64, 32);
this.SegmentRBDown.mirror = true;
this.setRotation(this.SegmentRBDown, 0.0f, 0.0f, 0.0f);
this.FootTop = new ModelRenderer((ModelBase)this, 24, 0);
this.FootTop.addBox(0.0f, 0.0f, 0.0f, 10, 2, 10);
this.FootTop.setRotationPoint(-5.0f, 20.0f, -5.0f);
this.FootTop.setTextureSize(64, 32);
this.FootTop.mirror = true;
this.setRotation(this.FootTop, 0.0f, 0.0f, 0.0f);
this.SegmentRFDown = new ModelRenderer((ModelBase)this, 20, 13);
this.SegmentRFDown.addBox(0.0f, 0.0f, 0.0f, 1, 4, 1);
this.SegmentRFDown.setRotationPoint(-4.0f, 20.0f, -4.0f);
this.SegmentRFDown.setTextureSize(64, 32);
this.SegmentRFDown.mirror = true;
this.setRotation(this.SegmentRFDown, 0.0f, 0.0f, 0.0f);
this.FootBottom = new ModelRenderer((ModelBase)this, 0, 18);
this.FootBottom.addBox(0.0f, 0.0f, 0.0f, 12, 2, 12);
this.FootBottom.setRotationPoint(-6.0f, 22.0f, -6.0f);
this.FootBottom.setTextureSize(64, 32);
this.FootBottom.mirror = true;
this.setRotation(this.FootBottom, 0.0f, 0.0f, 0.0f);
this.SegmentBFMid = new ModelRenderer((ModelBase)this, 30, 12);
this.SegmentBFMid.addBox(0.0f, 0.0f, 0.0f, 8, 1, 1);
this.SegmentBFMid.setRotationPoint(-4.0f, 19.0f, -4.0f);
this.SegmentBFMid.setTextureSize(64, 32);
this.SegmentBFMid.mirror = true;
this.setRotation(this.SegmentBFMid, 0.0f, 0.0f, 0.0f);
this.SegmentUBMid = new ModelRenderer((ModelBase)this, 30, 12);
this.SegmentUBMid.addBox(0.0f, 0.0f, 0.0f, 8, 1, 1);
this.SegmentUBMid.setRotationPoint(-4.0f, 12.0f, 3.0f);
this.SegmentUBMid.setTextureSize(64, 32);
this.SegmentUBMid.mirror = true;
this.setRotation(this.SegmentUBMid, 0.0f, 0.0f, 0.0f);
this.SegmentBBMid = new ModelRenderer((ModelBase)this, 30, 12);
this.SegmentBBMid.addBox(0.0f, 0.0f, 0.0f, 8, 1, 1);
this.SegmentBBMid.setRotationPoint(-4.0f, 19.0f, 3.0f);
this.SegmentBBMid.setTextureSize(64, 32);
this.SegmentBBMid.mirror = true;
this.setRotation(this.SegmentBBMid, 0.0f, 0.0f, 0.0f);
this.SegmentUFMid = new ModelRenderer((ModelBase)this, 30, 12);
this.SegmentUFMid.addBox(0.0f, 0.0f, 0.0f, 8, 1, 1);
this.SegmentUFMid.setRotationPoint(-4.0f, 12.0f, -4.0f);
this.SegmentUFMid.setTextureSize(64, 32);
this.SegmentUFMid.mirror = true;
this.setRotation(this.SegmentUFMid, 0.0f, 0.0f, 0.0f);
this.SegmentLBMid = new ModelRenderer((ModelBase)this, 48, 19);
this.SegmentLBMid.addBox(0.0f, 0.0f, 0.0f, 1, 6, 1);
this.SegmentLBMid.setRotationPoint(3.0f, 13.0f, 3.0f);
this.SegmentLBMid.setTextureSize(64, 32);
this.SegmentLBMid.mirror = true;
this.setRotation(this.SegmentLBMid, 0.0f, 0.0f, 0.0f);
this.SegmentLFMid = new ModelRenderer((ModelBase)this, 48, 19);
this.SegmentLFMid.addBox(0.0f, 0.0f, 0.0f, 1, 6, 1);
this.SegmentLFMid.setRotationPoint(3.0f, 13.0f, -4.0f);
this.SegmentLFMid.setTextureSize(64, 32);
this.SegmentLFMid.mirror = true;
this.setRotation(this.SegmentLFMid, 0.0f, 0.0f, 0.0f);
this.SegmentRBMid = new ModelRenderer((ModelBase)this, 48, 19);
this.SegmentRBMid.addBox(0.0f, 0.0f, 0.0f, 1, 6, 1);
this.SegmentRBMid.setRotationPoint(-4.0f, 13.0f, 3.0f);
this.SegmentRBMid.setTextureSize(64, 32);
this.SegmentRBMid.mirror = true;
this.setRotation(this.SegmentRBMid, 0.0f, 0.0f, 0.0f);
this.SegmentRFMid = new ModelRenderer((ModelBase)this, 48, 19);
this.SegmentRFMid.addBox(0.0f, 0.0f, 0.0f, 1, 6, 1);
this.SegmentRFMid.setRotationPoint(-4.0f, 13.0f, -4.0f);
this.SegmentRFMid.setTextureSize(64, 32);
this.SegmentRFMid.mirror = true;
this.setRotation(this.SegmentRFMid, 0.0f, 0.0f, 0.0f);
this.SegmentMidDiag4 = new ModelRenderer((ModelBase)this, 0, 0);
this.SegmentMidDiag4.addBox(0.0f, 0.0f, 0.0f, 1, 1, 10);
this.SegmentMidDiag4.setRotationPoint(-3.99f, 12.0f, -3.0f);
this.SegmentMidDiag4.setTextureSize(64, 32);
this.SegmentMidDiag4.mirror = true;
this.setRotation(this.SegmentMidDiag4, -0.7853982f, 0.0f, 0.0f);
this.SegmentRUMid = new ModelRenderer((ModelBase)this, 48, 12);
this.SegmentRUMid.addBox(0.0f, 0.0f, 0.0f, 1, 1, 6);
this.SegmentRUMid.setRotationPoint(-4.0f, 12.0f, -3.0f);
this.SegmentRUMid.setTextureSize(64, 32);
this.SegmentRUMid.mirror = true;
this.setRotation(this.SegmentRUMid, 0.0f, 0.0f, 0.0f);
this.SegmentBRMid = new ModelRenderer((ModelBase)this, 48, 12);
this.SegmentBRMid.addBox(0.0f, 0.0f, 0.0f, 1, 1, 6);
this.SegmentBRMid.setRotationPoint(-4.0f, 19.0f, -3.0f);
this.SegmentBRMid.setTextureSize(64, 32);
this.SegmentBRMid.mirror = true;
this.setRotation(this.SegmentBRMid, 0.0f, 0.0f, 0.0f);
this.SegmentBLMid = new ModelRenderer((ModelBase)this, 48, 12);
this.SegmentBLMid.addBox(0.0f, 0.0f, 0.0f, 1, 1, 6);
this.SegmentBLMid.setRotationPoint(3.0f, 19.0f, -3.0f);
this.SegmentBLMid.setTextureSize(64, 32);
this.SegmentBLMid.mirror = true;
this.setRotation(this.SegmentBLMid, 0.0f, 0.0f, 0.0f);
this.SegmentLUMid = new ModelRenderer((ModelBase)this, 48, 12);
this.SegmentLUMid.addBox(0.0f, 0.0f, 0.0f, 1, 1, 6);
this.SegmentLUMid.setRotationPoint(3.0f, 12.0f, -3.0f);
this.SegmentLUMid.setTextureSize(64, 32);
this.SegmentLUMid.mirror = true;
this.setRotation(this.SegmentLUMid, 0.0f, 0.0f, 0.0f);
this.SegmentMidDiag3 = new ModelRenderer((ModelBase)this, 0, 0);
this.SegmentMidDiag3.addBox(0.0f, 0.0f, 0.0f, 1, 1, 10);
this.SegmentMidDiag3.setRotationPoint(-4.0f, 19.0f, -4.0f);
this.SegmentMidDiag3.setTextureSize(64, 32);
this.SegmentMidDiag3.mirror = true;
this.setRotation(this.SegmentMidDiag3, 0.7853982f, 0.0f, 0.0f);
this.SegmentMidDiag7 = new ModelRenderer((ModelBase)this, 0, 0);
this.SegmentMidDiag7.addBox(0.0f, 0.0f, 0.0f, 1, 1, 10);
this.SegmentMidDiag7.setRotationPoint(-2.99f, 12.0f, 4.0f);
this.SegmentMidDiag7.setTextureSize(64, 32);
this.SegmentMidDiag7.mirror = true;
this.setRotation(this.SegmentMidDiag7, -0.7853982f, 1.570796f, 0.0f);
this.SegmentMidDiag8 = new ModelRenderer((ModelBase)this, 0, 0);
this.SegmentMidDiag8.addBox(0.0f, 0.0f, 0.0f, 1, 1, 10);
this.SegmentMidDiag8.setRotationPoint(-4.0f, 19.0f, 4.0f);
this.SegmentMidDiag8.setTextureSize(64, 32);
this.SegmentMidDiag8.mirror = true;
this.setRotation(this.SegmentMidDiag8, 0.7853982f, 1.570796f, 0.0f);
this.SegmentMidDiag1 = new ModelRenderer((ModelBase)this, 0, 0);
this.SegmentMidDiag1.addBox(0.0f, 0.0f, 0.0f, 1, 1, 10);
this.SegmentMidDiag1.setRotationPoint(3.0f, 19.0f, -4.0f);
this.SegmentMidDiag1.setTextureSize(64, 32);
this.SegmentMidDiag1.mirror = true;
this.setRotation(this.SegmentMidDiag1, 0.7853982f, 0.0f, 0.0f);
this.SegmentMidDiag2 = new ModelRenderer((ModelBase)this, 0, 0);
this.SegmentMidDiag2.addBox(0.0f, 0.0f, 0.0f, 1, 1, 10);
this.SegmentMidDiag2.setRotationPoint(3.01f, 12.0f, -3.0f);
this.SegmentMidDiag2.setTextureSize(64, 32);
this.SegmentMidDiag2.mirror = true;
this.setRotation(this.SegmentMidDiag2, -0.7853982f, 0.0f, 0.0f);
this.SegmentMidDiag6 = new ModelRenderer((ModelBase)this, 0, 0);
this.SegmentMidDiag6.addBox(0.0f, 0.0f, 0.0f, 1, 1, 10);
this.SegmentMidDiag6.setRotationPoint(-4.0f, 19.0f, -3.0f);
this.SegmentMidDiag6.setTextureSize(64, 32);
this.SegmentMidDiag6.mirror = true;
this.setRotation(this.SegmentMidDiag6, 0.7853982f, 1.570796f, 0.0f);
this.SegmentMidDiag5 = new ModelRenderer((ModelBase)this, 0, 0);
this.SegmentMidDiag5.addBox(0.0f, 0.0f, 0.0f, 1, 1, 10);
this.SegmentMidDiag5.setRotationPoint(-2.99f, 12.0f, -3.0f);
this.SegmentMidDiag5.setTextureSize(64, 32);
this.SegmentMidDiag5.mirror = true;
this.setRotation(this.SegmentMidDiag5, -0.7853982f, 1.570796f, 0.0f);
this.SegmentUBLeft = new ModelRenderer((ModelBase)this, 0, 13);
this.SegmentUBLeft.addBox(0.0f, 0.0f, 0.0f, 4, 1, 1);
this.SegmentUBLeft.setRotationPoint(4.0f, 12.0f, 3.0f);
this.SegmentUBLeft.setTextureSize(64, 32);
this.SegmentUBLeft.mirror = true;
this.setRotation(this.SegmentUBLeft, 0.0f, 0.0f, 0.0f);
this.SegmentUFLeft = new ModelRenderer((ModelBase)this, 0, 13);
this.SegmentUFLeft.addBox(0.0f, 0.0f, 0.0f, 4, 1, 1);
this.SegmentUFLeft.setRotationPoint(4.0f, 12.0f, -4.0f);
this.SegmentUFLeft.setTextureSize(64, 32);
this.SegmentUFLeft.mirror = true;
this.setRotation(this.SegmentUFLeft, 0.0f, 0.0f, 0.0f);
this.SegmentBFLeft = new ModelRenderer((ModelBase)this, 0, 13);
this.SegmentBFLeft.addBox(0.0f, 0.0f, 0.0f, 4, 1, 1);
this.SegmentBFLeft.setRotationPoint(4.0f, 19.0f, -4.0f);
this.SegmentBFLeft.setTextureSize(64, 32);
this.SegmentBFLeft.mirror = true;
this.setRotation(this.SegmentBFLeft, 0.0f, 0.0f, 0.0f);
this.SegmentBBLeft = new ModelRenderer((ModelBase)this, 0, 13);
this.SegmentBBLeft.addBox(0.0f, 0.0f, 0.0f, 4, 1, 1);
this.SegmentBBLeft.setRotationPoint(4.0f, 19.0f, 3.0f);
this.SegmentBBLeft.setTextureSize(64, 32);
this.SegmentBBLeft.mirror = true;
this.setRotation(this.SegmentBBLeft, 0.0f, 0.0f, 0.0f);
this.fixPositions();
}
public void fixPositions() {
this.SegmentBLBack.setRotationPoint(3.0f, 19.0f, 4.0f);
this.SegmentLUBack.setRotationPoint(3.0f, 12.0f, 4.0f);
this.SegmentRUBack.setRotationPoint(-4.0f, 12.0f, 4.0f);
this.SegmentBRBack.setRotationPoint(-4.0f, 19.0f, 4.0f);
this.SegmentBLFront.setRotationPoint(3.0f, 19.0f, -8.0f);
this.SegmentLUFront.setRotationPoint(3.0f, 12.0f, -8.0f);
this.SegmentRUFront.setRotationPoint(-4.0f, 12.0f, -8.0f);
this.SegmentBRFront.setRotationPoint(-4.0f, 19.0f, -8.0f);
this.SegmentLBUp.setRotationPoint(3.0f, 8.0f, 3.0f);
this.SegmentRBUp.setRotationPoint(-4.0f, 8.0f, 3.0f);
this.SegmentLFUp.setRotationPoint(3.0f, 8.0f, -4.0f);
this.SegmentRFUp.setRotationPoint(-4.0f, 8.0f, -4.0f);
this.SegmentUBRight.setRotationPoint(-8.0f, 12.0f, 3.0f);
this.SegmentBFRight.setRotationPoint(-8.0f, 19.0f, -4.0f);
this.SegmentUFRight.setRotationPoint(-8.0f, 12.0f, -4.0f);
this.SegmentBBRight.setRotationPoint(-8.0f, 19.0f, 3.0f);
this.SegmentLFDown.setRotationPoint(3.0f, 20.0f, -4.0f);
this.SegmentLBDown.setRotationPoint(3.0f, 20.0f, 3.0f);
this.SegmentRBDown.setRotationPoint(-4.0f, 20.0f, 3.0f);
this.SegmentRFDown.setRotationPoint(-4.0f, 20.0f, -4.0f);
this.SegmentBFMid.setRotationPoint(-4.0f, 19.0f, -4.0f);
this.SegmentUBMid.setRotationPoint(-4.0f, 12.0f, 3.0f);
this.SegmentBBMid.setRotationPoint(-4.0f, 19.0f, 3.0f);
this.SegmentUFMid.setRotationPoint(-4.0f, 12.0f, -4.0f);
this.SegmentLBMid.setRotationPoint(3.0f, 13.0f, 3.0f);
this.SegmentLFMid.setRotationPoint(3.0f, 13.0f, -4.0f);
this.SegmentRBMid.setRotationPoint(-4.0f, 13.0f, 3.0f);
this.SegmentRFMid.setRotationPoint(-4.0f, 13.0f, -4.0f);
this.SegmentRUMid.setRotationPoint(-4.0f, 12.0f, -3.0f);
this.SegmentBRMid.setRotationPoint(-4.0f, 19.0f, -3.0f);
this.SegmentBLMid.setRotationPoint(3.0f, 19.0f, -3.0f);
this.SegmentLUMid.setRotationPoint(3.0f, 12.0f, -3.0f);
this.SegmentMidDiag1.setRotationPoint(2.99f, 19.1f, -4.0f);
this.SegmentMidDiag2.setRotationPoint(2.99f, 12.0f, -3.1f);
this.SegmentMidDiag3.setRotationPoint(-3.99f, 19.1f, -4.0f);
this.SegmentMidDiag4.setRotationPoint(-3.99f, 12.0f, -3.1f);
this.SegmentMidDiag5.setRotationPoint(-3.1f, 12.0f, -2.99f);
this.SegmentMidDiag6.setRotationPoint(-4.0f, 19.1f, -2.99f);
this.SegmentMidDiag7.setRotationPoint(-3.1f, 12.0f, 3.99f);
this.SegmentMidDiag8.setRotationPoint(-4.0f, 19.0f, 3.99f);
this.SegmentUBLeft.setRotationPoint(4.0f, 12.0f, 3.0f);
this.SegmentUFLeft.setRotationPoint(4.0f, 12.0f, -4.0f);
this.SegmentBFLeft.setRotationPoint(4.0f, 19.0f, -4.0f);
this.SegmentBBLeft.setRotationPoint(4.0f, 19.0f, 3.0f);
}
public void render(boolean up, boolean down, boolean left, boolean right, boolean front, boolean back, boolean foot) {
float scale = 0.0625f;
if (up) {
this.SegmentLBUp.render(scale);
this.SegmentRBUp.render(scale);
this.SegmentLFUp.render(scale);
this.SegmentRFUp.render(scale);
}
if (down) {
this.SegmentLFDown.render(scale);
this.SegmentLBDown.render(scale);
this.SegmentRBDown.render(scale);
this.SegmentRFDown.render(scale);
}
if (left) {
this.SegmentUBLeft.render(scale);
this.SegmentUFLeft.render(scale);
this.SegmentBFLeft.render(scale);
this.SegmentBBLeft.render(scale);
}
if (right) {
this.SegmentUBRight.render(scale);
this.SegmentBFRight.render(scale);
this.SegmentUFRight.render(scale);
this.SegmentBBRight.render(scale);
}
if (front) {
this.SegmentBLFront.render(scale);
this.SegmentLUFront.render(scale);
this.SegmentRUFront.render(scale);
this.SegmentBRFront.render(scale);
}
if (back) {
this.SegmentBLBack.render(scale);
this.SegmentLUBack.render(scale);
this.SegmentRUBack.render(scale);
this.SegmentBRBack.render(scale);
}
if (foot) {
this.FootBottom.render(scale);
this.FootTop.render(scale);
}
this.SegmentBFMid.render(scale);
this.SegmentUBMid.render(scale);
this.SegmentBBMid.render(scale);
this.SegmentUFMid.render(scale);
this.SegmentLBMid.render(scale);
this.SegmentLFMid.render(scale);
this.SegmentRBMid.render(scale);
this.SegmentRFMid.render(scale);
this.SegmentRUMid.render(scale);
this.SegmentBRMid.render(scale);
this.SegmentBLMid.render(scale);
this.SegmentLUMid.render(scale);
this.SegmentMidDiag1.render(scale);
this.SegmentMidDiag2.render(scale);
this.SegmentMidDiag3.render(scale);
this.SegmentMidDiag4.render(scale);
this.SegmentMidDiag5.render(scale);
this.SegmentMidDiag6.render(scale);
this.SegmentMidDiag7.render(scale);
this.SegmentMidDiag8.render(scale);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,103 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelDropBox
extends ModelBase {
ModelRenderer Left;
ModelRenderer Top;
ModelRenderer Front;
ModelRenderer LeftB;
ModelRenderer Back;
ModelRenderer Right;
ModelRenderer RightB;
ModelRenderer Bottom;
ModelRenderer Back3;
ModelRenderer Back2;
public ModelDropBox() {
this.textureWidth = 128;
this.textureHeight = 128;
this.Left = new ModelRenderer((ModelBase)this, 33, 43);
this.Left.addBox(7.0f, -10.0f, -8.0f, 1, 7, 15);
this.Left.setRotationPoint(0.0f, 19.0f, 0.0f);
this.Left.setTextureSize(128, 128);
this.Left.mirror = true;
this.setRotation(this.Left, 0.0f, 0.0f, 0.0f);
this.Top = new ModelRenderer((ModelBase)this, 0, 65);
this.Top.addBox(-7.0f, -11.0f, -7.0f, 14, 1, 14);
this.Top.setRotationPoint(0.0f, 19.0f, 0.0f);
this.Top.setTextureSize(128, 128);
this.Top.mirror = true;
this.setRotation(this.Top, 0.0f, 0.0f, 0.0f);
this.Front = new ModelRenderer((ModelBase)this, 0, 33);
this.Front.addBox(-8.0f, -4.0f, -7.5f, 16, 5, 1);
this.Front.setRotationPoint(0.0f, 19.0f, 0.0f);
this.Front.setTextureSize(128, 128);
this.Front.mirror = true;
this.setRotation(this.Front, 0.5235988f, 0.0f, 0.0f);
this.LeftB = new ModelRenderer((ModelBase)this, 36, 21);
this.LeftB.addBox(7.0f, -3.0f, -6.0f, 1, 8, 13);
this.LeftB.setRotationPoint(0.0f, 19.0f, 0.0f);
this.LeftB.setTextureSize(128, 128);
this.LeftB.mirror = true;
this.setRotation(this.LeftB, 0.0f, 0.0f, 0.0f);
this.Back = new ModelRenderer((ModelBase)this, 0, 96);
this.Back.addBox(-5.0f, -8.0f, 4.0f, 10, 10, 4);
this.Back.setRotationPoint(0.0f, 19.0f, 0.0f);
this.Back.setTextureSize(128, 128);
this.Back.mirror = true;
this.setRotation(this.Back, 0.0f, 0.0f, 0.0f);
this.Right = new ModelRenderer((ModelBase)this, 0, 42);
this.Right.addBox(-8.0f, -10.0f, -8.0f, 1, 7, 15);
this.Right.setRotationPoint(0.0f, 19.0f, 0.0f);
this.Right.setTextureSize(128, 128);
this.Right.mirror = true;
this.setRotation(this.Right, 0.0f, 0.0f, 0.0f);
this.RightB = new ModelRenderer((ModelBase)this, 36, 0);
this.RightB.addBox(-8.0f, -3.0f, -6.0f, 1, 8, 13);
this.RightB.setRotationPoint(0.0f, 19.0f, 0.0f);
this.RightB.setTextureSize(128, 128);
this.RightB.mirror = true;
this.setRotation(this.RightB, 0.0f, 0.0f, 0.0f);
this.Bottom = new ModelRenderer((ModelBase)this, 0, 81);
this.Bottom.addBox(-7.0f, 4.0f, -6.0f, 14, 1, 13);
this.Bottom.setRotationPoint(0.0f, 19.0f, 0.0f);
this.Bottom.setTextureSize(128, 128);
this.Bottom.mirror = true;
this.setRotation(this.Bottom, 0.0f, 0.0f, 0.0f);
this.Back3 = new ModelRenderer((ModelBase)this, 0, 23);
this.Back3.addBox(-7.0f, -10.0f, -9.0f, 14, 8, 1);
this.Back3.setRotationPoint(0.0f, 19.0f, 0.0f);
this.Back3.setTextureSize(128, 128);
this.Back3.mirror = true;
this.setRotation(this.Back3, -0.1919862f, 0.0f, 0.0f);
this.Back2 = new ModelRenderer((ModelBase)this, 0, 7);
this.Back2.addBox(-7.0f, -10.0f, 3.0f, 14, 14, 1);
this.Back2.setRotationPoint(0.0f, 19.0f, 0.0f);
this.Back2.setTextureSize(128, 128);
this.Back2.mirror = true;
this.setRotation(this.Back2, 0.0f, 0.0f, 0.0f);
}
public void render(float f5) {
this.Left.render(f5);
this.Top.render(f5);
this.Front.render(f5);
this.LeftB.render(f5);
this.Back.render(f5);
this.Right.render(f5);
this.RightB.render(f5);
this.Bottom.render(f5);
this.Back.render(f5);
this.Back.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,142 @@
package assemblyline.client.model;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class ModelHelper {
private static int gTexWidth = 64;
private static int gTexHeight = 32;
private static int sTexWidth = 64;
private static int sTexHeight = 32;
private static int texOffsetX = 0;
private static int texOffsetY = 0;
private static float texScale = 16.0f;
private static boolean clip = false;
private static void drawQuadRaw(Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, ForgeDirection side) {
float yMax;
float xMax;
GL11.glBegin((int)7);
float quadWidth = 1.0f;
float quadHeight = 1.0f;
float subWidth = (float)sTexWidth / (float)gTexWidth;
float subHeight = (float)sTexHeight / (float)gTexHeight;
float xMin = (float)texOffsetX / (float)sTexWidth * subWidth;
float yMin = (float)texOffsetY / (float)sTexHeight * subHeight;
float subSqX = 0.0f;
float subSqY = 0.0f;
float subSqWidth = 0.25f * ((float)sTexWidth / (float)gTexWidth);
float subSqHeight = 0.5f * ((float)sTexHeight / (float)gTexHeight);
switch (side) {
case UP: {
subSqX = 2.0f * subSqWidth;
subSqY = 0.0f;
quadWidth = (float)Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float)Math.abs(v4.zCoord - v1.zCoord);
break;
}
case DOWN: {
subSqX = 1.0f * subSqWidth;
subSqY = 0.0f;
quadWidth = (float)Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float)Math.abs(v4.zCoord - v1.zCoord);
break;
}
case EAST: {
subSqX = 0.0f;
subSqY = subSqHeight;
quadWidth = (float)Math.abs(v2.zCoord - v1.zCoord);
quadHeight = (float)Math.abs(v4.yCoord - v1.yCoord);
break;
}
case WEST: {
subSqX = 2.0f * subSqWidth;
subSqY = subSqHeight;
quadWidth = (float)Math.abs(v2.zCoord - v1.zCoord);
quadHeight = (float)Math.abs(v4.yCoord - v1.yCoord);
break;
}
case SOUTH: {
subSqX = subSqWidth;
subSqY = subSqHeight;
quadWidth = (float)Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float)Math.abs(v4.yCoord - v1.yCoord);
break;
}
case NORTH: {
subSqX = 3.0f * subSqWidth;
subSqY = subSqHeight;
quadWidth = (float)Math.abs(v2.xCoord - v1.xCoord);
quadHeight = (float)Math.abs(v4.yCoord - v1.yCoord);
break;
}
}
xMin += subSqX;
yMin += subSqY;
if (clip) {
xMax = (xMin += (1.0f - quadWidth) * subSqWidth) + subSqWidth * quadWidth;
yMax = (yMin += (1.0f - quadHeight) * subSqHeight) + subSqHeight * quadHeight;
} else {
xMax = xMin + subSqWidth;
yMax = yMin + subSqHeight;
}
GL11.glTexCoord2f((float)xMin, (float)yMin);
GL11.glVertex3d((double)v1.xCoord, (double)v1.yCoord, (double)v1.zCoord);
GL11.glTexCoord2f((float)xMax, (float)yMin);
GL11.glVertex3d((double)v2.xCoord, (double)v2.yCoord, (double)v2.zCoord);
GL11.glTexCoord2f((float)xMax, (float)yMax);
GL11.glVertex3d((double)v3.xCoord, (double)v3.yCoord, (double)v3.zCoord);
GL11.glTexCoord2f((float)xMin, (float)yMax);
GL11.glVertex3d((double)v4.xCoord, (double)v4.yCoord, (double)v4.zCoord);
GL11.glEnd();
}
private static void drawCuboidRaw(Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4, Vec3 v5, Vec3 v6, Vec3 v7, Vec3 v8) {
ModelHelper.drawQuadRaw(v1, v2, v3, v4, ForgeDirection.UP);
ModelHelper.drawQuadRaw(v7, v6, v3, v2, ForgeDirection.EAST);
ModelHelper.drawQuadRaw(v5, v6, v7, v8, ForgeDirection.DOWN);
ModelHelper.drawQuadRaw(v5, v8, v1, v4, ForgeDirection.WEST);
ModelHelper.drawQuadRaw(v6, v5, v4, v3, ForgeDirection.NORTH);
ModelHelper.drawQuadRaw(v8, v7, v2, v1, ForgeDirection.SOUTH);
}
public static void drawCuboid(float xOffset, float yOffset, float zOffset, float xSize, float ySize, float zSize) {
float x = xOffset;
float y = yOffset;
float z = zOffset;
float x2 = x + xSize;
float y2 = y + ySize;
float z2 = z + zSize;
Vec3 v1 = Vec3.createVectorHelper((double)x, (double)y2, (double)z2);
Vec3 v2 = Vec3.createVectorHelper((double)x2, (double)y2, (double)z2);
Vec3 v3 = Vec3.createVectorHelper((double)x2, (double)y2, (double)z);
Vec3 v4 = Vec3.createVectorHelper((double)x, (double)y2, (double)z);
Vec3 v5 = Vec3.createVectorHelper((double)x, (double)y, (double)z);
Vec3 v6 = Vec3.createVectorHelper((double)x2, (double)y, (double)z);
Vec3 v7 = Vec3.createVectorHelper((double)x2, (double)y, (double)z2);
Vec3 v8 = Vec3.createVectorHelper((double)x, (double)y, (double)z2);
ModelHelper.drawCuboidRaw(v1, v2, v3, v4, v5, v6, v7, v8);
}
public static void setTextureOffset(int xOffset, int yOffset) {
texOffsetX = xOffset;
texOffsetY = yOffset;
}
public static void setGlobalTextureResolution(int width, int height) {
gTexWidth = width;
gTexHeight = height;
}
public static void setTextureSubResolution(int width, int height) {
sTexWidth = width;
sTexHeight = height;
}
public static void setTextureClip(boolean clip) {
ModelHelper.clip = clip;
}
}

View File

@ -0,0 +1,135 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelLaserDrill
extends ModelBase {
ModelRenderer Tip;
ModelRenderer Upper_plating;
ModelRenderer Middle_plating;
ModelRenderer Shape3_1;
ModelRenderer Shape3_2;
ModelRenderer Shape3_3;
ModelRenderer Shape3_4;
ModelRenderer LowerPlating_1;
ModelRenderer LowerPlating_2;
ModelRenderer Bump_1;
ModelRenderer Bump_2;
ModelRenderer Bump_3;
ModelRenderer Bump_4;
ModelRenderer Cross;
public ModelLaserDrill() {
this.textureWidth = 64;
this.textureHeight = 32;
this.Tip = new ModelRenderer((ModelBase)this, 0, 8);
this.Tip.addBox(-1.0f, 0.0f, -1.0f, 2, 16, 2);
this.Tip.setRotationPoint(0.0f, 8.0f, 0.0f);
this.Tip.setTextureSize(64, 32);
this.Tip.mirror = true;
this.setRotation(this.Tip, 0.0f, 0.0f, 0.0f);
this.Upper_plating = new ModelRenderer((ModelBase)this, 0, 0);
this.Upper_plating.addBox(-2.0f, 0.0f, -2.0f, 4, 1, 4);
this.Upper_plating.setRotationPoint(0.0f, 11.0f, 0.0f);
this.Upper_plating.setTextureSize(64, 32);
this.Upper_plating.mirror = true;
this.setRotation(this.Upper_plating, 0.0f, 0.0f, 0.0f);
this.Middle_plating = new ModelRenderer((ModelBase)this, 16, 0);
this.Middle_plating.addBox(-3.0f, 0.0f, -3.0f, 6, 1, 6);
this.Middle_plating.setRotationPoint(0.0f, 15.0f, 0.0f);
this.Middle_plating.setTextureSize(64, 32);
this.Middle_plating.mirror = true;
this.setRotation(this.Middle_plating, 0.0f, 0.0f, 0.0f);
this.Shape3_1 = new ModelRenderer((ModelBase)this, 8, 8);
this.Shape3_1.addBox(2.0f, 0.0f, -1.0f, 1, 6, 2);
this.Shape3_1.setRotationPoint(0.0f, 11.0f, 0.0f);
this.Shape3_1.setTextureSize(64, 32);
this.Shape3_1.mirror = true;
this.setRotation(this.Shape3_1, 0.0f, -3.141593f, 0.0f);
this.Shape3_2 = new ModelRenderer((ModelBase)this, 8, 8);
this.Shape3_2.addBox(2.0f, 0.0f, -1.0f, 1, 6, 2);
this.Shape3_2.setRotationPoint(0.0f, 11.0f, 0.0f);
this.Shape3_2.setTextureSize(64, 32);
this.Shape3_2.mirror = true;
this.setRotation(this.Shape3_2, 0.0f, -1.570796f, 0.0f);
this.Shape3_3 = new ModelRenderer((ModelBase)this, 8, 8);
this.Shape3_3.addBox(2.0f, 0.0f, -1.0f, 1, 6, 2);
this.Shape3_3.setRotationPoint(0.0f, 11.0f, 0.0f);
this.Shape3_3.setTextureSize(64, 32);
this.Shape3_3.mirror = true;
this.setRotation(this.Shape3_3, 0.0f, 1.570796f, 0.0f);
this.Shape3_4 = new ModelRenderer((ModelBase)this, 8, 8);
this.Shape3_4.addBox(2.0f, 0.0f, -1.0f, 1, 6, 2);
this.Shape3_4.setRotationPoint(0.0f, 11.0f, 0.0f);
this.Shape3_4.setTextureSize(64, 32);
this.Shape3_4.mirror = true;
this.setRotation(this.Shape3_4, 0.0f, 0.0f, 0.0f);
this.LowerPlating_1 = new ModelRenderer((ModelBase)this, 40, 0);
this.LowerPlating_1.addBox(-2.0f, 0.0f, -2.0f, 4, 1, 4);
this.LowerPlating_1.setRotationPoint(0.0f, 18.0f, 0.0f);
this.LowerPlating_1.setTextureSize(64, 32);
this.LowerPlating_1.mirror = true;
this.setRotation(this.LowerPlating_1, 0.0f, 0.0f, 0.0f);
this.LowerPlating_2 = new ModelRenderer((ModelBase)this, 40, 0);
this.LowerPlating_2.addBox(-2.0f, 0.0f, -2.0f, 4, 1, 4);
this.LowerPlating_2.setRotationPoint(0.0f, 20.0f, 0.0f);
this.LowerPlating_2.setTextureSize(64, 32);
this.LowerPlating_2.mirror = true;
this.setRotation(this.LowerPlating_2, 0.0f, 0.0f, 0.0f);
this.Bump_1 = new ModelRenderer((ModelBase)this, 56, 0);
this.Bump_1.addBox(-0.5f, -0.5f, -0.5f, 1, 4, 1);
this.Bump_1.setRotationPoint(0.0f, 12.0f, 3.0f);
this.Bump_1.setTextureSize(64, 32);
this.Bump_1.mirror = true;
this.setRotation(this.Bump_1, 0.0f, 0.7853982f, 0.0f);
this.Bump_2 = new ModelRenderer((ModelBase)this, 56, 0);
this.Bump_2.addBox(-0.5f, -0.5f, -0.5f, 1, 4, 1);
this.Bump_2.setRotationPoint(3.0f, 12.0f, 0.0f);
this.Bump_2.setTextureSize(64, 32);
this.Bump_2.mirror = true;
this.setRotation(this.Bump_2, 0.0f, 0.7853982f, 0.0f);
this.Bump_3 = new ModelRenderer((ModelBase)this, 56, 0);
this.Bump_3.addBox(-0.5f, -0.5f, -0.5f, 1, 4, 1);
this.Bump_3.setRotationPoint(0.0f, 12.0f, -3.0f);
this.Bump_3.setTextureSize(64, 32);
this.Bump_3.mirror = true;
this.setRotation(this.Bump_3, 0.0f, 0.7853982f, 0.0f);
this.Bump_4 = new ModelRenderer((ModelBase)this, 56, 0);
this.Bump_4.addBox(-0.5f, -0.5f, -0.5f, 1, 4, 1);
this.Bump_4.setRotationPoint(-3.0f, 12.0f, 0.0f);
this.Bump_4.setTextureSize(64, 32);
this.Bump_4.mirror = true;
this.setRotation(this.Bump_4, 0.0f, 0.7853982f, 0.0f);
this.Cross = new ModelRenderer((ModelBase)this, 14, 8);
this.Cross.addBox(-0.5f, -0.5f, -0.5f, 3, 1, 3);
this.Cross.setRotationPoint(-1.5f, 11.0f, 0.0f);
this.Cross.setTextureSize(64, 32);
this.Cross.mirror = true;
this.setRotation(this.Cross, 0.0f, 0.7853982f, 0.0f);
}
public void render(float rotation, float f5) {
this.Tip.render(f5);
this.Upper_plating.render(f5);
this.Middle_plating.render(f5);
this.Shape3_1.render(f5);
this.Shape3_2.render(f5);
this.Shape3_3.render(f5);
this.Shape3_4.render(f5);
this.LowerPlating_1.render(f5);
this.LowerPlating_2.render(f5);
this.Bump_1.render(f5);
this.Bump_2.render(f5);
this.Bump_3.render(f5);
this.Bump_4.render(f5);
this.Cross.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,189 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelManipulator
extends ModelBase {
ModelRenderer bBELTLong;
ModelRenderer FBELT;
ModelRenderer BacPanel;
ModelRenderer BBelt;
ModelRenderer FRL;
ModelRenderer MRL;
ModelRenderer FLL;
ModelRenderer BLL;
ModelRenderer MRoller;
ModelRenderer BRoller;
ModelRenderer tBELT;
ModelRenderer FRoller;
ModelRenderer BRL;
ModelRenderer BML;
ModelRenderer tBELTLong;
ModelRenderer RPanel;
ModelRenderer LPanel;
ModelRenderer TopPanel;
ModelRenderer RCPanel;
ModelRenderer LCPanel;
public ModelManipulator() {
this.textureWidth = 128;
this.textureHeight = 128;
this.bBELTLong = new ModelRenderer((ModelBase)this, 0, 66);
this.bBELTLong.addBox(0.0f, 0.0f, 0.0f, 14, 1, 16);
this.bBELTLong.setRotationPoint(-7.0f, 22.0f, -8.0f);
this.bBELTLong.setTextureSize(128, 128);
this.bBELTLong.mirror = true;
this.setRotation(this.bBELTLong, 0.0f, 0.0f, 0.0f);
this.FBELT = new ModelRenderer((ModelBase)this, 0, 16);
this.FBELT.addBox(0.0f, 0.0f, 0.0f, 14, 2, 1);
this.FBELT.setRotationPoint(-7.0f, 20.0f, -8.0f);
this.FBELT.setTextureSize(128, 128);
this.FBELT.mirror = true;
this.setRotation(this.FBELT, 0.0f, 0.0f, 0.0f);
this.BacPanel = new ModelRenderer((ModelBase)this, 0, 86);
this.BacPanel.addBox(0.0f, -12.0f, 0.0f, 14, 12, 1);
this.BacPanel.setRotationPoint(-7.0f, 24.0f, 7.0f);
this.BacPanel.setTextureSize(128, 128);
this.BacPanel.mirror = true;
this.setRotation(this.BacPanel, 0.0f, 0.0f, 0.0f);
this.BBelt = new ModelRenderer((ModelBase)this, 0, 31);
this.BBelt.addBox(0.0f, 0.0f, 0.0f, 14, 1, 14);
this.BBelt.setRotationPoint(-7.0f, 22.0f, -7.0f);
this.BBelt.setTextureSize(128, 128);
this.BBelt.mirror = true;
this.setRotation(this.BBelt, 0.0f, 0.0f, 0.0f);
this.FRL = new ModelRenderer((ModelBase)this, 0, 20);
this.FRL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.FRL.setRotationPoint(-8.0f, 21.0f, -6.0f);
this.FRL.setTextureSize(128, 128);
this.FRL.mirror = true;
this.setRotation(this.FRL, 0.0f, 0.0f, 0.0f);
this.MRL = new ModelRenderer((ModelBase)this, 0, 20);
this.MRL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.MRL.setRotationPoint(-8.0f, 21.0f, -1.0f);
this.MRL.setTextureSize(128, 128);
this.MRL.mirror = true;
this.setRotation(this.MRL, 0.0f, 0.0f, 0.0f);
this.FLL = new ModelRenderer((ModelBase)this, 0, 20);
this.FLL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.FLL.setRotationPoint(7.0f, 21.0f, -6.0f);
this.FLL.setTextureSize(128, 128);
this.FLL.mirror = true;
this.setRotation(this.FLL, 0.0f, 0.0f, 0.0f);
this.BLL = new ModelRenderer((ModelBase)this, 0, 20);
this.BLL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.BLL.setRotationPoint(7.0f, 21.0f, 4.0f);
this.BLL.setTextureSize(128, 128);
this.BLL.mirror = true;
this.setRotation(this.BLL, 0.0f, 0.0f, 0.0f);
this.MRoller = new ModelRenderer((ModelBase)this, 0, 26);
this.MRoller.addBox(-7.0f, -1.0f, -1.0f, 14, 2, 2);
this.MRoller.setRotationPoint(0.0f, 21.0f, 0.0f);
this.MRoller.setTextureSize(128, 128);
this.MRoller.mirror = true;
this.setRotation(this.MRoller, 0.0f, 0.0f, 0.0f);
this.BRoller = new ModelRenderer((ModelBase)this, 0, 26);
this.BRoller.addBox(-7.0f, -1.0f, -1.0f, 14, 2, 2);
this.BRoller.setRotationPoint(0.0f, 21.0f, 5.0f);
this.BRoller.setTextureSize(128, 128);
this.BRoller.mirror = true;
this.setRotation(this.BRoller, 0.0f, 0.0f, 0.0f);
this.tBELT = new ModelRenderer((ModelBase)this, 0, 0);
this.tBELT.addBox(0.0f, 0.0f, 0.0f, 14, 1, 14);
this.tBELT.setRotationPoint(-7.0f, 19.0f, -7.0f);
this.tBELT.setTextureSize(128, 128);
this.tBELT.mirror = true;
this.setRotation(this.tBELT, 0.0f, 0.0f, 0.0f);
this.FRoller = new ModelRenderer((ModelBase)this, 0, 26);
this.FRoller.addBox(-7.0f, -1.0f, -1.0f, 14, 2, 2);
this.FRoller.setRotationPoint(0.0f, 21.0f, -5.0f);
this.FRoller.setTextureSize(128, 128);
this.FRoller.mirror = true;
this.setRotation(this.FRoller, 0.0f, 0.0f, 0.0f);
this.BRL = new ModelRenderer((ModelBase)this, 0, 20);
this.BRL.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.BRL.setRotationPoint(-8.0f, 21.0f, 4.0f);
this.BRL.setTextureSize(128, 128);
this.BRL.mirror = true;
this.setRotation(this.BRL, 0.0f, 0.0f, 0.0f);
this.BML = new ModelRenderer((ModelBase)this, 0, 20);
this.BML.addBox(0.0f, 0.0f, 0.0f, 1, 3, 2);
this.BML.setRotationPoint(7.0f, 21.0f, -1.0f);
this.BML.setTextureSize(128, 128);
this.BML.mirror = true;
this.setRotation(this.BML, 0.0f, 0.0f, 0.0f);
this.tBELTLong = new ModelRenderer((ModelBase)this, 0, 48);
this.tBELTLong.addBox(0.0f, 0.0f, 0.0f, 14, 1, 16);
this.tBELTLong.setRotationPoint(-7.0f, 19.0f, -8.0f);
this.tBELTLong.setTextureSize(128, 128);
this.tBELTLong.mirror = true;
this.setRotation(this.tBELTLong, 0.0f, 0.0f, 0.0f);
this.RPanel = new ModelRenderer((ModelBase)this, 65, 41);
this.RPanel.addBox(0.0f, -2.0f, -8.0f, 1, 4, 16);
this.RPanel.setRotationPoint(-8.0f, 19.0f, 0.0f);
this.RPanel.setTextureSize(128, 128);
this.RPanel.mirror = true;
this.setRotation(this.RPanel, 0.0f, 0.0f, 0.0f);
this.LPanel = new ModelRenderer((ModelBase)this, 65, 20);
this.LPanel.addBox(0.0f, -2.0f, -8.0f, 1, 4, 16);
this.LPanel.setRotationPoint(7.0f, 19.0f, 0.0f);
this.LPanel.setTextureSize(128, 128);
this.LPanel.mirror = true;
this.setRotation(this.LPanel, 0.0f, 0.0f, 0.0f);
this.TopPanel = new ModelRenderer((ModelBase)this, 0, 105);
this.TopPanel.addBox(0.0f, 0.0f, 0.0f, 14, 2, 10);
this.TopPanel.setRotationPoint(-7.0f, 12.0f, -3.0f);
this.TopPanel.setTextureSize(128, 128);
this.TopPanel.mirror = true;
this.setRotation(this.TopPanel, 0.0f, 0.0f, 0.0f);
this.RCPanel = new ModelRenderer((ModelBase)this, 50, 105);
this.RCPanel.addBox(-1.0f, 0.0f, 0.0f, 2, 5, 10);
this.RCPanel.setRotationPoint(-7.0f, 14.0f, -3.0f);
this.RCPanel.setTextureSize(128, 128);
this.RCPanel.mirror = true;
this.setRotation(this.RCPanel, 0.0f, 0.0f, 0.0f);
this.LCPanel = new ModelRenderer((ModelBase)this, 76, 105);
this.LCPanel.addBox(0.0f, 0.0f, 0.0f, 2, 5, 10);
this.LCPanel.setRotationPoint(6.0f, 14.0f, -3.0f);
this.LCPanel.setTextureSize(128, 128);
this.LCPanel.mirror = true;
this.setRotation(this.LCPanel, 0.0f, 0.0f, 0.0f);
}
public void render(float f5, boolean isLongBelt, int radians) {
this.BacPanel.render(f5);
this.RPanel.render(f5);
this.LPanel.render(f5);
this.TopPanel.render(f5);
this.RCPanel.render(f5);
this.LCPanel.render(f5);
this.FRL.render(f5);
this.MRL.render(f5);
this.FLL.render(f5);
this.BLL.render(f5);
this.BRL.render(f5);
this.BML.render(f5);
this.MRoller.rotateAngleX = radians;
this.BRoller.rotateAngleX = radians;
this.FRoller.rotateAngleX = radians;
this.MRoller.render(f5);
this.BRoller.render(f5);
this.FRoller.render(f5);
if (isLongBelt) {
this.tBELTLong.render(f5);
this.bBELTLong.render(f5);
} else {
this.FBELT.render(f5);
this.tBELT.render(f5);
this.BBelt.render(f5);
}
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,157 @@
package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelRejectorPiston
extends ModelBase {
ModelRenderer BodyBottom;
ModelRenderer PistonFace2;
ModelRenderer PistonShaft;
ModelRenderer Piston;
ModelRenderer H1;
ModelRenderer H2;
ModelRenderer H3;
ModelRenderer PistonFace;
ModelRenderer WireCCRight;
ModelRenderer WireCCLeft;
ModelRenderer BodyP2;
ModelRenderer BodyP1;
ModelRenderer LeftSide;
ModelRenderer RightSide;
ModelRenderer PistonBack;
ModelRenderer WireCCFront;
public ModelRejectorPiston() {
this.textureWidth = 128;
this.textureHeight = 128;
this.BodyBottom = new ModelRenderer((ModelBase)this, 29, 69);
this.BodyBottom.addBox(-5.0f, 0.0f, -2.0f, 10, 5, 15);
this.BodyBottom.setRotationPoint(0.0f, 19.0f, -6.0f);
this.BodyBottom.setTextureSize(128, 128);
this.BodyBottom.mirror = true;
this.setRotation(this.BodyBottom, 0.0f, 0.0f, 0.0f);
this.PistonFace2 = new ModelRenderer((ModelBase)this, 0, 53);
this.PistonFace2.addBox(-2.0f, -2.0f, -1.0f, 4, 6, 1);
this.PistonFace2.setRotationPoint(0.0f, 15.0f, -6.0f);
this.PistonFace2.setTextureSize(128, 128);
this.PistonFace2.mirror = true;
this.setRotation(this.PistonFace2, 0.0f, 0.0f, 0.0f);
this.PistonShaft = new ModelRenderer((ModelBase)this, 0, 75);
this.PistonShaft.addBox(-1.5f, -1.5f, 0.0f, 3, 3, 10);
this.PistonShaft.setRotationPoint(0.0f, 16.0f, -6.0f);
this.PistonShaft.setTextureSize(128, 128);
this.PistonShaft.mirror = true;
this.setRotation(this.PistonShaft, 0.0f, 0.0f, 0.0f);
this.Piston = new ModelRenderer((ModelBase)this, 0, 22);
this.Piston.addBox(-3.0f, -1.0f, 0.0f, 6, 6, 10);
this.Piston.setRotationPoint(0.0f, 14.0f, -5.0f);
this.Piston.setTextureSize(128, 128);
this.Piston.mirror = true;
this.setRotation(this.Piston, 0.0f, 0.0f, 0.0f);
this.H1 = new ModelRenderer((ModelBase)this, 33, 23);
this.H1.addBox(-1.5f, 0.0f, 0.0f, 3, 1, 8);
this.H1.setRotationPoint(0.0f, 12.0f, -4.0f);
this.H1.setTextureSize(128, 128);
this.H1.mirror = true;
this.setRotation(this.H1, 0.0f, 0.0f, 0.0f);
this.H2 = new ModelRenderer((ModelBase)this, 90, 23);
this.H2.addBox(0.0f, -1.5f, 0.0f, 1, 3, 8);
this.H2.setRotationPoint(-4.0f, 16.0f, -4.0f);
this.H2.setTextureSize(128, 128);
this.H2.mirror = true;
this.setRotation(this.H2, 0.0f, 0.0f, 0.0f);
this.H3 = new ModelRenderer((ModelBase)this, 70, 23);
this.H3.addBox(0.0f, -1.5f, 0.0f, 1, 3, 8);
this.H3.setRotationPoint(3.0f, 16.0f, -4.0f);
this.H3.setTextureSize(128, 128);
this.H3.mirror = true;
this.setRotation(this.H3, 0.0f, 0.0f, 0.0f);
this.PistonFace = new ModelRenderer((ModelBase)this, 0, 62);
this.PistonFace.addBox(-3.0f, -2.0f, -1.0f, 6, 4, 1);
this.PistonFace.setRotationPoint(0.0f, 16.0f, -6.0f);
this.PistonFace.setTextureSize(128, 128);
this.PistonFace.mirror = true;
this.setRotation(this.PistonFace, 0.0f, 0.0f, 0.0f);
this.WireCCRight = new ModelRenderer((ModelBase)this, 69, 52);
this.WireCCRight.addBox(-3.0f, -3.0f, 0.0f, 6, 11, 1);
this.WireCCRight.setRotationPoint(0.0f, 16.0f, 7.0f);
this.WireCCRight.setTextureSize(128, 128);
this.WireCCRight.mirror = true;
this.setRotation(this.WireCCRight, 0.0f, 0.0f, 0.0f);
this.WireCCLeft = new ModelRenderer((ModelBase)this, 54, 37);
this.WireCCLeft.addBox(0.0f, -3.0f, -3.0f, 1, 8, 6);
this.WireCCLeft.setRotationPoint(7.0f, 16.0f, 0.0f);
this.WireCCLeft.setTextureSize(128, 128);
this.WireCCLeft.mirror = true;
this.setRotation(this.WireCCLeft, 0.0f, 0.0f, 0.0f);
this.BodyP2 = new ModelRenderer((ModelBase)this, 100, 60);
this.BodyP2.addBox(1.0f, -2.0f, -2.0f, 2, 7, 4);
this.BodyP2.setRotationPoint(-8.0f, 16.0f, 0.0f);
this.BodyP2.setTextureSize(128, 128);
this.BodyP2.mirror = true;
this.setRotation(this.BodyP2, 0.0f, 0.0f, 0.0f);
this.BodyP1 = new ModelRenderer((ModelBase)this, 87, 60);
this.BodyP1.addBox(3.0f, -2.0f, -2.0f, 2, 7, 4);
this.BodyP1.setRotationPoint(2.0f, 16.0f, 0.0f);
this.BodyP1.setTextureSize(128, 128);
this.BodyP1.mirror = true;
this.setRotation(this.BodyP1, 0.0f, 0.0f, 0.0f);
this.LeftSide = new ModelRenderer((ModelBase)this, 29, 91);
this.LeftSide.addBox(0.0f, 0.0f, -2.0f, 3, 3, 14);
this.LeftSide.setRotationPoint(5.0f, 21.0f, -5.0f);
this.LeftSide.setTextureSize(128, 128);
this.LeftSide.mirror = true;
this.setRotation(this.LeftSide, 0.0f, 0.0f, 0.0f);
this.RightSide = new ModelRenderer((ModelBase)this, 64, 91);
this.RightSide.addBox(0.0f, 0.0f, -2.0f, 3, 3, 14);
this.RightSide.setRotationPoint(-8.0f, 21.0f, -5.0f);
this.RightSide.setTextureSize(128, 128);
this.RightSide.mirror = true;
this.setRotation(this.RightSide, 0.0f, 0.0f, 0.0f);
this.PistonBack = new ModelRenderer((ModelBase)this, 0, 12);
this.PistonBack.addBox(-2.5f, -2.5f, -1.0f, 5, 5, 2);
this.PistonBack.setRotationPoint(0.0f, 16.0f, 6.0f);
this.PistonBack.setTextureSize(128, 128);
this.PistonBack.mirror = true;
this.setRotation(this.PistonBack, 0.0f, 0.0f, 0.0f);
this.WireCCFront = new ModelRenderer((ModelBase)this, 69, 37);
this.WireCCFront.addBox(0.0f, -3.0f, -3.0f, 1, 8, 6);
this.WireCCFront.setRotationPoint(-8.0f, 16.0f, 0.0f);
this.WireCCFront.setTextureSize(128, 128);
this.WireCCFront.mirror = true;
this.setRotation(this.WireCCFront, 0.0f, 0.0f, 0.0f);
}
public void render(float f5) {
this.BodyBottom.render(f5);
this.Piston.render(f5);
this.H1.render(f5);
this.H2.render(f5);
this.H3.render(f5);
this.WireCCRight.render(f5);
this.WireCCLeft.render(f5);
this.BodyP2.render(f5);
this.BodyP1.render(f5);
this.LeftSide.render(f5);
this.RightSide.render(f5);
this.PistonBack.render(f5);
this.WireCCFront.render(f5);
}
public void renderPiston(float f5, int p) {
this.PistonFace2.setRotationPoint(0.0f, 15.0f, -6.0f - (float)p);
this.PistonShaft.setRotationPoint(0.0f, 16.0f, -6.0f - (float)p);
this.PistonFace.setRotationPoint(0.0f, 16.0f, -6.0f - (float)p);
this.PistonFace2.render(f5);
this.PistonShaft.render(f5);
this.PistonFace.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View File

@ -0,0 +1,97 @@
package assemblyline.client.render;
import assemblyline.client.model.ModelConveyorBelt;
import assemblyline.client.model.ModelManipulator;
import assemblyline.client.model.ModelRejectorPiston;
import assemblyline.common.AssemblyLine;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
@SideOnly(value=Side.CLIENT)
public class BlockRenderingHandler
implements ISimpleBlockRenderingHandler {
public static BlockRenderingHandler instance = new BlockRenderingHandler();
public static final int BLOCK_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
private ModelConveyorBelt modelConveyorBelt = new ModelConveyorBelt();
private ModelRejectorPiston modelEjector = new ModelRejectorPiston();
private ModelManipulator modelInjector = new ModelManipulator();
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
if (block == AssemblyLine.blockConveyorBelt) {
GL11.glPushMatrix();
GL11.glTranslatef((float)0.0f, (float)1.5f, (float)0.0f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/belt/frame0.png"));
this.modelConveyorBelt.render(0.0625f, 0.0f, false, false, false, false);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockRejector) {
FMLClientHandler.instance().getClient().getTextureManager();
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/rejector.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)0.6f, (float)1.5f, (float)0.6f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
this.modelEjector.render(0.0625f);
this.modelEjector.renderPiston(0.0625f, 1);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockManipulator) {
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/manipulator1.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)0.6f, (float)1.5f, (float)0.6f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
this.modelInjector.render(0.0625f, true, 0);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockArmbot) {
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/armbot.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)0.4f, (float)0.8f, (float)0.0f);
GL11.glScalef((float)0.7f, (float)0.7f, (float)0.7f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
RenderArmbot.MODEL.render(0.0625f, 0.0f, 0.0f);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockCraneController) {
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/crane_controller_off.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
RenderCraneController.MODEL.render(0.0625f, false, false);
GL11.glPopMatrix();
} else if (block == AssemblyLine.blockCraneFrame) {
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(new ResourceLocation("assemblyline", "textures/models/crane_frame.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
RenderCraneFrame.MODEL.render(true, true, false, false, false, false, false);
GL11.glPopMatrix();
}
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public boolean shouldRender3DInInventory(int par0) {
return true;
}
@Override
public int getRenderId() {
return BLOCK_RENDER_ID;
}
}

View File

@ -0,0 +1,58 @@
package assemblyline.client.render;
import assemblyline.client.model.ModelArmbot;
import assemblyline.common.machine.armbot.TileEntityArmbot;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
public class RenderArmbot
extends TileEntitySpecialRenderer {
public static final ModelArmbot MODEL = new ModelArmbot();
public static final String TEXTURE = "armbot.png";
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
if (tileEntity instanceof TileEntityArmbot) {
EntityClientPlayerMP player;
MovingObjectPosition objectPosition;
String cmdText = ((TileEntityArmbot)tileEntity).getCommandDisplayText();
if (!(cmdText == null || cmdText.isEmpty() || (objectPosition = (player = Minecraft.getMinecraft().thePlayer).rayTrace(8.0, 1.0f)) == null || objectPosition.blockX != tileEntity.xCoord || objectPosition.blockY != tileEntity.yCoord && objectPosition.blockY != tileEntity.yCoord + 1 || objectPosition.blockZ != tileEntity.zCoord)) {
RenderHelper.renderFloatingText(cmdText, (float)x + 0.5f, (float)y + 0.25f, (float)z + 0.5f, 0xFFFFFF);
}
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/armbot.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)((float)x + 0.5f), (float)((float)y + 1.5f), (float)((float)z + 0.5f));
GL11.glScalef((float)1.0f, (float)-1.0f, (float)-1.0f);
MODEL.render(0.0625f, ((TileEntityArmbot)tileEntity).renderYaw, ((TileEntityArmbot)tileEntity).renderPitch);
GL11.glPopMatrix();
Vector3 handPosition = ((TileEntityArmbot)tileEntity).getDeltaHandPosition();
handPosition.add(0.5);
handPosition.add(new Vector3(x, y, z));
RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
for (ItemStack itemStack : ((TileEntityArmbot)tileEntity).getGrabbedItems()) {
if (itemStack == null) continue;
if (((TileEntityArmbot)tileEntity).renderEntityItem == null) {
((TileEntityArmbot)tileEntity).renderEntityItem = new EntityItem(tileEntity.getWorldObj(), 0.0, 0.0, 0.0, itemStack);
} else if (!itemStack.isItemEqual(((TileEntityArmbot)tileEntity).renderEntityItem.getEntityItem())) {
((TileEntityArmbot)tileEntity).renderEntityItem = new EntityItem(tileEntity.getWorldObj(), 0.0, 0.0, 0.0, itemStack);
}
renderItem.doRender(((TileEntityArmbot)tileEntity).renderEntityItem, handPosition.x, handPosition.y, handPosition.z, 0.0f, f);
break;
}
}
}
}

View File

@ -0,0 +1,106 @@
package assemblyline.client.render;
import assemblyline.client.model.ModelAngledBelt;
import assemblyline.client.model.ModelConveyorBelt;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(value=Side.CLIENT)
public class RenderConveyorBelt
extends TileEntitySpecialRenderer {
public static final ModelConveyorBelt MODEL = new ModelConveyorBelt();
public static final ModelAngledBelt MODEL2 = new ModelAngledBelt();
private void renderAModelAt(TileEntityConveyorBelt tileEntity, double x, double y, double z, float f) {
boolean mid = tileEntity.getIsMiddleBelt();
TileEntityConveyorBelt.SlantType slantType = tileEntity.getSlant();
int face = tileEntity.getDirection().ordinal();
GL11.glPushMatrix();
GL11.glTranslatef((float)((float)x + 0.5f), (float)((float)y + 1.5f), (float)((float)z + 0.5f));
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
int frame = tileEntity.getAnimationFrame();
if (slantType != null && slantType != TileEntityConveyorBelt.SlantType.NONE) {
boolean slantAdjust;
switch (face) {
case 2: {
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
break;
}
case 3: {
GL11.glRotatef((float)0.0f, (float)0.0f, (float)1.0f, (float)0.0f);
break;
}
case 4: {
GL11.glRotatef((float)90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
break;
}
case 5: {
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
}
}
if (slantType == TileEntityConveyorBelt.SlantType.UP) {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/slantedbelt/frame" + frame + ".png"));
GL11.glTranslatef((float)0.0f, (float)0.8f, (float)-0.8f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)1.0f);
slantAdjust = false;
TileEntity test = tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord + tileEntity.getDirection().offsetX, tileEntity.yCoord, tileEntity.zCoord + tileEntity.getDirection().offsetZ);
if (test != null && test instanceof TileEntityConveyorBelt && ((TileEntityConveyorBelt)test).getSlant() == TileEntityConveyorBelt.SlantType.TOP) {
GL11.glRotatef((float)10.0f, (float)1.0f, (float)0.0f, (float)0.0f);
slantAdjust = true;
}
MODEL2.render(0.0625f, true);
} else if (slantType == TileEntityConveyorBelt.SlantType.DOWN) {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/slantedbelt/frame" + frame + ".png"));
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
slantAdjust = false;
TileEntity test = tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord - tileEntity.getDirection().offsetX, tileEntity.yCoord, tileEntity.zCoord - tileEntity.getDirection().offsetZ);
if (test != null && test instanceof TileEntityConveyorBelt && ((TileEntityConveyorBelt)test).getSlant() == TileEntityConveyorBelt.SlantType.TOP) {
GL11.glRotatef((float)-10.0f, (float)1.0f, (float)0.0f, (float)0.0f);
GL11.glTranslatef((float)0.0f, (float)0.25f, (float)0.0f);
slantAdjust = true;
}
MODEL2.render(0.0625f, slantAdjust);
} else {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/belt/frame" + frame + ".png"));
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glTranslatef((float)0.0f, (float)-0.68f, (float)0.0f);
MODEL.render(0.0625f, (float)Math.toRadians(tileEntity.wheelRotation), tileEntity.getIsLastBelt(), tileEntity.getIsFirstBelt(), false, false);
}
} else {
switch (face) {
case 2: {
GL11.glRotatef((float)0.0f, (float)0.0f, (float)1.0f, (float)0.0f);
break;
}
case 3: {
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
break;
}
case 4: {
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
break;
}
case 5: {
GL11.glRotatef((float)90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
}
}
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/belt/frame" + frame + ".png"));
MODEL.render(0.0625f, (float)Math.toRadians(tileEntity.wheelRotation), tileEntity.getIsLastBelt(), tileEntity.getIsFirstBelt(), false, true);
}
Block ent = tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
this.renderAModelAt((TileEntityConveyorBelt)tileEntity, var2, var4, var6, var8);
}
}

View File

@ -0,0 +1,53 @@
package assemblyline.client.render;
import assemblyline.client.model.ModelCraneController;
import assemblyline.common.machine.crane.CraneHelper;
import assemblyline.common.machine.crane.TileEntityCraneController;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class RenderCraneController
extends RenderImprintable {
public static final String TEXTURE = "crane_controller_off.png";
public static final String TEXTURE_VALID = "crane_controller_on.png";
public static final ModelCraneController MODEL = new ModelCraneController();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
if (tileEntity != null && tileEntity instanceof TileEntityCraneController) {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/" + (((TileEntityCraneController)tileEntity).isCraneValid() ? TEXTURE_VALID : TEXTURE)));
ForgeDirection front = ForgeDirection.getOrientation((int)tileEntity.getWorldObj().getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
ForgeDirection right = CraneHelper.rotateClockwise(front);
float angle = 0.0f;
switch (front) {
case NORTH: {
angle = 90.0f;
break;
}
case SOUTH: {
angle = 270.0f;
break;
}
case EAST: {
angle = 180.0f;
}
}
int tX = tileEntity.xCoord;
int tY = tileEntity.yCoord;
int tZ = tileEntity.zCoord;
boolean connectFront = CraneHelper.canFrameConnectTo(tileEntity, tX + front.offsetX, tY, tZ + front.offsetZ, front.getOpposite());
boolean connectRight = CraneHelper.canFrameConnectTo(tileEntity, tX + right.offsetX, tY, tZ + right.offsetZ, right.getOpposite());
GL11.glPushMatrix();
GL11.glTranslated((double)(x + 0.5), (double)(y + 1.5), (double)(z + 0.5));
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
GL11.glRotatef((float)angle, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glEnable((int)2896);
MODEL.render(0.0625f, connectRight, connectFront);
GL11.glPopMatrix();
}
}
}

View File

@ -0,0 +1,44 @@
package assemblyline.client.render;
import assemblyline.client.model.ModelCraneRail;
import assemblyline.common.machine.crane.CraneHelper;
import assemblyline.common.machine.crane.TileEntityCraneRail;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class RenderCraneFrame
extends TileEntitySpecialRenderer {
public static final String TEXTURE = "crane_frame.png";
public static final ModelCraneRail MODEL = new ModelCraneRail();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
if (tileEntity != null && tileEntity instanceof TileEntityCraneRail) {
int tX = tileEntity.xCoord;
int tY = tileEntity.yCoord;
int tZ = tileEntity.zCoord;
boolean renderUp = CraneHelper.canFrameConnectTo(tileEntity, tX, tY + 1, tZ, ForgeDirection.DOWN);
boolean renderDown = CraneHelper.canFrameConnectTo(tileEntity, tX, tY - 1, tZ, ForgeDirection.UP);
boolean renderLeft = CraneHelper.canFrameConnectTo(tileEntity, tX - 1, tY, tZ, ForgeDirection.EAST);
boolean renderRight = CraneHelper.canFrameConnectTo(tileEntity, tX + 1, tY, tZ, ForgeDirection.WEST);
boolean renderFront = CraneHelper.canFrameConnectTo(tileEntity, tX, tY, tZ - 1, ForgeDirection.SOUTH);
boolean renderBack = CraneHelper.canFrameConnectTo(tileEntity, tX, tY, tZ + 1, ForgeDirection.NORTH);
boolean renderFoot = tileEntity.getWorldObj().isSideSolid(tX, tY - 1, tZ, ForgeDirection.UP);
if (renderLeft && renderRight || renderFront && renderBack) {
renderFoot = false;
}
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/crane_frame.png"));
GL11.glPushMatrix();
GL11.glTranslated((double)(x + 0.5), (double)(y + 1.5), (double)(z + 0.5));
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
GL11.glEnable((int)2896);
MODEL.render(renderUp, renderDown && !renderFoot, renderLeft, renderRight, renderFront, renderBack, renderFoot);
GL11.glPopMatrix();
}
}
}

View File

@ -0,0 +1,158 @@
package assemblyline.client.render;
import assemblyline.common.block.TileEntityCrate;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
public class RenderCrate
extends TileEntitySpecialRenderer {
private final RenderBlocks renderBlocks = new RenderBlocks();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
Vector3 vec = new Vector3(x, y, z);
double distance = vec.distanceTo(new Vector3(0.0, 0.0, 0.0));
if (tileEntity instanceof TileEntityCrate && distance < 15.0) {
TileEntityCrate tileCrate = (TileEntityCrate)tileEntity;
RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
String itemName = "Empty";
String amount = "";
ItemStack itemStack = tileCrate.getStackInSlot(0);
if (itemStack != null) {
itemName = itemStack.getDisplayName();
amount = Integer.toString(itemStack.stackSize);
}
for (int side = 2; side < 6; ++side) {
ForgeDirection direction = ForgeDirection.getOrientation((int)side);
if (tileCrate.getWorldObj().isSideSolid(tileCrate.xCoord + direction.offsetX, tileCrate.yCoord, tileCrate.zCoord + direction.offsetZ, direction.getOpposite())) continue;
this.setupLight(tileCrate, direction.offsetX, direction.offsetZ);
OpenGlHelper.setLightmapTextureCoords((int)OpenGlHelper.lightmapTexUnit, (float)240.0f, (float)240.0f);
if (itemStack != null) {
GL11.glPushMatrix();
switch (side) {
case 2: {
GL11.glTranslated((double)(x + 0.65), (double)(y + 0.9), (double)(z - 0.01));
break;
}
case 3: {
GL11.glTranslated((double)(x + 0.35), (double)(y + 0.9), (double)(z + 1.01));
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
break;
}
case 4: {
GL11.glTranslated((double)(x - 0.01), (double)(y + 0.9), (double)(z + 0.35));
GL11.glRotatef((float)90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
break;
}
case 5: {
GL11.glTranslated((double)(x + 1.01), (double)(y + 0.9), (double)(z + 0.65));
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
}
}
float scale = 0.03125f;
GL11.glScalef((float)(0.6f * scale), (float)(0.6f * scale), (float)0.0f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
GL11.glDisable((int)2896);
if (!ForgeHooksClient.renderInventoryItem((RenderBlocks)this.renderBlocks, renderEngine, (ItemStack)itemStack, (boolean)true, (float)0.0f, (float)0.0f, (float)0.0f)) {
renderItem.renderItemIntoGUI(this.func_147498_b(), renderEngine, itemStack, 0, 0);
}
GL11.glEnable((int)2896);
GL11.glPopMatrix();
}
this.renderText(itemName, side, 0.02f, x, y - (double)0.35f, z);
if (amount == "") continue;
this.renderText(amount, side, 0.02f, x, y - (double)0.15f, z);
}
}
}
private void setupLight(TileEntity tileEntity, int xDifference, int zDifference) {
World world = tileEntity.getWorldObj();
if (world.getBlock(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference).isOpaqueCube()) {
return;
}
int br = world.getLightBrightnessForSkyBlocks(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference, 0);
int var11 = br % 65536;
int var12 = br / 65536;
float scale = 0.6f;
OpenGlHelper.setLightmapTextureCoords((int)OpenGlHelper.lightmapTexUnit, (float)((float)var11 * scale), (float)((float)var12 * scale));
}
private void renderText(String text, int side, float maxScale, double x, double y, double z) {
GL11.glPushMatrix();
GL11.glPolygonOffset((float)-10.0f, (float)-10.0f);
GL11.glEnable((int)32823);
float displayX = 0.0f;
float displayY = 0.0f;
float displayWidth = 1.0f;
float displayHeight = 1.0f;
GL11.glTranslated((double)x, (double)y, (double)z);
switch (side) {
case 3: {
GL11.glTranslatef((float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)0.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)90.0f, (float)1.0f, (float)0.0f, (float)0.0f);
break;
}
case 2: {
GL11.glTranslatef((float)1.0f, (float)1.0f, (float)1.0f);
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)90.0f, (float)1.0f, (float)0.0f, (float)0.0f);
break;
}
case 5: {
GL11.glTranslatef((float)0.0f, (float)1.0f, (float)1.0f);
GL11.glRotatef((float)90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)90.0f, (float)1.0f, (float)0.0f, (float)0.0f);
break;
}
case 4: {
GL11.glTranslatef((float)1.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)-90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)90.0f, (float)1.0f, (float)0.0f, (float)0.0f);
}
}
GL11.glTranslatef((float)(displayWidth / 2.0f), (float)1.0f, (float)(displayHeight / 2.0f));
GL11.glRotatef((float)-90.0f, (float)1.0f, (float)0.0f, (float)0.0f);
FontRenderer fontRenderer = super.func_147498_b();
int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1);
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
int requiredHeight = lineHeight * 1;
float scaler = 0.8f;
float scaleX = displayWidth / (float)requiredWidth;
float scaleY = displayHeight / (float)requiredHeight;
float scale = scaleX * scaler;
if (maxScale > 0.0f) {
scale = Math.min(scale, maxScale);
}
GL11.glScalef((float)scale, (float)(-scale), (float)scale);
GL11.glDepthMask((boolean)false);
int realHeight = (int)Math.floor(displayHeight / scale);
int realWidth = (int)Math.floor(displayWidth / scale);
int offsetX = (realWidth - requiredWidth) / 2;
int offsetY = (realHeight - requiredHeight) / 2;
GL11.glDisable((int)2896);
fontRenderer.drawString("\u00a7f" + text, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2, 1);
GL11.glEnable((int)2896);
GL11.glDepthMask((boolean)true);
GL11.glDisable((int)32823);
GL11.glPopMatrix();
}
}

View File

@ -0,0 +1,38 @@
package assemblyline.client.render;
import assemblyline.client.model.ModelHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
@SideOnly(value=Side.CLIENT)
public class RenderDetector
extends RenderImprintable {
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
super.renderTileEntityAt(tileEntity, x, y, z, var8);
}
public static void render(boolean isInverted, Vector3 position) { //TODO: WTF
GL11.glPushMatrix();
GL11.glTranslated((double)position.x, (double)position.y, (double)position.z);
if (isInverted) {
// empty if block
}
ModelHelper.setGlobalTextureResolution(128, 128);
ModelHelper.setTextureClip(false);
ModelHelper.setTextureOffset(0, 64);
ModelHelper.setTextureSubResolution(64, 64);
ModelHelper.drawCuboid(0.45f, 0.75f, 0.45f, 0.125f, 0.25f, 0.125f);
ModelHelper.setTextureOffset(0, 0);
ModelHelper.setTextureSubResolution(128, 64);
ModelHelper.drawCuboid(0.25f, 0.25f, 0.25f, 0.5f, 0.5f, 0.5f);
ModelHelper.setTextureOffset(64, 64);
ModelHelper.setTextureSubResolution(64, 32);
ModelHelper.drawCuboid(0.375f, 0.1875f, 0.375f, 0.25f, 0.0625f, 0.25f);
GL11.glPopMatrix();
}
}

View File

@ -0,0 +1,54 @@
package assemblyline.client.render;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import org.lwjgl.opengl.GL11;
public class RenderHelper {
public static void renderFloatingText(String text, float x, float y, float z) {
RenderHelper.renderFloatingText(text, x, y, z, 0xFFFFFF);
}
public static void renderFloatingText(String text, float x, float y, float z, int color) {
RenderManager renderManager = RenderManager.instance;
FontRenderer fontRenderer = renderManager.getFontRenderer();
float scale = 0.027f;
GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)0.5f);
GL11.glPushMatrix();
GL11.glTranslatef((float)(x + 0.0f), (float)(y + 2.3f), (float)z);
GL11.glNormal3f((float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)(-renderManager.playerViewY), (float)0.0f, (float)1.0f, (float)0.0f);
GL11.glRotatef((float)renderManager.playerViewX, (float)1.0f, (float)0.0f, (float)0.0f);
GL11.glScalef((float)(-scale), (float)(-scale), (float)scale);
GL11.glDisable((int)2896);
OpenGlHelper.setLightmapTextureCoords((int)OpenGlHelper.lightmapTexUnit, (float)240.0f, (float)240.0f);
GL11.glDepthMask((boolean)false);
GL11.glDisable((int)2929);
GL11.glEnable((int)3042);
GL11.glBlendFunc((int)770, (int)771);
Tessellator tessellator = Tessellator.instance;
int yOffset = 0;
GL11.glDisable((int)3553);
tessellator.startDrawingQuads();
int stringMiddle = fontRenderer.getStringWidth(text) / 2;
tessellator.setColorRGBA_F(0.0f, 0.0f, 0.0f, 0.5f);
tessellator.addVertex((double)(-stringMiddle - 1), (double)(-1 + yOffset), 0.0);
tessellator.addVertex((double)(-stringMiddle - 1), (double)(8 + yOffset), 0.0);
tessellator.addVertex((double)(stringMiddle + 1), (double)(8 + yOffset), 0.0);
tessellator.addVertex((double)(stringMiddle + 1), (double)(-1 + yOffset), 0.0);
tessellator.draw();
GL11.glEnable((int)3553);
GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)0.5f);
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color);
GL11.glEnable((int)2929);
GL11.glDepthMask((boolean)true);
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color);
GL11.glEnable((int)2896);
GL11.glDisable((int)3042);
GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
GL11.glPopMatrix();
}
}

View File

@ -0,0 +1,34 @@
package assemblyline.client.render;
import assemblyline.common.machine.imprinter.ItemImprinter;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
public abstract class RenderImprintable
extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
EntityClientPlayerMP player;
MovingObjectPosition objectPosition;
TileEntityFilterable tileFilterable;
ItemStack filter;
if (tileEntity != null && tileEntity instanceof TileEntityFilterable && (filter = (tileFilterable = (TileEntityFilterable)tileEntity).getFilter()) != null && (objectPosition = (player = Minecraft.getMinecraft().thePlayer).rayTrace(8.0, 1.0f)) != null && objectPosition.blockX == tileFilterable.xCoord && objectPosition.blockY == tileFilterable.yCoord && objectPosition.blockZ == tileFilterable.zCoord) {
ArrayList filters = ItemImprinter.getFilters(filter);
for (int i = 0; i < filters.size(); ++i) {
if (((TileEntityFilterable)tileEntity).isInverted()) {
RenderHelper.renderFloatingText(((ItemStack)filters.get(i)).getTooltip((EntityPlayer)player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float)x + 0.5f, (float)y + (float)i * 0.25f - 1.0f, (float)z + 0.5f, 0xFF8888);
continue;
}
RenderHelper.renderFloatingText(((ItemStack)filters.get(i)).getTooltip((EntityPlayer)player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float)x + 0.5f, (float)y + (float)i * 0.25f - 1.0f, (float)z + 0.5f, 0x88FF88);
}
}
}
}

View File

@ -0,0 +1,43 @@
package assemblyline.client.render;
import assemblyline.client.model.ModelManipulator;
import assemblyline.common.machine.TileEntityManipulator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class RenderManipulator
extends RenderImprintable {
private ModelManipulator model = new ModelManipulator();
private void renderAModelAt(TileEntityManipulator tileEntity, double x, double y, double z, float f) {
int face = tileEntity.getDirection().ordinal();
GL11.glPushMatrix();
GL11.glTranslatef((float)((float)x + 0.5f), (float)((float)y + 1.5f), (float)((float)z + 0.5f));
GL11.glRotatef((float)180.0f, (float)0.0f, (float)0.0f, (float)1.0f);
if (tileEntity.isOutput()) {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/manipulator1.png"));
} else {
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/manipulator2.png"));
}
if (face == 2) {
GL11.glRotatef((float)0.0f, (float)0.0f, (float)1.0f, (float)0.0f);
} else if (face == 3) {
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
} else if (face == 4) {
GL11.glRotatef((float)270.0f, (float)0.0f, (float)1.0f, (float)0.0f);
} else if (face == 5) {
GL11.glRotatef((float)90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
}
this.model.render(0.0625f, true, 0);
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
this.renderAModelAt((TileEntityManipulator)tileEntity, var2, var4, var6, var8);
super.renderTileEntityAt(tileEntity, var2, var4, var6, var8);
}
}

View File

@ -0,0 +1,46 @@
package assemblyline.client.render;
import assemblyline.client.model.ModelRejectorPiston;
import assemblyline.common.machine.TileEntityRejector;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class RenderRejector
extends RenderImprintable {
private ModelRejectorPiston model = new ModelRejectorPiston();
private void renderAModelAt(TileEntityRejector tileEntity, double x, double y, double z, float f) {
boolean fire = tileEntity.firePiston;
int face = tileEntity.getDirection().ordinal();
int pos = 0;
if (fire) {
pos = 8;
}
this.bindTexture(new ResourceLocation("assemblyline", "textures/models/rejector.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)((float)x + 0.5f), (float)((float)y + 1.5f), (float)((float)z + 0.5f));
GL11.glScalef((float)1.0f, (float)-1.0f, (float)-1.0f);
if (face == 2) {
GL11.glRotatef((float)180.0f, (float)0.0f, (float)1.0f, (float)0.0f);
}
if (face == 3) {
GL11.glRotatef((float)0.0f, (float)0.0f, (float)1.0f, (float)0.0f);
} else if (face == 4) {
GL11.glRotatef((float)90.0f, (float)0.0f, (float)1.0f, (float)0.0f);
} else if (face == 5) {
GL11.glRotatef((float)270.0f, (float)0.0f, (float)1.0f, (float)0.0f);
}
this.model.render(0.0625f);
this.model.renderPiston(0.0625f, pos);
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
this.renderAModelAt((TileEntityRejector)tileEntity, var2, var4, var6, var8);
super.renderTileEntityAt(tileEntity, var2, var4, var6, var8);
}
}

View File

@ -0,0 +1,184 @@
package assemblyline.common;
import assemblyline.common.CommonProxy;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockCrate;
import assemblyline.common.block.BlockTurntable;
import assemblyline.common.block.ItemBlockCrate;
import assemblyline.common.machine.BlockManipulator;
import assemblyline.common.machine.BlockRejector;
import assemblyline.common.machine.armbot.BlockArmbot;
import assemblyline.common.machine.belt.BlockConveyorBelt;
import assemblyline.common.machine.command.GrabDictionary;
import assemblyline.common.machine.crane.BlockCraneController;
import assemblyline.common.machine.crane.BlockCraneFrame;
import assemblyline.common.machine.detector.BlockDetector;
import assemblyline.common.machine.encoder.BlockEncoder;
import assemblyline.common.machine.encoder.ItemDisk;
import assemblyline.common.machine.imprinter.BlockImprinter;
import assemblyline.common.machine.imprinter.ItemImprinter;
import assemblyline.common.network.MessageEncoder;
import assemblyline.common.network.MessageEncoderHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import java.io.File;
import java.util.Arrays;
import java.util.logging.Logger;
import net.minecraft.block.Block;
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.IRecipe;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.multiblock.BlockMulti;
@Mod(modid="AssemblyLine", name="Assembly Line", version="0.3.5.117", dependencies="after:BasicComponents; after:IC2", useMetadata=true)
public class AssemblyLine {
public static final String MAJOR_VERSION = "0";
public static final String MINOR_VERSION = "3";
public static final String REVIS_VERSION = "5";
public static final String BUILD_VERSION = "117";
public static final String MOD_ID = "AssemblyLine";
public static final String MOD_NAME = "Assembly Line";
public static final String VERSION = "0.3.5.117";
public static final String CHANNEL = "AssemblyLine";
@SidedProxy(clientSide="assemblyline.client.ClientProxy", serverSide="assemblyline.common.CommonProxy")
public static CommonProxy proxy;
@Mod.Instance(value="AssemblyLine")
public static AssemblyLine instance;
@Mod.Metadata(value="AssemblyLine")
public static ModMetadata meta;
public static final String LANGUAGE_PATH = "/assets/assemblyline/languages/";
private static final String[] LANGUAGES_SUPPORTED;
public static final Configuration CONFIGURATION;
public static final int BLOCK_ID_PREFIX = 3030;
public static Block blockConveyorBelt;
public static Block blockManipulator;
public static BlockCrate blockCrate;
public static Block blockImprinter;
public static Block blockEncoder;
public static Block blockDetector;
public static Block blockRejector;
public static Block blockArmbot;
public static Block blockCraneController;
public static Block blockCraneFrame;
public static Block blockTurntable;
public static BlockMulti blockMulti;
public static final int ITEM_ID_PREFIX = 13030;
public static Item itemImprint;
public static Item itemDisk;
public static ItemStack ic2Wrench;
public static Logger FMLog;
public static final boolean DEBUG = false;
public static boolean REQUIRE_NO_POWER;
public static SimpleNetworkWrapper NETWORK;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
//FMLog.setParent(FMLLog.getLogger());
instance = this;
CONFIGURATION.load();
blockConveyorBelt = new BlockConveyorBelt();
blockManipulator = new BlockManipulator();
blockCrate = new BlockCrate();
blockImprinter = new BlockImprinter();
blockDetector = new BlockDetector();
blockRejector = new BlockRejector();
blockEncoder = new BlockEncoder();
blockArmbot = new BlockArmbot();
blockMulti = new BlockMulti();
blockCraneController = new BlockCraneController();
blockCraneFrame = new BlockCraneFrame();
blockTurntable = new BlockTurntable();
itemImprint = new ItemImprinter();
itemDisk = new ItemDisk();
REQUIRE_NO_POWER = !CONFIGURATION.get("general", "requirePower", true).getBoolean(true);
CONFIGURATION.save();
NetworkRegistry.INSTANCE.registerGuiHandler((Object)this, (IGuiHandler)proxy);
NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID);
NETWORK.registerMessage(new MessageEncoderHandler(), MessageEncoder.class, 0, Side.SERVER);
GameRegistry.registerBlock(blockConveyorBelt, "conveyor_belt");
GameRegistry.registerBlock(blockCrate, ItemBlockCrate.class, "crate");
GameRegistry.registerBlock(blockManipulator, "manipulator");
GameRegistry.registerBlock(blockImprinter, "imprinter");
GameRegistry.registerBlock(blockEncoder, "encoder");
GameRegistry.registerBlock(blockDetector, "detector");
GameRegistry.registerBlock(blockRejector, "rejector");
GameRegistry.registerBlock(blockArmbot, "armbot");
GameRegistry.registerBlock(blockTurntable, "turntable");
GameRegistry.registerBlock(blockCraneController, "crane_controller");
GameRegistry.registerBlock(blockCraneFrame, "crane_frame");
GameRegistry.registerItem(itemDisk, "disk");
GameRegistry.registerItem(itemImprint, "imprint");
TabAssemblyLine.itemStack = new ItemStack(blockConveyorBelt);
proxy.preInit();
}
@EventHandler
public void load(FMLInitializationEvent evt) {
proxy.init();
GrabDictionary.registerList();
FMLog.info("Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " languages.");
AssemblyLine.meta.modId = "AssemblyLine";
AssemblyLine.meta.name = MOD_NAME;
AssemblyLine.meta.description = "A mod that brings conveyor belt transporting systems to Minecraft.";
AssemblyLine.meta.url = "http://calclavia.com/universalelectricity/?m=18";
AssemblyLine.meta.logoFile = "/al_logo.png";
AssemblyLine.meta.version = VERSION;
AssemblyLine.meta.authorList = Arrays.asList("DarkGuardsman, Briaman, Calclavia");
AssemblyLine.meta.credits = "Please see the website.";
AssemblyLine.meta.autogenerated = false;
this.createStandardRecipes();
this.createUERecipes();
}
private void createUERecipes() {
System.out.println("BasicComponents Found...adding UE recipes for Assembly Line.");
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockArmbot, new Object[]{"II ", "SIS", "MCM", Character.valueOf('S'), "plateSteel", Character.valueOf('C'), "advancedCircuit", Character.valueOf('I'), "ingotSteel", Character.valueOf('M'), "motor"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(itemDisk, new Object[]{"III", "ICI", "III", Character.valueOf('I'), itemImprint, Character.valueOf('C'), "advancedCircuit"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockEncoder, new Object[]{"SIS", "SCS", "SSS", Character.valueOf('I'), itemImprint, Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "advancedCircuit"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockDetector, new Object[]{"SES", "SCS", "S S", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "basicCircuit", Character.valueOf('E'), Items.ender_eye}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 10), new Object[]{"III", "WMW", Character.valueOf('I'), "ingotSteel", Character.valueOf('W'), Blocks.planks, Character.valueOf('M'), "motor"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockRejector, new Object[]{"WPW", "@R@", Character.valueOf('@'), "ingotSteel", Character.valueOf('R'), Items.redstone, Character.valueOf('P'), Blocks.piston, Character.valueOf('C'), "basicCircuit", Character.valueOf('W'), "copperWire"}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockTurntable, new Object[]{"M", "P", Character.valueOf('M'), "motor", Character.valueOf('P'), Blocks.piston}));
GameRegistry.addRecipe((IRecipe)new ShapelessOreRecipe(new ItemStack(blockManipulator, 2), new Object[]{Blocks.dispenser, "basicCircuit"}));
}
private void createStandardRecipes() {
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(itemImprint, 2), new Object[]{"R", "P", "I", Character.valueOf('P'), Items.paper, Character.valueOf('R'), Items.redstone, Character.valueOf('I'), new ItemStack(Items.dye, 1, 0)}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(blockImprinter, new Object[]{"SIS", "SPS", "WCW", Character.valueOf('S'), Items.iron_ingot, Character.valueOf('C'), Blocks.chest, Character.valueOf('W'), Blocks.crafting_table, Character.valueOf('P'), Blocks.piston, Character.valueOf('I'), new ItemStack(Items.dye, 1, 0)}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(blockCrate, 1, 0), new Object[]{"TST", "S S", "TST", Character.valueOf('S'), Items.iron_ingot, Character.valueOf('T'), Blocks.log}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(blockCrate, 1, 1), new Object[]{"TST", "SCS", "TST", Character.valueOf('C'), new ItemStack(blockCrate, 1, 0), Character.valueOf('S'), Items.iron_ingot, Character.valueOf('T'), Blocks.log}));
GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(blockCrate, 1, 2), new Object[]{"TST", "SCS", "TST", Character.valueOf('C'), new ItemStack(blockCrate, 1, 1), Character.valueOf('S'), Items.iron_ingot, Character.valueOf('T'), Blocks.log}));
}
public static void printSidedData(String data) {
System.out.print(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT ? "[C]" : "[S]");
System.out.println(" " + data);
}
static {
LANGUAGES_SUPPORTED = new String[]{"en_US"};
CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "UniversalElectricity/AssemblyLine.cfg"));
ic2Wrench = null;
FMLog = Logger.getLogger(MOD_NAME);
REQUIRE_NO_POWER = false;
}
}

View File

@ -0,0 +1,114 @@
package assemblyline.common;
import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.TileEntityManipulator;
import assemblyline.common.machine.TileEntityRejector;
import assemblyline.common.machine.armbot.TileEntityArmbot;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import assemblyline.common.machine.crane.TileEntityCraneController;
import assemblyline.common.machine.crane.TileEntityCraneRail;
import assemblyline.common.machine.detector.TileEntityDetector;
import assemblyline.common.machine.encoder.ContainerEncoder;
import assemblyline.common.machine.encoder.TileEntityEncoder;
import assemblyline.common.machine.imprinter.ContainerImprinter;
import assemblyline.common.machine.imprinter.TileEntityImprinter;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.prefab.multiblock.TileEntityMulti;
public class CommonProxy
implements IGuiHandler {
public static final int GUI_IMPRINTER = 1;
public static final int GUI_ENCODER = 2;
public void preInit() {
}
public void init() {
GameRegistry.registerTileEntity(TileEntityConveyorBelt.class, (String)"ALConveyorBelt");
GameRegistry.registerTileEntity(TileEntityRejector.class, (String)"ALSorter");
GameRegistry.registerTileEntity(TileEntityManipulator.class, (String)"ALManipulator");
GameRegistry.registerTileEntity(TileEntityCrate.class, (String)"ALCrate");
GameRegistry.registerTileEntity(TileEntityDetector.class, (String)"ALDetector");
GameRegistry.registerTileEntity(TileEntityEncoder.class, (String)"ALEncoder");
GameRegistry.registerTileEntity(TileEntityArmbot.class, (String)"ALArmbot");
GameRegistry.registerTileEntity(TileEntityCraneController.class, (String)"ALCraneController");
GameRegistry.registerTileEntity(TileEntityCraneRail.class, (String)"ALCraneRail");
GameRegistry.registerTileEntity(TileEntityImprinter.class, (String)"ALImprinter");
GameRegistry.registerTileEntity(TileEntityMulti.class, (String)"ALMulti");
}
private void extractZipToLocation(File zipFile, String sourceFolder, String destFolder) {
try {
File destFile = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getFile("."), destFolder);
String destinationName = destFile.getAbsolutePath();
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
zipinputstream = new ZipInputStream(new FileInputStream(zipFile));
ZipEntry zipentry = zipinputstream.getNextEntry();
while (zipentry != null) {
int n;
String zipentryName = zipentry.getName();
if (!zipentryName.startsWith(sourceFolder)) {
zipentry = zipinputstream.getNextEntry();
continue;
}
String entryName = destinationName + zipentryName.substring(Math.min(zipentryName.length(), sourceFolder.length() - 1));
entryName = entryName.replace('/', File.separatorChar);
entryName = entryName.replace('\\', File.separatorChar);
File newFile = new File(entryName);
if (zipentry.isDirectory()) {
if (!newFile.mkdirs()) break;
zipentry = zipinputstream.getNextEntry();
continue;
}
FileOutputStream fileoutputstream = new FileOutputStream(entryName);
while ((n = zipinputstream.read(buf, 0, 1024)) > -1) {
fileoutputstream.write(buf, 0, n);
}
fileoutputstream.close();
zipinputstream.closeEntry();
zipentry = zipinputstream.getNextEntry();
}
zipinputstream.close();
}
catch (Exception e) {
System.out.println("Error while loading AssemblyLine Lua libraries: ");
e.printStackTrace();
}
}
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
switch (ID) {
case 1: {
return new ContainerImprinter(player.inventory, (TileEntityImprinter)tileEntity);
}
case 2: {
if (tileEntity == null || !(tileEntity instanceof TileEntityEncoder)) break;
return new ContainerEncoder(player.inventory, (TileEntityEncoder)tileEntity);
}
}
}
return null;
}
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
public boolean isCtrKeyDown() {
return false;
}
}

View File

@ -0,0 +1,35 @@
package assemblyline.common;
public class Pair {
private final Object left;
private final Object right;
public Pair(Object left, Object right) {
this.left = left;
this.right = right;
}
public Object getKey() {
return this.left;
}
public Object getValue() {
return this.right;
}
public int hashCode() {
return this.left.hashCode() ^ this.right.hashCode();
}
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (!(o instanceof Pair)) {
return false;
}
Pair pairo = (Pair)o;
return this.left.equals(pairo.getKey()) && this.right.equals(pairo.getValue());
}
}

View File

@ -0,0 +1,63 @@
package assemblyline.common;
import assemblyline.common.block.TileEntityCrate;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
public class PathfinderCrate {
public IPathCallBack callBackCheck = new IPathCallBack(){
@Override
public boolean isValidNode(PathfinderCrate finder, ForgeDirection direction, TileEntity provider, TileEntity node) {
return node instanceof TileEntityCrate;
}
@Override
public boolean onSearch(PathfinderCrate finder, TileEntity provider) {
return false;
}
};
public List<TileEntity> iteratedNodes;
public List results;
public PathfinderCrate() {
this.clear();
}
public boolean findNodes(TileEntity provider) {
if (provider != null) {
this.iteratedNodes.add(provider);
if (this.callBackCheck.onSearch(this, provider)) {
return false;
}
for (int i = 0; i < 6; ++i) {
TileEntity connectedTile = VectorHelper.getTileEntityFromSide(provider.getWorldObj(), new Vector3(provider), ForgeDirection.getOrientation((int)i));
if (this.iteratedNodes.contains((Object)connectedTile) || !this.callBackCheck.isValidNode(this, ForgeDirection.getOrientation((int)i), provider, connectedTile) || this.findNodes(connectedTile)) continue;
return false;
}
}
return true;
}
public PathfinderCrate init(TileEntity provider) {
this.findNodes(provider);
return this;
}
public PathfinderCrate clear() {
this.iteratedNodes = new ArrayList<>();
this.results = new ArrayList();
return this;
}
public static interface IPathCallBack {
public boolean isValidNode(PathfinderCrate var1, ForgeDirection var2, TileEntity var3, TileEntity var4);
public boolean onSearch(PathfinderCrate var1, TileEntity var2);
}
}

View File

@ -0,0 +1,25 @@
package assemblyline.common;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class TabAssemblyLine
extends CreativeTabs {
public static final TabAssemblyLine INSTANCE = new TabAssemblyLine("assemblyline");
public static ItemStack itemStack;
public TabAssemblyLine(String par2Str) {
super(par2Str);
}
public ItemStack getIconItemStack() {
return itemStack;
}
@Override
public Item getTabIconItem() {
return itemStack.getItem();
}
}

View File

@ -0,0 +1,45 @@
package assemblyline.common.block;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.prefab.block.BlockAdvanced;
public abstract class BlockALMachine
extends BlockAdvanced {
public IIcon machine_icon;
public BlockALMachine(Material material) {
super(material);
}
@SideOnly(value=Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister iconReg) {
this.machine_icon = iconReg.registerIcon("assemblyline:machine");
}
@SideOnly(value=Side.CLIENT)
@Override
public IIcon getIcon(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
return this.machine_icon;
}
@SideOnly(value=Side.CLIENT)
@Override
public IIcon getIcon(int par1, int par2) {
return this.machine_icon;
}
@Override
public TileEntity createTileEntity(World w, int meta) {
return this.createNewTileEntity(w, meta);
}
}

View File

@ -0,0 +1,239 @@
package assemblyline.common.block;
import assemblyline.common.AssemblyLine;
import assemblyline.common.PathfinderCrate;
import assemblyline.common.TabAssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
public class BlockCrate
extends BlockALMachine {
IIcon crate_icon;
public BlockCrate() {
super(UniversalElectricity.machine);
this.setBlockName("crate");
this.setCreativeTab(TabAssemblyLine.INSTANCE);
}
@Override
@SideOnly(value=Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg) {
this.crate_icon = iconReg.registerIcon("assemblyline:crate");
}
@Override
public IIcon getIcon(IBlockAccess iBlockAccess, int x, int y, int z, int side) {
return this.crate_icon;
}
@Override
public IIcon getIcon(int side, int metadata) {
return this.crate_icon;
}
@Override
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityCrate) {
TileEntityCrate tileEntity = (TileEntityCrate)world.getTileEntity(x, y, z);
boolean allMode = world.getWorldTime() - tileEntity.prevClickTime < 10L;
tileEntity.prevClickTime = world.getWorldTime();
this.tryEject(tileEntity, player, allMode);
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
if (super.onBlockActivated(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ)) {
return true;
}
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityCrate) {
TileEntityCrate tileEntity = (TileEntityCrate)world.getTileEntity(x, y, z);
boolean allMode = world.getWorldTime() - tileEntity.prevClickTime < 10L;
tileEntity.prevClickTime = world.getWorldTime();
ItemStack current = entityPlayer.inventory.getCurrentItem();
if (side == 1 || side > 1 && (double)hitY > 0.5 || !entityPlayer.capabilities.isCreativeMode) {
if (current != null && (current.getMaxStackSize() > 1 || current.getItem() == Item.getItemFromBlock(this))) {
this.tryInsert(tileEntity, entityPlayer, allMode);
}
} else if (side == 0 || side > 1 && (double)hitY <= 0.5) {
this.tryEject(tileEntity, entityPlayer, allMode);
}
}
return true;
}
public void tryInsert(TileEntityCrate tileEntity, EntityPlayer player, boolean allMode, boolean doSearch) {
boolean success = allMode ? this.insertAllItems(tileEntity, player) : this.insertCurrentItem(tileEntity, player);
if (!success && doSearch) {
PathfinderCrate pathfinder = new PathfinderCrate().init(tileEntity);
for (TileEntity checkTile : pathfinder.iteratedNodes) {
if (!(checkTile instanceof TileEntityCrate)) continue;
AssemblyLine.blockCrate.tryInsert((TileEntityCrate)checkTile, player, allMode, false);
}
}
}
public void tryInsert(TileEntityCrate tileEntity, EntityPlayer player, boolean allMode) {
this.tryInsert(tileEntity, player, allMode, true);
}
public void tryEject(TileEntityCrate tileEntity, EntityPlayer player, boolean allMode) {
if (allMode && !player.isSneaking()) {
this.ejectItems(tileEntity, player, tileEntity.getMaxLimit());
} else if (player.isSneaking()) {
this.ejectItems(tileEntity, player, 1);
} else {
ItemStack stack = tileEntity.getStackInSlot(0);
if (stack != null) {
this.ejectItems(tileEntity, player, stack.getMaxStackSize());
}
}
}
public boolean insertCurrentItem(TileEntityCrate tileEntity, EntityPlayer player) {
ItemStack currentStack = player.getCurrentEquippedItem();
if (currentStack != null) {
if (currentStack.isStackable()) {
if (tileEntity.getStackInSlot(0) != null && !tileEntity.getStackInSlot(0).isItemEqual(currentStack)) {
return false;
}
player.inventory.setInventorySlotContents(player.inventory.currentItem, BlockCrate.putIn(tileEntity, currentStack));
return true;
}
if (currentStack.getItem() == Item.getItemFromBlock(AssemblyLine.blockCrate)) {
ItemStack containedStack = ItemBlockCrate.getContainingItemStack(currentStack);
ItemStack crateStack = tileEntity.getStackInSlot(0);
if (containedStack != null && (crateStack == null || crateStack != null && containedStack.getItem() == crateStack.getItem() && containedStack.getItemDamage() == crateStack.getItemDamage())) {
ItemStack returned = BlockCrate.putIn(tileEntity, containedStack);
ItemBlockCrate.setContainingItemStack(currentStack, returned);
return true;
}
}
}
return false;
}
public boolean insertAllItems(TileEntityCrate tileEntity, EntityPlayer player) {
ItemStack requestStack = null;
if (tileEntity.getStackInSlot(0) != null) {
requestStack = tileEntity.getStackInSlot(0).copy();
}
if (requestStack == null) {
requestStack = player.getCurrentEquippedItem();
}
if (requestStack != null && requestStack.isStackable()) {
boolean success = false;
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
ItemStack currentStack = player.inventory.getStackInSlot(i);
if (currentStack == null || !requestStack.isItemEqual(currentStack)) continue;
player.inventory.setInventorySlotContents(i, BlockCrate.putIn(tileEntity, currentStack));
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
}
success = true;
}
return success;
}
return false;
}
public boolean ejectItems(TileEntityCrate tileEntity, EntityPlayer player, int requestSize) {
World world = tileEntity.getWorldObj();
ItemStack containingStack = tileEntity.getStackInSlot(0);
if (containingStack != null) {
if (containingStack.stackSize > 0 && requestSize > 0) {
int amountToTake = Math.min(containingStack.stackSize, requestSize);
ItemStack dropStack = containingStack.copy();
dropStack.stackSize = amountToTake;
if (!world.isRemote) {
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, dropStack);
entityItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld((Entity)entityItem);
}
containingStack.stackSize -= amountToTake;
}
if (containingStack.stackSize <= 0) {
containingStack = null;
}
tileEntity.setInventorySlotContents(0, containingStack);
return true;
}
return false;
}
public static ItemStack putIn(TileEntityCrate tileEntity, ItemStack itemStack) {
ItemStack containingStack = tileEntity.getStackInSlot(0);
if (containingStack != null) {
if (containingStack.isStackable() && containingStack.isItemEqual(itemStack)) {
int newStackSize = containingStack.stackSize + itemStack.stackSize;
int overFlowAmount = newStackSize - tileEntity.getInventoryStackLimit();
itemStack.stackSize = overFlowAmount > 0 ? overFlowAmount : 0;
containingStack.stackSize = newStackSize;
tileEntity.setInventorySlotContents(0, containingStack);
}
} else {
tileEntity.setInventorySlotContents(0, itemStack.copy());
itemStack.stackSize = 0;
}
if (itemStack.stackSize <= 0) {
return null;
}
return itemStack;
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
TileEntityCrate tileEntity;
ItemStack containingStack;
if (!world.isRemote && world.getTileEntity(x, y, z) != null && (containingStack = (tileEntity = (TileEntityCrate)world.getTileEntity(x, y, z)).getStackInSlot(0)) != null && containingStack.stackSize > 0) {
float var6 = 0.7f;
double var7 = (double)(world.rand.nextFloat() * var6) + (double)(1.0f - var6) * 0.5;
double var9 = (double)(world.rand.nextFloat() * var6) + (double)(1.0f - var6) * 0.5;
double var11 = (double)(world.rand.nextFloat() * var6) + (double)(1.0f - var6) * 0.5;
ItemStack dropStack = new ItemStack((Block)this, 1, tileEntity.getTier());
ItemBlockCrate.setContainingItemStack(dropStack, containingStack);
EntityItem var13 = new EntityItem(world, (double)x + var7, (double)y + var9, (double)z + var11, dropStack);
var13.delayBeforeCanPickup = 10;
world.spawnEntityInWorld((Entity)var13);
tileEntity.setInventorySlotContents(0, null);
world.setBlock(x, y, z, Blocks.air, 0, 3);
return true;
}
return false;
}
@Override
public int damageDropped(int metadata) {
return metadata;
}
@Override
public TileEntity createNewTileEntity(World var1, int meta) {
return new TileEntityCrate();
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) {
for (int i = 0; i < 3; ++i) {
list.add(new ItemStack((Block)this, 1, i));
}
}
}

View File

@ -0,0 +1,138 @@
package assemblyline.common.block;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
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.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRotatable;
public class BlockTurntable
extends BlockALMachine {
private IIcon top;
public BlockTurntable() {
super(Material.piston);
this.setBlockName("turntable");
this.setCreativeTab(TabAssemblyLine.INSTANCE);
}
@Override
@SideOnly(value=Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg) {
super.registerBlockIcons(iconReg);
this.top = iconReg.registerIcon("assemblyline:turntable");
}
@Override
public void updateTick(World world, int x, int y, int z, Random par5Random) {
this.updateTurntableState(world, x, y, z);
}
@Override
@SideOnly(value=Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
if (side == ForgeDirection.UP.ordinal()) {
return this.top;
}
return this.machine_icon;
}
@Override
@SideOnly(value=Side.CLIENT)
public IIcon getIcon(int side, int meta) {
if (side == ForgeDirection.UP.ordinal()) {
return this.top;
}
return this.machine_icon;
}
public static int determineOrientation(World world, int x, int y, int z, EntityPlayer entityPlayer) {
int var7;
if (MathHelper.abs((float)((float)entityPlayer.posX - (float)x)) < 2.0f && MathHelper.abs((float)((float)entityPlayer.posZ - (float)z)) < 2.0f) {
double var5 = entityPlayer.posY + 1.82 - (double)entityPlayer.yOffset;
if (var5 - (double)y > 2.0) {
return 1;
}
if ((double)y - var5 > 0.0) {
return 0;
}
}
return (var7 = MathHelper.floor_double((double)((double)(entityPlayer.rotationYaw * 4.0f / 360.0f) + 0.5)) & 3) == 0 ? 2 : (var7 == 1 ? 5 : (var7 == 2 ? 3 : (var7 == 3 ? 4 : 0)));
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack) {
int metadata = BlockTurntable.determineOrientation(world, x, y, z, (EntityPlayer)par5EntityLiving);
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
world.scheduleBlockUpdate(x, y, z, this, 20);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
world.scheduleBlockUpdate(x, y, z, this, 20);
}
private void updateTurntableState(World world, int x, int y, int z) {
if (world.isBlockIndirectlyGettingPowered(x, y, z)) {
try {
Vector3 position = new Vector3(x, y, z);
position.modifyPositionFromSide(ForgeDirection.UP);
IRotatable rotatable = null;
TileEntity tileEntity = position.getTileEntity((IBlockAccess)world);
Block block = position.getBlock((IBlockAccess)world);
if (tileEntity instanceof IRotatable) {
rotatable = (IRotatable)tileEntity;
} else if (block instanceof IRotatable) {
rotatable = (IRotatable)block;
}
if (rotatable != null) {
ForgeDirection newDir = ((IRotatable)tileEntity).getDirection((IBlockAccess)world, x, y, z);
switch (newDir) {
case EAST:
newDir = ForgeDirection.SOUTH;
break;
case NORTH:
newDir = ForgeDirection.EAST;
break;
case SOUTH:
newDir = ForgeDirection.WEST;
break;
case WEST:
newDir = ForgeDirection.NORTH;
break;
default:
break;
}
rotatable.setDirection(world, x, y, z, newDir);
world.markBlockForUpdate(position.intX(), position.intY(), position.intZ());
world.playSoundEffect((double)x + 0.5, (double)y + 0.5, (double)z + 0.5, "tile.piston.in", 0.5f, world.rand.nextFloat() * 0.15f + 0.6f);
}
}
catch (Exception e) {
System.out.println("Failed to rotate:");
e.printStackTrace();
}
}
}
@Override
public TileEntity createNewTileEntity(World arg0, int arg1) {
return null;
}
}

View File

@ -0,0 +1,96 @@
package assemblyline.common.block;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemBlockCrate
extends ItemBlock {
public ItemBlockCrate(Block block) {
super(block);
this.setMaxStackSize(1);
}
@Override
public String getUnlocalizedName(ItemStack itemStack) {
return this.getUnlocalizedName() + "." + itemStack.getItemDamage();
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
ItemStack containingStack = ItemBlockCrate.getContainingItemStack(itemStack);
if (containingStack != null) {
par3List.add(containingStack.getDisplayName());
par3List.add("Amount: " + containingStack.stackSize);
} else {
par3List.add("Empty");
}
}
@Override
public void onUpdate(ItemStack itemStack, World par2World, Entity entity, int par4, boolean par5) {
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)entity;
ItemStack containingStack = ItemBlockCrate.getContainingItemStack(itemStack);
if (containingStack != null) {
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, (int)((float)containingStack.stackSize / (float)TileEntityCrate.getMaxLimit(itemStack.getItemDamage())) * 5));
}
}
}
public static void setContainingItemStack(ItemStack itemStack, ItemStack containingStack) {
if (itemStack.stackTagCompound == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
if (containingStack != null) {
NBTTagCompound itemTagCompound = new NBTTagCompound();
containingStack.stackSize = Math.abs(containingStack.stackSize);
containingStack.writeToNBT(itemTagCompound);
itemStack.getTagCompound().setTag("Item", (NBTBase)itemTagCompound);
itemStack.getTagCompound().setInteger("Count", containingStack.stackSize);
} else {
itemStack.getTagCompound().setTag("Item", (NBTBase)new NBTTagCompound());
itemStack.getTagCompound().setInteger("Count", 0);
}
}
public static ItemStack getContainingItemStack(ItemStack itemStack) {
if (itemStack.stackTagCompound == null) {
itemStack.setTagCompound(new NBTTagCompound());
return null;
}
NBTTagCompound itemTagCompound = itemStack.getTagCompound().getCompoundTag("Item");
ItemStack containingStack = ItemStack.loadItemStackFromNBT((NBTTagCompound)itemTagCompound);
if (containingStack != null) {
containingStack.stackSize = itemStack.getTagCompound().getInteger("Count");
}
return containingStack;
}
@Override
public int getMetadata(int metadata) {
return metadata;
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) {
ItemStack containingItem = ItemBlockCrate.getContainingItemStack(stack);
if (world.getTileEntity(x, y, z) != null && containingItem != null && containingItem.stackSize > 0) {
TileEntityCrate tileEntity = (TileEntityCrate)world.getTileEntity(x, y, z);
tileEntity.setInventorySlotContents(0, containingItem);
}
}
return true;
}
}

View File

@ -0,0 +1,227 @@
package assemblyline.common.block;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import universalelectricity.prefab.implement.ITier;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class TileEntityCrate
extends TileEntityAdvanced
implements ITier,
IInventory {
private ItemStack[] containingItems = new ItemStack[1];
public long prevClickTime = -1000L;
public int getMaxLimit() {
return TileEntityCrate.getMaxLimit(this.getTier());
}
public static int getMaxLimit(int tier) {
if (tier >= 2) {
return 16384;
}
if (tier >= 1) {
return 4096;
}
return 2048;
}
@Override
public boolean canUpdate() {
return false;
}
/*@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) {
if (this.field_70331_k.isRemote) {
try {
if (dataStream.readBoolean()) {
if (this.containingItems[0] == null) {
this.containingItems[0] = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
} else {
this.containingItems[0].field_77993_c = dataStream.readInt();
this.containingItems[0].stackSize = dataStream.readInt();
this.containingItems[0].setItemDamage(dataStream.readInt());
}
} else {
this.containingItems[0] = null;
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}*/
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
if (this.worldObj.isRemote) {
NBTTagCompound nbt = pkt.func_148857_g();
if (nbt.getBoolean("containsItems")) {
if (containingItems[0] == null) {
containingItems[0] = new ItemStack(Item.getItemById(nbt.getShort("id")), nbt.getByte("Count"), nbt.getShort("Damage"));
} else {
containingItems[0].readFromNBT(nbt);
}
} else {
containingItems[0] = null;
}
}
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
if (this.containingItems[0] != null) {
nbt.setBoolean("containsItems", true);
containingItems[0].writeToNBT(nbt);
//return PacketManager.getPacket("AssemblyLine", this, new Object[]{true, this.containingItems[0].field_77993_c, this.containingItems[0].stackSize, this.containingItems[0].getItemDamage()});
} else {
nbt.setBoolean("containsItems", false);
}
//return PacketManager.getPacket("AssemblyLine", this, new Object[]{false});
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(), nbt);
}
@Override
public ItemStack getStackInSlot(int par1) {
return this.containingItems[par1];
}
@Override
public ItemStack decrStackSize(int par1, int par2) {
if (this.containingItems[par1] != null) {
if (this.containingItems[par1].stackSize <= par2) {
ItemStack var3 = this.containingItems[par1];
this.setInventorySlotContents(par1, null);
return var3;
}
ItemStack var3 = this.containingItems[par1].splitStack(par2);
if (this.containingItems[par1].stackSize == 0) {
this.containingItems[par1] = null;
}
this.setInventorySlotContents(par1, this.containingItems[par1]);
return var3;
}
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int par1) {
if (this.containingItems[par1] != null) {
ItemStack var2 = this.containingItems[par1];
this.containingItems[par1] = null;
return var2;
}
return null;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
if (stack != null) {
if (stack.isStackable()) {
this.containingItems[slot] = stack;
if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
stack.stackSize = this.getInventoryStackLimit();
}
}
} else {
this.containingItems[slot] = null;
}
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@Override
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) {
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
NBTTagList var2 = nbt.getTagList("Items", 10);
this.containingItems = new ItemStack[this.getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
NBTTagCompound var4 = (NBTTagCompound)var2.getCompoundTagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 < 0 || var5 >= this.containingItems.length) continue;
this.containingItems[var5] = ItemStack.loadItemStackFromNBT((NBTTagCompound)var4);
}
if (this.containingItems[0] != null) {
this.containingItems[0].stackSize = nbt.getInteger("Count");
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.containingItems.length; ++var3) {
if (this.containingItems[var3] == null) continue;
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.containingItems[var3].writeToNBT(var4);
var2.appendTag((NBTBase)var4);
}
nbt.setTag("Items", (NBTBase)var2);
if (this.containingItems[0] != null) {
nbt.setInteger("Count", this.containingItems[0].stackSize);
}
}
@Override
public int getInventoryStackLimit() {
return this.getMaxLimit();
}
@Override
public int getSizeInventory() {
return this.containingItems.length;
}
@Override
public String getInventoryName() {
return "Crate";
}
@Override
public int getTier() {
return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
}
@Override
public void setTier(int tier) {
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, tier, 3);
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
}
}

View File

@ -0,0 +1,23 @@
package assemblyline.common.machine;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockBeltSorter
extends BlockALMachine {
public BlockBeltSorter() {
super(Material.iron);
this.setCreativeTab(TabAssemblyLine.INSTANCE);
this.setBlockName("BeltSorter");
}
@Override
public TileEntity createNewTileEntity(World arg0, int arg1) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,82 @@
package assemblyline.common.machine;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.machine.imprinter.BlockImprintable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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;
public class BlockManipulator
extends BlockImprintable {
public BlockManipulator() {
super("manipulator", UniversalElectricity.machine, TabAssemblyLine.INSTANCE);
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.29f, 1.0f);
}
public AxisAlignedBB func_71911_a_(World par1World, int par2, int par3, int par4) {
return AxisAlignedBB.getBoundingBox((double)par2, (double)par3, (double)par4, (double)par2 + 1.0, (double)par3 + 1.0, (double)par4 + 1.0);
}
@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.getTileEntity(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.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityManipulator) {
TileEntityManipulator manip = (TileEntityManipulator)tileEntity;
boolean manipMode = manip.isOutput();
boolean inverted = manip.isInverted();
if (manipMode && !inverted) {
manip.toggleInversion();
} else if (manipMode && inverted) {
manip.toggleOutput();
manip.toggleInversion();
} else if (!manipMode && !inverted) {
manip.toggleInversion();
} else {
manip.toggleOutput();
manip.toggleInversion();
}
}
return true;
}
@Override
public TileEntity createNewTileEntity(World var1, int metadata) {
return new TileEntityManipulator();
}
@Override
@SideOnly(value=Side.CLIENT)
public int getRenderType() {
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int damageDropped(int par1) {
return 0;
}
}

View File

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

View File

@ -0,0 +1,73 @@
package assemblyline.common.machine;
import assemblyline.common.AssemblyLine;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.prefab.tile.TileEntityElectricityRunnable;
public abstract class TileEntityAssemblyNetwork
extends TileEntityElectricityRunnable {
public int powerTransferRange = 0;
public boolean isRunning() {
return AssemblyLine.REQUIRE_NO_POWER || this.powerTransferRange > 0 || this.wattsReceived > this.getRequest().getWatts();
}
public void updatePowerTransferRange() {
int maximumTransferRange = 0;
for (int i = 0; i < 6; ++i) {
ForgeDirection direction = ForgeDirection.getOrientation((int)i);
TileEntity tileEntity = this.worldObj.getTileEntity(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ);
if (tileEntity == null || !(tileEntity instanceof TileEntityAssemblyNetwork)) continue;
TileEntityAssemblyNetwork assemblyNetwork = (TileEntityAssemblyNetwork)tileEntity;
if (assemblyNetwork.powerTransferRange <= maximumTransferRange) continue;
maximumTransferRange = assemblyNetwork.powerTransferRange;
}
this.powerTransferRange = Math.max(maximumTransferRange - 1, 0);
}
@Override
public void updateEntity() {
super.updateEntity();
this.onUpdate();
if (this.ticks % 10L == 0L) {
if (this.wattsReceived >= this.getRequest().getWatts()) {
this.wattsReceived -= this.getRequest().getWatts();
this.powerTransferRange = this.getMaxTransferRange();
} else {
this.powerTransferRange = 0;
this.updatePowerTransferRange();
}
if (!this.worldObj.isRemote) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
protected void onUpdate() {
}
@Override
public ElectricityPack getRequest() {
return new ElectricityPack(1.0, this.getVoltage());
}
protected int getMaxTransferRange() {
return 20;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setDouble("wattsReceived", this.wattsReceived);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.wattsReceived = nbt.getDouble("wattsReceived");
}
}

View File

@ -0,0 +1,312 @@
package assemblyline.common.machine;
import assemblyline.api.IManipulator;
import assemblyline.common.block.BlockCrate;
import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.multiblock.TileEntityMulti;
public class TileEntityManipulator
extends TileEntityFilterable
implements IRotatable,
IRedstoneReceptor,
IManipulator {
public boolean selfPulse = false;
private boolean isOutput = false;
private boolean isRedstonePowered = false;
public boolean isOutput() {
return this.isOutput;
}
public void setOutput(boolean isOutput) {
this.isOutput = isOutput;
if (!this.worldObj.isRemote) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
public void toggleOutput() {
this.setOutput(!this.isOutput());
}
@Override
protected void onUpdate() {
if (!this.worldObj.isRemote) {
if (this.ticks % 20L == 0L) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
if (!this.isDisabled() && this.isRunning()) {
if (!this.isOutput) {
this.inject();
} else {
if (this.selfPulse && this.ticks % 10L == 0L) {
this.isRedstonePowered = true;
}
if (this.isRedstonePowered) {
this.eject();
}
}
}
}
}
@Override
public void inject() {
Vector3 inputPosition = new Vector3(this);
Vector3 outputUp = new Vector3(this);
outputUp.modifyPositionFromSide(ForgeDirection.UP);
Vector3 outputDown = new Vector3(this);
outputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 outputPosition = new Vector3(this);
outputPosition.modifyPositionFromSide(this.getDirection().getOpposite());
if (outputPosition.getTileEntity((IBlockAccess)this.worldObj) instanceof TileEntityManipulator && ((TileEntityManipulator)outputPosition.getTileEntity((IBlockAccess)this.worldObj)).getDirection() == this.getDirection().getOpposite()) {
return;
}
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox((double)inputPosition.x, (double)inputPosition.y, (double)inputPosition.z, (double)(inputPosition.x + 1.0), (double)(inputPosition.y + 1.0), (double)(inputPosition.z + 1.0));
List<EntityItem> itemsInBound = this.worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
for (EntityItem entity : itemsInBound) {
if (entity.isDead) continue;
ItemStack remainingStack = entity.getEntityItem().copy();
if (this.getFilter() != null && !this.isFiltering(remainingStack)) continue;
if ((remainingStack = this.tryPlaceInPosition(remainingStack, outputUp, ForgeDirection.DOWN)) != null) {
remainingStack = this.tryPlaceInPosition(remainingStack, outputDown, ForgeDirection.UP);
}
if (remainingStack != null) {
remainingStack = this.tryPlaceInPosition(remainingStack, outputPosition, this.getDirection().getOpposite());
}
if (remainingStack != null && remainingStack.stackSize > 0) {
this.throwItem(outputPosition, remainingStack);
}
entity.setDead();
}
}
@Override
public void eject() {
this.onPowerOff();
Vector3 inputUp = new Vector3(this);
inputUp.modifyPositionFromSide(ForgeDirection.UP);
Vector3 inputDown = new Vector3(this);
inputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 inputPosition = new Vector3(this);
inputPosition.modifyPositionFromSide(this.getDirection().getOpposite());
Vector3 outputPosition = new Vector3(this);
outputPosition.modifyPositionFromSide(this.getDirection());
ItemStack itemStack = this.tryGrabFromPosition(inputUp, ForgeDirection.DOWN);
if (itemStack == null) {
itemStack = this.tryGrabFromPosition(inputDown, ForgeDirection.UP);
}
if (itemStack == null) {
itemStack = this.tryGrabFromPosition(inputPosition, this.getDirection().getOpposite());
}
if (itemStack != null && itemStack.stackSize > 0) {
this.throwItem(outputPosition, itemStack);
}
}
public void throwItem(Vector3 outputPosition, ItemStack items) {
if (!this.worldObj.isRemote) {
EntityItem entityItem = new EntityItem(this.worldObj, outputPosition.x + 0.5, outputPosition.y + 0.8, outputPosition.z + 0.5, items);
entityItem.motionX = 0.0;
entityItem.motionZ = 0.0;
entityItem.motionY /= 5.0;
entityItem.delayBeforeCanPickup = 20;
this.worldObj.spawnEntityInWorld((Entity)entityItem);
}
}
private ItemStack tryPlaceInPosition(ItemStack itemStack, Vector3 position, ForgeDirection direction) {
TileEntity tileEntity = position.getTileEntity((IBlockAccess)this.worldObj);
if (tileEntity != null && itemStack != null) {
if (tileEntity instanceof TileEntityMulti) {
Vector3 mainBlockPosition = ((TileEntityMulti)tileEntity).mainBlockPosition;
if (mainBlockPosition != null && !(mainBlockPosition.getTileEntity((IBlockAccess)this.worldObj) instanceof TileEntityMulti)) {
return this.tryPlaceInPosition(itemStack, mainBlockPosition, direction);
}
} else if (tileEntity instanceof TileEntityChest) {
TileEntityChest[] chests = new TileEntityChest[]{(TileEntityChest)tileEntity, null};
for (int i = 2; i < 6; ++i) {
ForgeDirection searchDirection = ForgeDirection.getOrientation((int)i);
Vector3 searchPosition = position.clone();
searchPosition.modifyPositionFromSide(searchDirection);
if (searchPosition.getTileEntity((IBlockAccess)this.worldObj) == null || searchPosition.getTileEntity((IBlockAccess)this.worldObj).getClass() != chests[0].getClass()) continue;
chests[1] = (TileEntityChest)searchPosition.getTileEntity((IBlockAccess)this.worldObj);
break;
}
for (TileEntityChest chest : chests) {
if (chest == null) continue;
for (int i = 0; i < chest.getSizeInventory(); ++i) {
if ((itemStack = this.addStackToInventory(i, (IInventory)chest, itemStack)) != null) continue;
return null;
}
}
} else {
if (tileEntity instanceof TileEntityCrate) {
return BlockCrate.putIn((TileEntityCrate)tileEntity, itemStack);
}
if (tileEntity instanceof ISidedInventory) {
int startIndex;
ISidedInventory inventory = (ISidedInventory)tileEntity;
for (int i : inventory.getAccessibleSlotsFromSide(direction.ordinal())) {
if ((itemStack = this.addStackToInventory(i, (IInventory)inventory, itemStack)) != null) continue;
return null;
}
} else if (tileEntity instanceof IInventory) {
IInventory inventory = (IInventory)tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
if ((itemStack = this.addStackToInventory(i, inventory, itemStack)) != null) continue;
return null;
}
}
}
}
if (itemStack.stackSize <= 0) {
return null;
}
return itemStack;
}
public ItemStack addStackToInventory(int slotIndex, IInventory inventory, ItemStack itemStack) {
if (inventory.getSizeInventory() > slotIndex) {
ItemStack stackInInventory = inventory.getStackInSlot(slotIndex);
if (stackInInventory == null) {
inventory.setInventorySlotContents(slotIndex, itemStack);
if (inventory.getStackInSlot(slotIndex) == null) {
return itemStack;
}
return null;
}
if (stackInInventory.isItemEqual(itemStack) && stackInInventory.isStackable()) {
stackInInventory = stackInInventory.copy();
int stackLim = Math.min(inventory.getInventoryStackLimit(), itemStack.getMaxStackSize());
int rejectedAmount = Math.max(stackInInventory.stackSize + itemStack.stackSize - stackLim, 0);
stackInInventory.stackSize = Math.min(Math.max(stackInInventory.stackSize + itemStack.stackSize - rejectedAmount, 0), inventory.getInventoryStackLimit());
itemStack.stackSize = rejectedAmount;
inventory.setInventorySlotContents(slotIndex, stackInInventory);
}
}
if (itemStack.stackSize <= 0) {
return null;
}
return itemStack;
}
private ItemStack tryGrabFromPosition(Vector3 position, ForgeDirection direction) {
ItemStack returnStack;
block6: {
TileEntity tileEntity;
block9: {
int startIndex;
block8: {
block7: {
returnStack = null;
tileEntity = position.getTileEntity((IBlockAccess)this.worldObj);
if (tileEntity == null) break block6;
if (!(tileEntity instanceof TileEntityMulti)) break block7;
Vector3 mainBlockPosition = ((TileEntityMulti)tileEntity).mainBlockPosition;
if (mainBlockPosition != null && !(mainBlockPosition.getTileEntity((IBlockAccess)this.worldObj) instanceof TileEntityMulti)) {
return this.tryGrabFromPosition(mainBlockPosition, direction);
}
break block6;
}
if (!(tileEntity instanceof TileEntityChest)) break block8;
TileEntityChest[] chests = new TileEntityChest[]{(TileEntityChest)tileEntity, null};
for (int i = 2; i < 6; ++i) {
ForgeDirection searchDirection = ForgeDirection.getOrientation((int)i);
Vector3 searchPosition = position.clone();
searchPosition.modifyPositionFromSide(searchDirection);
if (searchPosition.getTileEntity((IBlockAccess)this.worldObj) == null || searchPosition.getTileEntity((IBlockAccess)this.worldObj).getClass() != chests[0].getClass()) continue;
chests[1] = (TileEntityChest)searchPosition.getTileEntity((IBlockAccess)this.worldObj);
break;
}
for (TileEntityChest chest : chests) {
if (chest == null) continue;
for (int i = 0; i < chest.getSizeInventory(); ++i) {
ItemStack itemStack = this.removeStackFromInventory(i, (IInventory)chest);
if (itemStack == null) continue;
returnStack = itemStack;
break block6;
}
}
break block6;
}
if (!(tileEntity instanceof ISidedInventory)) break block9;
ISidedInventory inventory = (ISidedInventory)tileEntity;
for (int i : inventory.getAccessibleSlotsFromSide(direction.ordinal())) {
ItemStack itemStack = this.removeStackFromInventory(i, (IInventory)inventory);
if (itemStack == null) continue;
returnStack = itemStack;
break block6;
}
break block6;
}
if (!(tileEntity instanceof IInventory)) break block6;
IInventory inventory = (IInventory)tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
ItemStack itemStack = this.removeStackFromInventory(i, inventory);
if (itemStack == null) continue;
returnStack = itemStack;
break;
}
}
return returnStack;
}
public ItemStack removeStackFromInventory(int slotIndex, IInventory inventory) {
if (inventory.getStackInSlot(slotIndex) != null) {
ItemStack itemStack = inventory.getStackInSlot(slotIndex).copy();
if (this.getFilter() == null || this.isFiltering(itemStack)) {
itemStack.stackSize = 1;
inventory.decrStackSize(slotIndex, 1);
return itemStack;
}
}
return null;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.isOutput = nbt.getBoolean("isOutput");
this.selfPulse = nbt.getBoolean("selfpulse");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("isOutput", this.isOutput);
nbt.setBoolean("selfpulse", this.selfPulse);
}
@Override
public void onPowerOn() {
this.isRedstonePowered = true;
}
@Override
public void onPowerOff() {
this.isRedstonePowered = false;
}
@Override
public boolean canConnect(ForgeDirection dir) {
return dir != this.getDirection();
}
}

View File

@ -0,0 +1,85 @@
package assemblyline.common.machine;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
public class TileEntityRejector
extends TileEntityFilterable {
public boolean firePiston = false;
@Override
protected int getMaxTransferRange() {
return 20;
}
@Override
public void onUpdate() {
super.onUpdate();
if (this.ticks % 5L == 0L && !this.isDisabled()) {
int metadata = this.getBlockMetadata();
this.firePiston = false;
Vector3 searchPosition = new Vector3(this);
searchPosition.modifyPositionFromSide(this.getDirection());
TileEntity tileEntity = searchPosition.getTileEntity((IBlockAccess)this.worldObj);
try {
boolean flag = false;
if (this.isRunning()) {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox((double)searchPosition.x, (double)searchPosition.y, (double)searchPosition.z, (double)(searchPosition.x + 1.0), (double)(searchPosition.y + 1.0), (double)(searchPosition.z + 1.0));
List<Entity> entitiesInFront = this.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : entitiesInFront) {
if (!this.canEntityBeThrow(entity)) continue;
this.throwItem(this.getDirection(), entity);
flag = true;
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
public void throwItem(ForgeDirection side, Entity entity) {
this.firePiston = true;
entity.motionX = (double)side.offsetX * 0.2;
entity.motionY += 0.10000000298023223;
entity.motionZ = (double)side.offsetZ * 0.2;
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
public boolean canEntityBeThrow(Entity entity) {
if (entity instanceof EntityItem) {
EntityItem entityItem = (EntityItem)entity;
ItemStack itemStack = entityItem.getEntityItem();
return this.isFiltering(itemStack);
}
return false;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.firePiston = nbt.getBoolean("piston");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("piston", this.firePiston);
}
@Override
public boolean canConnect(ForgeDirection dir) {
return dir != this.getDirection();
}
}

View File

@ -0,0 +1,79 @@
package assemblyline.common.machine.armbot;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
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.multiblock.IMultiBlock;
public class BlockArmbot
extends BlockALMachine {
public BlockArmbot() {
super(UniversalElectricity.machine);
this.setBlockName("armbot");
this.setCreativeTab(TabAssemblyLine.INSTANCE);
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(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.getTileEntity(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, Block par5, int par6) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof IMultiBlock) {
((IMultiBlock)tileEntity).onDestroy(tileEntity);
}
this.dropBlockAsItem(world, x, y, z, new ItemStack(this));
super.breakBlock(world, x, y, z, par5, par6);
}
@Override
public int quantityDropped(Random par1Random) {
return 0;
}
@Override
public TileEntity createNewTileEntity(World var1, int meta) {
return new TileEntityArmbot();
}
@SideOnly(value=Side.CLIENT)
@Override
public int getRenderType() {
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean canProvidePower() {
return true;
}
}

View File

@ -0,0 +1,684 @@
package assemblyline.common.machine.armbot;
import assemblyline.api.IArmbot;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandDrop;
import assemblyline.common.machine.command.CommandFire;
import assemblyline.common.machine.command.CommandGrab;
import assemblyline.common.machine.command.CommandManager;
import assemblyline.common.machine.command.CommandReturn;
import assemblyline.common.machine.command.CommandRotateBy;
import assemblyline.common.machine.command.CommandRotateTo;
import assemblyline.common.machine.command.CommandUse;
import assemblyline.common.machine.encoder.ItemDisk;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import dark.library.helpers.ItemFindingHelper;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.block.IElectricityStorage;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.multiblock.IMultiBlock;
public class TileEntityArmbot
extends TileEntityAssemblyNetwork
implements IMultiBlock,
IInventory,
IElectricityStorage,
IArmbot,
IPeripheral {
private final CommandManager commandManager = new CommandManager();
private static final int PACKET_COMMANDS = 128;
protected ItemStack disk = null;
public final double WATT_REQUEST = 20.0;
public double wattsReceived = 0.0;
private int playerUsing = 0;
private int computersAttached = 0;
private List connectedComputers = new ArrayList();
public float rotationPitch = 0.0f;
public float rotationYaw = 0.0f;
public float renderPitch = 0.0f;
public float renderYaw = 0.0f;
private int ticksSincePower = 0;
public final float ROTATION_SPEED = 1.3f;
private String displayText = "";
public boolean isProvidingPower = false;
private final List<Entity> grabbedEntities = new ArrayList<>();
private final List<ItemStack> grabbedItems = new ArrayList();
public EntityItem renderEntityItem = null;
@Override
public void onUpdate() {
Vector3 handPosition = this.getHandPosition();
for (Entity entity : this.grabbedEntities) {
if (entity == null) continue;
entity.setPosition(handPosition.x, handPosition.y, handPosition.z);
entity.motionX = 0.0;
entity.motionY = 0.0;
entity.motionZ = 0.0;
if (!(entity instanceof EntityItem)) continue;
((EntityItem)entity).delayBeforeCanPickup = 20;
((EntityItem)entity).age = 0;
}
if (this.isRunning()) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.disk == null && this.computersAttached == 0) {
this.commandManager.clear();
if (this.grabbedEntities.size() > 0 || this.grabbedItems.size() > 0) {
this.addCommand(CommandDrop.class);
} else if (!this.commandManager.hasTasks() && ((double)Math.abs(this.rotationYaw - 0.0f) > 0.01 || (double)Math.abs(this.rotationPitch - 0.0f) > 0.01)) {
this.addCommand(CommandReturn.class);
}
this.commandManager.setCurrentTask(0);
}
if (!this.worldObj.isRemote) {
this.commandManager.onUpdate();
}
this.ticksSincePower = 0;
} else {
++this.ticksSincePower;
}
if (!this.worldObj.isRemote) {
if (!this.commandManager.hasTasks()) {
this.displayText = "";
} else {
try {
Command curCommand = (Command)this.commandManager.getCommands().get(this.commandManager.getCurrentTask());
if (curCommand != null) {
this.displayText = curCommand.toString();
}
}
catch (Exception ex) {
// empty catch block
}
}
}
if (Math.abs(this.renderYaw - this.rotationYaw) > 0.001f) {
float speedYaw;
if (this.renderYaw > this.rotationYaw) {
if (Math.abs(this.renderYaw - this.rotationYaw) >= 180.0f) {
this.getClass();
speedYaw = 1.3f;
} else {
this.getClass();
speedYaw = -1.3f;
}
} else if (Math.abs(this.renderYaw - this.rotationYaw) >= 180.0f) {
this.getClass();
speedYaw = -1.3f;
} else {
this.getClass();
speedYaw = 1.3f;
}
this.renderYaw += speedYaw;
while (this.renderYaw < 0.0f) {
this.renderYaw += 360.0f;
}
while (this.renderYaw > 360.0f) {
this.renderYaw -= 360.0f;
}
if (this.ticks % 5L == 0L && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
this.worldObj.playSound((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, "assemblyline:conveyor", 0.8f, 1.7f, true);
}
float f = Math.abs(this.renderYaw - this.rotationYaw);
this.getClass();
if (f < 1.3f + 0.1f) {
this.renderYaw = this.rotationYaw;
}
for (Entity e : (List<Entity>)this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox((double)this.xCoord, (double)(this.yCoord + 2), (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 3), (double)(this.zCoord + 1)))) {
e.rotationYaw = this.renderYaw;
}
}
if (Math.abs(this.renderPitch - this.rotationPitch) > 0.001f) {
float speedPitch;
if (this.renderPitch > this.rotationPitch) {
this.getClass();
speedPitch = -1.3f;
} else {
this.getClass();
speedPitch = 1.3f;
}
this.renderPitch += speedPitch;
while (this.renderPitch < 0.0f) {
this.renderPitch += 60.0f;
}
while (this.renderPitch > 60.0f) {
this.renderPitch -= 60.0f;
}
if (this.ticks % 4L == 0L && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
this.worldObj.playSound((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, "assemblyline:conveyor", 2.0f, 2.5f, true);
}
float f = Math.abs(this.renderPitch - this.rotationPitch);
this.getClass();
if (f < 1.3f + 0.1f) {
this.renderPitch = this.rotationPitch;
}
for (Entity e : (List<Entity>)this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox((double)this.xCoord, (double)(this.yCoord + 2), (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 3), (double)(this.zCoord + 1)))) {
e.rotationPitch = this.renderPitch;
}
}
while (this.rotationYaw < 0.0f) {
this.rotationYaw += 360.0f;
}
while (this.rotationYaw > 360.0f) {
this.rotationYaw -= 360.0f;
}
while (this.rotationPitch < 0.0f) {
this.rotationPitch += 60.0f;
}
while (this.rotationPitch > 60.0f) {
this.rotationPitch -= 60.0f;
}
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.ticks % 20L == 0L) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
public Command getCurrentCommand() {
if (this.commandManager.hasTasks() && this.commandManager.getCurrentTask() >= 0 && this.commandManager.getCurrentTask() < this.commandManager.getCommands().size()) {
return (Command)this.commandManager.getCommands().get(this.commandManager.getCurrentTask());
}
return null;
}
public Vector3 getHandPosition() {
Vector3 position = new Vector3(this);
position.add(0.5);
position.add(this.getDeltaHandPosition());
return position;
}
public Vector3 getDeltaHandPosition() {
double distance = 1.0;
Vector3 delta = new Vector3();
delta.y = Math.sin(Math.toRadians(this.renderPitch)) * distance * 2.0;
double dH = Math.cos(Math.toRadians(this.renderPitch)) * distance;
delta.x = Math.sin(Math.toRadians(-this.renderYaw)) * dH;
delta.z = Math.cos(Math.toRadians(-this.renderYaw)) * dH;
return delta;
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound data = new NBTTagCompound();
this.writeToNBT(data);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setTag("data", data);
nbt.setInteger("transferRange", this.powerTransferRange);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(), nbt);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
if (this.worldObj.isRemote) {
NBTTagCompound nbt = pkt.func_148857_g();
this.powerTransferRange = nbt.getInteger("transferRange");
NBTTagCompound data = nbt.getCompoundTag("data");
this.readFromNBT(data);
}
}
@Override
public int getSizeInventory() {
return 1;
}
@Override
public String getInventoryName() {
return TranslationHelper.getLocal("tile.armbot.name");
}
@Override
public ItemStack getStackInSlot(int par1) {
return this.disk;
}
@Override
public ItemStack decrStackSize(int par1, int par2) {
if (this.disk != null) {
if (this.disk.stackSize <= par2) {
ItemStack var3 = this.disk;
this.disk = null;
return var3;
}
ItemStack var3 = this.disk.splitStack(par2);
if (this.disk.stackSize == 0) {
this.disk = null;
}
return var3;
}
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int par1) {
if (this.disk != null) {
ItemStack var2 = this.disk;
this.disk = null;
return var2;
}
return null;
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
this.disk = par2ItemStack;
this.markDirty();
}
@Override
public int getInventoryStackLimit() {
return 1;
}
@Override
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) {
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
}
@Override
public void openInventory() {
++this.playerUsing;
}
@Override
public void closeInventory() {
--this.playerUsing;
}
public String getCommandDisplayText() {
return this.displayText;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
NBTTagCompound diskNBT = nbt.getCompoundTag("disk");
this.disk = diskNBT != null ? ItemStack.loadItemStackFromNBT((NBTTagCompound)diskNBT) : null;
this.rotationYaw = nbt.getFloat("yaw");
this.rotationPitch = nbt.getFloat("pitch");
if (this.worldObj != null && this.worldObj.isRemote) {
this.displayText = nbt.getString("cmdText");
}
this.commandManager.setCurrentTask(nbt.getInteger("curTask"));
NBTTagList entities = nbt.getTagList("entities", 10);
this.grabbedEntities.clear();
for (int i = 0; i < entities.tagCount(); ++i) {
NBTTagCompound entityTag = (NBTTagCompound)entities.getCompoundTagAt(i);
if (entityTag == null) continue;
Entity entity = EntityList.createEntityFromNBT((NBTTagCompound)entityTag, (World)this.worldObj);
this.grabbedEntities.add(entity);
}
NBTTagList items = nbt.getTagList("items", 10);
this.grabbedItems.clear();
for (int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound itemTag = (NBTTagCompound)items.getCompoundTagAt(i);
if (itemTag == null) continue;
ItemStack item = ItemStack.loadItemStackFromNBT((NBTTagCompound)itemTag);
this.grabbedItems.add(item);
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagCompound diskNBT = new NBTTagCompound();
if (this.disk != null) {
this.disk.writeToNBT(diskNBT);
}
nbt.setTag("disk", (NBTBase)diskNBT);
nbt.setFloat("yaw", this.rotationYaw);
nbt.setFloat("pitch", this.rotationPitch);
nbt.setString("cmdText", this.displayText);
nbt.setInteger("curTask", this.commandManager.getCurrentTask());
NBTTagList entities = new NBTTagList();
for (Entity entity : this.grabbedEntities) {
if (entity == null) continue;
NBTTagCompound entityNBT = new NBTTagCompound();
entity.writeToNBT(entityNBT);
entity.writeToNBTOptional(entityNBT);
entities.appendTag((NBTBase)entityNBT);
}
nbt.setTag("entities", (NBTBase)entities);
NBTTagList items = new NBTTagList();
for (ItemStack itemStack : this.grabbedItems) {
if (itemStack == null) continue;
NBTTagCompound entityNBT = new NBTTagCompound();
itemStack.writeToNBT(entityNBT);
items.appendTag((NBTBase)entityNBT);
}
nbt.setTag("items", (NBTBase)items);
}
@Override
public double getJoules() {
return this.wattsReceived;
}
@Override
public void setJoules(double joules) {
this.wattsReceived = joules;
}
@Override
public double getMaxJoules() {
return 1000.0;
}
@Override
public boolean onActivated(EntityPlayer player) {
ItemStack containingStack = this.getStackInSlot(0);
if (containingStack != null) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
EntityItem dropStack = new EntityItem(this.worldObj, player.posX, player.posY, player.posZ, containingStack);
dropStack.delayBeforeCanPickup = 0;
this.worldObj.spawnEntityInWorld((Entity)dropStack);
}
this.setInventorySlotContents(0, null);
return true;
}
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemDisk) {
this.setInventorySlotContents(0, player.getCurrentEquippedItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
return true;
}
return false;
}
public void markDirty() {
this.commandManager.clear();
if (this.disk != null) {
List<String> commands = ItemDisk.getCommands(this.disk);
for (String commandString : commands) {
String commandName = commandString.split(" ")[0];
Class command = Command.getCommand(commandName);
if (command == null) continue;
ArrayList<String> commandParameters = new ArrayList<String>();
for (String param : commandString.split(" ")) {
if (param.equals(commandName)) continue;
commandParameters.add(param);
}
this.addCommand(command, commandParameters.toArray(new String[0]));
}
} else {
this.addCommand(Command.getCommand("DROP"));
this.addCommand(Command.getCommand("RETURN"));
}
}
public void addCommand(Class command) {
this.commandManager.addCommand(this, command);
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
public void addCommand(Class command, String[] parameters) {
this.commandManager.addCommand(this, command, parameters);
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@Override
public void onCreate(Vector3 placedPosition) {
AssemblyLine.blockMulti.makeFakeBlock(this.worldObj, Vector3.add(placedPosition, new Vector3(0.0, 1.0, 0.0)), placedPosition);
}
@Override
public void onDestroy(TileEntity callingBlock) {
this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.air, 0, 3);
this.worldObj.setBlock(this.xCoord, this.yCoord + 1, this.zCoord, Blocks.air, 0, 3);
}
@Override
public String getType() {
return "ArmBot";
}
@Override
public String[] getMethodNames() {
return new String[]{"rotateBy", "rotateTo", "grab", "drop", "reset", "isWorking", "touchingEntity", "use", "fire", "return", "clear", "isHolding"};
}
@Override
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException {
switch (method) {
case 0: {
if (arguments.length > 0) {
try {
double yaw = (Double)arguments[0];
double pitch = (Double)arguments[1];
this.addCommand(CommandRotateBy.class, new String[]{Double.toString(yaw), Double.toString(pitch)});
break;
}
catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("expected number");
}
}
throw new IllegalArgumentException("expected number");
}
case 1: {
if (arguments.length > 0) {
try {
double yaw = (Double)arguments[0];
double pitch = (Double)arguments[1];
this.addCommand(CommandRotateTo.class, new String[]{Double.toString(yaw), Double.toString(pitch)});
break;
}
catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("expected number");
}
}
throw new IllegalArgumentException("expected number");
}
case 2: {
this.addCommand(CommandGrab.class);
break;
}
case 3: {
this.addCommand(CommandDrop.class);
break;
}
case 4: {
this.commandManager.clear();
this.addCommand(CommandReturn.class);
break;
}
case 5: {
return new Object[]{this.commandManager.hasTasks()};
}
case 6: {
Vector3 serachPosition = this.getHandPosition();
List found = this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox((double)(serachPosition.x - 0.5), (double)(serachPosition.y - 0.5), (double)(serachPosition.z - 0.5), (double)(serachPosition.x + 0.5), (double)(serachPosition.y + 0.5), (double)(serachPosition.z + 0.5)));
if (found != null && found.size() > 0) {
for (int i = 0; i < found.size(); ++i) {
if (found.get(i) == null || found.get(i) instanceof EntityPlayer || ((Entity)found.get((int)i)).ridingEntity != null) continue;
return new Object[]{true};
}
}
return new Object[]{false};
}
case 7: {
if (arguments.length > 0) {
try {
int times = (Integer)arguments[0];
this.addCommand(CommandUse.class, new String[]{Integer.toString(times)});
break;
}
catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("expected number");
}
}
this.addCommand(CommandUse.class);
break;
}
case 8: {
if (arguments.length > 0) {
try {
float strength = (float)((Double)arguments[0]).doubleValue();
this.addCommand(CommandFire.class, new String[]{Float.toString(strength)});
break;
}
catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException("expected number");
}
}
this.addCommand(CommandFire.class);
break;
}
case 9: {
this.addCommand(CommandReturn.class);
break;
}
case 10: {
this.commandManager.clear();
break;
}
case 11: {
return new Object[]{this.grabbedEntities.size() > 0};
}
}
return null;
}
//TODO: WTF
//@Override
public boolean canAttachToSide(int side) {
return side != ForgeDirection.UP.ordinal();
}
@Override
public void attach(IComputerAccess computer) {
++this.computersAttached;
List list = this.connectedComputers;
synchronized (list) {
this.connectedComputers.add(computer);
}
}
@Override
public void detach(IComputerAccess computer) {
--this.computersAttached;
List list = this.connectedComputers;
synchronized (list) {
this.connectedComputers.remove(computer);
}
}
@Override
public List<Entity> getGrabbedEntities() {
return this.grabbedEntities;
}
@Override
public List<ItemStack> getGrabbedItems() {
return this.grabbedItems;
}
@Override
public void grabEntity(Entity entity) {
if (entity instanceof EntityItem) {
this.grabItem(((EntityItem)entity).getEntityItem());
entity.setDead();
} else {
this.grabbedEntities.add(entity);
}
}
@Override
public void grabItem(ItemStack itemStack) {
this.grabbedItems.add(itemStack);
}
@Override
public void dropEntity(Entity entity) {
this.grabbedEntities.remove((Object)entity);
}
@Override
public void dropItem(ItemStack itemStack) {
Vector3 handPosition = this.getHandPosition();
this.worldObj.spawnEntityInWorld((Entity)new EntityItem(this.worldObj, handPosition.x, handPosition.y, handPosition.z, itemStack));
this.grabbedItems.remove((Object)itemStack);
}
@Override
public void dropAll() {
Vector3 handPosition = this.getHandPosition();
Iterator it = this.grabbedItems.iterator();
while (it.hasNext()) {
ItemFindingHelper.dropItemStackExact(this.worldObj, handPosition.x, handPosition.y, handPosition.z, (ItemStack)it.next());
}
this.grabbedEntities.clear();
this.grabbedItems.clear();
}
public boolean isProvidingPowerSide(ForgeDirection dir) {
return this.isProvidingPower && dir.getOpposite() == this.getFacingDirectionFromAngle();
}
public ForgeDirection getFacingDirectionFromAngle() {
float angle = MathHelper.wrapAngleTo180_float((float)this.rotationYaw);
if (angle >= -45.0f && angle <= 45.0f) {
return ForgeDirection.SOUTH;
}
if (angle >= 45.0f && angle <= 135.0f) {
return ForgeDirection.WEST;
}
if (angle >= 135.0f && angle <= -135.0f) {
return ForgeDirection.NORTH;
}
return ForgeDirection.EAST;
}
@Override
public boolean canConnect(ForgeDirection direction) {
return direction == ForgeDirection.DOWN;
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return false;
}
@Override
public boolean equals(IPeripheral other) {
return super.equals(other);
}
}

View File

@ -0,0 +1,257 @@
package assemblyline.common.machine.belt;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
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.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
public class BlockConveyorBelt
extends BlockALMachine {
public BlockConveyorBelt() {
super(UniversalElectricity.machine);
this.setBlockName("conveyorBelt");
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.3f, 1.0f);
this.setCreativeTab(TabAssemblyLine.INSTANCE);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityConveyorBelt) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt)world.getTileEntity(x, y, z);
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP || tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.96f, 1.0f);
return;
}
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.TOP) {
this.setBlockBounds(0.0f, 0.68f, 0.0f, 1.0f, 0.96f, 1.0f);
return;
}
}
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.3f, 1.0f);
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
TileEntity t = world.getTileEntity(x, y, z);
if (t != null && t instanceof TileEntityConveyorBelt) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt)t;
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP || tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
return AxisAlignedBB.getBoundingBox((double)x + this.minX, (double)y + this.minY, (double)z + this.minZ, (double)x + 1.0, (double)y + 1.0, (double)z + 1.0);
}
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.TOP) {
return AxisAlignedBB.getBoundingBox((double)x + this.minX, (double)y + (double)0.68f, (double)z + this.minZ, (double)x + this.maxX, (double)y + (double)0.98f, (double)z + this.maxZ);
}
}
return AxisAlignedBB.getBoundingBox((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 void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
AxisAlignedBB newBounds;
TileEntity t = world.getTileEntity(x, y, z);
if (t != null && t instanceof TileEntityConveyorBelt) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt)t;
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP || tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
AxisAlignedBB boundBottom = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)(x + 1), (double)y + 0.3, (double)(z + 1));
AxisAlignedBB boundTop = null;
ForgeDirection direction = tileEntity.getDirection();
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.UP) {
if (direction.offsetX > 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)((float)x + (float)direction.offsetX / 2.0f), (double)y, (double)z, (double)(x + 1), (double)y + 0.8, (double)(z + 1));
} else if (direction.offsetX < 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)((float)x + (float)direction.offsetX / -2.0f), (double)y + 0.8, (double)(z + 1));
} else if (direction.offsetZ > 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)((float)z + (float)direction.offsetZ / 2.0f), (double)(x + 1), (double)y + 0.8, (double)(z + 1));
} else if (direction.offsetZ < 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)(x + 1), (double)y + 0.8, (double)((float)z + (float)direction.offsetZ / -2.0f));
}
} else if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.DOWN) {
if (direction.offsetX > 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)((float)x + (float)direction.offsetX / 2.0f), (double)y + 0.8, (double)(z + 1));
} else if (direction.offsetX < 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)((float)x + (float)direction.offsetX / -2.0f), (double)y, (double)z, (double)(x + 1), (double)y + 0.8, (double)(z + 1));
} else if (direction.offsetZ > 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)(x + 1), (double)y + 0.8, (double)((float)z + (float)direction.offsetZ / 2.0f));
} else if (direction.offsetZ < 0) {
boundTop = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)((float)z + (float)direction.offsetZ / -2.0f), (double)(x + 1), (double)y + 0.8, (double)(z + 1));
}
}
if (par5AxisAlignedBB.intersectsWith(boundBottom)) {
par6List.add(boundBottom);
}
if (boundTop != null && par5AxisAlignedBB.intersectsWith(boundTop)) {
par6List.add(boundTop);
}
return;
}
if (tileEntity.getSlant() == TileEntityConveyorBelt.SlantType.TOP) {
AxisAlignedBB newBounds2 = AxisAlignedBB.getBoundingBox((double)x, (double)y + 0.68, (double)z, (double)(x + 1), (double)y + 0.98, (double)(z + 1));
if (newBounds2 != null && par5AxisAlignedBB.intersectsWith(newBounds2)) {
par6List.add(newBounds2);
}
return;
}
}
if ((newBounds = AxisAlignedBB.getBoundingBox((double)x, (double)y, (double)z, (double)(x + 1), (double)y + 0.3, (double)(z + 1))) != null && par5AxisAlignedBB.intersectsWith(newBounds)) {
par6List.add(newBounds);
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack) {
int angle = MathHelper.floor_double((double)((double)(par5EntityLiving.rotationYaw * 4.0f / 360.0f) + 0.5)) & 3;
int change = 2;
switch (angle) {
case 0: {
change = 3;
break;
}
case 1: {
change = 4;
break;
}
case 2: {
change = 2;
break;
}
case 3: {
change = 5;
}
}
world.setBlockMetadataWithNotify(x, y, z, change, 3);
}
@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;
}
}
world.setBlockMetadataWithNotify(x, y, z, change, 3);
return true;
}
@Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt)world.getTileEntity(x, y, z);
int slantOrdinal = tileEntity.getSlant().ordinal() + 1;
if (slantOrdinal >= TileEntityConveyorBelt.SlantType.values().length) {
slantOrdinal = 0;
}
tileEntity.setSlant(TileEntityConveyorBelt.SlantType.values()[slantOrdinal]);
return true;
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
TileEntityConveyorBelt tileEntity = (TileEntityConveyorBelt)world.getTileEntity(x, y, z);
tileEntity.updatePowerTransferRange();
if (tileEntity.IgnoreList.contains((Object)entity)) {
return;
}
if (tileEntity.isRunning() && !world.isBlockIndirectlyGettingPowered(x, y, z)) {
tileEntity.getClass();
float acceleration = 0.01f;
tileEntity.getClass();
float maxSpeed = 0.1f;
TileEntityConveyorBelt.SlantType slantType = tileEntity.getSlant();
ForgeDirection direction = tileEntity.getDirection();
if (entity instanceof EntityLiving) {
acceleration *= 5.0f;
maxSpeed *= 10.0f;
}
entity.addVelocity((double)((float)direction.offsetX * acceleration), 0.0, (double)((float)direction.offsetZ * acceleration));
if (direction.offsetX != 0 && Math.abs(entity.motionX) > (double)maxSpeed) {
entity.motionX = (float)direction.offsetX * maxSpeed;
entity.motionZ = 0.0;
}
if (direction.offsetZ != 0 && Math.abs(entity.motionZ) > (double)maxSpeed) {
entity.motionZ = (float)direction.offsetZ * maxSpeed;
entity.motionX = 0.0;
}
entity.motionY += (double)0.0125f;
if (entity instanceof EntityItem) {
double difference;
if (direction.offsetX != 0) {
difference = (double)z + 0.5 - entity.posZ;
entity.motionZ += difference * 0.1;
} else if (direction.offsetZ != 0) {
difference = (double)x + 0.5 - entity.posX;
entity.motionX += difference * 0.1;
}
++((EntityItem)entity).age;
boolean foundSneaking = false;
for (EntityPlayer player : (List<EntityPlayer>) world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox((double)(x - 1), (double)(y - 1), (double)(z - 1), (double)(x + 1), (double)(y + 1), (double)(z + 1)))) {
if (!player.isSneaking()) continue;
foundSneaking = true;
}
((EntityItem)entity).delayBeforeCanPickup = foundSneaking ? 0 : 20;
entity.onGround = false;
}
if (slantType == TileEntityConveyorBelt.SlantType.UP) {
if (entity.motionY < 0.4) {
entity.addVelocity(0.0, 0.4, 0.0);
}
} else if (slantType == TileEntityConveyorBelt.SlantType.DOWN && entity.motionY > -0.1) {
entity.addVelocity(0.0, -0.1, 0.0);
}
}
}
@Override
public TileEntity createNewTileEntity(World var1, int meta) {
return new TileEntityConveyorBelt();
}
@Override
@SideOnly(value=Side.CLIENT)
public int getRenderType() {
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int damageDropped(int par1) {
return 0;
}
}

View File

@ -0,0 +1,256 @@
package assemblyline.common.machine.belt;
import assemblyline.api.IBelt;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.implement.IRotatable;
public class TileEntityConveyorBelt
extends TileEntityAssemblyNetwork
implements IBelt,
IRotatable {
public static final int MAX_FRAME = 13;
public static final int MAX_SLANT_FRAME = 23;
public final float acceleration = 0.01f;
public final float maxSpeed = 0.1f;
public float wheelRotation = 0.0f;
private int animFrame = 0;
private SlantType slantType = SlantType.NONE;
public List<Entity> IgnoreList = new ArrayList<>();
@Override
public void updatePowerTransferRange() {
ForgeDirection direction;
int maximumTransferRange = 0;
for (int i = 0; i < 6; ++i) {
direction = ForgeDirection.getOrientation((int)i);
TileEntity tileEntity = this.worldObj.getTileEntity(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ);
if (tileEntity == null || !(tileEntity instanceof TileEntityAssemblyNetwork)) continue;
TileEntityAssemblyNetwork assemblyNetwork = (TileEntityAssemblyNetwork)tileEntity;
if (assemblyNetwork.powerTransferRange <= maximumTransferRange) continue;
maximumTransferRange = assemblyNetwork.powerTransferRange;
}
for (int d = 0; d <= 1; ++d) {
direction = this.getDirection();
if (d == 1) {
direction = direction.getOpposite();
}
for (int i = -1; i <= 1; ++i) {
TileEntity tileEntity = this.worldObj.getTileEntity(this.xCoord + direction.offsetX, this.yCoord + i, this.zCoord + direction.offsetZ);
if (tileEntity == null || !(tileEntity instanceof TileEntityAssemblyNetwork)) continue;
TileEntityAssemblyNetwork assemblyNetwork = (TileEntityAssemblyNetwork)tileEntity;
if (assemblyNetwork.powerTransferRange <= maximumTransferRange) continue;
maximumTransferRange = assemblyNetwork.powerTransferRange;
}
}
this.powerTransferRange = Math.max(maximumTransferRange - 1, 0);
}
@Override
public void onUpdate() {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.ticks % 10L == 0L) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
ArrayList<Entity> newList = new ArrayList<Entity>();
for (Entity ent : this.IgnoreList) {
if (!this.getAffectedEntities().contains((Object)ent)) continue;
newList.add(ent);
}
this.IgnoreList = newList;
if (this.isRunning() && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) {
if (this.ticks % 10L == 0L && this.worldObj.isRemote && this.worldObj.getBlock(this.xCoord - 1, this.yCoord, this.zCoord) != AssemblyLine.blockConveyorBelt && this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord - 1) != AssemblyLine.blockConveyorBelt) {
this.worldObj.playSound((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, "assemblyline:conveyor", 0.5f, 0.7f, true);
}
this.wheelRotation += 40.0f;
if (this.wheelRotation > 360.0f) {
this.wheelRotation = 0.0f;
}
float wheelRotPct = this.wheelRotation / 360.0f;
if (this.getSlant() == SlantType.NONE || this.getSlant() == SlantType.TOP) {
this.animFrame = (int)(wheelRotPct * 13.0f);
if (this.animFrame < 0) {
this.animFrame = 0;
}
if (this.animFrame > 13) {
this.animFrame = 13;
}
} else {
this.animFrame = (int)(wheelRotPct * 23.0f);
if (this.animFrame < 0) {
this.animFrame = 0;
}
if (this.animFrame > 23) {
this.animFrame = 23;
}
}
}
}
@Override
protected int getMaxTransferRange() {
return 20;
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setDouble("wattsReceived", this.wattsReceived);
nbt.setInteger("slantType", this.slantType.ordinal());
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(), nbt);
}
public SlantType getSlant() {
return this.slantType;
}
public void setSlant(SlantType slantType) {
if (slantType == null) {
slantType = SlantType.NONE;
}
this.slantType = slantType;
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
public boolean getIsFirstBelt() {
ForgeDirection front = this.getDirection();
ForgeDirection back = this.getDirection().getOpposite();
TileEntity fBelt = this.worldObj.getTileEntity(this.xCoord + front.offsetX, this.yCoord + front.offsetY, this.zCoord + front.offsetZ);
TileEntity BBelt = this.worldObj.getTileEntity(this.xCoord + back.offsetX, this.yCoord + back.offsetY, this.zCoord + back.offsetZ);
if (fBelt instanceof TileEntityConveyorBelt) {
ForgeDirection TD;
ForgeDirection fD = ((TileEntityConveyorBelt)fBelt).getDirection();
return fD == (TD = this.getDirection());
}
return false;
}
public boolean getIsMiddleBelt() {
ForgeDirection front = this.getDirection();
ForgeDirection back = this.getDirection().getOpposite();
TileEntity fBelt = this.worldObj.getTileEntity(this.xCoord + front.offsetX, this.yCoord + front.offsetY, this.zCoord + front.offsetZ);
TileEntity BBelt = this.worldObj.getTileEntity(this.xCoord + back.offsetX, this.yCoord + back.offsetY, this.zCoord + back.offsetZ);
if (fBelt instanceof TileEntityConveyorBelt && BBelt instanceof TileEntityConveyorBelt) {
ForgeDirection fD = ((TileEntityConveyorBelt)fBelt).getDirection();
ForgeDirection BD = ((TileEntityConveyorBelt)BBelt).getDirection();
ForgeDirection TD = this.getDirection();
return fD == TD && BD == TD;
}
return false;
}
public boolean getIsLastBelt() {
ForgeDirection front = this.getDirection();
ForgeDirection back = this.getDirection().getOpposite();
TileEntity fBelt = this.worldObj.getTileEntity(this.xCoord + front.offsetX, this.yCoord + front.offsetY, this.zCoord + front.offsetZ);
TileEntity BBelt = this.worldObj.getTileEntity(this.xCoord + back.offsetX, this.yCoord + back.offsetY, this.zCoord + back.offsetZ);
if (BBelt instanceof TileEntityConveyorBelt) {
ForgeDirection TD;
ForgeDirection BD = ((TileEntityConveyorBelt)BBelt).getDirection();
return BD == (TD = this.getDirection());
}
return false;
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
if (this.worldObj.isRemote) {
NBTTagCompound nbt = pkt.func_148857_g();
this.wattsReceived = nbt.getDouble("wattsReceived");
this.slantType = SlantType.values()[nbt.getInteger("slantType")];
}
}
@Override
public void setDirection(World world, int x, int y, int z, ForgeDirection facingDirection) {
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3);
}
@Override
public ForgeDirection getDirection(IBlockAccess world, int x, int y, int z) {
return ForgeDirection.getOrientation((int)this.getBlockMetadata());
}
public ForgeDirection getDirection() {
return this.getDirection((IBlockAccess)this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
public void setDirection(ForgeDirection facingDirection) {
this.setDirection(this.worldObj, this.xCoord, this.yCoord, this.zCoord, facingDirection);
}
@Override
public List getAffectedEntities() {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1));
return this.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
}
public int getAnimationFrame() {
if (!this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) {
TileEntity te = null;
te = this.worldObj.getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord);
if (te != null && te instanceof TileEntityConveyorBelt && ((TileEntityConveyorBelt)te).getSlant() == this.slantType) {
return ((TileEntityConveyorBelt)te).getAnimationFrame();
}
te = this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 1);
if (te != null && te instanceof TileEntityConveyorBelt && ((TileEntityConveyorBelt)te).getSlant() == this.slantType) {
return ((TileEntityConveyorBelt)te).getAnimationFrame();
}
}
return this.animFrame;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.slantType = SlantType.values()[nbt.getByte("slant")];
if (this.worldObj != null) {
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, nbt.getInteger("rotation"), 3);
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setByte("slant", (byte)this.slantType.ordinal());
if (this.worldObj != null) {
nbt.setInteger("rotation", this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
}
}
@Override
public void IgnoreEntity(Entity entity) {
if (!this.IgnoreList.contains((Object)entity)) {
this.IgnoreList.add(entity);
}
}
@Override
public boolean canConnect(ForgeDirection direction) {
return direction == ForgeDirection.DOWN;
}
public static enum SlantType {
NONE,
UP,
DOWN,
TOP;
}
}

View File

@ -0,0 +1,6 @@
package assemblyline.common.machine.belt;
public class TileEntityCoveredBelt
extends TileEntityConveyorBelt {
}

View File

@ -0,0 +1,23 @@
package assemblyline.common.machine.belt;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
public class TileEntityElevatorBelt
extends TileEntityConveyorBelt {
public List conveyList = new ArrayList();
public void doBeltAction() {
this.conveyItemsVertical(true, false);
}
public boolean isBellowABelt() {
TileEntity ent = this.worldObj.getTileEntity(this.xCoord, this.xCoord - 1, this.zCoord);
return ent instanceof TileEntityElevatorBelt;
}
public void conveyItemsVertical(boolean extendLife, boolean preventPickUp) {
}
}

View File

@ -0,0 +1,138 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.armbot.TileEntityArmbot;
import assemblyline.common.machine.command.CommandBreak;
import assemblyline.common.machine.command.CommandDrop;
import assemblyline.common.machine.command.CommandFire;
import assemblyline.common.machine.command.CommandGrab;
import assemblyline.common.machine.command.CommandHarvest;
import assemblyline.common.machine.command.CommandIdle;
import assemblyline.common.machine.command.CommandManager;
import assemblyline.common.machine.command.CommandPlace;
import assemblyline.common.machine.command.CommandPowerTo;
import assemblyline.common.machine.command.CommandRepeat;
import assemblyline.common.machine.command.CommandReturn;
import assemblyline.common.machine.command.CommandRotateBy;
import assemblyline.common.machine.command.CommandRotateTo;
import assemblyline.common.machine.command.CommandUse;
import java.util.HashMap;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public abstract class Command {
private static final HashMap COMMANDS = new HashMap();
private static final HashMap REVERSE_LOOKUP = new HashMap();
protected int ticks = 0;
public World world;
public TileEntityArmbot tileEntity;
public CommandManager commandManager;
private String[] parameters;
public static void registerCommand(String command, Class commandClass) {
COMMANDS.put(command, commandClass);
REVERSE_LOOKUP.put(commandClass, command);
}
public static Class getCommand(String command) {
return (Class)COMMANDS.get(command.toLowerCase());
}
public static String getCommandName(Class command) {
return (String)REVERSE_LOOKUP.get(command);
}
protected boolean doTask() {
++this.ticks;
return false;
}
public void onTaskStart() {
}
public void onTaskEnd() {
}
public int getTickInterval() {
return 1;
}
public void setParameters(String[] strings) {
this.parameters = strings;
}
public String[] getArgs() {
return this.parameters;
}
protected String getArg(int i) {
if (i >= 0 && i < this.parameters.length) {
return this.parameters[i];
}
return null;
}
protected int getIntArg(int i) {
if (this.getArg(i) != null) {
try {
return Integer.parseInt(this.getArg(i));
}
catch (Exception exception) {
// empty catch block
}
}
return 0;
}
protected Double getDoubleArg(int i) {
if (this.getArg(i) != null) {
try {
return Double.parseDouble(this.getArg(i));
}
catch (Exception exception) {
// empty catch block
}
}
return 0.0;
}
protected Float getFloatArg(int i) {
if (this.getArg(i) != null) {
try {
return Float.valueOf(Float.parseFloat(this.getArg(i)));
}
catch (Exception exception) {
// empty catch block
}
}
return Float.valueOf(0.0f);
}
public void readFromNBT(NBTTagCompound taskCompound) {
this.ticks = taskCompound.getInteger("ticks");
}
public void writeToNBT(NBTTagCompound taskCompound) {
taskCompound.setInteger("ticks", this.ticks);
}
public String toString() {
return "COMMAND";
}
static {
Command.registerCommand("idle", CommandIdle.class);
Command.registerCommand("grab", CommandGrab.class);
Command.registerCommand("drop", CommandDrop.class);
Command.registerCommand("rotate", CommandRotateBy.class);
Command.registerCommand("rotateto", CommandRotateTo.class);
Command.registerCommand("return", CommandReturn.class);
Command.registerCommand("repeat", CommandRepeat.class);
Command.registerCommand("use", CommandUse.class);
Command.registerCommand("powerto", CommandPowerTo.class);
Command.registerCommand("fire", CommandFire.class);
Command.registerCommand("break", CommandBreak.class);
Command.registerCommand("place", CommandPlace.class);
Command.registerCommand("harvest", CommandHarvest.class);
}
}

View File

@ -0,0 +1,44 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandRotateTo;
import dark.library.helpers.ItemFindingHelper;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import universalelectricity.core.vector.Vector3;
public class CommandBreak
extends Command {
private CommandRotateTo rotateToCommand;
int BREAK_TIME = 30;
boolean keep = false;
@Override
protected boolean doTask() {
super.doTask();
Vector3 serachPosition = this.tileEntity.getHandPosition();
Block block = serachPosition.getBlock(this.world);
if (block != null && this.BREAK_TIME <= this.ticks) {
ArrayList items = block.getDrops(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), serachPosition.getBlockMetadata((IBlockAccess)this.world), 0);
if (!this.keep || items.size() > 1) {
ItemFindingHelper.dropBlockAsItem(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ());
} else {
this.tileEntity.grabEntity((Entity)new EntityItem(this.world, (double)serachPosition.intX() + 0.5, (double)serachPosition.intY() + 0.5, (double)serachPosition.intZ() + 0.5, (ItemStack)items.get(0)));
}
this.world.setBlock(serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), Blocks.air, 0, 3);
return false;
}
return true;
}
@Override
public String toString() {
return "BREAK";
}
}

View File

@ -0,0 +1,20 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
public class CommandDrop
extends Command {
@Override
protected boolean doTask() {
super.doTask();
this.tileEntity.dropAll();
this.world.playSound((double)this.tileEntity.xCoord, (double)this.tileEntity.yCoord, (double)this.tileEntity.zCoord, "random.pop", 0.2f, ((this.tileEntity.getWorldObj().rand.nextFloat() - this.tileEntity.getWorldObj().rand.nextFloat()) * 0.7f + 1.0f) * 1.0f, true);
return false;
}
@Override
public String toString() {
return "DROP";
}
}

View File

@ -0,0 +1,128 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandDrop;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import universalelectricity.core.vector.Vector3;
public class CommandFire
extends Command {
private static final float MIN_ACTUAL_PITCH = -80.0f;
private static final float MAX_ACTUAL_PITCH = 80.0f;
private float actualYaw;
private float actualPitch;
private float velocity;
private Vector3 finalVelocity;
@Override
public void onTaskStart() {
super.onTaskStart();
this.velocity = this.getFloatArg(0).floatValue();
if (this.velocity > 2.5f) {
this.velocity = 2.5f;
}
if (this.velocity < 0.125f) {
this.velocity = 1.0f;
}
this.actualYaw = this.tileEntity.rotationYaw;
this.actualPitch = 160.0f * (this.tileEntity.rotationPitch / 60.0f) + -80.0f;
double yaw = Math.toRadians(this.actualYaw);
double pitch = Math.toRadians(this.actualPitch);
double x = -Math.sin(yaw) * Math.cos(pitch);
double y = Math.sin(pitch);
double z = Math.cos(yaw) * Math.cos(pitch);
this.finalVelocity = new Vector3(x, y, z);
Random random = new Random(System.currentTimeMillis());
this.finalVelocity.x *= (double)(0.995f + random.nextFloat() * 0.01f);
this.finalVelocity.y *= (double)(0.995f + random.nextFloat() * 0.01f);
this.finalVelocity.z *= (double)(0.995f + random.nextFloat() * 0.01f);
this.finalVelocity.multiply(this.velocity);
}
@Override
protected boolean doTask() {
Entity held;
if (this.finalVelocity == null) {
this.finalVelocity = new Vector3(0.0, 0.0, 0.0);
}
if (this.tileEntity.getGrabbedEntities().size() > 0 && (held = (Entity)this.tileEntity.getGrabbedEntities().get(0)) != null) {
this.world.playSound((double)this.tileEntity.xCoord, (double)this.tileEntity.yCoord, (double)this.tileEntity.zCoord, "random.bow", this.velocity, 2.0f - this.velocity / 4.0f, true);
if (held instanceof EntityItem) {
EntityItem item = (EntityItem)held;
ItemStack stack = item.getEntityItem();
ItemStack thrown = stack.copy();
thrown.stackSize = 1;
if (item.getEntityItem().stackSize > 0) {
--stack.stackSize;
item.setEntityItemStack(stack);
} else {
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[0]).doTask();
if (!this.world.isRemote) {
this.world.removeEntity(held);
}
}
if (item.getEntityItem().getItem() == Items.arrow) {
EntityArrow arrow = new EntityArrow(this.world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z);
arrow.motionX = this.finalVelocity.x;
arrow.motionY = this.finalVelocity.y;
arrow.motionZ = this.finalVelocity.z;
if (!this.world.isRemote) {
this.world.spawnEntityInWorld((Entity)arrow);
}
} else {
EntityItem item2 = new EntityItem(this.world, this.tileEntity.getHandPosition().x, this.tileEntity.getHandPosition().y, this.tileEntity.getHandPosition().z, thrown);
item2.motionX = this.finalVelocity.x;
item2.motionY = this.finalVelocity.y;
item2.motionZ = this.finalVelocity.z;
if (!this.world.isRemote) {
this.world.spawnEntityInWorld((Entity)item2);
}
}
} else {
this.commandManager.getNewCommand(this.tileEntity, CommandDrop.class, new String[0]).doTask();
held.motionX = this.finalVelocity.x;
held.motionY = this.finalVelocity.y;
held.motionZ = this.finalVelocity.z;
}
}
return false;
}
@Override
public void readFromNBT(NBTTagCompound taskCompound) {
super.readFromNBT(taskCompound);
this.actualYaw = taskCompound.getFloat("fireYaw");
this.actualPitch = taskCompound.getFloat("firePitch");
this.velocity = taskCompound.getFloat("fireVelocity");
this.finalVelocity = new Vector3();
this.finalVelocity.x = taskCompound.getDouble("fireVectorX");
this.finalVelocity.y = taskCompound.getDouble("fireVectorY");
this.finalVelocity.z = taskCompound.getDouble("fireVectorZ");
}
@Override
public void writeToNBT(NBTTagCompound taskCompound) {
super.writeToNBT(taskCompound);
taskCompound.setFloat("fireYaw", this.actualYaw);
taskCompound.setFloat("firePitch", this.actualPitch);
taskCompound.setFloat("fireVelocity", this.velocity);
if (this.finalVelocity != null) {
taskCompound.setDouble("fireVectorX", this.finalVelocity.x);
taskCompound.setDouble("fireVectorY", this.finalVelocity.y);
taskCompound.setDouble("fireVectorZ", this.finalVelocity.z);
}
}
@Override
public String toString() {
return "FIRE " + Float.toString(this.velocity);
}
}

View File

@ -0,0 +1,100 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.GrabDictionary;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import universalelectricity.core.vector.Vector3;
public class CommandGrab
extends Command {
public static final float radius = 0.5f;
public boolean child = false;
private TileEntityConveyorBelt belt;
private Class entityToInclude;
@Override
public void onTaskStart() {
super.onTaskStart();
this.entityToInclude = Entity.class;
if (this.getArgs() != null && this.getArgs().length > 0 && this.getArgs()[0] != null) {
if (this.getArg(0).equalsIgnoreCase("baby") || this.getArg(0).equalsIgnoreCase("child")) {
this.child = true;
if (this.getArgs().length > 1 && this.getArgs()[1] != null) {
this.entityToInclude = GrabDictionary.get(this.getArg(1)).getEntityClass();
}
} else {
this.entityToInclude = GrabDictionary.get(this.getArg(0)).getEntityClass();
if (this.getArgs().length > 1 && this.getArgs()[1] != null && (this.getArg(1).equalsIgnoreCase("baby") || this.getArg(0).equalsIgnoreCase("child"))) {
this.child = true;
}
}
}
}
@Override
protected boolean doTask() {
super.doTask();
if (this.tileEntity.getGrabbedEntities().size() > 0) {
return false;
}
Vector3 serachPosition = this.tileEntity.getHandPosition();
List found = this.world.getEntitiesWithinAABB(this.entityToInclude, AxisAlignedBB.getBoundingBox((double)(serachPosition.x - 0.5), (double)(serachPosition.y - 0.5), (double)(serachPosition.z - 0.5), (double)(serachPosition.x + 0.5), (double)(serachPosition.y + 0.5), (double)(serachPosition.z + 0.5)));
TileEntity ent = serachPosition.getTileEntity((IBlockAccess)this.world);
Vector3 searchPostion2 = Vector3.add(serachPosition, new Vector3(0.0, -1.0, 0.0));
TileEntity ent2 = searchPostion2.getTileEntity((IBlockAccess)this.world);
if (ent instanceof TileEntityConveyorBelt) {
this.belt = (TileEntityConveyorBelt)ent;
} else if (ent2 instanceof TileEntityConveyorBelt) {
this.belt = (TileEntityConveyorBelt)ent2;
}
if (found != null && found.size() > 0) {
for (int i = 0; i < found.size(); ++i) {
if (found.get(i) == null || found.get(i) instanceof EntityArrow || found.get(i) instanceof EntityPlayer || ((Entity)found.get((int)i)).ridingEntity != null || found.get(i) instanceof EntityAgeable && (!(found.get(i) instanceof EntityAgeable) || this.child != ((EntityAgeable)found.get(i)).isChild())) continue;
this.tileEntity.grabEntity((Entity)found.get(i));
this.world.playSound((double)this.tileEntity.xCoord, (double)this.tileEntity.yCoord, (double)this.tileEntity.zCoord, "random.pop", 0.2f, ((this.tileEntity.getWorldObj().rand.nextFloat() - this.tileEntity.getWorldObj().rand.nextFloat()) * 0.7f + 1.0f) * 1.0f, true);
if (this.belt != null) {
this.belt.IgnoreEntity((Entity)found.get(i));
}
return false;
}
}
return true;
}
@Override
public void readFromNBT(NBTTagCompound taskCompound) {
super.readFromNBT(taskCompound);
this.child = taskCompound.getBoolean("child");
this.entityToInclude = GrabDictionary.get(taskCompound.getString("name")).getEntityClass();
}
@Override
public void writeToNBT(NBTTagCompound taskCompound) {
super.writeToNBT(taskCompound);
taskCompound.setBoolean("child", this.child);
taskCompound.setString("name", this.entityToInclude != null ? GrabDictionary.get(this.entityToInclude).getName() : "");
}
@Override
public String toString() {
String baby = "";
String entity = "";
if (this.entityToInclude != null) {
entity = GrabDictionary.get(this.entityToInclude).getName();
if (this.child) {
baby = "baby ";
}
}
return "GRAB " + baby + entity;
}
}

View File

@ -0,0 +1,20 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.CommandBreak;
import assemblyline.common.machine.command.CommandRotateTo;
public class CommandHarvest
extends CommandBreak {
private CommandRotateTo rotateToCommand;
@Override
public void onTaskStart() {
this.keep = true;
}
@Override
public String toString() {
return "HARVEST";
}
}

View File

@ -0,0 +1,47 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import net.minecraft.nbt.NBTTagCompound;
public class CommandIdle
extends Command {
public int idleTime = 80;
private int totalIdleTime = 80;
@Override
public void onTaskStart() {
super.onTaskStart();
if (this.getIntArg(0) > 0) {
this.totalIdleTime = this.idleTime = this.getIntArg(0);
}
}
@Override
protected boolean doTask() {
if (this.idleTime > 0) {
--this.idleTime;
return true;
}
return false;
}
@Override
public void readFromNBT(NBTTagCompound taskCompound) {
super.readFromNBT(taskCompound);
this.idleTime = taskCompound.getInteger("idleTime");
this.totalIdleTime = taskCompound.getInteger("idleTotal");
}
@Override
public void writeToNBT(NBTTagCompound taskCompound) {
super.writeToNBT(taskCompound);
taskCompound.setInteger("idleTime", this.idleTime);
taskCompound.setInteger("idleTotal", this.totalIdleTime);
}
@Override
public String toString() {
return "IDLE " + Integer.toString(this.totalIdleTime);
}
}

View File

@ -0,0 +1,162 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.armbot.TileEntityArmbot;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandRepeat;
import cpw.mods.fml.common.FMLLog;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
public class CommandManager {
private final List tasks = new ArrayList();
private int ticks = 0;
private int currentTask = 0;
private int lastTask = -1;
public void onUpdate() {
try {
if (this.tasks.size() > 0) {
if (this.currentTask < this.tasks.size()) {
if (this.currentTask < 0) {
this.currentTask = 0;
this.lastTask = -1;
}
Command task = (Command)this.tasks.get(this.currentTask);
if (this.currentTask != this.lastTask) {
this.lastTask = this.currentTask;
task.onTaskStart();
}
if (!task.doTask()) {
int tempCurrentTask = this.currentTask++;
task.onTaskEnd();
if (!(task instanceof CommandRepeat)) {
this.tasks.set(tempCurrentTask, this.getNewCommand(task.tileEntity, task.getClass(), task.getArgs()));
}
}
} else {
this.clear();
}
}
}
catch (Exception e) {
FMLLog.severe((String)"Failed to execute task in Assembly Line.", (Object[])new Object[0]);
e.printStackTrace();
}
++this.ticks;
}
public Command getNewCommand(TileEntityArmbot tileEntity, Class commandClass, String[] parameters) {
try {
Command newCommand = (Command)commandClass.newInstance();
newCommand.world = tileEntity.getWorldObj();
newCommand.tileEntity = tileEntity;
newCommand.commandManager = this;
newCommand.setParameters(parameters);
return newCommand;
}
catch (Exception e) {
FMLLog.severe((String)"Failed to add command", (Object[])new Object[0]);
e.printStackTrace();
return null;
}
}
public void addCommand(TileEntityArmbot tileEntity, Class commandClass, String[] parameters) {
Command newCommand = this.getNewCommand(tileEntity, commandClass, parameters);
if (newCommand != null) {
this.tasks.add(newCommand);
}
}
public void addCommand(TileEntityArmbot tileEntity, Class task) {
this.addCommand(tileEntity, task, new String[0]);
}
public boolean hasTasks() {
return this.tasks.size() > 0;
}
public List getCommands() {
return this.tasks;
}
public void clear() {
this.tasks.clear();
this.currentTask = 0;
this.lastTask = -1;
this.ticks = 0;
}
public void setCurrentTask(int i) {
this.currentTask = Math.min(i, this.tasks.size());
}
public int getCurrentTask() {
return this.currentTask;
}
public void readFromNBT(TileEntityArmbot tileEntity, NBTTagCompound nbt) {
this.currentTask = nbt.getInteger("curTasks");
this.lastTask = nbt.getInteger("lastTask");
this.ticks = nbt.getInteger("ticks");
if (nbt.getInteger("numTasks") > 0) {
NBTTagList taskList = nbt.getTagList("commands", 10);
for (int i = 0; i < taskList.tagCount(); ++i) {
NBTTagCompound cmdTag = (NBTTagCompound)taskList.getCompoundTagAt(i);
try {
Class<?> cmdClass = Class.forName(cmdTag.getString("commandClass"));
ArrayList<String> pars = new ArrayList<String>();
if (cmdTag.getInteger("numParameters") > 0) {
NBTTagList parameters = cmdTag.getTagList("parameters", 8);
for (int ii = 0; ii < parameters.tagCount(); ++ii) {
pars.add(parameters.getStringTagAt((int)ii));
}
}
Command cmd = this.getNewCommand(tileEntity, cmdClass, pars.toArray(new String[0]));
cmd.readFromNBT((NBTTagCompound)cmdTag.getTag("customData"));
continue;
}
catch (ClassNotFoundException e) {
System.out.println("Error loading CommandManger: ");
e.printStackTrace();
}
}
}
}
public void writeToNBT(NBTTagCompound nbt) {
nbt.setInteger("numTasks", this.tasks.size());
if (this.tasks.size() > 0) {
NBTTagList taskList = new NBTTagList();
for (int i = 0; i < this.tasks.size(); ++i) {
NBTTagCompound taskCompound = new NBTTagCompound();
String cmdName = ((Command)this.tasks.get(i)).getClass().getName();
if (cmdName != null && !cmdName.isEmpty()) {
taskCompound.setString("commandClass", cmdName);
}
if (((Command)this.tasks.get(i)).getArgs().length > 0) {
NBTTagList parameters = new NBTTagList();
for (String par : ((Command)this.tasks.get(i)).getArgs()) {
if (par == null || par.isEmpty()) continue;
parameters.appendTag((NBTBase)new NBTTagString(par));
}
taskCompound.setTag("parameters", (NBTBase)parameters);
}
taskCompound.setInteger("numParameters", ((Command)this.tasks.get(i)).getArgs().length);
NBTTagCompound customData = new NBTTagCompound();
((Command)this.tasks.get(i)).writeToNBT(customData);
taskCompound.setTag("customData", customData);
taskList.appendTag((NBTBase)taskCompound);
}
nbt.setTag("commands", (NBTBase)taskList);
}
nbt.setInteger("curTask", this.currentTask);
nbt.setInteger("lastTask", this.lastTask);
nbt.setInteger("ticks", this.ticks);
}
}

View File

@ -0,0 +1,58 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
public class CommandPlace
extends Command {
int PLACE_TIME = 30;
@Override
public void onTaskStart() {
super.onTaskStart();
}
@Override
protected boolean doTask() {
super.doTask();
Vector3 serachPosition = this.tileEntity.getHandPosition();
Block block = serachPosition.getBlock((IBlockAccess)this.world);
if (block == null && this.ticks >= this.PLACE_TIME) {
for (Entity entity : this.tileEntity.getGrabbedEntities()) {
ItemStack itemStack;
if (!(entity instanceof EntityItem) || (itemStack = ((EntityItem)entity).getEntityItem()) == null) continue;
if (itemStack.getItem() instanceof ItemBlock) {
((ItemBlock)itemStack.getItem()).placeBlockAt(itemStack, null, this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), 0, 0.5f, 0.5f, 0.5f, itemStack.getItemDamage());
this.tileEntity.dropEntity(entity);
return false;
}
if (!(itemStack.getItem() instanceof IPlantable)) continue;
IPlantable plantable = (IPlantable)itemStack.getItem();
Block blockBelow = Vector3.add(serachPosition, new Vector3(0.0, -1.0, 0.0)).getBlock((IBlockAccess)this.world);
if (blockBelow == null || !blockBelow.canSustainPlant(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), ForgeDirection.UP, plantable)) continue;
Block plantBlock = plantable.getPlant(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ());
int blockMetadata = plantable.getPlantMetadata(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ());
if (!this.world.setBlock(serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), plantBlock, blockMetadata, 3) || this.world.getBlock(serachPosition.intX(), serachPosition.intY(), serachPosition.intZ()) != plantBlock) continue;
plantBlock.onBlockPlacedBy(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), null, itemStack);
plantBlock.onPostBlockPlaced(this.world, serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), blockMetadata);
this.tileEntity.dropEntity(entity);
return false;
}
}
return false;
}
@Override
public String toString() {
return "PLACE";
}
}

View File

@ -0,0 +1,86 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import dark.library.helpers.ItemFindingHelper;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.vector.Vector3;
public class CommandPowerTo
extends Command {
private int duration;
private int ticksRan;
@Override
public void onTaskStart() {
this.duration = 0;
this.ticksRan = 0;
if (this.getArgs().length > 0) {
this.duration = this.getIntArg(0);
}
if (this.duration <= 30) {
this.duration = 30;
}
}
@Override
protected boolean doTask() {
super.doTask();
if (this.tileEntity.isProvidingPower && this.ticksRan >= this.duration) {
this.powerBlock(false);
return false;
}
if (this.tileEntity.isProvidingPower) {
Vector3 loc = this.tileEntity.getHandPosition();
this.world.spawnParticle("smoke", loc.x, loc.y, loc.z, 0.0, 0.0, 0.0);
this.world.spawnParticle("flame", loc.x, loc.y, loc.z, 0.0, 0.0, 0.0);
}
Block block = this.world.getBlock(this.tileEntity.getHandPosition().intX(), this.tileEntity.getHandPosition().intY(), this.tileEntity.getHandPosition().intZ());
TileEntity targetTile = this.tileEntity.getHandPosition().getTileEntity((IBlockAccess)this.world);
if (this.tileEntity.getGrabbedItems().size() > 0) {
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
stacks.add(new ItemStack(Blocks.redstone_torch, 1, 0));
stacks.add(new ItemStack(Blocks.unlit_redstone_torch, 1, 0));
if (ItemFindingHelper.filterItems(this.tileEntity.getGrabbedItems(), stacks).size() > 0) {
this.powerBlock(true);
}
}
++this.ticksRan;
return true;
}
public void powerBlock(boolean on) {
this.tileEntity.isProvidingPower = on;
Block block = this.tileEntity.getWorldObj().getBlock(this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord);
for (int i = 2; i < 6; ++i) {
ForgeDirection dir = ForgeDirection.getOrientation((int)i);
this.world.notifyBlockOfNeighborChange(this.tileEntity.xCoord + dir.offsetX, this.tileEntity.yCoord + dir.offsetY, this.tileEntity.zCoord + dir.offsetZ, block);
}
}
@Override
public String toString() {
return "POWERTO " + Integer.toString(this.duration);
}
@Override
public void readFromNBT(NBTTagCompound taskCompound) {
super.readFromNBT(taskCompound);
this.duration = taskCompound.getInteger("useTimes");
this.ticksRan = taskCompound.getInteger("useCurTimes");
}
@Override
public void writeToNBT(NBTTagCompound taskCompound) {
super.writeToNBT(taskCompound);
taskCompound.setInteger("useTimes", this.duration);
taskCompound.setInteger("useCurTimes", this.ticksRan);
}
}

View File

@ -0,0 +1,70 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import net.minecraft.nbt.NBTTagCompound;
public class CommandRepeat
extends Command {
private int tasksToRepeat;
private int numReps;
private int curReps;
private boolean initialized = false;
@Override
public void onTaskStart() {
this.tasksToRepeat = Math.max(this.getIntArg(0), 0);
this.numReps = this.getIntArg(1);
if (this.numReps == 0) {
this.numReps = -1;
}
if (!this.initialized) {
this.initialized = true;
this.curReps = 0;
}
}
@Override
public void onTaskEnd() {
if (this.curReps < this.numReps || this.numReps == -1) {
++this.curReps;
if (this.tasksToRepeat > 0) {
this.commandManager.setCurrentTask(this.commandManager.getCurrentTask() - this.tasksToRepeat - 1);
return;
}
this.commandManager.setCurrentTask(-2);
return;
}
this.initialized = false;
}
@Override
public void readFromNBT(NBTTagCompound taskCompound) {
super.readFromNBT(taskCompound);
this.initialized = taskCompound.getBoolean("repInitialized");
this.tasksToRepeat = taskCompound.getInteger("repTasks");
this.curReps = taskCompound.getInteger("repCur");
this.numReps = taskCompound.getInteger("repGoal");
}
@Override
public void writeToNBT(NBTTagCompound taskCompound) {
super.writeToNBT(taskCompound);
taskCompound.setBoolean("repInitialized", this.initialized);
taskCompound.setInteger("repTasks", this.tasksToRepeat);
taskCompound.setInteger("repCur", this.curReps);
taskCompound.setInteger("repGoal", this.numReps);
}
@Override
public String toString() {
int cmdToTest = 0;
if (this.tasksToRepeat > 0) {
cmdToTest = this.commandManager.getCurrentTask() - this.tasksToRepeat;
}
if (this.commandManager.hasTasks() && this.commandManager.getCurrentTask() >= 0 && this.commandManager.getCurrentTask() < this.commandManager.getCommands().size()) {
return ((Command)this.commandManager.getCommands().get(cmdToTest)).toString();
}
return "REPEAT " + Integer.toString(this.tasksToRepeat) + " " + (this.numReps > 0 ? Integer.toString(this.numReps) : "");
}
}

View File

@ -0,0 +1,36 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.command.CommandRotateTo;
public class CommandReturn
extends Command {
public static final float IDLE_ROTATION_PITCH = 0.0f;
public static final float IDLE_ROTATION_YAW = 0.0f;
private CommandRotateTo rotateToCommand;
@Override
public void onTaskStart() {
this.rotateToCommand = (CommandRotateTo)this.commandManager.getNewCommand(this.tileEntity, CommandRotateTo.class, new String[]{"0", "0"});
this.rotateToCommand.onTaskStart();
}
@Override
protected boolean doTask() {
if (this.rotateToCommand == null) {
this.onTaskStart();
}
return this.rotateToCommand.doTask();
}
@Override
public void onTaskEnd() {
this.rotateToCommand.onTaskEnd();
}
@Override
public String toString() {
return "RETURN";
}
}

View File

@ -0,0 +1,85 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import net.minecraft.nbt.NBTTagCompound;
public class CommandRotateBy
extends Command {
float targetRotationYaw = 0.0f;
float targetRotationPitch = 0.0f;
float deltaPitch = 0.0f;
float deltaYaw = 90.0f;
float totalTicks = 0.0f;
@Override
public void onTaskStart() {
super.onTaskStart();
this.ticks = 0;
if (this.getArg(0) != null) {
this.targetRotationYaw = this.tileEntity.rotationYaw + this.getFloatArg(0).floatValue();
this.deltaYaw = this.getFloatArg(0).floatValue();
} else {
this.targetRotationYaw = this.tileEntity.rotationYaw + 90.0f;
}
if (this.getArg(1) != null) {
this.targetRotationPitch = this.tileEntity.rotationPitch + this.getFloatArg(1).floatValue();
this.deltaPitch = this.getFloatArg(1).floatValue();
} else {
this.targetRotationPitch = this.tileEntity.rotationPitch;
}
while (this.targetRotationYaw < 0.0f) {
this.targetRotationYaw += 360.0f;
}
while (this.targetRotationYaw > 360.0f) {
this.targetRotationYaw -= 360.0f;
}
while (this.targetRotationPitch < 0.0f) {
this.targetRotationPitch += 60.0f;
}
while (this.targetRotationPitch > 60.0f) {
this.targetRotationPitch -= 60.0f;
}
float f = Math.abs(this.targetRotationYaw - this.tileEntity.rotationYaw);
this.tileEntity.getClass();
float totalTicksYaw = f / 1.3f;
float f2 = Math.abs(this.targetRotationPitch - this.tileEntity.rotationPitch);
this.tileEntity.getClass();
float totalTicksPitch = f2 / 1.3f;
this.totalTicks = Math.max(totalTicksYaw, totalTicksPitch);
}
@Override
protected boolean doTask() {
super.doTask();
if (Math.abs(this.tileEntity.rotationYaw - this.targetRotationYaw) > 0.001f) {
this.tileEntity.rotationYaw = this.targetRotationYaw;
}
if (Math.abs(this.tileEntity.rotationPitch - this.targetRotationPitch) > 0.001f) {
this.tileEntity.rotationPitch = this.targetRotationPitch;
}
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch) > 0.001f) {
return true;
}
return Math.abs(this.tileEntity.renderYaw - this.tileEntity.rotationYaw) > 0.001f;
}
@Override
public void readFromNBT(NBTTagCompound taskCompound) {
super.readFromNBT(taskCompound);
this.targetRotationPitch = taskCompound.getFloat("rotPitch");
this.targetRotationYaw = taskCompound.getFloat("rotYaw");
}
@Override
public void writeToNBT(NBTTagCompound taskCompound) {
super.writeToNBT(taskCompound);
taskCompound.setFloat("rotPitch", this.targetRotationPitch);
taskCompound.setFloat("rotYaw", this.targetRotationYaw);
}
@Override
public String toString() {
return "ROTATE " + Float.toString(this.deltaYaw) + " " + Float.toString(this.deltaPitch);
}
}

View File

@ -0,0 +1,70 @@
package assemblyline.common.machine.command;
import assemblyline.common.machine.command.Command;
import net.minecraft.nbt.NBTTagCompound;
public class CommandRotateTo
extends Command {
float targetRotationYaw = 0.0f;
float targetRotationPitch = 0.0f;
int totalTicks = 0;
@Override
public void onTaskStart() {
super.onTaskStart();
this.ticks = 0;
this.totalTicks = 0;
this.targetRotationYaw = this.getArg(0) != null ? this.getFloatArg(0).floatValue() : 0.0f;
this.targetRotationPitch = this.getArg(1) != null ? this.getFloatArg(1).floatValue() : 0.0f;
while (this.targetRotationYaw < 0.0f) {
this.targetRotationYaw += 360.0f;
}
while (this.targetRotationYaw > 360.0f) {
this.targetRotationYaw -= 360.0f;
}
while (this.targetRotationPitch < -60.0f) {
this.targetRotationPitch += 60.0f;
}
while (this.targetRotationPitch > 60.0f) {
this.targetRotationPitch -= 60.0f;
}
float f = Math.abs(this.targetRotationYaw - this.tileEntity.renderYaw);
this.tileEntity.getClass();
int totalTicksYaw = (int)(f / 1.3f);
float f2 = Math.abs(this.targetRotationPitch - this.tileEntity.renderPitch);
this.tileEntity.getClass();
int totalTicksPitch = (int)(f2 / 1.3f);
this.totalTicks = Math.max(totalTicksYaw, totalTicksPitch);
}
@Override
protected boolean doTask() {
super.doTask();
this.tileEntity.rotationYaw = this.targetRotationYaw;
this.tileEntity.rotationPitch = this.targetRotationPitch;
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch) > 0.001f) {
return true;
}
return Math.abs(this.tileEntity.renderYaw - this.tileEntity.rotationYaw) > 0.001f;
}
@Override
public String toString() {
return "ROTATETO " + Float.toString(this.targetRotationYaw) + " " + Float.toString(this.targetRotationPitch);
}
@Override
public void readFromNBT(NBTTagCompound taskCompound) {
super.readFromNBT(taskCompound);
this.targetRotationPitch = taskCompound.getFloat("rotPitch");
this.targetRotationYaw = taskCompound.getFloat("rotYaw");
}
@Override
public void writeToNBT(NBTTagCompound taskCompound) {
super.writeToNBT(taskCompound);
taskCompound.setFloat("rotPitch", this.targetRotationPitch);
taskCompound.setFloat("rotYaw", this.targetRotationYaw);
}
}

View File

@ -0,0 +1,69 @@
package assemblyline.common.machine.command;
import assemblyline.api.IArmbotUseable;
import assemblyline.common.machine.command.Command;
import net.minecraft.block.Block;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
public class CommandUse
extends Command {
private int times;
private int curTimes;
@Override
public void onTaskStart() {
this.times = 0;
this.curTimes = 0;
if (this.getArgs().length > 0) {
this.times = this.getIntArg(0);
}
if (this.times <= 0) {
this.times = 1;
}
}
@Override
protected boolean doTask() {
Block block = this.world.getBlock(this.tileEntity.getHandPosition().intX(), this.tileEntity.getHandPosition().intY(), this.tileEntity.getHandPosition().intZ());
TileEntity targetTile = this.tileEntity.getHandPosition().getTileEntity((IBlockAccess)this.world);
if (targetTile != null) {
if (targetTile instanceof IArmbotUseable) {
((IArmbotUseable)targetTile).onUse(this.tileEntity, this.getArgs());
} else if (targetTile instanceof ISidedInventory && this.tileEntity.getGrabbedEntities().size() > 0) {
// empty if block
}
} else if (block != null) {
try {
boolean f = block.onBlockActivated(this.world, this.tileEntity.getHandPosition().intX(), this.tileEntity.getHandPosition().intY(), this.tileEntity.getHandPosition().intZ(), null, 0, 0.0f, 0.0f, 0.0f);
}
catch (Exception e) {
e.printStackTrace();
}
}
++this.curTimes;
return this.curTimes < this.times;
}
@Override
public String toString() {
return "USE " + Integer.toString(this.times);
}
@Override
public void readFromNBT(NBTTagCompound taskCompound) {
super.readFromNBT(taskCompound);
this.times = taskCompound.getInteger("useTimes");
this.curTimes = taskCompound.getInteger("useCurTimes");
}
@Override
public void writeToNBT(NBTTagCompound taskCompound) {
super.writeToNBT(taskCompound);
taskCompound.setInteger("useTimes", this.times);
taskCompound.setInteger("useCurTimes", this.curTimes);
}
}

View File

@ -0,0 +1,102 @@
package assemblyline.common.machine.command;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
public class GrabDictionary {
private static List<GrabDictionary> grabList = new ArrayList<>();
private Class<? extends Entity> entityClass;
private String name;
public GrabDictionary(String name, Class<? extends Entity> Class2) {
this.entityClass = Class2;
this.name = name;
}
public static List<GrabDictionary> getList() {
return grabList;
}
public static GrabDictionary get(Object ob) {
if (ob instanceof String) {
String name = (String)ob;
for (GrabDictionary ref : grabList) {
if (!ref.getName().equalsIgnoreCase(name)) continue;
return ref;
}
}
if (ob instanceof Class) {
Class cc = (Class)ob;
for (GrabDictionary ref : grabList) {
if (ref.getEntityClass() != cc) continue;
return ref;
}
}
return new GrabDictionary("Entity", Entity.class);
}
public String getName() {
if (this.name != null) {
return this.name;
}
return "";
}
public Class getEntityClass() {
if (this.entityClass != null) {
return this.entityClass;
}
return Entity.class;
}
public static void registerGrabableEntity(String name, Class eClass) {
GrabDictionary newGrab = new GrabDictionary(name, eClass);
if (!grabList.contains(newGrab)) {
for (GrabDictionary ref : grabList) {
if (!ref.getName().equalsIgnoreCase(name)) continue;
return;
}
GrabDictionary.getList().add(newGrab);
}
}
public static void registerList() {
GrabDictionary.registerGrabableEntity("chicken", EntityChicken.class);
GrabDictionary.registerGrabableEntity("cow", EntityCow.class);
GrabDictionary.registerGrabableEntity("sheep", EntitySheep.class);
GrabDictionary.registerGrabableEntity("pig", EntityPig.class);
GrabDictionary.registerGrabableEntity("player", EntityPlayer.class);
GrabDictionary.registerGrabableEntity("zombie", EntityZombie.class);
GrabDictionary.registerGrabableEntity("zomb", EntityZombie.class);
GrabDictionary.registerGrabableEntity("skeleton", EntitySkeleton.class);
GrabDictionary.registerGrabableEntity("skel", EntitySkeleton.class);
GrabDictionary.registerGrabableEntity("animal", EntityAnimal.class);
GrabDictionary.registerGrabableEntity("monster", EntityMob.class);
GrabDictionary.registerGrabableEntity("mob", EntityMob.class);
GrabDictionary.registerGrabableEntity("creeper", EntityCreeper.class);
GrabDictionary.registerGrabableEntity("spider", EntitySpider.class);
GrabDictionary.registerGrabableEntity("slime", EntitySlime.class);
GrabDictionary.registerGrabableEntity("items", EntityItem.class);
GrabDictionary.registerGrabableEntity("all", Entity.class);
GrabDictionary.registerGrabableEntity("everything", Entity.class);
GrabDictionary.registerGrabableEntity("boat", EntityBoat.class);
GrabDictionary.registerGrabableEntity("cart", EntityMinecart.class);
}
}

View File

@ -0,0 +1,64 @@
package assemblyline.common.machine.crane;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
public class BlockCraneController
extends BlockALMachine {
public BlockCraneController() {
super(UniversalElectricity.machine);
this.setBlockName("craneController");
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
int rot = (int)Math.min((entity.rotationYaw + 315.0f) % 360.0f / 90.0f, 3.0f);
switch (rot) {
case 0: {
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.WEST.ordinal(), 3);
break;
}
case 1: {
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.NORTH.ordinal(), 3);
break;
}
case 2: {
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.EAST.ordinal(), 3);
break;
}
default: {
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.SOUTH.ordinal(), 3);
}
}
}
@Override
@SideOnly(value=Side.CLIENT)
public int getRenderType() {
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityCraneController();
}
}

View File

@ -0,0 +1,126 @@
package assemblyline.common.machine.crane;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
public class BlockCraneFrame
extends BlockALMachine {
public BlockCraneFrame() {
super(UniversalElectricity.machine);
this.setBlockName("craneFrame");
this.setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
TileEntity tE = world.getTileEntity(x, y, z);
if (tE != null && tE instanceof TileEntityCraneRail) {
AxisAlignedBB middle = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.25, (double)0.75, (double)0.75, (double)0.75);
AxisAlignedBB up = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.75, (double)0.25, (double)0.75, (double)1.0, (double)0.75);
AxisAlignedBB down = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.0, (double)0.25, (double)0.75, (double)0.25, (double)0.75);
AxisAlignedBB left = AxisAlignedBB.getBoundingBox((double)0.0, (double)0.25, (double)0.25, (double)0.25, (double)0.75, (double)0.75);
AxisAlignedBB right = AxisAlignedBB.getBoundingBox((double)0.75, (double)0.25, (double)0.25, (double)1.0, (double)0.75, (double)0.75);
AxisAlignedBB front = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.0, (double)0.75, (double)0.75, (double)0.25);
AxisAlignedBB back = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.75, (double)0.75, (double)0.75, (double)1.0);
boolean connectUp = CraneHelper.canFrameConnectTo(tE, x, y + 1, z, ForgeDirection.DOWN);
boolean connectDown = CraneHelper.canFrameConnectTo(tE, x, y - 1, z, ForgeDirection.UP);
boolean connectLeft = CraneHelper.canFrameConnectTo(tE, x - 1, y, z, ForgeDirection.EAST);
boolean connectRight = CraneHelper.canFrameConnectTo(tE, x + 1, y, z, ForgeDirection.WEST);
boolean connectFront = CraneHelper.canFrameConnectTo(tE, x, y, z - 1, ForgeDirection.SOUTH);
boolean connectBack = CraneHelper.canFrameConnectTo(tE, x, y, z + 1, ForgeDirection.NORTH);
if (connectUp) {
middle.maxY = up.maxY;
}
if (connectDown) {
middle.minY = down.minY;
}
if (connectLeft) {
middle.minX = left.minX;
}
if (connectRight) {
middle.maxX = right.maxX;
}
if (connectFront) {
middle.minZ = front.minZ;
}
if (connectBack) {
middle.maxZ = back.maxZ;
}
this.setBlockBounds((float)middle.minX, (float)middle.minY, (float)middle.minZ, (float)middle.maxX, (float)middle.maxY, (float)middle.maxZ);
middle.offset((double)x, (double)y, (double)z);
return middle;
}
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntity tE = world.getTileEntity(x, y, z);
if (tE != null && tE instanceof TileEntityCraneRail) {
AxisAlignedBB middle = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.25, (double)0.75, (double)0.75, (double)0.75);
AxisAlignedBB up = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.75, (double)0.25, (double)0.75, (double)1.0, (double)0.75);
AxisAlignedBB down = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.0, (double)0.25, (double)0.75, (double)0.25, (double)0.75);
AxisAlignedBB left = AxisAlignedBB.getBoundingBox((double)0.0, (double)0.25, (double)0.25, (double)0.25, (double)0.75, (double)0.75);
AxisAlignedBB right = AxisAlignedBB.getBoundingBox((double)0.75, (double)0.25, (double)0.25, (double)1.0, (double)0.75, (double)0.75);
AxisAlignedBB front = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.0, (double)0.75, (double)0.75, (double)0.25);
AxisAlignedBB back = AxisAlignedBB.getBoundingBox((double)0.25, (double)0.25, (double)0.75, (double)0.75, (double)0.75, (double)1.0);
boolean connectUp = CraneHelper.canFrameConnectTo(tE, x, y + 1, z, ForgeDirection.DOWN);
boolean connectDown = CraneHelper.canFrameConnectTo(tE, x, y - 1, z, ForgeDirection.UP);
boolean connectLeft = CraneHelper.canFrameConnectTo(tE, x - 1, y, z, ForgeDirection.EAST);
boolean connectRight = CraneHelper.canFrameConnectTo(tE, x + 1, y, z, ForgeDirection.WEST);
boolean connectFront = CraneHelper.canFrameConnectTo(tE, x, y, z - 1, ForgeDirection.SOUTH);
boolean connectBack = CraneHelper.canFrameConnectTo(tE, x, y, z + 1, ForgeDirection.NORTH);
if (connectUp) {
middle.maxY = up.maxY;
}
if (connectDown) {
middle.minY = down.minY;
}
if (connectLeft) {
middle.minX = left.minX;
}
if (connectRight) {
middle.maxX = right.maxX;
}
if (connectFront) {
middle.minZ = front.minZ;
}
if (connectBack) {
middle.maxZ = back.maxZ;
}
this.setBlockBounds((float)middle.minX, (float)middle.minY, (float)middle.minZ, (float)middle.maxX, (float)middle.maxY, (float)middle.maxZ);
return;
}
this.setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityCraneRail();
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
@SideOnly(value=Side.CLIENT)
public int getRenderType() {
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
}

View File

@ -0,0 +1,59 @@
package assemblyline.common.machine.crane;
import assemblyline.api.ICraneConnectable;
import assemblyline.api.ICraneStructure;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class CraneHelper {
public static final int MAX_SIZE = 64;
public static boolean isCraneBlock(World world, int x, int y, int z) {
return world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof ICraneConnectable;
}
public static boolean isCraneStructureBlock(World world, int x, int y, int z) {
return world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof ICraneStructure;
}
public static boolean canFrameConnectTo(TileEntity tileEntity, int x, int y, int z, ForgeDirection side) {
if (tileEntity.getWorldObj().getTileEntity(x, y, z) != null && tileEntity.getWorldObj().getTileEntity(x, y, z) instanceof ICraneConnectable) {
return ((ICraneConnectable)tileEntity.getWorldObj().getTileEntity(x, y, z)).canFrameConnectTo(side);
}
return false;
}
public static ForgeDirection rotateClockwise(ForgeDirection direction) {
if (direction == ForgeDirection.NORTH) {
return ForgeDirection.EAST;
}
if (direction == ForgeDirection.EAST) {
return ForgeDirection.SOUTH;
}
if (direction == ForgeDirection.SOUTH) {
return ForgeDirection.WEST;
}
if (direction == ForgeDirection.WEST) {
return ForgeDirection.NORTH;
}
return ForgeDirection.UNKNOWN;
}
public static ForgeDirection rotateCounterClockwise(ForgeDirection direction) {
if (direction == ForgeDirection.NORTH) {
return ForgeDirection.WEST;
}
if (direction == ForgeDirection.WEST) {
return ForgeDirection.SOUTH;
}
if (direction == ForgeDirection.SOUTH) {
return ForgeDirection.EAST;
}
if (direction == ForgeDirection.EAST) {
return ForgeDirection.NORTH;
}
return ForgeDirection.UNKNOWN;
}
}

View File

@ -0,0 +1,159 @@
package assemblyline.common.machine.crane;
import assemblyline.api.ICraneConnectable;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
import assemblyline.common.machine.crane.CraneHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCraneController
extends TileEntityAssemblyNetwork
implements ICraneConnectable {
int width = 0;
int height = 0;
int depth = 0;
boolean isCraneValid = false;
long ticks = 0L;
@Override
public void updateEntity() {
++this.ticks;
if (this.ticks % 20L == 0L) {
this.validateCrane();
}
}
public boolean isCraneValid() {
return this.isCraneValid;
}
private void validateCrane() {
this.isCraneValid = false;
this.depth = 0;
this.height = 0;
this.width = 0;
this.findCraneHeight();
this.findCraneWidth();
this.findCraneDepth();
if (Math.abs(this.height) > 1 && Math.abs(this.width) > 1 && Math.abs(this.depth) > 1) {
this.isCraneValid = this.isFrameValid();
}
}
private boolean isFrameValid() {
int z;
int x;
for (x = Math.min(0, this.width); x <= Math.max(0, this.width); ++x) {
if (CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord + x, this.yCoord + this.height, this.zCoord)) continue;
return false;
}
for (x = Math.min(0, this.width); x <= Math.max(0, this.width); ++x) {
if (CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord + x, this.yCoord + this.height, this.zCoord + this.depth)) continue;
return false;
}
for (z = Math.min(0, this.depth); z <= Math.max(0, this.depth); ++z) {
if (CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord, this.yCoord + this.height, this.zCoord + z)) continue;
return false;
}
for (z = Math.min(0, this.depth); z <= Math.max(0, this.depth); ++z) {
if (CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord + this.width, this.yCoord + this.height, this.zCoord + z)) continue;
return false;
}
for (x = Math.min(this.width + 1, 1); x <= Math.max(-1, this.width - 1); ++x) {
for (int z2 = Math.min(this.depth + 1, 1); z2 <= Math.max(-1, this.depth - 1); ++z2) {
if (this.worldObj.isAirBlock(this.xCoord + x, this.yCoord + this.height, this.zCoord + z2)) continue;
return false;
}
}
return true;
}
private void findCraneWidth() {
if (this.height == 0) {
this.width = 0;
return;
}
int x = 0;
ForgeDirection facing = ForgeDirection.getOrientation((int)this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
while (Math.abs(x) <= 64 && CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord + x, this.yCoord + this.height, this.zCoord)) {
if (facing == ForgeDirection.NORTH || facing == ForgeDirection.EAST) {
++x;
continue;
}
--x;
}
this.width = x;
if (this.width < 0) {
++this.width;
}
if (this.width > 0) {
--this.width;
}
}
private void findCraneHeight() {
int y;
for (y = 1; this.yCoord + y < 256 && y <= 64 && CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord, this.yCoord + y, this.zCoord); ++y) {
}
this.height = y - 1;
}
private void findCraneDepth() {
if (this.height == 0) {
this.width = 0;
return;
}
int z = 0;
ForgeDirection facing = ForgeDirection.getOrientation((int)this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
while (Math.abs(z) <= 64 && CraneHelper.isCraneStructureBlock(this.worldObj, this.xCoord, this.yCoord + this.height, this.zCoord + z)) {
if (facing == ForgeDirection.SOUTH || facing == ForgeDirection.EAST) {
++z;
continue;
}
--z;
}
this.depth = z;
if (this.depth < 0) {
++this.depth;
}
if (this.depth > 0) {
--this.depth;
}
}
@Override
public boolean canFrameConnectTo(ForgeDirection side) {
ForgeDirection facing = ForgeDirection.getOrientation((int)this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
if (side == facing) {
return true;
}
if (side == CraneHelper.rotateClockwise(facing)) {
return true;
}
return side == ForgeDirection.UP;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("width", this.width);
nbt.setInteger("height", this.height);
nbt.setInteger("depth", this.depth);
nbt.setBoolean("isValid", this.isCraneValid);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.width = nbt.getInteger("width");
this.height = nbt.getInteger("height");
this.depth = nbt.getInteger("depth");
this.isCraneValid = nbt.getBoolean("isValid");
}
@Override
public boolean canConnect(ForgeDirection direction) {
return true;
}
}

View File

@ -0,0 +1,20 @@
package assemblyline.common.machine.crane;
import assemblyline.api.ICraneStructure;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCraneRail
extends TileEntityAssemblyNetwork
implements ICraneStructure {
@Override
public boolean canFrameConnectTo(ForgeDirection side) {
return true;
}
@Override
public boolean canConnect(ForgeDirection direction) {
return false;
}
}

View File

@ -0,0 +1,146 @@
package assemblyline.common.machine.detector;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.machine.detector.TileEntityDetector;
import assemblyline.common.machine.imprinter.BlockImprintable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
public class BlockDetector
extends BlockImprintable {
IIcon eye_red;
IIcon eye_green;
public BlockDetector() {
super("detector", UniversalElectricity.machine, TabAssemblyLine.INSTANCE);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
int angle = MathHelper.floor_double((double)((double)(entity.rotationYaw * 4.0f / 360.0f) + 0.5)) & 3;
int change = 2;
switch (angle) {
case 0: {
change = ForgeDirection.NORTH.ordinal();
break;
}
case 1: {
change = ForgeDirection.EAST.ordinal();
break;
}
case 2: {
change = ForgeDirection.SOUTH.ordinal();
break;
}
case 3: {
change = ForgeDirection.WEST.ordinal();
}
}
if (entity.rotationPitch < -70.0f) {
change = ForgeDirection.DOWN.ordinal();
}
if (entity.rotationPitch > 70.0f) {
change = ForgeDirection.UP.ordinal();
}
world.setBlockMetadataWithNotify(x, y, z, change, 3);
}
@Override
@SideOnly(value=Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg) {
super.registerBlockIcons(iconReg);
this.eye_green = iconReg.registerIcon("assemblyline:detector_green");
this.eye_red = iconReg.registerIcon("assemblyline:detector_red");
}
@Override
public IIcon getIcon(IBlockAccess iBlockAccess, int x, int y, int z, int side) {
TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityDetector && side == ForgeDirection.getOrientation((int)iBlockAccess.getBlockMetadata(x, y, z)).ordinal()) {
if (((TileEntityDetector)tileEntity).isInverted()) {
return this.eye_red;
}
return this.eye_green;
}
return this.machine_icon;
}
@Override
public IIcon getIcon(int side, int metadata) {
if (side == ForgeDirection.SOUTH.ordinal()) {
return this.eye_green;
}
return this.machine_icon;
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
world.setBlockMetadataWithNotify(x, y, z, side, 3);
return true;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block blockID) {
if (!this.canBlockStay(world, x, y, z)) {
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlock(x, y, z, Blocks.air, 0, 3);
}
}
@Override
public boolean isOpaqueCube() {
return false;
}
public boolean isBlockNormalCube(World world, int x, int y, int z) {
return false;
}
@Override
public boolean isBlockSolid(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
return false;
}
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int direction) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityDetector) {
return ((TileEntityDetector)tileEntity).isPoweringTo(ForgeDirection.getOrientation((int)direction));
}
return 0;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int direction) {
return this.isProvidingStrongPower(world, x, y, z, direction);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityDetector();
}
}

View File

@ -0,0 +1,85 @@
package assemblyline.common.machine.detector;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.imprinter.TileEntityFilterable;
import java.util.ArrayList;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityDetector
extends TileEntityFilterable {
private boolean powering = false;
@Override
public void updateEntity() {
super.updateEntity();
if (!this.worldObj.isRemote && this.ticks % 10L == 0L) {
int metadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
AxisAlignedBB testArea = AxisAlignedBB.getBoundingBox((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1));
ForgeDirection dir = ForgeDirection.getOrientation((int)metadata);
testArea.offset((double)dir.offsetX, (double)dir.offsetY, (double)dir.offsetZ);
ArrayList entities = (ArrayList)this.worldObj.getEntitiesWithinAABB(EntityItem.class, testArea);
boolean powerCheck = false;
if (entities.size() > 0) {
if (this.getFilter() != null) {
for (int i = 0; i < entities.size(); ++i) {
EntityItem e = (EntityItem)entities.get(i);
ItemStack itemStack = e.getEntityItem();
powerCheck = this.isFiltering(itemStack);
}
} else {
powerCheck = true;
}
} else {
powerCheck = false;
}
if (powerCheck != this.powering) {
this.powering = powerCheck;
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, AssemblyLine.blockDetector);
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord + 1, this.zCoord, AssemblyLine.blockDetector);
for (int x = this.xCoord - 1; x <= this.xCoord + 1; ++x) {
for (int z = this.zCoord - 1; z <= this.zCoord + 1; ++z) {
this.worldObj.notifyBlocksOfNeighborChange(x, this.yCoord + 1, z, AssemblyLine.blockDetector);
}
}
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
@Override
public void invalidate() {
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, AssemblyLine.blockDetector);
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord + 1, this.zCoord, AssemblyLine.blockDetector);
super.invalidate();
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
this.powering = tag.getBoolean("powering");
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setBoolean("powering", this.powering);
}
public int isPoweringTo(ForgeDirection side) {
return this.powering && this.getDirection() != side.getOpposite() ? 15 : 0;
}
public boolean isIndirectlyPoweringTo(ForgeDirection side) {
return this.isPoweringTo(side) > 0;
}
@Override
public boolean canConnect(ForgeDirection direction) {
return direction != this.getDirection();
}
}

View File

@ -0,0 +1,64 @@
package assemblyline.common.machine.encoder;
import assemblyline.common.AssemblyLine;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockEncoder
extends BlockALMachine {
IIcon encoder_side;
IIcon encoder_top;
IIcon encoder_bottom;
public BlockEncoder() {
super(Material.wood);
this.setBlockName("encoder");
this.setCreativeTab(TabAssemblyLine.INSTANCE);
}
@Override
@SideOnly(value=Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg) {
this.encoder_side = iconReg.registerIcon("assemblyline:encoder_side");
this.encoder_top = iconReg.registerIcon("assemblyline:encoder_top");
this.encoder_bottom = iconReg.registerIcon("assemblyline:encoder_bottom");
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return this.getIcon(side, 0);
}
@Override
public IIcon getIcon(int side, int meta) {
if (side == 1) {
return this.encoder_top;
}
if (side == 0) {
return this.encoder_bottom;
}
return this.encoder_side;
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
if (!world.isRemote) {
entityPlayer.openGui((Object)AssemblyLine.instance, 2, world, x, y, z);
}
return true;
}
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityEncoder();
}
}

View File

@ -0,0 +1,60 @@
package assemblyline.common.machine.encoder;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.imprinter.SlotCustom;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerEncoder
extends Container {
public static final int Y_OFFSET = 0;
private ItemStack[] containingItems = new ItemStack[1];
private InventoryPlayer inventoryPlayer;
private TileEntityEncoder tileEntity;
public ContainerEncoder(InventoryPlayer inventoryPlayer, TileEntityEncoder encoder) {
int var3;
this.inventoryPlayer = inventoryPlayer;
this.tileEntity = encoder;
this.addSlotToContainer(new SlotCustom((IInventory)encoder, 0, 80, 24, new ItemStack(AssemblyLine.itemDisk)));
for (var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot((IInventory)inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 155 + var3 * 18 + 0));
}
}
for (var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(new Slot((IInventory)inventoryPlayer, var3, 8 + var3 * 18, 213));
}
}
public boolean canInteractWith(EntityPlayer player) {
return this.tileEntity.isUseableByPlayer(player);
}
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack copyStack = null;
Slot slotObj = (Slot)this.inventorySlots.get(slot);
if (slotObj != null && slotObj.getHasStack()) {
ItemStack slotStack = slotObj.getStack();
copyStack = slotStack.copy();
if (slot >= 1 ? this.getSlot(0).isItemValid(slotStack) && !this.mergeItemStack(slotStack, 0, 1, false) : !this.mergeItemStack(slotStack, this.containingItems.length, 37, false)) {
return null;
}
if (slotStack.stackSize == 0) {
slotObj.putStack((ItemStack)null);
} else {
slotObj.onSlotChanged();
}
if (slotStack.stackSize == copyStack.stackSize) {
return null;
}
slotObj.onPickupFromSlot(player, slotStack);
}
return copyStack;
}
}

View File

@ -0,0 +1,6 @@
package assemblyline.common.machine.encoder;
public interface IInventoryWatcher {
public void inventoryChanged();
}

View File

@ -0,0 +1,79 @@
package assemblyline.common.machine.encoder;
import assemblyline.common.TabAssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class ItemDisk
extends Item {
public ItemDisk() {
super();
this.setUnlocalizedName("disk");
this.setCreativeTab(TabAssemblyLine.INSTANCE);
this.setHasSubtypes(true);
}
@Override
@SideOnly(value=Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {
this.itemIcon = par1IconRegister.registerIcon("assemblyline:disk");
}
@Override
public int getItemStackLimit() {
return 1;
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
ArrayList commands = ItemDisk.getCommands(itemStack);
if (commands.size() > 0) {
if (commands.size() == 1) {
list.add(commands.size() + " command");
} else {
list.add(commands.size() + " commands");
}
} else {
list.add("No commands");
}
}
public static void setCommands(ItemStack itemStack, ArrayList commands) {
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
NBTTagList nbt = new NBTTagList();
for (int i = 0; i < commands.size(); ++i) {
if (commands.get(i) == null) continue;
NBTTagCompound newCompound = new NBTTagCompound();
newCompound.setString("command", (String)commands.get(i));
nbt.appendTag((NBTBase)newCompound);
}
itemStack.getTagCompound().setTag("Commands", (NBTBase)nbt);
}
public static ArrayList getCommands(ItemStack itemStack) {
ArrayList<String> commands = new ArrayList<String>();
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound nbt = itemStack.getTagCompound();
NBTTagList tagList = nbt.getTagList("Commands", 10);
for (int i = 0; i < tagList.tagCount(); ++i) {
NBTTagCompound curTag = tagList.getCompoundTagAt(i);
String cmd = curTag.getString("command");
commands.add(cmd);
}
return commands;
}
}

View File

@ -0,0 +1,18 @@
package assemblyline.common.machine.encoder;
import assemblyline.common.AssemblyLine;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotDisk
extends Slot {
public SlotDisk(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack itemStack) {
return itemStack.getItem() == AssemblyLine.itemDisk;
}
}

View File

@ -0,0 +1,28 @@
package assemblyline.common.machine.encoder;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotDiskResult
extends Slot {
public SlotDiskResult(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
}
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) {
super.onPickupFromSlot(par1EntityPlayer, par2ItemStack);
if (this.inventory.getStackInSlot(0) != null) {
--this.inventory.getStackInSlot((int)0).stackSize;
if (this.inventory.getStackInSlot((int)0).stackSize <= 0) {
this.inventory.setInventorySlotContents(0, null);
}
}
}
}

View File

@ -0,0 +1,163 @@
package assemblyline.common.machine.encoder;
import assemblyline.common.machine.command.Command;
import assemblyline.common.machine.encoder.IInventoryWatcher;
import assemblyline.common.machine.encoder.ItemDisk;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class TileEntityEncoder
extends TileEntityAdvanced
implements ISidedInventory {
private ItemStack disk;
private IInventoryWatcher watcher;
@Override
public int getSizeInventory() {
return 1;
}
@Override
public ItemStack getStackInSlot(int slot) {
if (slot == 0) {
return this.disk;
}
return null;
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
if (slot == 0 && amount >= 1) {
ItemStack ret = this.disk.copy();
this.disk = null;
return ret;
}
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return null;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
if (slot == 0) {
if (stack != null && stack.stackSize > 1) {
stack.stackSize = 1;
}
this.disk = stack;
}
}
@Override
public void markDirty() {
super.markDirty();
if (this.watcher != null) {
this.watcher.inventoryChanged();
}
}
@Override
public String getInventoryName() {
return "Encoder";
}
@Override
public int getInventoryStackLimit() {
return 1;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
public void setWatcher(IInventoryWatcher watcher) {
this.watcher = watcher;
}
public IInventoryWatcher getWatcher() {
return this.watcher;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
if (this.disk != null) {
NBTTagCompound diskNBT = new NBTTagCompound();
this.disk.writeToNBT(diskNBT);
nbt.setTag("disk", diskNBT);
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
NBTTagCompound diskNBT = nbt.getCompoundTag("disk");
if (diskNBT != null) {
this.disk = ItemStack.loadItemStackFromNBT((NBTTagCompound)diskNBT);
}
}
public void handleMessage(NBTTagCompound nbt) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.disk != null) {
ArrayList<String> tempCmds = ItemDisk.getCommands(this.disk);
if (nbt.getBoolean("create")) {
String newCommand = nbt.getString("newCommand");
String commandName = newCommand.split(" ")[0];
if (Command.getCommand(commandName) != null) {
tempCmds.add(newCommand);
}
} else {
int commandToRemove = nbt.getInteger("commandToRemove");
tempCmds.remove(commandToRemove);
}
ItemDisk.setCommands(this.disk, tempCmds);
}
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return false;
}
@Override
public boolean canExtractItem(int arg0, ItemStack arg1, int arg2) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean canInsertItem(int arg0, ItemStack arg1, int arg2) {
// TODO Auto-generated method stub
return false;
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return side == ForgeDirection.UP.ordinal() ? new int[] {0} : new int[0];
}
}

View File

@ -0,0 +1,123 @@
package assemblyline.common.machine.imprinter;
import assemblyline.api.IFilterable;
import assemblyline.common.block.BlockALMachine;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import universalelectricity.prefab.implement.IRedstoneReceptor;
public abstract class BlockImprintable
extends BlockALMachine {
public BlockImprintable(String name, Material material, CreativeTabs creativeTab) {
super(material);
this.setBlockName(name);
this.setCreativeTab(creativeTab);
}
@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.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof IFilterable) {
ItemStack containingStack = ((IFilterable)tileEntity).getFilter();
if (containingStack != null) {
if (!world.isRemote) {
EntityItem dropStack = new EntityItem(world, player.posX, player.posY, player.posZ, containingStack);
dropStack.delayBeforeCanPickup = 0;
world.spawnEntityInWorld((Entity)dropStack);
}
((IFilterable)tileEntity).setFilter(null);
return true;
}
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemImprinter) {
((IFilterable)tileEntity).setFilter(player.getCurrentEquippedItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
return true;
}
}
return false;
}
@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.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof TileEntityFilterable) {
((TileEntityFilterable)tileEntity).toggleInversion();
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
world.markBlockForUpdate(x, y, z);
}
return true;
}
@Override
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return this.onMachineActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
}
@Override
public void onNeighborBlockChange(World par1World, int x, int y, int z, Block side) {
super.onNeighborBlockChange(par1World, x, y, z, side);
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneReceptor && par1World.isBlockIndirectlyGettingPowered(x, y, z)) {
((IRedstoneReceptor)par1World.getTileEntity(x, y, z)).onPowerOn();
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack) {
int angle = MathHelper.floor_double((double)((double)(par5EntityLiving.rotationYaw * 4.0f / 360.0f) + 0.5)) & 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;
}
}
world.setBlockMetadataWithNotify(x, y, z, change, 3);
}
@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;
}
}
world.setBlockMetadataWithNotify(x, y, z, change, 3);
return true;
}
}

View File

@ -0,0 +1,117 @@
package assemblyline.common.machine.imprinter;
import assemblyline.common.AssemblyLine;
import assemblyline.common.TabAssemblyLine;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockImprinter
extends BlockALMachine {
IIcon imprinter_side;
IIcon imprinter_top;
IIcon imprinter_bottom;
public BlockImprinter() {
super(Material.wood);
this.setBlockName("imprinter");
this.setCreativeTab(TabAssemblyLine.INSTANCE);
}
@Override
@SideOnly(value=Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg) {
this.imprinter_side = iconReg.registerIcon("assemblyline:imprinter_side");
this.imprinter_top = iconReg.registerIcon("assemblyline:imprinter_top");
this.imprinter_bottom = iconReg.registerIcon("assemblyline:imprinter_bottom");
}
@Override
@SideOnly(value=Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return this.getIcon(side, 0);
}
@Override
public IIcon getIcon(int side, int meta) {
if (side == 1) {
return this.imprinter_top;
}
if (side == 0) {
return this.imprinter_bottom;
}
return this.imprinter_side;
}
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
if (!world.isRemote) {
entityPlayer.openGui((Object)AssemblyLine.instance, 1, world, x, y, z);
}
return true;
}
@Override
public void dropEntireInventory(World par1World, int x, int y, int z, Block par5, int par6) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof TileEntityImprinter) {
TileEntityImprinter inventory = (TileEntityImprinter)tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
ItemStack itemStack = inventory.getStackInSlot(i);
if (itemStack == null) continue;
Random random = new Random();
float var8 = random.nextFloat() * 0.8f + 0.1f;
float var9 = random.nextFloat() * 0.8f + 0.1f;
float var10 = random.nextFloat() * 0.8f + 0.1f;
while (itemStack.stackSize > 0) {
int var11 = random.nextInt(21) + 10;
if (var11 > itemStack.stackSize) {
var11 = itemStack.stackSize;
}
itemStack.stackSize -= var11;
if (i == inventory.imprinterMatrix.length + 9 - 1) continue;
EntityItem entityItem = new EntityItem(par1World, (double)((float)x + var8), (double)((float)y + var9), (double)((float)z + var10), new ItemStack(itemStack.getItem(), var11, itemStack.getItemDamage()));
if (itemStack.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy());
}
float var13 = 0.05f;
entityItem.motionX = (float)random.nextGaussian() * var13;
entityItem.motionY = (float)random.nextGaussian() * var13 + 0.2f;
entityItem.motionZ = (float)random.nextGaussian() * var13;
par1World.spawnEntityInWorld((Entity)entityItem);
}
}
}
}
@Override
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) {
TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityImprinter) {
((TileEntityImprinter)tileEntity).searchInventories = !((TileEntityImprinter)tileEntity).searchInventories;
par1World.markBlockForUpdate(x, y, z);
return true;
}
return false;
}
@Override
public TileEntity createNewTileEntity(World var1, int meta) {
return new TileEntityImprinter();
}
}

View File

@ -0,0 +1,100 @@
package assemblyline.common.machine.imprinter;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.imprinter.ISlotWatcher;
import assemblyline.common.machine.imprinter.SlotCraftingResult;
import assemblyline.common.machine.imprinter.SlotCustom;
import assemblyline.common.machine.imprinter.TileEntityImprinter;
import assemblyline.common.machine.imprinter.WatchedSlot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerImprinter
extends Container
implements ISlotWatcher {
public InventoryPlayer inventoryPlayer;
public TileEntityImprinter tileEntity;
public ContainerImprinter(InventoryPlayer inventoryPlayer, TileEntityImprinter tileEntity) {
int var3;
this.tileEntity = tileEntity;
this.tileEntity.container = this;
this.inventoryPlayer = inventoryPlayer;
for (int x = 0; x < 3; ++x) {
for (int y = 0; y < 3; ++y) {
this.addSlotToContainer(new WatchedSlot((IInventory)this.tileEntity, y + x * 3, 9 + y * 18, 16 + x * 18, this));
}
}
this.addSlotToContainer(new SlotCustom((IInventory)this.tileEntity, 9, 68, 34, new ItemStack(AssemblyLine.itemImprint)));
this.addSlotToContainer(new WatchedSlot((IInventory)this.tileEntity, 10, 92, 34, this));
this.addSlotToContainer(new SlotCraftingResult(this, (IInventory)this.tileEntity, 11, 148, 34));
for (int ii = 0; ii < 2; ++ii) {
for (int i = 0; i < 9; ++i) {
this.addSlotToContainer(new WatchedSlot((IInventory)this.tileEntity, i + ii * 9 + 12, 8 + i * 18, 80 + ii * 18, this));
}
}
for (var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new WatchedSlot((IInventory)inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 120 + var3 * 18, this));
}
}
for (var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(new WatchedSlot((IInventory)inventoryPlayer, var3, 8 + var3 * 18, 178, this));
}
this.tileEntity.openInventory();
}
public void onContainerClosed(EntityPlayer par1EntityPlayer) {
super.onContainerClosed(par1EntityPlayer);
this.tileEntity.closeInventory();
}
public boolean canInteractWith(EntityPlayer player) {
return this.tileEntity.isUseableByPlayer(player);
}
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack copyStack = null;
Slot slotObj = (Slot)this.inventorySlots.get(slot);
if (slotObj != null && slotObj.getHasStack()) {
ItemStack slotStack = slotObj.getStack();
copyStack = slotStack.copy();
if (slot == 12 - 1) {
this.tileEntity.setInventorySlotContents(12 - 1, null);
}
if (slot > this.tileEntity.getSizeInventory() - 1) {
if (this.getSlot(9).isItemValid(slotStack)) {
if (!this.mergeItemStack(slotStack, 9, 9 + 1, true)) {
return null;
}
} else if (!this.mergeItemStack(slotStack, 12, this.tileEntity.getSizeInventory(), false)) {
return null;
}
} else if (!this.mergeItemStack(slotStack, this.tileEntity.getSizeInventory(), this.tileEntity.getSizeInventory() + 36, false)) {
return null;
}
if (slotStack.stackSize == 0) {
slotObj.putStack(null);
} else {
slotObj.onSlotChanged();
}
if (slotStack.stackSize == copyStack.stackSize) {
return null;
}
slotObj.onPickupFromSlot(player, slotStack);
}
this.slotContentsChanged();
return copyStack;
}
@Override
public void slotContentsChanged() {
this.tileEntity.markDirty();
this.detectAndSendChanges();
}
}

View File

@ -0,0 +1,6 @@
package assemblyline.common.machine.imprinter;
public interface ISlotWatcher {
public void slotContentsChanged();
}

View File

@ -0,0 +1,92 @@
package assemblyline.common.machine.imprinter;
import assemblyline.common.TabAssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentText;
public class ItemImprinter
extends Item {
public ItemImprinter() {
super();
this.setUnlocalizedName("imprint");
this.setCreativeTab(TabAssemblyLine.INSTANCE);
this.setHasSubtypes(true);
}
@Override
@SideOnly(value=Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {
this.itemIcon = par1IconRegister.registerIcon("assemblyline:imprint");
}
@Override
public int getItemStackLimit() {
return 1;
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
if (entity != null && !(entity instanceof IProjectile) && !(entity instanceof EntityPlayer)) {
String stringName = EntityList.getEntityString((Entity)entity);
player.addChatMessage(new ChatComponentText("Target: " + stringName));
return true;
}
return false;
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
List<ItemStack> filterItems = ItemImprinter.getFilters(itemStack);
if (filterItems.size() > 0) {
for (ItemStack filterItem : filterItems) {
list.add(filterItem.getDisplayName());
}
} else {
list.add("No filters");
}
}
public static void setFilters(ItemStack itemStack, ArrayList filterStacks) {
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
NBTTagList nbt = new NBTTagList();
for (int i = 0; i < filterStacks.size(); ++i) {
if (filterStacks.get(i) == null) continue;
NBTTagCompound newCompound = new NBTTagCompound();
newCompound.setByte("Slot", (byte)i);
((ItemStack)filterStacks.get(i)).writeToNBT(newCompound);
nbt.appendTag((NBTBase)newCompound);
}
itemStack.getTagCompound().setTag("Items", (NBTBase)nbt);
}
public static ArrayList getFilters(ItemStack itemStack) {
ArrayList<ItemStack> filterStacks = new ArrayList<ItemStack>();
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound nbt = itemStack.getTagCompound();
NBTTagList tagList = nbt.getTagList("Items", 10);
for (int i = 0; i < tagList.tagCount(); ++i) {
NBTTagCompound var4 = (NBTTagCompound)tagList.getCompoundTagAt(i);
byte var5 = var4.getByte("Slot");
filterStacks.add(ItemStack.loadItemStackFromNBT((NBTTagCompound)var4));
}
return filterStacks;
}
}

View File

@ -0,0 +1,31 @@
package assemblyline.common.machine.imprinter;
import assemblyline.common.machine.imprinter.ContainerImprinter;
import assemblyline.common.machine.imprinter.WatchedSlot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class SlotCraftingResult
extends WatchedSlot {
private ContainerImprinter container;
public SlotCraftingResult(ContainerImprinter container, IInventory inventory, int par2, int par3, int par4) {
super(inventory, par2, par3, par4, container);
this.container = container;
}
public boolean isItemValid(ItemStack itemStack) {
return false;
}
public boolean canTakeStack(EntityPlayer player) {
return true;
}
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) {
this.container.tileEntity.onPickUpFromResult(entityPlayer, itemStack);
super.onPickupFromSlot(entityPlayer, itemStack);
}
}

View File

@ -0,0 +1,20 @@
package assemblyline.common.machine.imprinter;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotCustom
extends Slot {
private ItemStack itemStack;
public SlotCustom(IInventory par1iInventory, int par2, int par3, int par4, ItemStack itemStack) {
super(par1iInventory, par2, par3, par4);
this.itemStack = itemStack;
}
public boolean isItemValid(ItemStack itemStack) {
return itemStack.isItemEqual(this.itemStack);
}
}

View File

@ -0,0 +1,28 @@
package assemblyline.common.machine.imprinter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotImprintResult
extends Slot {
public SlotImprintResult(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
}
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) {
super.onPickupFromSlot(par1EntityPlayer, par2ItemStack);
if (this.inventory.getStackInSlot(0) != null) {
--this.inventory.getStackInSlot((int)0).stackSize;
if (this.inventory.getStackInSlot((int)0).stackSize <= 0) {
this.inventory.setInventorySlotContents(0, null);
}
}
}
}

View File

@ -0,0 +1,116 @@
package assemblyline.common.machine.imprinter;
import assemblyline.api.IFilterable;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.implement.IRotatable;
public abstract class TileEntityFilterable
extends TileEntityAssemblyNetwork
implements IRotatable,
IFilterable {
private ItemStack filterItem;
private boolean inverted;
public boolean isFiltering(ItemStack itemStack) {
ArrayList checkStacks;
if (this.getFilter() != null && itemStack != null && (checkStacks = ItemImprinter.getFilters(this.getFilter())) != null) {
for (int i = 0; i < checkStacks.size(); ++i) {
if (checkStacks.get(i) == null || !((ItemStack)checkStacks.get(i)).isItemEqual(itemStack)) continue;
return !this.inverted;
}
}
return this.inverted;
}
@Override
public void setFilter(ItemStack filter) {
this.filterItem = filter;
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@Override
public ItemStack getFilter() {
return this.filterItem;
}
public void setInverted(boolean inverted) {
this.inverted = inverted;
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
public boolean isInverted() {
return this.inverted;
}
public void toggleInversion() {
this.setInverted(!this.isInverted());
}
@Override
public ForgeDirection getDirection(IBlockAccess world, int x, int y, int z) {
return ForgeDirection.getOrientation((int)this.getBlockMetadata());
}
@Override
public void setDirection(World world, int x, int y, int z, ForgeDirection facingDirection) {
this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, facingDirection.ordinal(), 3);
}
public void setDirection(ForgeDirection facingDirection) {
this.setDirection(this.worldObj, this.xCoord, this.yCoord, this.zCoord, facingDirection);
}
public ForgeDirection getDirection() {
return this.getDirection((IBlockAccess)this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
this.writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, getBlockMetadata(), tag);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
if (this.worldObj.isRemote) {
this.readFromNBT(pkt.func_148857_g());
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagCompound filter = new NBTTagCompound();
if (this.getFilter() != null) {
this.getFilter().writeToNBT(filter);
}
nbt.setTag("filter", (NBTBase)filter);
nbt.setBoolean("inverted", this.inverted);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.inverted = nbt.getBoolean("inverted");
NBTTagCompound filter = nbt.getCompoundTag("filter");
this.filterItem = ItemStack.loadItemStackFromNBT((NBTTagCompound)filter);
}
}

Some files were not shown because too many files have changed in this diff Show More