implemented robot stations and robot hierarchy

This commit is contained in:
SpaceToad 2014-02-08 10:28:16 +01:00
parent 12cb51373e
commit ec265fd6f3
33 changed files with 1028 additions and 155 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -39,10 +39,9 @@ import buildcraft.core.DefaultProps;
import buildcraft.core.EntityEnergyLaser; import buildcraft.core.EntityEnergyLaser;
import buildcraft.core.EntityFrame; import buildcraft.core.EntityFrame;
import buildcraft.core.EntityPowerLaser; import buildcraft.core.EntityPowerLaser;
import buildcraft.core.EntityRobot;
import buildcraft.core.EntityRobotBuilder;
import buildcraft.core.InterModComms; import buildcraft.core.InterModComms;
import buildcraft.core.ItemBuildCraft; import buildcraft.core.ItemBuildCraft;
import buildcraft.core.ItemRobot;
import buildcraft.core.ItemSpring; import buildcraft.core.ItemSpring;
import buildcraft.core.ItemWrench; import buildcraft.core.ItemWrench;
import buildcraft.core.SpringPopulate; import buildcraft.core.SpringPopulate;
@ -70,6 +69,9 @@ import buildcraft.core.utils.Localization;
import buildcraft.core.recipes.AssemblyRecipeManager; import buildcraft.core.recipes.AssemblyRecipeManager;
import buildcraft.core.recipes.IntegrationRecipeManager; import buildcraft.core.recipes.IntegrationRecipeManager;
import buildcraft.core.recipes.RefineryRecipeManager; import buildcraft.core.recipes.RefineryRecipeManager;
import buildcraft.core.robots.EntityRobot;
import buildcraft.core.robots.EntityRobotBuilder;
import buildcraft.core.robots.EntityRobotPicker;
import buildcraft.core.triggers.TriggerRedstoneInput; import buildcraft.core.triggers.TriggerRedstoneInput;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
@ -114,6 +116,9 @@ public class BuildCraftCore {
public static Item diamondGearItem; public static Item diamondGearItem;
public static Item wrenchItem; public static Item wrenchItem;
public static Item redstoneCrystal; public static Item redstoneCrystal;
public static Item robotBaseItem;
public static Item robotBuilderItem;
public static Item robotPickerItem;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static Icon redLaserTexture; public static Icon redLaserTexture;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -211,6 +216,9 @@ public class BuildCraftCore {
Property goldenGearId = BuildCraftCore.mainConfiguration.getItem("goldenGearItem.id", DefaultProps.GOLDEN_GEAR_ID); Property goldenGearId = BuildCraftCore.mainConfiguration.getItem("goldenGearItem.id", DefaultProps.GOLDEN_GEAR_ID);
Property diamondGearId = BuildCraftCore.mainConfiguration.getItem("diamondGearItem.id", DefaultProps.DIAMOND_GEAR_ID); Property diamondGearId = BuildCraftCore.mainConfiguration.getItem("diamondGearItem.id", DefaultProps.DIAMOND_GEAR_ID);
Property redstoneCrystalId = BuildCraftCore.mainConfiguration.getItem("redstoneCrystalItem.id", DefaultProps.REDSTONE_CRYSTAL_ID); Property redstoneCrystalId = BuildCraftCore.mainConfiguration.getItem("redstoneCrystalItem.id", DefaultProps.REDSTONE_CRYSTAL_ID);
Property robotBaseItemId = BuildCraftCore.mainConfiguration.getItem("robotBaseItem.id", DefaultProps.ROBOT_BASE_ITEM_ID);
Property robotBuilderItemId = BuildCraftCore.mainConfiguration.getItem("robotBuilderItem.id", DefaultProps.ROBOT_BUILDER_ITEM_ID);
Property robotPickerItemId = BuildCraftCore.mainConfiguration.getItem("robotPickerItem.id", DefaultProps.ROBOT_PICKER_ITEM_ID);
Property modifyWorldProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "modifyWorld", true); Property modifyWorldProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "modifyWorld", true);
modifyWorldProp.comment = "set to false if BuildCraft should not generate custom blocks (e.g. oil)"; modifyWorldProp.comment = "set to false if BuildCraft should not generate custom blocks (e.g. oil)";
modifyWorld = modifyWorldProp.getBoolean(true); modifyWorld = modifyWorldProp.getBoolean(true);
@ -255,6 +263,19 @@ public class BuildCraftCore {
CoreProxy.proxy.registerItem(redstoneCrystal); CoreProxy.proxy.registerItem(redstoneCrystal);
OreDictionary.registerOre("redstoneCrystal", new ItemStack(redstoneCrystal)); OreDictionary.registerOre("redstoneCrystal", new ItemStack(redstoneCrystal));
robotBaseItem = (new ItemRobot(robotBaseItemId.getInt(), EntityRobot.class)).setUnlocalizedName("robotBaseItem");
LanguageRegistry.addName(robotBaseItem, "Base Robot");
CoreProxy.proxy.registerItem(robotBaseItem);
robotBuilderItem = (new ItemRobot(robotBuilderItemId.getInt(), EntityRobotBuilder.class)).setUnlocalizedName("robotBuilderItem");
LanguageRegistry.addName(robotBuilderItem, "Builder Robot");
CoreProxy.proxy.registerItem(robotBuilderItem);
robotPickerItem = (new ItemRobot(robotPickerItemId.getInt(), EntityRobotPicker.class)).setUnlocalizedName("robotPickerItem");
LanguageRegistry.addName(robotPickerItem, "Picker Robot");
CoreProxy.proxy.registerItem(robotPickerItem);
Property colorBlindProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "client.colorblindmode", false); Property colorBlindProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "client.colorblindmode", false);
colorBlindProp.comment = "Set to true to enable alternate textures"; colorBlindProp.comment = "Set to true to enable alternate textures";
colorBlindMode = colorBlindProp.getBoolean(false); colorBlindMode = colorBlindProp.getBoolean(false);
@ -282,6 +303,7 @@ public class BuildCraftCore {
loadRecipes(); loadRecipes();
} }
EntityRegistry.registerModEntity(EntityRobot.class, "bcRobot", EntityIds.ROBOT, instance, 50, 1, true); EntityRegistry.registerModEntity(EntityRobot.class, "bcRobot", EntityIds.ROBOT, instance, 50, 1, true);
EntityRegistry.registerModEntity(EntityRobotPicker.class, "bcRobotPicker", EntityIds.ROBOT_PICKER, instance, 50, 1, true);
EntityRegistry.registerModEntity(EntityRobotBuilder.class, "bcRobotBuilder", EntityIds.ROBOT_BUILDER, instance, 50, 1, true); EntityRegistry.registerModEntity(EntityRobotBuilder.class, "bcRobotBuilder", EntityIds.ROBOT_BUILDER, instance, 50, 1, true);
EntityRegistry.registerModEntity(EntityRobotUrbanism.class, "bcRobotUrbanism", EntityIds.ROBOT_URBANISM, instance, 50, 1, true); EntityRegistry.registerModEntity(EntityRobotUrbanism.class, "bcRobotUrbanism", EntityIds.ROBOT_URBANISM, instance, 50, 1, true);
EntityRegistry.registerModEntity(EntityPowerLaser.class, "bcLaser", EntityIds.LASER, instance, 50, 1, true); EntityRegistry.registerModEntity(EntityPowerLaser.class, "bcLaser", EntityIds.LASER, instance, 50, 1, true);

View file

@ -28,6 +28,7 @@ import buildcraft.transport.ItemFacade;
import buildcraft.transport.gates.ItemGate; import buildcraft.transport.gates.ItemGate;
import buildcraft.transport.ItemPipe; import buildcraft.transport.ItemPipe;
import buildcraft.transport.ItemPlug; import buildcraft.transport.ItemPlug;
import buildcraft.transport.ItemRobotStation;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTriggerProvider; import buildcraft.transport.PipeTriggerProvider;
@ -156,6 +157,7 @@ public class BuildCraftTransport {
public static Item pipePowerHeat; public static Item pipePowerHeat;
public static ItemFacade facadeItem; public static ItemFacade facadeItem;
public static Item plugItem; public static Item plugItem;
public static Item robotStationItem;
public static BlockFilteredBuffer filteredBufferBlock; public static BlockFilteredBuffer filteredBufferBlock;
// public static Item pipeItemsStipes; // public static Item pipeItemsStipes;
public static Item pipeStructureCobblestone; public static Item pipeStructureCobblestone;
@ -339,6 +341,11 @@ public class BuildCraftTransport {
plugItem.setUnlocalizedName("pipePlug"); plugItem.setUnlocalizedName("pipePlug");
CoreProxy.proxy.registerItem(plugItem); CoreProxy.proxy.registerItem(plugItem);
Property robotStationId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "robotStation.id", DefaultProps.ROBOT_STATION_ID);
robotStationItem = new ItemRobotStation(robotStationId.getInt());
robotStationItem.setUnlocalizedName("robotStation");
CoreProxy.proxy.registerItem(robotStationItem);
Property filteredBufferId = BuildCraftCore.mainConfiguration.getBlock("filteredBuffer.id", DefaultProps.FILTERED_BUFFER_ID); Property filteredBufferId = BuildCraftCore.mainConfiguration.getBlock("filteredBuffer.id", DefaultProps.FILTERED_BUFFER_ID);
filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt()); filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt());
CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock")); CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock"));

View file

