use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class CommandThreadClear method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
for (IWorkerThread thread : VoltzEngineAPI.WORKER_THREADS.values()) {
if (thread != null) {
int process = thread.containedProcesses();
thread.clearProcesses();
sender.addChatMessage(new ChatComponentText("Cleared " + process + " process from thread " + thread.toString()));
}
}
return true;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class AbstractCommand method printHelp.
/**
* Added the help output to the player's chat
*
* @param sender - user running the command
* @param p - page number to output
*/
protected void printHelp(ICommandSender sender, int p) {
List<String> items = new ArrayList();
getHelpOutput(sender, items);
sender.addChatMessage(new ChatComponentText("====== help -" + getPrefix().replace("/", "") + "- page " + p + " ======"));
for (int i = 0 + (p * 10); i < 10 + (p * 10) && i < items.size(); i++) {
sender.addChatMessage(new ChatComponentText(getPrefix() + " " + items.get(i)));
}
sender.addChatMessage(new ChatComponentText(""));
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class CommandJsonRecipe method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
if (args != null && args.length > 0 && !"help".equalsIgnoreCase(args[0])) {
if (args[0].equals("generate") || args[0].equals("gen")) {
if (args.length > 1) {
String entryID = args[1];
ItemStack stack = new JsonCraftingRecipeData(null, null, null, false, false).toStack(entryID);
if (stack != null) {
List<IRecipe> recipes = entryID.contains("#") ? InventoryUtility.getRecipesWithOutput(stack) : InventoryUtility.getRecipesWithOutput(stack.getItem());
if (recipes != null) {
sender.addChatMessage(new ChatComponentText("Found " + recipes.size() + " for '" + entryID + "' saving to external json file"));
File writeFile = new File(JsonContentLoader.INSTANCE.externalContentFolder.getParent(), "json-gen/" + (entryID + "-recipes.json").replace(":", "_"));
if (!writeFile.getParentFile().exists()) {
writeFile.getParentFile().mkdirs();
}
try {
JsonObject object = new JsonObject();
int index = 0;
for (IRecipe recipe : recipes) {
try {
if (recipe instanceof ShapedOreRecipe) {
int width = 0;
int height = 0;
Object[] recipeItems = null;
Field field = ShapedOreRecipe.class.getDeclaredField("input");
field.setAccessible(true);
recipeItems = (Object[]) field.get(recipe);
field = ShapedOreRecipe.class.getDeclaredField("width");
field.setAccessible(true);
width = field.getInt(recipe);
field = ShapedOreRecipe.class.getDeclaredField("height");
field.setAccessible(true);
height = field.getInt(recipe);
Pair<String, HashMap<String, JsonElement>> itemSet = generateItemData(recipeItems, width, height);
//Build data
if (itemSet != null) {
JsonObject recipeObject = new JsonObject();
recipeObject.add("type", new JsonPrimitive("shaped"));
recipeObject.add("output", toItemJson(recipe.getRecipeOutput()));
recipeObject.add("grid", new JsonPrimitive(itemSet.left()));
JsonObject itemEntry = new JsonObject();
for (Map.Entry<String, JsonElement> entry : itemSet.right().entrySet()) {
itemEntry.add(entry.getKey(), entry.getValue());
}
recipeObject.add("items", itemEntry);
object.add("craftingGridRecipe:" + (index++), recipeObject);
} else {
sender.addChatMessage(new ChatComponentText("Failed to map recipe items for '" + recipe + "'"));
}
} else if (recipe instanceof ShapedRecipes) {
Pair<String, HashMap<String, JsonElement>> itemSet = generateItemData(((ShapedRecipes) recipe).recipeItems, ((ShapedRecipes) recipe).recipeWidth, ((ShapedRecipes) recipe).recipeHeight);
//Build data
if (itemSet != null) {
JsonObject recipeObject = new JsonObject();
recipeObject.add("type", new JsonPrimitive("shaped"));
recipeObject.add("output", toItemJson(recipe.getRecipeOutput()));
recipeObject.add("grid", new JsonPrimitive(itemSet.left()));
JsonObject itemEntry = new JsonObject();
for (Map.Entry<String, JsonElement> entry : itemSet.right().entrySet()) {
itemEntry.add(entry.getKey(), entry.getValue());
}
recipeObject.add("items", itemEntry);
object.add("craftingGridRecipe:" + (index++), recipeObject);
} else {
sender.addChatMessage(new ChatComponentText("Failed to map recipe items for '" + recipe + "'"));
}
} else {
sender.addChatMessage(new ChatComponentText("Failed to ID recipe type of '" + recipe + "'"));
}
} catch (Exception e) {
sender.addChatMessage(new ChatComponentText("Error processing recipe '" + recipe + "', see logs for details."));
e.printStackTrace();
}
}
if (object.entrySet().size() > 0) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
try (FileWriter file = new FileWriter(writeFile)) {
file.write(gson.toJson(object));
}
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
sender.addChatMessage(new ChatComponentText("Failed to locate recipes for '" + entryID + "'"));
}
} else {
sender.addChatMessage(new ChatComponentText("Failed to locate entry for '" + entryID + "'"));
}
return true;
}
}
}
return handleHelp(sender, args);
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class CommandDebugMap method handleEntityPlayerCommand.
@Override
public boolean handleEntityPlayerCommand(EntityPlayer player, String[] args) {
if (args != null && args.length > 0 && !"help".equalsIgnoreCase(args[0])) {
if (args[0].equalsIgnoreCase("radar")) {
} else if (args[0].equalsIgnoreCase("tile") && args.length > 1) {
if (args[1].equalsIgnoreCase("enableDebug")) {
if (args.length > 2) {
RadarMap map = TileMapRegistry.getRadarMapForWorld(player.worldObj);
if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("t")) {
map.setDebugEnabled(true);
player.addChatComponentMessage(new ChatComponentText("Debug enabled for tile map in your world."));
} else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("f")) {
map.setDebugEnabled(false);
player.addChatComponentMessage(new ChatComponentText("Debug disabled for tile map in your world."));
} else {
player.addChatComponentMessage(new ChatComponentText("Could not parse [" + args[2] + "], enable status can only be true or false"));
}
return true;
} else {
RadarMap map = TileMapRegistry.getRadarMapForWorld(player.worldObj);
if (!map.debugRadarMap) {
map.setDebugEnabled(true);
player.addChatComponentMessage(new ChatComponentText("Debug enabled for tile map in your world."));
} else {
map.setDebugEnabled(false);
player.addChatComponentMessage(new ChatComponentText("Debug disabled for tile map in your world."));
}
return true;
}
} else if (args[1].equalsIgnoreCase("objects")) {
RadarMap map = TileMapRegistry.getRadarMapForWorld(player.worldObj);
if (map.allEntities.size() > 0) {
player.addChatComponentMessage(new ChatComponentText("There are " + map.allEntities.size() + " tiles in the map."));
} else {
player.addChatComponentMessage(new ChatComponentText("No tiles detected in global tile list."));
}
return true;
} else if (args[1].equalsIgnoreCase("chunks")) {
RadarMap map = TileMapRegistry.getRadarMapForWorld(player.worldObj);
if (map.chunk_to_entities.size() > 0) {
player.addChatComponentMessage(new ChatComponentText("There are " + map.chunk_to_entities.size() + " chunk locations in the map."));
} else {
player.addChatComponentMessage(new ChatComponentText("No chunks detected in map."));
}
return true;
} else if (args[1].equalsIgnoreCase("around")) {
int range = 100;
if (args.length > 2) {
try {
range = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
player.addChatComponentMessage(new ChatComponentText("Invalid range number"));
return true;
}
}
RadarMap map = TileMapRegistry.getRadarMapForWorld(player.worldObj);
List<RadarObject> list = map.getRadarObjects(player.posX, player.posZ, range);
if (list.size() > 0) {
player.addChatComponentMessage(new ChatComponentText("There are " + list.size() + " tiles within " + range + " meters"));
} else {
player.addChatComponentMessage(new ChatComponentText("No tiles detected in within " + range + " meters"));
}
return true;
}
return handleHelp(player, args);
} else if (args[0].equalsIgnoreCase("heat")) {
}
}
return handleHelp(player, args);
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.
the class BlockBase method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
try {
boolean activated = false;
Object tile = getTile(world, x, y, z);
if (WrenchUtility.isUsableWrench(player, player.inventory.getCurrentItem(), x, y, z)) {
ListenerIterator it = new ListenerIterator(world, x, y, z, this, "wrench");
while (it.hasNext()) {
ITileEventListener next = it.next();
if (next instanceof IWrenchListener && ((IWrenchListener) next).handlesWrenchRightClick() && ((IWrenchListener) next).onPlayerRightClickWrench(player, side, hitX, hitY, hitZ)) {
activated = true;
}
}
if (activated) {
WrenchUtility.damageWrench(player, player.inventory.getCurrentItem(), x, y, z);
}
if (activated) {
return true;
}
}
//TODO move to listener to prevent usage of IGuiTile in special cases
if (tile instanceof IGuiTile && ((IGuiTile) tile).shouldOpenOnRightClick(player)) {
int id = ((IGuiTile) tile).getDefaultGuiID(player);
if (id >= 0) {
Object o = ((IGuiTile) tile).getServerGuiElement(id, player);
if (o != null) {
player.openGui(mod, id, world, x, y, z);
return true;
}
}
}
ListenerIterator it = new ListenerIterator(world, x, y, z, this, "activation");
while (it.hasNext()) {
ITileEventListener next = it.next();
if (next instanceof IActivationListener) {
if (((IActivationListener) next).onPlayerActivated(player, side, hitX, hitY, hitZ)) {
activated = true;
}
}
}
return activated;
} catch (Exception e) {
outputError(world, x, y, z, "while right click block on side " + side, e);
player.addChatComponentMessage(new ChatComponentText(Colors.RED.code + LanguageUtility.getLocal("blockTile.error.onBlockActivated")));
}
return false;
}
Aggregations