-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathObjective.java
More file actions
78 lines (67 loc) · 2.33 KB
/
Copy pathObjective.java
File metadata and controls
78 lines (67 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.custommods.ai;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
public class Objective {
///Check if can Craft an Item
public static boolean canCraft(ItemStack item, AIinventory inve){
List<ItemStack> items = RecipesList.getIngredientList(item);
if (items == null){
return false;
}
for (ItemStack itemStack : items) {
if (!inve.haveItem(itemStack)){
return false;
}
}
return true;
}
///Check if can smelt an item
public static boolean canSmelt(ItemStack item, AIinventory inve){
ItemStack result = RecipesList.getSmeltingItem(item);
if (result == null){
return false;
}
return inve.haveItem(result);
}
///Check if the player can harvest block
public static boolean canHarvestBlock(AIPlayer player, Block block){
return player.getPlayer().canHarvestBlock(block);
}
///Check if the player have the items to make a portal
public static boolean canMakePortal(Block block, AIinventory inve){
//check if the player have "Flint and Steel"
if (!inve.haveItem(new ItemStack(Item.getItemById(259)))){
return false;
}
ItemStack itemToCheck = new ItemStack(block);
itemToCheck.stackSize = 10;
return inve.haveItem(itemToCheck);
}
///Check if the block is in a reach of the player
public static boolean nearBlock(AIPlayer player, Vec3 blockLoc){
double distance = blockLoc.distanceTo(player.eyesLoc());
return (distance < UserSetting.rechDistance);
}
///Check if the specific block is near the player
public static boolean blockNearPlayer(AIPlayer player, AIWorld world, Block block){
Vec3 playerPos = player.eyesLoc();
Vec3 blockLoc;
if ((blockLoc = world.findNearestBlock(playerPos, block, (int)UserSetting.rechDistance + 1)) == null){
return false;
}
return nearBlock(player, blockLoc);
}
///Check if the specific block is near the player
public static boolean blockNearPlayer(AIPlayer player, AIWorld world, int blockId){
Vec3 playerPos = player.eyesLoc();
Vec3 blockLoc;
if ((blockLoc = world.findNearestBlock(playerPos, blockId, (int)UserSetting.rechDistance + 2)) == null){
return false;
}
return nearBlock(player, blockLoc);
}
}