added farmer and harvester robots, part of #1922
This commit is contained in:
parent
1ab3bcef10
commit
7721d0d95d
20 changed files with 419 additions and 33 deletions
|
@ -25,6 +25,7 @@ public final class BuildCraftAPI {
|
|||
public static IWorldProperty isLeavesProperty;
|
||||
public static IWorldProperty isBasicOreProperty;
|
||||
public static IWorldProperty isExtendedOreProperty;
|
||||
public static IWorldProperty isHarvestableProperty;
|
||||
|
||||
/**
|
||||
* Deactivate constructor
|
||||
|
|
|
@ -8,6 +8,8 @@ buildcraft.boardRobotCarrier=Carrier
|
|||
buildcraft.boardRobotBomber=Bomber
|
||||
buildcraft.boardRobotKnight=Knight
|
||||
buildcraft.boardRobotMiner=Miner
|
||||
buildcraft.boardRobotFarmer=Farmer
|
||||
buildcraft.boardRobotHarvester=Harvester
|
||||
buildcraft.boardDetail.parameters=Parameters
|
||||
buildcraft.boardDetail.range=Range
|
||||
|
||||
|
|
BIN
buildcraft_resources/assets/buildcraft/textures/entities/robot_farmer.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/entities/robot_farmer.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
buildcraft_resources/assets/buildcraft/textures/entities/robot_harvester.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/entities/robot_harvester.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
|
@ -105,6 +105,7 @@ import buildcraft.core.triggers.TriggerInventoryLevel;
|
|||
import buildcraft.core.triggers.TriggerMachine;
|
||||
import buildcraft.core.triggers.TriggerRedstoneInput;
|
||||
import buildcraft.core.utils.CraftingHandler;
|
||||
import buildcraft.core.utils.WorldPropertyIsHarvestable;
|
||||
import buildcraft.core.utils.WorldPropertyIsLeave;
|
||||
import buildcraft.core.utils.WorldPropertyIsOre;
|
||||
import buildcraft.core.utils.WorldPropertyIsSoft;
|
||||
|
@ -366,6 +367,7 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
BuildCraftAPI.isLeavesProperty = new WorldPropertyIsLeave();
|
||||
BuildCraftAPI.isBasicOreProperty = new WorldPropertyIsOre(false);
|
||||
BuildCraftAPI.isExtendedOreProperty = new WorldPropertyIsOre(true);
|
||||
BuildCraftAPI.isHarvestableProperty = new WorldPropertyIsHarvestable();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
|
@ -471,6 +473,7 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
BuildCraftAPI.isLeavesProperty.clear();
|
||||
BuildCraftAPI.isBasicOreProperty.clear();
|
||||
BuildCraftAPI.isExtendedOreProperty.clear();
|
||||
BuildCraftAPI.isHarvestableProperty.clear();
|
||||
RedstoneBoardRobot.reservedBlocks.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ import buildcraft.core.proxy.CoreProxy;
|
|||
import buildcraft.core.robots.RobotIntegrationRecipe;
|
||||
import buildcraft.core.robots.boards.BoardRobotBomberNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotCarrierNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotFarmerNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotHarvesterNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotKnightNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotLeaveCutterNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotLumberjackNBT;
|
||||
|
@ -144,8 +146,10 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPickerNBT.instance, 20);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotCarrierNBT.instance, 10);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotLumberjackNBT.instance, 10);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotHarvesterNBT.instance, 10);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotMinerNBT.instance, 10);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPlanterNBT.instance, 5);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotFarmerNBT.instance, 5);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotLeaveCutterNBT.instance, 5);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotKnightNBT.instance, 1);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotBomberNBT.instance, 1);
|
||||
|
|
|
@ -21,7 +21,7 @@ import buildcraft.api.robots.EntityRobotBase;
|
|||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
|
||||
public class AIRobotBreakWithTool extends AIRobot {
|
||||
public class AIRobotBreak extends AIRobot {
|
||||
|
||||
public BlockIndex blockToBreak;
|
||||
private float blockDamage = 0;
|
||||
|
@ -31,11 +31,11 @@ public class AIRobotBreakWithTool extends AIRobot {
|
|||
private float hardness;
|
||||
private float speed;
|
||||
|
||||
public AIRobotBreakWithTool(EntityRobotBase iRobot) {
|
||||
public AIRobotBreak(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
public AIRobotBreakWithTool(EntityRobotBase iRobot, BlockIndex iBlockToBreak) {
|
||||
public AIRobotBreak(EntityRobotBase iRobot, BlockIndex iBlockToBreak) {
|
||||
super(iRobot);
|
||||
|
||||
blockToBreak = iBlockToBreak;
|
||||
|
@ -60,15 +60,27 @@ public class AIRobotBreakWithTool extends AIRobot {
|
|||
robot.worldObj.destroyBlockInWorldPartially(robot.getEntityId(), blockToBreak.x,
|
||||
blockToBreak.y, blockToBreak.z, -1);
|
||||
blockDamage = 0;
|
||||
robot.getHeldItem().getItem()
|
||||
.onBlockStartBreak(robot.getHeldItem(), blockToBreak.x, blockToBreak.y, blockToBreak.z,
|
||||
|
||||
if (robot.getHeldItem() != null) {
|
||||
robot.getHeldItem().getItem()
|
||||
.onBlockStartBreak(robot.getHeldItem(), blockToBreak.x, blockToBreak.y, blockToBreak.z,
|
||||
CoreProxy.proxy.getBuildCraftPlayer((WorldServer) robot.worldObj).get());
|
||||
}
|
||||
|
||||
BlockUtil.breakBlock((WorldServer) robot.worldObj, blockToBreak.x, blockToBreak.y, blockToBreak.z, 6000);
|
||||
robot.getHeldItem().getItem().onBlockDestroyed(robot.getHeldItem(), robot.worldObj, block, blockToBreak.x,
|
||||
|
||||
robot.worldObj.playAuxSFXAtEntity(null, 2001,
|
||||
blockToBreak.x, blockToBreak.y, blockToBreak.z,
|
||||
Block.getIdFromBlock(block) + (meta << 12));
|
||||
|
||||
if (robot.getHeldItem() != null) {
|
||||
robot.getHeldItem().getItem()
|
||||
.onBlockDestroyed(robot.getHeldItem(), robot.worldObj, block, blockToBreak.x,
|
||||
blockToBreak.y, blockToBreak.z, robot);
|
||||
|
||||
if (robot.getHeldItem().getItemDamage() >= robot.getHeldItem().getMaxDamage()) {
|
||||
robot.setItemInUse(null);
|
||||
if (robot.getHeldItem().getItemDamage() >= robot.getHeldItem().getMaxDamage()) {
|
||||
robot.setItemInUse(null);
|
||||
}
|
||||
}
|
||||
|
||||
terminate();
|
|
@ -39,6 +39,11 @@ public class AIRobotFindRandomGroundBlock extends AIRobot {
|
|||
|
||||
@Override
|
||||
public void update() {
|
||||
if (filter == null) {
|
||||
// defensive code
|
||||
terminate();
|
||||
}
|
||||
|
||||
attempts++;
|
||||
|
||||
if (attempts > MAX_ATTEMPTS) {
|
||||
|
|
|
@ -45,8 +45,13 @@ public class AIRobotSearchBlock extends AIRobot {
|
|||
public void update() {
|
||||
if (blockScannerJob.isDone()) {
|
||||
LinkedList<BlockIndex> path = blockScanner.getResult();
|
||||
blockFound = path.removeLast();
|
||||
startDelegateAI(new AIRobotGotoBlock(robot, path));
|
||||
|
||||
if (path != null) {
|
||||
blockFound = path.removeLast();
|
||||
startDelegateAI(new AIRobotGotoBlock(robot, path));
|
||||
} else {
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,42 +11,53 @@ package buildcraft.core.robots;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.core.BlockIndex;
|
||||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
||||
public class AIRobotPlantSaple extends AIRobot {
|
||||
public class AIRobotUseToolOnBlock extends AIRobot {
|
||||
|
||||
private BlockIndex toPlant;
|
||||
private int plantCycles = 0;
|
||||
private BlockIndex useToBlock;
|
||||
private int useCycles = 0;
|
||||
|
||||
public AIRobotPlantSaple(EntityRobotBase iRobot) {
|
||||
public AIRobotUseToolOnBlock(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
public AIRobotPlantSaple(EntityRobotBase iRobot, BlockIndex index) {
|
||||
public AIRobotUseToolOnBlock(EntityRobotBase iRobot, BlockIndex index) {
|
||||
super(iRobot);
|
||||
|
||||
toPlant = index;
|
||||
useToBlock = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
robot.aimItemAt(toPlant.x, toPlant.y, toPlant.z);
|
||||
robot.aimItemAt(useToBlock.x, useToBlock.y, useToBlock.z);
|
||||
robot.setItemActive(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
plantCycles++;
|
||||
useCycles++;
|
||||
|
||||
if (plantCycles > 40) {
|
||||
if (useCycles > 40) {
|
||||
ItemStack stack = robot.getHeldItem();
|
||||
robot.setItemInUse(null);
|
||||
|
||||
if (robot.getHeldItem().isItemStackDamageable()) {
|
||||
robot.getHeldItem().damageItem(1, robot);
|
||||
|
||||
if (robot.getHeldItem().getItemDamage() >= robot.getHeldItem().getMaxDamage()) {
|
||||
robot.setItemInUse(null);
|
||||
}
|
||||
} else {
|
||||
robot.setItemInUse(null);
|
||||
}
|
||||
|
||||
stack.getItem().onItemUse(stack, CoreProxy.proxy.getBuildCraftPlayer((WorldServer) robot.worldObj).get(),
|
||||
robot.worldObj, toPlant.x, toPlant.y + 1, toPlant.z, 0, 0, 0, 0);
|
||||
robot.worldObj, useToBlock.x, useToBlock.y, useToBlock.z, ForgeDirection.UP.ordinal(), 0, 0, 0);
|
||||
|
||||
terminate();
|
||||
}
|
78
common/buildcraft/core/robots/boards/BoardRobotFarmer.java
Executable file
78
common/buildcraft/core/robots/boards/BoardRobotFarmer.java
Executable file
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* 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.block.Block;
|
||||
import net.minecraft.block.BlockDirt;
|
||||
import net.minecraft.block.BlockGrass;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.boards.RedstoneBoardRobot;
|
||||
import buildcraft.api.boards.RedstoneBoardRobotNBT;
|
||||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.core.inventory.filters.IStackFilter;
|
||||
import buildcraft.core.robots.AIRobotFetchAndEquipItemStack;
|
||||
import buildcraft.core.robots.AIRobotGotoRandomGroundBlock;
|
||||
import buildcraft.core.robots.AIRobotGotoSleep;
|
||||
import buildcraft.core.robots.AIRobotUseToolOnBlock;
|
||||
import buildcraft.core.robots.IBlockFilter;
|
||||
|
||||
public class BoardRobotFarmer extends RedstoneBoardRobot {
|
||||
|
||||
public BoardRobotFarmer(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobotNBT getNBTHandler() {
|
||||
return BoardRobotFarmerNBT.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (robot.getHeldItem() == null) {
|
||||
startDelegateAI(new AIRobotFetchAndEquipItemStack(robot, new IStackFilter() {
|
||||
@Override
|
||||
public boolean matches(ItemStack stack) {
|
||||
return stack != null && stack.getItem() instanceof ItemHoe;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
startDelegateAI(new AIRobotGotoRandomGroundBlock(robot, 100, new IBlockFilter() {
|
||||
@Override
|
||||
public boolean matches(World world, int x, int y, int z) {
|
||||
Block b = robot.worldObj.getBlock(x, y, z);
|
||||
|
||||
return b instanceof BlockDirt || b instanceof BlockGrass;
|
||||
}
|
||||
}, robot.getAreaToWork()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delegateAIEnded(AIRobot ai) {
|
||||
if (ai instanceof AIRobotGotoRandomGroundBlock) {
|
||||
AIRobotGotoRandomGroundBlock gotoBlock = (AIRobotGotoRandomGroundBlock) ai;
|
||||
|
||||
if (((AIRobotGotoRandomGroundBlock) ai).blockFound == null) {
|
||||
startDelegateAI(new AIRobotGotoSleep(robot));
|
||||
} else {
|
||||
startDelegateAI(new AIRobotUseToolOnBlock(robot, ((AIRobotGotoRandomGroundBlock) ai).blockFound));
|
||||
}
|
||||
} else if (ai instanceof AIRobotFetchAndEquipItemStack) {
|
||||
if (robot.getHeldItem() == null) {
|
||||
startDelegateAI(new AIRobotGotoSleep(robot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
72
common/buildcraft/core/robots/boards/BoardRobotFarmerNBT.java
Executable file
72
common/buildcraft/core/robots/boards/BoardRobotFarmerNBT.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 BoardRobotFarmerNBT extends RedstoneBoardRobotNBT {
|
||||
|
||||
public static BoardRobotFarmerNBT instance = new BoardRobotFarmerNBT();
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft",
|
||||
DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_farmer.png");
|
||||
|
||||
private IIcon icon;
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) {
|
||||
return new BoardRobotFarmer(robot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRobotTexture() {
|
||||
return TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "buildcraft:boardRobotFarmer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
list.add(StringUtils.localize("buildcraft.boardRobotFarmer"));
|
||||
}
|
||||
|
||||
@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 nbt) {
|
||||
}
|
||||
}
|
|
@ -16,13 +16,16 @@ import buildcraft.api.core.BlockIndex;
|
|||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.core.inventory.filters.IStackFilter;
|
||||
import buildcraft.core.robots.AIRobotBreakWithTool;
|
||||
import buildcraft.core.robots.AIRobotBreak;
|
||||
import buildcraft.core.robots.AIRobotFetchAndEquipItemStack;
|
||||
import buildcraft.core.robots.AIRobotGotoSleep;
|
||||
import buildcraft.core.robots.AIRobotSearchBlock;
|
||||
import buildcraft.core.utils.IPathFound;
|
||||
|
||||
public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
|
||||
|
||||
private BlockIndex indexStored;
|
||||
|
||||
public BoardRobotGenericBreakBlock(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
@ -31,9 +34,19 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
|
|||
|
||||
public abstract boolean isExpectedBlock(World world, int x, int y, int z);
|
||||
|
||||
public final void preemt(AIRobot ai) {
|
||||
if (ai instanceof AIRobotSearchBlock) {
|
||||
BlockIndex index = ((AIRobotSearchBlock) ai).blockFound;
|
||||
|
||||
if (!RedstoneBoardRobot.isFreeBlock(index)) {
|
||||
abortDelegateAI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void update() {
|
||||
if (robot.getHeldItem() == null) {
|
||||
if (!isExpectedTool(null) && robot.getHeldItem() == null) {
|
||||
startDelegateAI(new AIRobotFetchAndEquipItemStack(robot, new IStackFilter() {
|
||||
@Override
|
||||
public boolean matches(ItemStack stack) {
|
||||
|
@ -57,13 +70,25 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
|
|||
@Override
|
||||
public void delegateAIEnded(AIRobot ai) {
|
||||
if (ai instanceof AIRobotSearchBlock) {
|
||||
BlockIndex index = ((AIRobotSearchBlock) ai).blockFound;
|
||||
indexStored = ((AIRobotSearchBlock) ai).blockFound;
|
||||
|
||||
if (index != null && reserveBlock(index)) {
|
||||
startDelegateAI(new AIRobotBreakWithTool(robot, ((AIRobotSearchBlock) ai).blockFound));
|
||||
if (indexStored == null) {
|
||||
startDelegateAI(new AIRobotGotoSleep(robot));
|
||||
} else {
|
||||
if (reserveBlock(indexStored)) {
|
||||
startDelegateAI(new AIRobotBreak(robot, indexStored));
|
||||
}
|
||||
}
|
||||
} else if (ai instanceof AIRobotBreakWithTool) {
|
||||
releaseBlock(((AIRobotBreakWithTool) ai).blockToBreak);
|
||||
} else if (ai instanceof AIRobotBreak) {
|
||||
releaseBlock(indexStored);
|
||||
indexStored = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
if (indexStored != null) {
|
||||
releaseBlock(indexStored);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
43
common/buildcraft/core/robots/boards/BoardRobotHarvester.java
Executable file
43
common/buildcraft/core/robots/boards/BoardRobotHarvester.java
Executable file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* 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.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.boards.RedstoneBoardRobotNBT;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
|
||||
public class BoardRobotHarvester extends BoardRobotGenericBreakBlock {
|
||||
|
||||
public BoardRobotHarvester(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
public BoardRobotHarvester(EntityRobotBase iRobot, NBTTagCompound nbt) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobotNBT getNBTHandler() {
|
||||
return BoardRobotHarvesterNBT.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpectedTool(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpectedBlock(World world, int x, int y, int z) {
|
||||
return BuildCraftAPI.isHarvestableProperty.get(world, x, y, z);
|
||||
}
|
||||
}
|
77
common/buildcraft/core/robots/boards/BoardRobotHarvesterNBT.java
Executable file
77
common/buildcraft/core/robots/boards/BoardRobotHarvesterNBT.java
Executable file
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* 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 BoardRobotHarvesterNBT extends RedstoneBoardRobotNBT {
|
||||
|
||||
public static BoardRobotHarvesterNBT instance = new BoardRobotHarvesterNBT();
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft",
|
||||
DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_harvester.png");
|
||||
|
||||
public IIcon icon;
|
||||
|
||||
private BoardRobotHarvesterNBT() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "buildcraft:boardRobotHarvester";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
list.add(StringUtils.localize("buildcraft.boardRobotHarvester"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) {
|
||||
return new BoardRobotHarvester(robot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(NBTTagCompound nbt) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:board_blue");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRandomBoard(NBTTagCompound nbt) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDefaultBoard(NBTTagCompound nbt) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRobotTexture() {
|
||||
return TEXTURE;
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ public class BoardRobotLeaveCutter extends BoardRobotGenericBreakBlock {
|
|||
|
||||
@Override
|
||||
public boolean isExpectedTool(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemShears;
|
||||
return stack != null && stack.getItem() instanceof ItemShears;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,7 @@ public class BoardRobotLumberjack extends BoardRobotGenericBreakBlock {
|
|||
|
||||
@Override
|
||||
public boolean isExpectedTool(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemAxe;
|
||||
return stack != null && stack.getItem() instanceof ItemAxe;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -50,7 +50,7 @@ public class BoardRobotMiner extends BoardRobotGenericBreakBlock {
|
|||
|
||||
@Override
|
||||
public boolean isExpectedTool(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemPickaxe;
|
||||
return stack != null && stack.getItem() instanceof ItemPickaxe;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,7 @@ import buildcraft.core.inventory.filters.OreStackFilter;
|
|||
import buildcraft.core.robots.AIRobotFetchAndEquipItemStack;
|
||||
import buildcraft.core.robots.AIRobotGotoRandomGroundBlock;
|
||||
import buildcraft.core.robots.AIRobotGotoSleep;
|
||||
import buildcraft.core.robots.AIRobotPlantSaple;
|
||||
import buildcraft.core.robots.AIRobotUseToolOnBlock;
|
||||
import buildcraft.core.robots.IBlockFilter;
|
||||
|
||||
public class BoardRobotPlanter extends RedstoneBoardRobot {
|
||||
|
@ -59,7 +59,7 @@ public class BoardRobotPlanter extends RedstoneBoardRobot {
|
|||
if (((AIRobotGotoRandomGroundBlock) ai).blockFound == null) {
|
||||
startDelegateAI(new AIRobotGotoSleep(robot));
|
||||
} else {
|
||||
startDelegateAI(new AIRobotPlantSaple(robot, ((AIRobotGotoRandomGroundBlock) ai).blockFound));
|
||||
startDelegateAI(new AIRobotUseToolOnBlock(robot, ((AIRobotGotoRandomGroundBlock) ai).blockFound));
|
||||
}
|
||||
} else if (ai instanceof AIRobotFetchAndEquipItemStack) {
|
||||
if (robot.getHeldItem() == null) {
|
||||
|
|
48
common/buildcraft/core/utils/WorldPropertyIsHarvestable.java
Executable file
48
common/buildcraft/core/utils/WorldPropertyIsHarvestable.java
Executable file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* 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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCactus;
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.block.BlockDoublePlant;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.block.BlockMelon;
|
||||
import net.minecraft.block.BlockMushroom;
|
||||
import net.minecraft.block.BlockReed;
|
||||
import net.minecraft.block.BlockTallGrass;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class WorldPropertyIsHarvestable extends WorldProperty {
|
||||
|
||||
public WorldPropertyIsHarvestable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean get(IBlockAccess blockAccess, Block block, int meta, int x, int y, int z) {
|
||||
if (block == null) {
|
||||
return false;
|
||||
} else if (block instanceof BlockFlower
|
||||
|| block instanceof BlockTallGrass
|
||||
|| block instanceof BlockMelon
|
||||
|| block instanceof BlockMushroom
|
||||
|| block instanceof BlockDoublePlant) {
|
||||
return true;
|
||||
} else if (block instanceof BlockCactus || block instanceof BlockReed) {
|
||||
if (y > 0 && blockAccess.getBlock(x, y - 1, z) == block) {
|
||||
return true;
|
||||
}
|
||||
} else if (block instanceof BlockCrops) {
|
||||
return meta == 7;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue