use of v1_8_9.net.minecraft.util.ChatComponentText in project BloodMagic by WayofTime.
the class SubCommandOrb method processSubCommand.
@Override
public void processSubCommand(ICommandSender commandSender, String[] args) {
super.processSubCommand(commandSender, args);
if (args.length > 0) {
if (args[0].equalsIgnoreCase("help"))
return;
String givenName = commandSender.getCommandSenderName();
if (args.length > 1)
givenName = args[1];
boolean displayHelp = isBounded(0, 2, args.length);
try {
switch(ValidCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH))) {
case SET:
{
if (displayHelp) {
displayHelpString(commandSender, ValidCommands.SET.help);
break;
}
if (args.length == 3) {
if (isInteger(args[2])) {
int amount = Integer.parseInt(args[2]);
SoulNetworkHandler.setMaxOrbToMax(givenName, amount);
displaySuccessString(commandSender, "commands.success");
} else {
displayErrorString(commandSender, "commands.error.arg.invalid");
}
} else {
displayErrorString(commandSender, "commands.error.arg.missing");
}
break;
}
case GET:
{
if (displayHelp) {
displayHelpString(commandSender, ValidCommands.GET.help);
break;
}
if (args.length > 1)
commandSender.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("message.orb.currenttier", SoulNetworkHandler.getCurrentMaxOrb(givenName))));
break;
}
}
} catch (IllegalArgumentException e) {
displayErrorString(commandSender, "commands.error.404");
}
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project BloodMagic by WayofTime.
the class ItemAttunedCrystal method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (world.isRemote) {
return itemStack;
}
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
if (movingobjectposition == null) {
if (player.isSneaking()) {
this.setHasSavedCoordinates(itemStack, false);
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.clearing"));
}
return itemStack;
} else {
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
int x = movingobjectposition.blockX;
int y = movingobjectposition.blockY;
int z = movingobjectposition.blockZ;
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof IReagentHandler)) {
return itemStack;
}
IReagentHandler relay = (IReagentHandler) tile;
if (player.isSneaking()) {
ReagentContainerInfo[] infos = relay.getContainerInfo(ForgeDirection.UNKNOWN);
if (infos != null) {
List<Reagent> reagentList = new LinkedList();
for (ReagentContainerInfo info : infos) {
if (info != null) {
ReagentStack reagentStack = info.reagent;
if (reagentStack != null) {
Reagent reagent = reagentStack.reagent;
if (reagent != null) {
reagentList.add(reagent);
}
}
}
}
Reagent pastReagent = this.getReagent(itemStack);
if (reagentList.size() <= 0) {
return itemStack;
}
int reagentLocation;
reagentLocation = reagentList.indexOf(pastReagent);
if (reagentLocation == -1 || reagentLocation + 1 >= reagentList.size()) {
this.setReagentWithNotification(itemStack, reagentList.get(0), player);
} else {
this.setReagentWithNotification(itemStack, reagentList.get(reagentLocation + 1), player);
}
}
} else {
if (this.getHasSavedCoordinates(itemStack)) {
Int3 coords = this.getCoordinates(itemStack);
int dimension = this.getDimension(itemStack);
if (coords == null) {
return itemStack;
}
if (dimension != world.provider.dimensionId || Math.abs(coords.xCoord - x) > maxDistance || Math.abs(coords.yCoord - y) > maxDistance || Math.abs(coords.zCoord - z) > maxDistance) {
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.toofar"));
return itemStack;
}
TileEntity pastTile = world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord);
if (!(pastTile instanceof TEReagentConduit)) {
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.cannotfind"));
return itemStack;
}
Reagent reagent = this.getReagent(itemStack);
if (reagent == null) {
return itemStack;
}
TEReagentConduit pastRelay = (TEReagentConduit) pastTile;
if (player.isSneaking()) {
pastRelay.removeReagentDestinationViaActual(reagent, x, y, z);
} else {
if (pastRelay.addReagentDestinationViaActual(reagent, x, y, z)) {
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.attunedcrystal.linked") + " " + reagent.name));
} else {
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.noconnections"));
}
}
world.markBlockForUpdate(coords.xCoord, coords.yCoord, coords.zCoord);
} else {
int dimension = world.provider.dimensionId;
this.setDimension(itemStack, dimension);
this.setCoordinates(itemStack, new Int3(x, y, z));
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.linking"));
}
}
}
}
return itemStack;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project BloodMagic by WayofTime.
the class ItemTankSegmenter method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (world.isRemote) {
return itemStack;
}
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
if (movingobjectposition == null) {
return itemStack;
} else {
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
int x = movingobjectposition.blockX;
int y = movingobjectposition.blockY;
int z = movingobjectposition.blockZ;
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof ISegmentedReagentHandler)) {
return itemStack;
}
ISegmentedReagentHandler reagentHandler = (ISegmentedReagentHandler) tile;
if (player.isSneaking()) {
ReagentContainerInfo[] infos = reagentHandler.getContainerInfo(ForgeDirection.UNKNOWN);
if (infos != null) {
List<Reagent> reagentList = new LinkedList();
for (ReagentContainerInfo info : infos) {
if (info != null) {
ReagentStack reagentStack = info.reagent;
if (reagentStack != null) {
Reagent reagent = reagentStack.reagent;
if (reagent != null) {
reagentList.add(reagent);
}
}
}
}
Reagent pastReagent = this.getReagent(itemStack);
boolean goForNext = false;
boolean hasFound = false;
for (Reagent reagent : reagentList) {
if (goForNext) {
goForNext = false;
break;
}
if (reagent == pastReagent) {
goForNext = true;
hasFound = true;
}
}
if (hasFound) {
if (goForNext) {
this.setReagentWithNotification(itemStack, reagentList.get(0), player);
}
} else {
if (reagentList.size() >= 1) {
this.setReagentWithNotification(itemStack, reagentList.get(0), player);
}
}
}
} else {
Reagent reagent = this.getReagent(itemStack);
if (reagent == null) {
// TODO: Send message that "All are wiped"
reagentHandler.getAttunedTankMap().clear();
return itemStack;
}
int totalTankSize = reagentHandler.getNumberOfTanks();
int numberAssigned = reagentHandler.getTanksTunedToReagent(reagent) + 1;
if (numberAssigned > totalTankSize) {
numberAssigned = 0;
}
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.tanksegmenter.nowhas") + " " + numberAssigned + " " + StatCollector.translateToLocal("message.tanksegmenter.tankssetto") + " " + reagent.name));
reagentHandler.setTanksTunedToReagent(reagent, numberAssigned);
}
} else if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.MISS) {
this.setReagent(itemStack, null);
}
}
return itemStack;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project BloodMagic by WayofTime.
the class RoutingFocus method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return false;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof IInventory) {
if (player.isSneaking()) {
if (this instanceof ILimitedRoutingFocus) {
int pastAmount = ((ILimitedRoutingFocus) this).getRoutingFocusLimit(stack);
int amount = SpellHelper.getNumberOfItemsInInventory((IInventory) tile, ForgeDirection.getOrientation(side));
if (amount != pastAmount) {
((ILimitedRoutingFocus) this).setRoutingFocusLimit(stack, amount);
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.routerfocus.limit") + amount));
}
}
}
this.setCoordinates(stack, x, y, z);
this.setSetDirection(stack, ForgeDirection.getOrientation(side));
return true;
}
return true;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project TecTech by Technus.
the class GiveEM method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) {
if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) {
if (args.length < 3) {
sender.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
} else {
TecTech.Logger.info("Spawninig EM for " + ((EntityPlayerMP) sender).getDisplayName() + " - " + Arrays.toString(args));
ArrayList<String> list = new ArrayList<>();
list.addAll(Arrays.asList(args));
String energy = list.remove(0);
cElementalDefinitionStack def = getDefinitionStack(list);
cElementalInstanceStack instanceStack = new cElementalInstanceStack(def, 1, 0, Long.parseLong(energy));
sender.addChatMessage(new ChatComponentText(instanceStack.definition.getSymbol() + " - " + instanceStack.definition.getName()));
cElementalInstanceStackMap instanceMap = new cElementalInstanceStackMap(instanceStack);
ItemStack itemStack = new ItemStack(DebugElementalInstanceContainer_EM.INSTANCE);
NBTTagCompound contents = new NBTTagCompound();
contents.setTag("info", instanceMap.getInfoNBT());
contents.setTag("content", instanceMap.toNBT());
itemStack.setTagCompound(contents);
((EntityPlayerMP) sender).inventory.addItemStackToInventory(itemStack);
}
}
}
Aggregations