@ -17,7 +17,6 @@ import buildcraft.api.power.PowerHandler.Type;
import buildcraft.builders.blueprints.Blueprint; import buildcraft.builders.blueprints.Blueprint;
import buildcraft.builders.blueprints.BlueprintBuilder; import buildcraft.builders.blueprints.BlueprintBuilder;
import buildcraft.core.Box; import buildcraft.core.Box;
import buildcraft.core.EntityRobotBuilder;
import buildcraft.core.IBuilderInventory; import buildcraft.core.IBuilderInventory;
import buildcraft.core.IMachine; import buildcraft.core.IMachine;
import buildcraft.core.TileBuildCraft; import buildcraft.core.TileBuildCraft;
@ -25,8 +24,11 @@ import buildcraft.core.inventory.InventoryMapper;
import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.inventory.SimpleInventory;
import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.NetworkData; import buildcraft.core.network.NetworkData;
import buildcraft.core.robots.EntityRobotBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.ListIterator; import java.util.ListIterator;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -2,8 +2,8 @@ package buildcraft.builders.urbanism;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import buildcraft.core.EntityRobot;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.robots.EntityRobot;
public class EntityRobotUrbanism extends EntityRobot { public class EntityRobotUrbanism extends EntityRobot {

View file

@ -184,8 +184,8 @@ public class TileUrbanist extends TileBuildCraft implements IBuilderInventory {
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
EntityRobotUrbanism robot = new EntityRobotUrbanism(worldObj); EntityRobotUrbanism robot = new EntityRobotUrbanism(worldObj);
robot.setLocationAndAngles(xCoord, yCoord, zCoord, 0, 0); robot.setLocationAndAngles(xCoord, yCoord, zCoord, 0, 0);
robot.setDestination(xCoord, yCoord, zCoord); //robot.setDestination(xCoord, yCoord, zCoord);
robot.setDestinationAround(xCoord, yCoord, zCoord); //robot.setDestinationAround(xCoord, yCoord, zCoord);
worldObj.spawnEntityInWorld(robot); worldObj.spawnEntityInWorld(robot);

View file

@ -17,7 +17,7 @@ public class UrbanistTaskBuildSchematic extends UrbanistTask {
} }
public void setup(EntityRobotUrbanism robot) { public void setup(EntityRobotUrbanism robot) {
robot.setDestinationAround(builder.getX(), builder.getY(), builder.getZ()); //robot.setDestinationAround(builder.getX(), builder.getY(), builder.getZ());
} }
public void work(EntityRobotUrbanism robot) { public void work(EntityRobotUrbanism robot) {

View file

@ -15,7 +15,7 @@ public class UrbanistTaskErase extends UrbanistTask {
} }
public void setup(EntityRobotUrbanism robot) { public void setup(EntityRobotUrbanism robot) {
robot.setDestinationAround(x, y, z); //robot.setDestinationAround(x, y, z);
} }
public void work(EntityRobotUrbanism robot) { public void work(EntityRobotUrbanism robot) {

View file

@ -50,6 +50,7 @@ public class DefaultProps {
public static int GATE_AUTARCHIC_ID = 19140; public static int GATE_AUTARCHIC_ID = 19140;
public static int PIPE_FACADE_ID = 19141; public static int PIPE_FACADE_ID = 19141;
public static int PIPE_PLUG_ID = 19142; public static int PIPE_PLUG_ID = 19142;
public static int ROBOT_STATION_ID = 19143;
public static int PIPE_ITEMS_WOOD_ID = 19160; public static int PIPE_ITEMS_WOOD_ID = 19160;
public static int PIPE_ITEMS_COBBLESTONE_ID = 19161; public static int PIPE_ITEMS_COBBLESTONE_ID = 19161;
@ -95,6 +96,10 @@ public class DefaultProps {
public static int PIPE_LIQUIDS_SANDSTONE_ID = 19223; public static int PIPE_LIQUIDS_SANDSTONE_ID = 19223;
public static int PIPE_STRUCTURE_COBBLESTONE_ID = 19224; public static int PIPE_STRUCTURE_COBBLESTONE_ID = 19224;
public static int ROBOT_BASE_ITEM_ID = 19300;
public static int ROBOT_BUILDER_ITEM_ID = 19301;
public static int ROBOT_PICKER_ITEM_ID = 19302;
public static int MINING_WELL_ID = 1500; public static int MINING_WELL_ID = 1500;
public static int DRILL_ID = 1501; public static int DRILL_ID = 1501;
public static int AUTO_WORKBENCH_ID = 1502; public static int AUTO_WORKBENCH_ID = 1502;

View file

@ -1,8 +1,9 @@
/** /**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public License * BuildCraft is distributed under the terms of the Minecraft Mod Public
* 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.core; package buildcraft.core;

View file

@ -0,0 +1,34 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
import buildcraft.core.robots.EntityRobot;
import net.minecraft.world.World;
public class ItemRobot extends ItemBuildCraft {
Class <? extends EntityRobot> robotClass;
public ItemRobot(int par1, Class <? extends EntityRobot> robotClass) {
super(par1);
this.robotClass = robotClass;
}
public EntityRobot createRobot (World world) {
try {
return this.robotClass.getConstructor(World.class).newInstance(world);
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
}

View file

@ -6,6 +6,7 @@ public class EntityIds {
public static final int ROBOT_BUILDER = 11; public static final int ROBOT_BUILDER = 11;
public static final int ROBOT_URBANISM = 12; public static final int ROBOT_URBANISM = 12;
public static final int FRAME = 13; public static final int FRAME = 13;
public static final int ROBOT_PICKER = 14;
public static final int ENERGY_LASER = 20; public static final int ENERGY_LASER = 20;
public static final int LASER = 30; public static final int LASER = 30;
public static final int MECHANICAL_ARM = 40; public static final int MECHANICAL_ARM = 40;

View file

@ -15,8 +15,6 @@ import buildcraft.core.EntityBlock;
import buildcraft.core.EntityEnergyLaser; import buildcraft.core.EntityEnergyLaser;
import buildcraft.core.EntityFrame; import buildcraft.core.EntityFrame;
import buildcraft.core.EntityPowerLaser; import buildcraft.core.EntityPowerLaser;
import buildcraft.core.EntityRobot;
import buildcraft.core.EntityRobotBuilder;
import buildcraft.core.render.RenderEnergyLaser; import buildcraft.core.render.RenderEnergyLaser;
import buildcraft.core.render.RenderEntityBlock; import buildcraft.core.render.RenderEntityBlock;
import buildcraft.core.render.RenderFrame; import buildcraft.core.render.RenderFrame;
@ -25,6 +23,8 @@ import buildcraft.core.render.RenderRobot;
import buildcraft.core.render.RenderingEntityBlocks; import buildcraft.core.render.RenderingEntityBlocks;
import buildcraft.core.render.RenderingMarkers; import buildcraft.core.render.RenderingMarkers;
import buildcraft.core.render.RenderingOil; import buildcraft.core.render.RenderingOil;
import buildcraft.core.robots.EntityRobot;
import buildcraft.core.robots.EntityRobotBuilder;
import buildcraft.transport.render.TileEntityPickupFX; import buildcraft.transport.render.TileEntityPickupFX;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
@ -46,6 +46,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatMessageComponent; import net.minecraft.util.ChatMessageComponent;
import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
public class CoreProxyClient extends CoreProxy { public class CoreProxyClient extends CoreProxy {
@ -121,6 +122,10 @@ public class CoreProxyClient extends CoreProxy {
RenderingRegistry.registerBlockHandler(BuildCraftCore.legacyPipeModel, new RenderingEntityBlocks()); RenderingRegistry.registerBlockHandler(BuildCraftCore.legacyPipeModel, new RenderingEntityBlocks());
RenderingRegistry.registerBlockHandler(new RenderingOil()); RenderingRegistry.registerBlockHandler(new RenderingOil());
RenderingRegistry.registerBlockHandler(new RenderingMarkers()); RenderingRegistry.registerBlockHandler(new RenderingMarkers());
MinecraftForgeClient.registerItemRenderer(BuildCraftCore.robotBaseItem.itemID, new RenderRobot());
MinecraftForgeClient.registerItemRenderer(BuildCraftCore.robotBuilderItem.itemID, new RenderRobot());
MinecraftForgeClient.registerItemRenderer(BuildCraftCore.robotPickerItem.itemID, new RenderRobot());
} }
@Override @Override

View file

@ -1,19 +1,35 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.render; package buildcraft.core.render;
import buildcraft.BuildCraftCore;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.EntityLaser; import buildcraft.core.EntityLaser;
import buildcraft.core.EntityRobot; import buildcraft.core.robots.EntityRobot;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class RenderRobot extends Render { public class RenderRobot extends Render implements IItemRenderer {
public static final ResourceLocation TEXTURE_BASE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_base.png");
public static final ResourceLocation TEXTURE_BUILDER = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_builder.png");
public static final ResourceLocation TEXTURE_PICKER = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_picker.png");
public static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot.png");
protected ModelBase model = new ModelBase() { protected ModelBase model = new ModelBase() {
}; };
private ModelRenderer box; private ModelRenderer box;
@ -33,10 +49,10 @@ public class RenderRobot extends Render {
private void doRender(EntityRobot robot, double x, double y, double z, float f, float f1) { private void doRender(EntityRobot robot, double x, double y, double z, float f, float f1) {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glDisable(2896 /* GL_LIGHTING */); GL11.glDisable(GL11.GL_LIGHTING);
GL11.glTranslated(x, y, z); GL11.glTranslated(x, y, z);
renderManager.renderEngine.bindTexture(TEXTURE); renderManager.renderEngine.bindTexture(robot.getTexture());
float factor = (float) (1.0 / 16.0); float factor = (float) (1.0 / 16.0);
@ -50,13 +66,64 @@ public class RenderRobot extends Render {
RenderLaser.doRenderLaser(renderManager.renderEngine, robot.laser, EntityLaser.LASER_TEXTURES [1]); RenderLaser.doRenderLaser(renderManager.renderEngine, robot.laser, EntityLaser.LASER_TEXTURES [1]);
} }
GL11.glEnable(2896 /* GL_LIGHTING */); GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@Override @Override
protected ResourceLocation getEntityTexture(Entity entity) { protected ResourceLocation getEntityTexture(Entity entity) {
return TEXTURE; return TEXTURE_BASE;
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
ItemRendererHelper helper) {
if (helper == ItemRendererHelper.BLOCK_3D) {
return true;
} else if (helper == ItemRendererHelper.INVENTORY_BLOCK){
return true;
} else {
return false;
}
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if (RenderManager.instance == null
|| RenderManager.instance.renderEngine == null) {
return;
}
RenderBlocks renderBlocks = (RenderBlocks) data[0];
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
// FIXME: Texture localisation should be factorized between items and
// entities.
if (item.itemID == BuildCraftCore.robotBaseItem.itemID) {
RenderManager.instance.renderEngine.bindTexture(TEXTURE_BASE);
} else if (item.itemID == BuildCraftCore.robotBuilderItem.itemID) {
RenderManager.instance.renderEngine.bindTexture(TEXTURE_BUILDER);
} else if (item.itemID == BuildCraftCore.robotPickerItem.itemID) {
RenderManager.instance.renderEngine.bindTexture(TEXTURE_PICKER);
}
float factor = (float) (1.0 / 16.0);
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslated(0.25F, 0.5F, 0);
}
box.render(1F / 16F);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
} }
} }

View file

@ -0,0 +1,38 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.robots;
public abstract class AIBase {
protected float destX, destY, destZ;
protected double dirX, dirY, dirZ;
public abstract void update (EntityRobot robot);
public void setDestination(EntityRobot robot, float x, float y, float z) {
destX = x;
destY = y;
destZ = z;
dirX = (destX - robot.posX);
dirY = (destY - robot.posY);
dirZ = (destZ - robot.posZ);
double magnitude = Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
dirX /= magnitude;
dirY /= magnitude;
dirZ /= magnitude;
robot.motionX = dirX / 10F;
robot.motionY = dirY / 10F;
robot.motionZ = dirZ / 10F;
}
}

View file

@ -0,0 +1,20 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.robots;
public class AIDocked extends AIBase {
@Override
public void update(EntityRobot robot) {
robot.motionX = 0;
robot.motionY = 0;
robot.motionZ = 0;
}
}

View file

@ -0,0 +1,66 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.robots;
import net.minecraft.block.Block;
import buildcraft.core.proxy.CoreProxy;
public class AIMoveAround extends AIBase {
protected float aroundX, aroundY, aroundZ;
double prevDistance = Double.MAX_VALUE;
public AIMoveAround (EntityRobot robot, float x, float y, float z) {
aroundX = x;
aroundY = y;
aroundZ = z;
randomDestination(robot);
}
@Override
public void update(EntityRobot robot) {
if (!CoreProxy.proxy.isSimulating(robot.worldObj)) {
return;
}
double distance = robot.getDistance(destX, destY, destZ);
if (distance >= prevDistance) {
randomDestination(robot);
prevDistance = Double.MAX_VALUE;
} else {
prevDistance = robot.getDistance(destX, destY, destZ);
}
}
public void randomDestination(EntityRobot robot) {
for (int i = 0; i < 5; ++i) {
float testX = aroundX + robot.worldObj.rand.nextFloat() * 10F - 5F;
float testY = aroundY + robot.worldObj.rand.nextFloat() * 5F;
float testZ = aroundZ + robot.worldObj.rand.nextFloat() * 10F - 5F;
int blockId = robot.worldObj.getBlockId((int) testX, (int) testY,
(int) testZ);
// We set a destination. If it's wrong, we try a new one.
// Eventually, we'll accept even a wrong one if none can be easily
// found.
setDestination(robot, testX, testY, testZ);
if (Block.blocksList[blockId] == null
|| Block.blocksList[blockId].isAirBlock(robot.worldObj,
(int) testX, (int) testY, (int) testZ)) {
return;
}
}
}
}

View file

@ -0,0 +1,65 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.robots;
import buildcraft.core.proxy.CoreProxy;
public class AIReturnToDock extends AIBase {
double prevDistance = Double.MAX_VALUE;
int phase = 0;
@Override
public void update(EntityRobot robot) {
if (!CoreProxy.proxy.isSimulating(robot.worldObj)) {
return;
}
if (phase == 0) {
float x = robot.dockingStation.x + 0.5F + robot.dockingStation.side.offsetX * 1.5F;
float y = robot.dockingStation.y + 0.5F + robot.dockingStation.side.offsetY * 1.5F;
float z = robot.dockingStation.z + 0.5F + robot.dockingStation.side.offsetZ * 1.5F;
setDestination(robot, x, y, z);
phase = 1;
} else if (phase == 1) {
double distance = robot.getDistance(destX, destY, destZ);
if (distance >= prevDistance) {
prevDistance = Double.MAX_VALUE;
float x = robot.dockingStation.x + 0.5F + robot.dockingStation.side.offsetX * 0.5F;
float y = robot.dockingStation.y + 0.5F + robot.dockingStation.side.offsetY * 0.5F;
float z = robot.dockingStation.z + 0.5F + robot.dockingStation.side.offsetZ * 0.5F;
setDestination(robot, x, y, z);
phase = 2;
} else {
prevDistance = distance;
}
} else if (phase == 2) {
double distance = robot.getDistance(destX, destY, destZ);
if (distance >= prevDistance) {
float x = robot.dockingStation.x + 0.5F + robot.dockingStation.side.offsetX * 0.5F;
float y = robot.dockingStation.y + 0.5F + robot.dockingStation.side.offsetY * 0.5F;
float z = robot.dockingStation.z + 0.5F + robot.dockingStation.side.offsetZ * 0.5F;
robot.motionX = 0;
robot.motionY = 0;
robot.motionZ = 0;
robot.setPosition(x, y, z);
robot.currentAI = new AIDocked();
} else {
prevDistance = distance;
}
}
}
}

View file

@ -1,16 +1,18 @@
/** /**
* Copyright (c) 2011 - 2014 SpaceToad and the BuildCraft Team * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com * http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public License * BuildCraft is distributed under the terms of the Minecraft Mod Public
* 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.core.robots;
package buildcraft.core;
import buildcraft.builders.blueprints.IBlueprintBuilderAgent; import buildcraft.builders.blueprints.IBlueprintBuilderAgent;
import buildcraft.core.DefaultProps;
import buildcraft.core.LaserData;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.TileGenericPipe;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteArrayDataOutput;
@ -20,33 +22,46 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
public class EntityRobot extends EntityLivingBase implements public class EntityRobot extends EntityLivingBase implements
IEntityAdditionalSpawnData, IBlueprintBuilderAgent, IInventory { IEntityAdditionalSpawnData, IBlueprintBuilderAgent, IInventory {
protected int aroundX, aroundY, aroundZ;
protected float destX, destY, destZ;
double dirX, dirY, dirZ;
public LaserData laser = new LaserData (); public LaserData laser = new LaserData ();
private boolean needsUpdate = false; private boolean needsUpdate = false;
float curBlockDamage = 0; float curBlockDamage = 0;
float buildEnergy = 0; float buildEnergy = 0;
ItemStack buildingStack = null; ItemStack buildingStack = null;
private static ResourceLocation defaultTexture = new ResourceLocation(
"buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES
+ "/robot_base.png");
public AIBase currentAI;
public class DockingStation {
public int x, y, z;
public ForgeDirection side;
}
public DockingStation dockingStation = new DockingStation();
public EntityRobot(World par1World) { public EntityRobot(World par1World) {
super(par1World); super(par1World);
dirX = 0;
dirY = 0;
dirZ = 0;
motionX = 0; motionX = 0;
motionY = 0; motionY = 0;
motionZ = 0; motionZ = 0;
ignoreFrustumCheck = true; ignoreFrustumCheck = true;
laser.isVisible = false;
width = 0.5F;
height = 0.5F;
} }
@Override @Override
@ -61,6 +76,10 @@ public class EntityRobot extends EntityLivingBase implements
dataWatcher.addObject(11, Float.valueOf(0)); dataWatcher.addObject(11, Float.valueOf(0));
dataWatcher.addObject(12, Float.valueOf(0)); dataWatcher.addObject(12, Float.valueOf(0));
dataWatcher.addObject(13, Byte.valueOf((byte) 0)); dataWatcher.addObject(13, Byte.valueOf((byte) 0));
dataWatcher.addObject(14, Float.valueOf(0));
dataWatcher.addObject(15, Float.valueOf(0));
dataWatcher.addObject(16, Float.valueOf(0));
dataWatcher.addObject(17, Byte.valueOf((byte) 0));
} }
protected void updateDataClient() { protected void updateDataClient() {
@ -105,55 +124,6 @@ public class EntityRobot extends EntityLivingBase implements
} }
} }
public void setDestination(float x, float y, float z) {
destX = x;
destY = y;
destZ = z;
dirX = (destX - posX);
dirY = (destY - posY);
dirZ = (destZ - posZ);
double magnitude = Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
dirX /= magnitude;
dirY /= magnitude;
dirZ /= magnitude;
}
public void setDestinationAround(int x, int y, int z) {
aroundX = x;
aroundY = y;
aroundZ = z;
randomDestination();
}
public void randomDestination() {
for (int i = 0; i < 5; ++i) {
float testX = aroundX + rand.nextFloat() * 10F - 5F;
float testY = aroundY + rand.nextFloat() * 5F;
float testZ = aroundZ + rand.nextFloat() * 10F - 5F;
int blockId = worldObj.getBlockId((int) testX, (int) testY,
(int) testZ);
// We set a destination. If it's wrong, we try a new one.
// Eventually, we'll accept even a wrong one if none can be easily
// found.
setDestination(testX, testY, testZ);
if (Block.blocksList[blockId] == null
|| Block.blocksList[blockId].isAirBlock(worldObj,
(int) testX, (int) testY, (int) testZ)) {
return;
}
}
}
double prevDistance = Double.MAX_VALUE;
@Override @Override
public void onUpdate() { public void onUpdate() {
if (CoreProxy.proxy.isSimulating(worldObj) && needsUpdate) { if (CoreProxy.proxy.isSimulating(worldObj) && needsUpdate) {
@ -165,20 +135,17 @@ public class EntityRobot extends EntityLivingBase implements
updateDataClient(); updateDataClient();
} }
if (CoreProxy.proxy.isSimulating(worldObj)) { if (currentAI != null) {
double distance = getDistance(destX, destY, destZ); currentAI.update(this);
if (distance >= prevDistance) {
randomDestination();
} }
prevDistance = getDistance(destX, destY, destZ); super.onUpdate();
motionX = dirX / 10F;
motionY = dirY / 10F;
motionZ = dirZ / 10F;
} }
public void setRegularBoundingBox () {
width = 0.5F;
height = 0.5F;
if (laser.isVisible) { if (laser.isVisible) {
boundingBox.minX = Math.min(posX, laser.tail.x); boundingBox.minX = Math.min(posX, laser.tail.x);
boundingBox.minY = Math.min(posY, laser.tail.y); boundingBox.minY = Math.min(posY, laser.tail.y);
@ -196,27 +163,41 @@ public class EntityRobot extends EntityLivingBase implements
boundingBox.maxY++; boundingBox.maxY++;
boundingBox.maxZ++; boundingBox.maxZ++;
} else { } else {
boundingBox.minX = posX - 1; boundingBox.minX = posX - 0.25F;
boundingBox.minY = posY - 1; boundingBox.minY = posY - 0.25F;
boundingBox.minZ = posZ - 1; boundingBox.minZ = posZ - 0.25F;
boundingBox.maxX = posX + 1; boundingBox.maxX = posX + 0.25F;
boundingBox.maxY = posY + 1; boundingBox.maxY = posY + 0.25F;
boundingBox.maxZ = posZ + 1; boundingBox.maxZ = posZ + 0.25F;
}
} }
super.onUpdate(); public void setNullBoundingBox () {
width = 0F;
height = 0F;
boundingBox.minX = posX;
boundingBox.minY = posY;
boundingBox.minZ = posZ;
boundingBox.maxX = posX;
boundingBox.maxY = posY;
boundingBox.maxZ = posZ;
}
private void iterateBehaviorDocked () {
motionX = 0F;
motionY = 0F;
motionZ = 0F;
setNullBoundingBox ();
} }
protected void move() { protected void move() {
} }
protected boolean reachedDesination() {
return getDistance(destX, destY, destZ) <= 0.2F;
}
@Override @Override
public void writeSpawnData(ByteArrayDataOutput data) { public void writeSpawnData(ByteArrayDataOutput data) {
@ -411,4 +392,21 @@ public class EntityRobot extends EntityLivingBase implements
return false; return false;
} }
public ResourceLocation getTexture () {
return defaultTexture;
}
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
super.readEntityFromNBT(par1NBTTagCompound);
setDead();
}
public void setDockingStation (TileGenericPipe tile, ForgeDirection side) {
dockingStation.x = tile.xCoord;
dockingStation.y = tile.yCoord;
dockingStation.z = tile.zCoord;
dockingStation.side = side;
}
} }

View file

@ -5,18 +5,24 @@
* 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.core; package buildcraft.core.robots;
import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder;
import buildcraft.core.BlockIndex;
import buildcraft.core.Box;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.BlockUtil;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteArrayDataOutput;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -40,7 +46,7 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional
protected void init() { protected void init() {
if (box != null) { if (box != null) {
setDestination((int) box.centerX(), (int) box.centerY(), (int) box.centerZ()); //setDestination((int) box.centerX(), (int) box.centerY(), (int) box.centerZ());
} }
super.init(); super.init();
@ -94,22 +100,13 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional
protected void move() { protected void move() {
super.move(); super.move();
if (reachedDesination()) { /*if (reachedDesination()) {
BlockIndex newDesination = getNewDestination(); BlockIndex newDesination = getNewDestination();
if (newDesination != null) { if (newDesination != null) {
setDestination(newDesination.x, newDesination.y, newDesination.z); setDestination(newDesination.x, newDesination.y, newDesination.z);
} }
} }*/
}
@Override
public void setDestination(float x, float y, float z) {
super.setDestination(x, y, z);
/*motionX = (destX - posX) / 75 * (laser.getPowerAverage() / 2 + 1);
motionY = (destY - posY) / 75 * (laser.getPowerAverage() / 2 + 1);
motionZ = (destZ - posZ) / 75 * (laser.getPowerAverage() / 2 + 1);*/
} }
@Override @Override
@ -130,7 +127,7 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional
movementBoundary.expand(1); movementBoundary.expand(1);
Box moveArea = new Box(); Box moveArea = new Box();
moveArea.initialize((int) destX, (int) destY, (int) destZ, 1); //moveArea.initialize((int) destX, (int) destY, (int) destZ, 1);
List<BlockIndex> potentialDestinations = new ArrayList<BlockIndex>(); List<BlockIndex> potentialDestinations = new ArrayList<BlockIndex>();
for (BlockIndex blockIndex : moveArea.getBlocksInArea()) { for (BlockIndex blockIndex : moveArea.getBlocksInArea()) {
@ -233,7 +230,7 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional
public void setBox(Box box) { public void setBox(Box box) {
this.box = box; this.box = box;
setDestination((int) box.centerX(), (int) box.centerY(), (int) box.centerZ()); //setDestination((int) box.centerX(), (int) box.centerY(), (int) box.centerZ());
} }
@Override @Override

View file

@ -0,0 +1,102 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.robots;
import java.util.HashSet;
import java.util.Set;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.core.DefaultProps;
import buildcraft.core.proxy.CoreProxy;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class EntityRobotPicker extends EntityRobot {
private static ResourceLocation texture = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_picker.png");
SafeTimeTracker scanTracker = new SafeTimeTracker(40, 10);
SafeTimeTracker pickTracker = new SafeTimeTracker(20, 0);
int pickTime = -1;
public EntityRobotPicker(World par1World) {
super(par1World);
}
@Override
public ResourceLocation getTexture () {
return texture;
}
private static Set <Integer> targettedItems = new HashSet<Integer>();
private EntityItem target;
@Override
public void onUpdate () {
super.onUpdate();
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
return;
}
if (target != null) {
if (target.isDead) {
targettedItems.remove(target.entityId);
target = null;
currentAI = new AIReturnToDock();
hideLaser();
scan ();
} else if (pickTime == -1){
if (getDistance(target.posX, target.posY, target.posZ) < 10) {
setLaserDestination((float) target.posX, (float) target.posY, (float) target.posZ);
showLaser();
pickTracker = new SafeTimeTracker (200);
pickTime = 0;
}
} else {
pickTime++;
if (pickTime > 20) {
target.setDead();
}
}
} else {
if (scanTracker.markTimeIfDelay(worldObj)) {
scan ();
}
}
}
public void scan () {
for (Object o : worldObj.loadedEntityList) {
Entity e = (Entity) o;
if (!e.isDead && e instanceof EntityItem && !targettedItems.contains(e.entityId)) {
double dx = e.posX - posX;
double dy = e.posY - posY;
double dz = e.posZ - posZ;
double sqrDistance = dx * dx + dy * dy + dz * dz;
double maxDistance = 100 * 100;
if (sqrDistance <= maxDistance) {
EntityItem item = (EntityItem) e;
target = item;
targettedItems.add(e.entityId);
currentAI = new AIMoveAround(this, (float) e.posX, (float) e.posY, (float) e.posZ);
pickTime = -1;
break;
}
}
}
}
}

View file

@ -22,23 +22,27 @@ import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.core.Box; import buildcraft.core.Box;
import buildcraft.core.CoreConstants; import buildcraft.core.CoreConstants;
import buildcraft.core.DefaultAreaProvider; import buildcraft.core.DefaultAreaProvider;
import buildcraft.core.EntityRobotBuilder;
import buildcraft.core.IBuilderInventory; import buildcraft.core.IBuilderInventory;
import buildcraft.core.IMachine; import buildcraft.core.IMachine;
import buildcraft.core.TileBuildCraft; import buildcraft.core.TileBuildCraft;
import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.NetworkData; import buildcraft.core.network.NetworkData;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.robots.EntityRobotBuilder;
import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.BlockUtil;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.network.Player;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Set; import java.util.Set;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,14 +1,16 @@
/** /**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public License * BuildCraft is distributed under the terms of the Minecraft Mod Public
* 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.transport; package buildcraft.transport;
import buildcraft.api.transport.PipeWire; import buildcraft.api.transport.PipeWire;
import buildcraft.transport.gates.ItemGate; import buildcraft.transport.gates.ItemGate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -42,7 +44,10 @@ import buildcraft.api.tools.IToolWrench;
import buildcraft.core.BlockBuildCraft; import buildcraft.core.BlockBuildCraft;
import buildcraft.core.BlockIndex; import buildcraft.core.BlockIndex;
import buildcraft.core.CoreConstants; import buildcraft.core.CoreConstants;
import buildcraft.core.ItemRobot;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.robots.AIDocked;
import buildcraft.core.robots.EntityRobot;
import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import buildcraft.core.utils.MatrixTranformations; import buildcraft.core.utils.MatrixTranformations;
@ -51,17 +56,19 @@ import buildcraft.transport.gates.GateFactory;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.Arrays; import java.util.Arrays;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
public class BlockGenericPipe extends BlockBuildCraft { public class BlockGenericPipe extends BlockBuildCraft {
static enum Part { static enum Part {
Pipe, Pipe,
Gate, Gate,
Facade, Facade,
Plug Plug,
RobotStation
} }
static class RaytraceResult { static class RaytraceResult {
@ -237,7 +244,8 @@ public class BlockGenericPipe extends BlockBuildCraft {
AxisAlignedBB box = rayTraceResult.boundingBox; AxisAlignedBB box = rayTraceResult.boundingBox;
switch (rayTraceResult.hitPart) { switch (rayTraceResult.hitPart) {
case Gate: case Gate:
case Plug: { case Plug:
case RobotStation: {
float scale = 0.001F; float scale = 0.001F;
box = box.expand(scale, scale, scale); box = box.expand(scale, scale, scale);
break; break;
@ -298,9 +306,9 @@ public class BlockGenericPipe extends BlockBuildCraft {
* pipe hits along x, y, and z axis, gate (all 6 sides) [and * pipe hits along x, y, and z axis, gate (all 6 sides) [and
* wires+facades] * wires+facades]
*/ */
MovingObjectPosition[] hits = new MovingObjectPosition[25]; MovingObjectPosition[] hits = new MovingObjectPosition[31];
AxisAlignedBB[] boxes = new AxisAlignedBB[25]; AxisAlignedBB[] boxes = new AxisAlignedBB[31];
ForgeDirection[] sideHit = new ForgeDirection[25]; ForgeDirection[] sideHit = new ForgeDirection[31];
Arrays.fill(sideHit, ForgeDirection.UNKNOWN); Arrays.fill(sideHit, ForgeDirection.UNKNOWN);
// pipe // pipe
@ -351,6 +359,18 @@ public class BlockGenericPipe extends BlockBuildCraft {
} }
} }
// robotStations
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
if (tileG.hasRobotStation(side)) {
AxisAlignedBB bb = getRobotStationBoundingBox(side);
setBlockBounds(bb);
boxes[25 + side.ordinal()] = bb;
hits[25 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction);
sideHit[25 + side.ordinal()] = side;
}
}
// TODO: check wires // TODO: check wires
// get closest hit // get closest hit
@ -386,8 +406,10 @@ public class BlockGenericPipe extends BlockBuildCraft {
hitPart = Part.Gate; hitPart = Part.Gate;
} else if (minIndex < 19) { } else if (minIndex < 19) {
hitPart = Part.Facade; hitPart = Part.Facade;
} else { } else if (minIndex < 25) {
hitPart = Part.Plug; hitPart = Part.Plug;
} else {
hitPart = Part.RobotStation;
} }
return new RaytraceResult(hitPart, hits[minIndex], boxes[minIndex], sideHit[minIndex]); return new RaytraceResult(hitPart, hits[minIndex], boxes[minIndex], sideHit[minIndex]);
@ -449,6 +471,22 @@ public class BlockGenericPipe extends BlockBuildCraft {
return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]); return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
} }
private AxisAlignedBB getRobotStationBoundingBox(ForgeDirection side) {
float[][] bounds = new float[3][2];
// X START - END
bounds[0][0] = 0.25F;
bounds[0][1] = 0.75F;
// Y START - END
bounds[1][0] = 0.125F;
bounds[1][1] = 0.251F;
// Z START - END
bounds[2][0] = 0.25F;
bounds[2][1] = 0.75F;
MatrixTranformations.transform(bounds, side);
return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
}
private AxisAlignedBB getPipeBoundingBox(ForgeDirection side) { private AxisAlignedBB getPipeBoundingBox(ForgeDirection side) {
float min = CoreConstants.PIPE_MIN_POS; float min = CoreConstants.PIPE_MIN_POS;
float max = CoreConstants.PIPE_MAX_POS; float max = CoreConstants.PIPE_MAX_POS;
@ -594,6 +632,8 @@ public class BlockGenericPipe extends BlockBuildCraft {
return pipe.gate.getGateItem(); return pipe.gate.getGateItem();
case Plug: case Plug:
return new ItemStack(BuildCraftTransport.plugItem); return new ItemStack(BuildCraftTransport.plugItem);
case RobotStation:
return new ItemStack(BuildCraftTransport.robotStationItem);
} }
} }
return super.getPickBlock(target, world, x, y, z); return super.getPickBlock(target, world, x, y, z);
@ -685,10 +725,41 @@ public class BlockGenericPipe extends BlockBuildCraft {
if (addOrStripPlug(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) { if (addOrStripPlug(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) {
return true; return true;
} }
} else if (currentItem.getItem() instanceof ItemFacade) } else if (currentItem.getItem() instanceof ItemRobotStation) {
if (addOrStripRobotStation(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) {
return true;
}
} else if (currentItem.getItem() instanceof ItemFacade) {
if (addOrStripFacade(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) { if (addOrStripFacade(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) {
return true; return true;
} }
} else if (currentItem.getItem () instanceof ItemRobot) {
if (CoreProxy.proxy.isSimulating(world)) {
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z,
player);
if (rayTraceResult.hitPart == Part.RobotStation) {
EntityRobot robot = ((ItemRobot) currentItem.getItem())
.createRobot(world);
float px = x + 0.5F + (float) rayTraceResult.sideHit.offsetX * 0.5F;
float py = y + 0.5F + (float) rayTraceResult.sideHit.offsetY * 0.5F;
float pz = z + 0.5F + (float) rayTraceResult.sideHit.offsetZ * 0.5F;
robot.setPosition(px, py, pz);
robot.setDockingStation(pipe.container,
rayTraceResult.sideHit);
robot.currentAI = new AIDocked();
world.spawnEntityInWorld(robot);
if (!player.capabilities.isCreativeMode) {
player.getCurrentEquippedItem().stackSize--;
}
return true;
}
}
}
boolean clickedOnGate = false; boolean clickedOnGate = false;
@ -823,6 +894,21 @@ public class BlockGenericPipe extends BlockBuildCraft {
return false; return false;
} }
private boolean addOrStripRobotStation(World world, int x, int y, int z, EntityPlayer player, ForgeDirection side, Pipe pipe) {
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
if (player.isSneaking()) {
if (rayTraceResult != null && rayTraceResult.hitPart == Part.RobotStation) {
if (stripRobotStation(pipe, rayTraceResult.sideHit))
return true;
}
}
if (rayTraceResult != null && (rayTraceResult.hitPart == Part.Pipe || rayTraceResult.hitPart == Part.Gate)) {
if (addRobotStation(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side))
return true;
}
return false;
}
private boolean addPlug(EntityPlayer player, Pipe pipe, ForgeDirection side) { private boolean addPlug(EntityPlayer player, Pipe pipe, ForgeDirection side) {
ItemStack stack = player.getCurrentEquippedItem(); ItemStack stack = player.getCurrentEquippedItem();
if (pipe.container.addPlug(side)) { if (pipe.container.addPlug(side)) {
@ -834,10 +920,25 @@ public class BlockGenericPipe extends BlockBuildCraft {
return false; return false;
} }
private boolean addRobotStation(EntityPlayer player, Pipe pipe, ForgeDirection side) {
ItemStack stack = player.getCurrentEquippedItem();
if (pipe.container.addRobotStation(side)) {
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
return true;
}
return false;
}
private boolean stripPlug(Pipe pipe, ForgeDirection side) { private boolean stripPlug(Pipe pipe, ForgeDirection side) {
return pipe.container.removeAndDropPlug(side); return pipe.container.removeAndDropPlug(side);
} }
private boolean stripRobotStation(Pipe pipe, ForgeDirection side) {
return pipe.container.removeAndDropPlug(side);
}
private boolean stripEquipment(World world, int x, int y, int z, EntityPlayer player, Pipe pipe) { private boolean stripEquipment(World world, int x, int y, int z, EntityPlayer player, Pipe pipe) {
// Try to strip facades first // Try to strip facades first
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);

View file

@ -0,0 +1,46 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.transport;
import buildcraft.core.ItemBuildCraft;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemRobotStation extends ItemBuildCraft {
public ItemRobotStation(int i) {
super(i);
}
@Override
public String getUnlocalizedName(ItemStack itemstack) {
return "item.PipeRobotStation";
}
@Override
public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z ) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
// NOOP
}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber() {
return 0;
}
}

View file

@ -385,12 +385,21 @@ public abstract class Pipe<T extends PipeTransport> implements IDropControlInven
} }
public boolean hasGate(ForgeDirection side) { public boolean hasGate(ForgeDirection side) {
if (!hasGate()) if (!hasGate()) {
return false; return false;
if (container.hasFacade(side)) }
if (container.hasFacade(side)) {
return false; return false;
if (container.hasPlug(side)) }
if (container.hasPlug(side)) {
return false; return false;
}
if (container.hasRobotStation(side)) {
return false;
}
int connections = 0; int connections = 0;
ForgeDirection targetOrientation = ForgeDirection.UNKNOWN; ForgeDirection targetOrientation = ForgeDirection.UNKNOWN;
@ -440,9 +449,14 @@ public abstract class Pipe<T extends PipeTransport> implements IDropControlInven
if (container.hasFacade(direction)) { if (container.hasFacade(direction)) {
container.dropFacade(direction); container.dropFacade(direction);
} }
if (container.hasPlug(direction)) { if (container.hasPlug(direction)) {
container.removeAndDropPlug(direction); container.removeAndDropPlug(direction);
} }
if (container.hasRobotStation(direction)) {
container.removeAndDropRobotStation(direction);
}
} }
} }

View file

@ -113,6 +113,8 @@ public class PipeIconProvider implements IIconProvider {
PipePowerHeat7("pipePowerHeat7"), PipePowerHeat7("pipePowerHeat7"),
PipePowerHeat8("pipePowerHeat8"), PipePowerHeat8("pipePowerHeat8"),
// //
PipeRobotStation("pipeRobotStation"),
//
Power_Normal("texture_cyan"), Power_Normal("texture_cyan"),
Power_Overload("texture_red_lit"), Power_Overload("texture_red_lit"),
Stripes("pipeStripes"), Stripes("pipeStripes"),

View file

@ -21,6 +21,7 @@ public class PipeRenderState implements IClientState {
public final TextureMatrix textureMatrix = new TextureMatrix(); public final TextureMatrix textureMatrix = new TextureMatrix();
public final WireMatrix wireMatrix = new WireMatrix(); public final WireMatrix wireMatrix = new WireMatrix();
public final ConnectionMatrix plugMatrix = new ConnectionMatrix(); public final ConnectionMatrix plugMatrix = new ConnectionMatrix();
public final ConnectionMatrix robotStationMatrix = new ConnectionMatrix();
public final FacadeMatrix facadeMatrix = new FacadeMatrix(); public final FacadeMatrix facadeMatrix = new FacadeMatrix();
private boolean dirty = true; private boolean dirty = true;
@ -61,14 +62,20 @@ public class PipeRenderState implements IClientState {
facadeMatrix.clean(); facadeMatrix.clean();
wireMatrix.clean(); wireMatrix.clean();
plugMatrix.clean(); plugMatrix.clean();
robotStationMatrix.clean();
} }
public boolean isDirty() { public boolean isDirty() {
return dirty || pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || wireMatrix.isDirty() || facadeMatrix.isDirty() || plugMatrix.isDirty(); return dirty || pipeConnectionMatrix.isDirty()
|| textureMatrix.isDirty() || wireMatrix.isDirty()
|| facadeMatrix.isDirty() || plugMatrix.isDirty()
|| robotStationMatrix.isDirty();
} }
public boolean needsRenderUpdate() { public boolean needsRenderUpdate() {
return pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || facadeMatrix.isDirty() || plugMatrix.isDirty(); return pipeConnectionMatrix.isDirty() || textureMatrix.isDirty()
|| facadeMatrix.isDirty() || plugMatrix.isDirty()
|| robotStationMatrix.isDirty();
} }
@Override @Override
@ -81,6 +88,7 @@ public class PipeRenderState implements IClientState {
wireMatrix.writeData(data); wireMatrix.writeData(data);
facadeMatrix.writeData(data); facadeMatrix.writeData(data);
plugMatrix.writeData(data); plugMatrix.writeData(data);
robotStationMatrix.writeData(data);
} }
@Override @Override
@ -93,5 +101,6 @@ public class PipeRenderState implements IClientState {
wireMatrix.readData(data); wireMatrix.readData(data);
facadeMatrix.readData(data); facadeMatrix.readData(data);
plugMatrix.readData(data); plugMatrix.readData(data);
robotStationMatrix.readData(data);
} }
} }

View file

@ -1,8 +1,9 @@
/** /**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public License * BuildCraft is distributed under the terms of the Minecraft Mod Public
* 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.transport; package buildcraft.transport;
@ -111,6 +112,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
private int[] facadeBlocks = new int[ForgeDirection.VALID_DIRECTIONS.length]; private int[] facadeBlocks = new int[ForgeDirection.VALID_DIRECTIONS.length];
private int[] facadeMeta = new int[ForgeDirection.VALID_DIRECTIONS.length]; private int[] facadeMeta = new int[ForgeDirection.VALID_DIRECTIONS.length];
private boolean[] plugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length]; private boolean[] plugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
private boolean[] robotStations = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
public TileGenericPipe() { public TileGenericPipe() {
} }
@ -130,6 +132,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
nbt.setInteger("facadeBlocks[" + i + "]", facadeBlocks[i]); nbt.setInteger("facadeBlocks[" + i + "]", facadeBlocks[i]);
nbt.setInteger("facadeMeta[" + i + "]", facadeMeta[i]); nbt.setInteger("facadeMeta[" + i + "]", facadeMeta[i]);
nbt.setBoolean("plug[" + i + "]", plugs[i]); nbt.setBoolean("plug[" + i + "]", plugs[i]);
nbt.setBoolean("robotStation[" + i + "]", robotStations[i]);
} }
} }
@ -154,6 +157,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
facadeBlocks[i] = nbt.getInteger("facadeBlocks[" + i + "]"); facadeBlocks[i] = nbt.getInteger("facadeBlocks[" + i + "]");
facadeMeta[i] = nbt.getInteger("facadeMeta[" + i + "]"); facadeMeta[i] = nbt.getInteger("facadeMeta[" + i + "]");
plugs[i] = nbt.getBoolean("plug[" + i + "]"); plugs[i] = nbt.getBoolean("plug[" + i + "]");
robotStations[i] = nbt.getBoolean("robotStation[" + i + "]");
} }
} }
@ -285,6 +289,11 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
renderState.plugMatrix.setConnected(direction, plugs[direction.ordinal()]); renderState.plugMatrix.setConnected(direction, plugs[direction.ordinal()]);
} }
//RobotStations
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
renderState.robotStationMatrix.setConnected(direction, robotStations[direction.ordinal()]);
}
if (renderState.isDirty()) { if (renderState.isDirty()) {
renderState.clean(); renderState.clean();
sendUpdateToClient(); sendUpdateToClient();
@ -470,7 +479,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
if (with == null) if (with == null)
return false; return false;
if (hasPlug(side)) if (hasPlug(side) || hasRobotStation(side))
return false; return false;
if (!BlockGenericPipe.isValid(pipe)) if (!BlockGenericPipe.isValid(pipe))
@ -544,7 +553,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
*/ */
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from)) if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from) && !hasRobotStation(from))
return ((IFluidHandler) pipe.transport).fill(from, resource, doFill); return ((IFluidHandler) pipe.transport).fill(from, resource, doFill);
else else
return 0; return 0;
@ -552,7 +561,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
@Override @Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from)) if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from) && !hasRobotStation(from))
return ((IFluidHandler) pipe.transport).drain(from, maxDrain, doDrain); return ((IFluidHandler) pipe.transport).drain(from, maxDrain, doDrain);
else else
return null; return null;
@ -560,7 +569,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
@Override @Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from)) if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from) && !hasRobotStation(from))
return ((IFluidHandler) pipe.transport).drain(from, resource, doDrain); return ((IFluidHandler) pipe.transport).drain(from, resource, doDrain);
else else
return null; return null;
@ -568,7 +577,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
@Override @Override
public boolean canFill(ForgeDirection from, Fluid fluid) { public boolean canFill(ForgeDirection from, Fluid fluid) {
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from)) if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from) && !hasRobotStation(from))
return ((IFluidHandler) pipe.transport).canFill(from, fluid); return ((IFluidHandler) pipe.transport).canFill(from, fluid);
else else
return false; return false;
@ -576,7 +585,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
@Override @Override
public boolean canDrain(ForgeDirection from, Fluid fluid) { public boolean canDrain(ForgeDirection from, Fluid fluid) {
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from)) if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof IFluidHandler && !hasPlug(from) &&!hasRobotStation(from))
return ((IFluidHandler) pipe.transport).canDrain(from, fluid); return ((IFluidHandler) pipe.transport).canDrain(from, fluid);
else else
return false; return false;
@ -722,16 +731,34 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
} }
public boolean hasPlug(ForgeDirection side) { public boolean hasPlug(ForgeDirection side) {
if (side == null || side == ForgeDirection.UNKNOWN) if (side == null || side == ForgeDirection.UNKNOWN) {
return false; return false;
if (this.worldObj.isRemote) }
if (this.worldObj.isRemote) {
return renderState.plugMatrix.isConnected(side); return renderState.plugMatrix.isConnected(side);
}
return plugs[side.ordinal()]; return plugs[side.ordinal()];
} }
public boolean removeAndDropPlug(ForgeDirection side) { public boolean hasRobotStation(ForgeDirection side) {
if (!hasPlug(side)) if (side == null || side == ForgeDirection.UNKNOWN) {
return false; return false;
}
if (this.worldObj.isRemote) {
return renderState.robotStationMatrix.isConnected(side);
}
return robotStations[side.ordinal()];
}
public boolean removeAndDropPlug(ForgeDirection side) {
if (!hasPlug(side)) {
return false;
}
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
plugs[side.ordinal()] = false; plugs[side.ordinal()] = false;
InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord); InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord);
@ -739,12 +766,30 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
scheduleNeighborChange(); //To force recalculation of connections scheduleNeighborChange(); //To force recalculation of connections
scheduleRenderUpdate(); scheduleRenderUpdate();
} }
return true;
}
public boolean removeAndDropRobotStation(ForgeDirection side) {
if (!hasRobotStation(side)) {
return false;
}
if (!worldObj.isRemote) {
robotStations[side.ordinal()] = false;
InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.robotStationItem), this.xCoord, this.yCoord, this.zCoord);
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
scheduleNeighborChange(); //To force recalculation of connections
scheduleRenderUpdate();
}
return true; return true;
} }
public boolean addPlug(ForgeDirection forgeDirection) { public boolean addPlug(ForgeDirection forgeDirection) {
if (hasPlug(forgeDirection)) if (hasPlug(forgeDirection)) {
return false; return false;
}
plugs[forgeDirection.ordinal()] = true; plugs[forgeDirection.ordinal()] = true;
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
@ -753,6 +798,19 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
return true; return true;
} }
public boolean addRobotStation(ForgeDirection forgeDirection) {
if (hasRobotStation(forgeDirection)) {
return false;
}
robotStations[forgeDirection.ordinal()] = true;
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
scheduleNeighborChange(); //To force recalculation of connections
scheduleRenderUpdate();
return true;
}
public int getBlockId() { public int getBlockId() {
Block block = getBlockType(); Block block = getBlockType();
if (block != null) if (block != null)

View file

@ -7,6 +7,7 @@ import buildcraft.transport.render.PipeItemRenderer;
import buildcraft.transport.render.PipeRendererWorld; import buildcraft.transport.render.PipeRendererWorld;
import buildcraft.transport.render.PlugItemRenderer; import buildcraft.transport.render.PlugItemRenderer;
import buildcraft.transport.render.PipeRendererTESR; import buildcraft.transport.render.PipeRendererTESR;
import buildcraft.transport.render.RobotStationItemRenderer;
import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
@ -17,6 +18,7 @@ public class TransportProxyClient extends TransportProxy {
public final static PipeRendererWorld pipeWorldRenderer = new PipeRendererWorld(); public final static PipeRendererWorld pipeWorldRenderer = new PipeRendererWorld();
public final static FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer(); public final static FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer();
public final static PlugItemRenderer plugItemRenderer = new PlugItemRenderer(); public final static PlugItemRenderer plugItemRenderer = new PlugItemRenderer();
public final static RobotStationItemRenderer robotStationItemRenderer = new RobotStationItemRenderer();
public final static GateItemRenderer gateItemRenderer = new GateItemRenderer(); public final static GateItemRenderer gateItemRenderer = new GateItemRenderer();
@Override @Override
@ -68,6 +70,7 @@ public class TransportProxyClient extends TransportProxy {
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.facadeItem.itemID, facadeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.facadeItem.itemID, facadeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.plugItem.itemID, plugItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.plugItem.itemID, plugItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.robotStationItem.itemID, robotStationItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeGate.itemID, gateItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeGate.itemID, gateItemRenderer);
TransportProxy.pipeModel = RenderingRegistry.getNextAvailableRenderId(); TransportProxy.pipeModel = RenderingRegistry.getNextAvailableRenderId();

View file

@ -1,8 +1,9 @@
/** /**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public License * BuildCraft is distributed under the terms of the Minecraft Mod Public
* 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.transport.render; package buildcraft.transport.render;
@ -562,7 +563,11 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
} }
private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) { private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) {
return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction) && !isOpenOrientation(state, direction); return !state.pipeConnectionMatrix.isConnected(direction)
&& state.facadeMatrix.getFacadeBlockId(direction) == 0
&& !state.plugMatrix.isConnected(direction)
&& !state.robotStationMatrix.isConnected(direction)
&& !isOpenOrientation(state, direction);
} }
public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) { public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) {

View file

@ -66,6 +66,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
pipeFacadeRenderer(renderblocks, block, state, x, y, z); pipeFacadeRenderer(renderblocks, block, state, x, y, z);
pipePlugRenderer(renderblocks, block, state, x, y, z); pipePlugRenderer(renderblocks, block, state, x, y, z);
pipeRobotStationRenderer(renderblocks, block, state, x, y, z);
} }
private void resetToCenterDimensions(float[] dim) { private void resetToCenterDimensions(float[] dim) {
@ -147,6 +148,104 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
} }
private void pipeRobotStationPartRender(RenderBlocks renderblocks,
Block block, PipeRenderState state, int x, int y, int z,
float xStart, float xEnd, float yStart, float yEnd, float zStart,
float zEnd) {
float zFightOffset = 1F / 4096F;
float[][] zeroState = new float[3][2];
// X START - END
zeroState[0][0] = xStart + zFightOffset;
zeroState[0][1] = xEnd - zFightOffset;
// Y START - END
zeroState[1][0] = yStart;
zeroState[1][1] = yEnd;
// Z START - END
zeroState[2][0] = zStart + zFightOffset;
zeroState[2][1] = zEnd - zFightOffset;
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStation.ordinal()); // Structure
// Pipe
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (state.robotStationMatrix.isConnected(direction)) {
float[][] rotated = MatrixTranformations.deepClone(zeroState);
MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0],
rotated[2][0], rotated[0][1], rotated[1][1],
rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
}
}
}
private void pipeRobotStationRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
float width = 0.075F;
pipeRobotStationPartRender (renderblocks, block, state, x, y, z,
0.45F, 0.55F,
0.0F, 0.224F,
0.45F, 0.55F);
/*pipeRobotStationPartRender (renderblocks, block, state, x, y, z,
0.25F, 0.75F,
0.025F, 0.224F,
0.25F, 0.25F + width);
pipeRobotStationPartRender (renderblocks, block, state, x, y, z,
0.25F, 0.75F,
0.025F, 0.224F,
0.75F - width, 0.75F);
pipeRobotStationPartRender (renderblocks, block, state, x, y, z,
0.25F, 0.25F + width,
0.025F, 0.224F,
0.25F + width, 0.75F - width);
pipeRobotStationPartRender (renderblocks, block, state, x, y, z,
0.75F - width, 0.75F,
0.025F, 0.224F,
0.25F + width, 0.75F - width);*/
float zFightOffset = 1F / 4096F;
float[][] zeroState = new float[3][2];
// X START - END
zeroState[0][0] = 0.25F + zFightOffset;
zeroState[0][1] = 0.75F - zFightOffset;
// Y START - END
zeroState[1][0] = 0.225F;
zeroState[1][1] = 0.251F;
// Z START - END
zeroState[2][0] = 0.25F + zFightOffset;
zeroState[2][1] = 0.75F - zFightOffset;
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStation.ordinal()); // Structure
// Pipe
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (state.robotStationMatrix.isConnected(direction)) {
float[][] rotated = MatrixTranformations.deepClone(zeroState);
MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0],
rotated[2][0], rotated[0][1], rotated[1][1],
rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
}
}
}
@Override @Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View file

