implement miner robot, close #1915
This commit is contained in:
parent
fe47f56cf1
commit
e4e477a241
8 changed files with 203 additions and 2 deletions
|
@ -23,6 +23,8 @@ public final class BuildCraftAPI {
|
|||
public static IWorldProperty isSoftProperty;
|
||||
public static IWorldProperty isWoodProperty;
|
||||
public static IWorldProperty isLeavesProperty;
|
||||
public static IWorldProperty isBasicOreProperty;
|
||||
public static IWorldProperty isExtendedOreProperty;
|
||||
|
||||
/**
|
||||
* Deactivate constructor
|
||||
|
|
BIN
buildcraft_resources/assets/buildcraft/textures/entities/robot_miner.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/entities/robot_miner.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
|
@ -107,6 +107,7 @@ import buildcraft.core.triggers.TriggerMachine;
|
|||
import buildcraft.core.triggers.TriggerRedstoneInput;
|
||||
import buildcraft.core.utils.CraftingHandler;
|
||||
import buildcraft.core.utils.WorldPropertyIsLeave;
|
||||
import buildcraft.core.utils.WorldPropertyIsOre;
|
||||
import buildcraft.core.utils.WorldPropertyIsSoft;
|
||||
import buildcraft.core.utils.WorldPropertyIsWood;
|
||||
|
||||
|
@ -366,6 +367,8 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
BuildCraftAPI.isSoftProperty = new WorldPropertyIsSoft();
|
||||
BuildCraftAPI.isWoodProperty = new WorldPropertyIsWood();
|
||||
BuildCraftAPI.isLeavesProperty = new WorldPropertyIsLeave();
|
||||
BuildCraftAPI.isBasicOreProperty = new WorldPropertyIsOre(false);
|
||||
BuildCraftAPI.isExtendedOreProperty = new WorldPropertyIsOre(true);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
|
@ -469,6 +472,8 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
BuildCraftAPI.isSoftProperty.clear();
|
||||
BuildCraftAPI.isWoodProperty.clear();
|
||||
BuildCraftAPI.isLeavesProperty.clear();
|
||||
BuildCraftAPI.isBasicOreProperty.clear();
|
||||
BuildCraftAPI.isExtendedOreProperty.clear();
|
||||
RedstoneBoardRobot.reservedBlocks.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import buildcraft.core.robots.boards.BoardRobotCarrierNBT;
|
|||
import buildcraft.core.robots.boards.BoardRobotKnightNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotLeaveCutterNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotLumberjackNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotMinerNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotPickerNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotPlanterNBT;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
|
@ -129,9 +130,10 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
|
||||
RedstoneBoardRegistry.instance = new ImplRedstoneBoardRegistry();
|
||||
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPickerNBT.instance, 10);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPickerNBT.instance, 20);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotCarrierNBT.instance, 10);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotLumberjackNBT.instance, 10);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotMinerNBT.instance, 10);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPlanterNBT.instance, 5);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotLeaveCutterNBT.instance, 5);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotKnightNBT.instance, 1);
|
||||
|
|
|
@ -55,7 +55,7 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final void delegateAIEnded(AIRobot ai) {
|
||||
public void delegateAIEnded(AIRobot ai) {
|
||||
if (ai instanceof AIRobotSearchBlock) {
|
||||
BlockIndex index = ((AIRobotSearchBlock) ai).blockFound;
|
||||
|
||||
|
|
65
common/buildcraft/core/robots/boards/BoardRobotMiner.java
Executable file
65
common/buildcraft/core/robots/boards/BoardRobotMiner.java
Executable 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.boards;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.boards.RedstoneBoardRobotNBT;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.core.robots.AIRobotFetchAndEquipItemStack;
|
||||
|
||||
public class BoardRobotMiner extends BoardRobotGenericBreakBlock {
|
||||
|
||||
private boolean extendedOre = false;
|
||||
|
||||
public BoardRobotMiner(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delegateAIEnded(AIRobot ai) {
|
||||
super.delegateAIEnded(ai);
|
||||
|
||||
if (ai instanceof AIRobotFetchAndEquipItemStack) {
|
||||
ItemStack stack = robot.getItemInUse();
|
||||
|
||||
if (stack != null && stack.getItem() instanceof ItemPickaxe) {
|
||||
ItemPickaxe pickaxe = (ItemPickaxe) stack.getItem();
|
||||
|
||||
extendedOre = pickaxe.func_150913_i() == Item.ToolMaterial.EMERALD
|
||||
|| pickaxe.func_150913_i() == Item.ToolMaterial.IRON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobotNBT getNBTHandler() {
|
||||
return BoardRobotMinerNBT.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpectedTool(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemPickaxe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpectedBlock(World world, int x, int y, int z) {
|
||||
if (!extendedOre) {
|
||||
return BuildCraftAPI.isBasicOreProperty.get(world, x, y, z);
|
||||
} else {
|
||||
return BuildCraftAPI.isExtendedOreProperty.get(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
72
common/buildcraft/core/robots/boards/BoardRobotMinerNBT.java
Executable file
72
common/buildcraft/core/robots/boards/BoardRobotMinerNBT.java
Executable file
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* 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.boards;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.api.boards.RedstoneBoardRobot;
|
||||
import buildcraft.api.boards.RedstoneBoardRobotNBT;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public final class BoardRobotMinerNBT extends RedstoneBoardRobotNBT {
|
||||
|
||||
public static BoardRobotMinerNBT instance = new BoardRobotMinerNBT();
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft",
|
||||
DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_miner.png");
|
||||
|
||||
private IIcon icon;
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) {
|
||||
return new BoardRobotMiner(robot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRobotTexture() {
|
||||
return TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "buildcraft:miner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
list.add(StringUtils.localize("buildcraft.boardRobotMiner"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:board_blue");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(NBTTagCompound nbt) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRandomBoard(NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDefaultBoard(NBTTagCompound itemData) {
|
||||
}
|
||||
}
|
55
common/buildcraft/core/utils/WorldPropertyIsOre.java
Executable file
55
common/buildcraft/core/utils/WorldPropertyIsOre.java
Executable file
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* 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.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class WorldPropertyIsOre extends WorldProperty {
|
||||
|
||||
public ArrayList<Integer> ores = new ArrayList<Integer>();
|
||||
|
||||
public WorldPropertyIsOre(boolean extendedHarvest) {
|
||||
ores.add(OreDictionary.getOreID("oreCoal"));
|
||||
ores.add(OreDictionary.getOreID("oreIron"));
|
||||
ores.add(OreDictionary.getOreID("oreQuartz"));
|
||||
|
||||
if (extendedHarvest) {
|
||||
ores.add(OreDictionary.getOreID("oreGold"));
|
||||
ores.add(OreDictionary.getOreID("oreDiamond"));
|
||||
ores.add(OreDictionary.getOreID("oreEmerald"));
|
||||
ores.add(OreDictionary.getOreID("oreLapis"));
|
||||
ores.add(OreDictionary.getOreID("oreRedstone"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean get(IBlockAccess blockAccess, Block block, int meta, int x, int y, int z) {
|
||||
if (block == null) {
|
||||
return false;
|
||||
} else {
|
||||
ItemStack stack = new ItemStack(block);
|
||||
|
||||
if (stack.getItem() != null) {
|
||||
for (int id : OreDictionary.getOreIDs(stack)) {
|
||||
if (ores.contains(id)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue