-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArtificialIntelligence.java
More file actions
146 lines (129 loc) · 4.47 KB
/
Copy pathArtificialIntelligence.java
File metadata and controls
146 lines (129 loc) · 4.47 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.custommods.ai;
import com.custommods.walkmod.IWorldInfo;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.lwjgl.Sys;
import com.custommods.walkmod.IWorldInfo;
import com.custommods.walkmod.MinecraftWorldInfo;
import com.custommods.walkmod.NeighborCollector;
import com.custommods.walkmod.WalkMod;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameData.GameDataSnapshot;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenLakes;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.event.entity.minecart.MinecartEvent;
import tv.twitch.broadcast.GameInfo;
import tv.twitch.broadcast.GameInfoList;
public class ArtificialIntelligence{
private AIPlayer player;
private AIinventory inventory;
private AIWorld world;
///Constructor
public ArtificialIntelligence(EntityPlayer player){
this.player = new AIPlayer(player);
this.inventory = new AIinventory(player.inventory);
this.world = new AIWorld(Minecraft.getMinecraft().theWorld);
this.player.sendMessage("Successfully Start");
}
///Handle the get command
public void get(String requset){
ItemStack item = Util.getItemStack(requset);
if (item == null){
player.sendMessage("There is no item named " + requset);
}
else if (getItem(item)){
player.sendMessage("Successfully Get " + item.getDisplayName());
}
else{
player.sendMessage("Could not get " + item.getDisplayName());
}
}
///Handle the craft command
public void craft(String toCraft){
ItemStack item = Util.getItemStack(toCraft);
if (item!=null && player.craftItem(inventory, item, world)){
player.sendMessage("Successfully Craft " + item.getDisplayName());
}
else{
player.sendMessage("Could not craft " + toCraft);
}
}
///Handle the smelt command
public void smelt(String toSmelt){
ItemStack item = Util.getItemStack(toSmelt);
if (player.smeltItem(inventory, item, world)){
player.sendMessage("Successfully Smelt " + toSmelt);
}
else{
player.sendMessage("Could not smelt " + toSmelt);
}
}
///Handle the if the command not exist
public void commandNotExist(){
player.sendMessage("Command not exist");
}
///Handle the if the command not exist
public void goToPoint(String strX, String strY, String strZ){
if (strX == null || strY == null || strZ == null){
player.sendMessage("Command not enter currctly");
}
else{
Vec3 dest = Vec3.createVectorHelper(Integer.parseInt(strX), Integer.parseInt(strY), Integer.parseInt(strZ));
if (player.moveToPoint(dest, world)){
player.sendMessage("Successfully got to " + dest);
}
else{
player.sendMessage("Could not found a path to the destion");
}
}
}
///Function for testing only
public void test(String numberS){
if (numberS == null){
numberS = "0";
}
//ItemStack item = inventory.getCurrentItem();
ItemStack item = Util.getItemStack(numberS);
Logger.debug("Start Test whit " + numberS);
if (item == null){
Logger.debug("no id");
}
else{
List<ItemStack> craftInger = RecipesList.getIngredientList(item);
for (ItemStack itemStack : craftInger) {
Logger.debug("Test: " + itemStack.getDisplayName(), Logger.LOG);
}
}
Logger.debug("End Test");
}
///Get an item
private boolean getItem(ItemStack item){
return player.getItem(item, world, inventory);
}
}