@ -0,0 +1,102 @@
package buildcraft.transport.render;
import buildcraft.BuildCraftTransport;
import buildcraft.transport.PipeIconProvider;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
public class RobotStationItemRenderer implements IItemRenderer {
private void renderPlugItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
// Render StructurePipe
Block block = BuildCraftTransport.genericPipeBlock;
Tessellator tessellator = Tessellator.instance;
block = BuildCraftTransport.genericPipeBlock;
Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeRobotStation.ordinal()); // Structure pipe
block.setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.375F, 0.75F);
block.setBlockBoundsForItemRender();
render.setRenderBoundsFromBlock(block);
GL11.glTranslatef(translateX, translateY, translateZ + 0.25F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -0F, 0.0F);
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1F);
render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1F, 0.0F, 0.0F);
render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
switch (type) {
case ENTITY:
return true;
case EQUIPPED:
return true;
case EQUIPPED_FIRST_PERSON:
return true;
case INVENTORY:
return true;
default:
return false;
}
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return helper != ItemRendererHelper.BLOCK_3D;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
switch (type) {
case ENTITY:
GL11.glScalef(0.50F, 0.50F, 0.50F);
renderPlugItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F);
break;
case EQUIPPED:
case EQUIPPED_FIRST_PERSON:
GL11.glRotatef(70, 0, 0, 1F);
GL11.glRotatef(-55, 1, 0, 0);
GL11.glScalef(2F, 2F, 2F);
GL11.glTranslatef(0, -0.6F, -0.4F);
renderPlugItem((RenderBlocks) data[0], item, 0F, 0F, 0f);
break;
case INVENTORY:
GL11.glScalef(1.1F, 1.1F, 1.1F);
renderPlugItem((RenderBlocks) data[0], item, -0.3f, -0.35f, -0.7f);
break;
default:
}
}
}