use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.
the class VampireAbilityHandler method abilityHandler.
@SubscribeEvent
public void abilityHandler(PlayerTickEvent evt) {
if (evt.phase == Phase.START && !evt.player.world.isRemote) {
PotionEffect nv = evt.player.getActivePotionEffect(MobEffects.NIGHT_VISION);
if ((nv == null || nv.getDuration() <= 220) && evt.player.getCapability(CapabilityTransformationData.CAPABILITY, null).isNightVisionActive()) {
if (BewitchmentAPI.getAPI().addVampireBlood(evt.player, -2)) {
evt.player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 300, 0, true, false));
} else {
evt.player.sendStatusMessage(new TextComponentTranslation("vampire.nightvision.low_blood"), true);
evt.player.getCapability(CapabilityTransformationData.CAPABILITY, null).setNightVision(false);
}
}
}
}
use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.
the class VampireAbilityHandler method sleepBed.
@SubscribeEvent
public void sleepBed(RightClickBlock evt) {
ITransformationData data = evt.getEntityPlayer().getCapability(CapabilityTransformationData.CAPABILITY, null);
if (data.getType() == ModTransformations.VAMPIRE && evt.getEntityPlayer().world.getBlockState(evt.getPos()).getBlock() == Blocks.BED) {
evt.setCancellationResult(EnumActionResult.FAIL);
evt.setCanceled(true);
evt.getEntityPlayer().sendStatusMessage(new TextComponentTranslation("vampire.bed_blocked"), true);
}
}
use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.
the class CommandFortuneActivator method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (sender instanceof EntityPlayer) {
CapabilityDivination dc = ((EntityPlayer) sender).getCapability(CapabilityDivination.CAPABILITY, null);
if (dc.getFortune() != null) {
if (dc.isActive()) {
throw new CommandException("commands.enable_fortune.error.already_active");
}
dc.setActive();
sender.sendMessage(new TextComponentTranslation("commands.enable_fortune.success"));
} else {
throw new CommandException("commands.enable_fortune.error.no_fortune");
}
} else {
throw new CommandException("commands.error.no_console");
}
}
use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.
the class CommandTransformationModifier method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length == 0)
throw new WrongUsageException("commands.set_transformation.usage");
if (sender instanceof EntityPlayer) {
String typeStr = args[0].toLowerCase();
ITransformation transf = null;
if (typeStr.equals("v") || typeStr.equals("vamp")) {
transf = ModTransformations.VAMPIRE;
} else if (typeStr.equals("w") || typeStr.equals("ww") || typeStr.equals("wolf")) {
transf = ModTransformations.WEREWOLF;
} else if (typeStr.equals("h") || typeStr.equals("hunt") || typeStr.equals("wh")) {
transf = ModTransformations.HUNTER;
} else if (typeStr.equals("s") || typeStr.equals("ghost") || typeStr.equals("phantom")) {
transf = ModTransformations.SPECTRE;
} else if (typeStr.equals("n")) {
transf = ModTransformations.NONE;
} else
for (ITransformation tt : ModTransformations.REGISTRY) {
if (typeStr.equals(tt.getRegistryName().getResourcePath().toLowerCase()) || typeStr.equals(tt.getRegistryName().toString().toLowerCase())) {
transf = tt;
break;
}
}
if (transf == null)
throw new WrongUsageException("commands.set_transformation.usage.no_transformation");
int level = 0;
try {
if (transf != ModTransformations.NONE) {
level = Integer.valueOf(args[1]);
}
} catch (ArrayIndexOutOfBoundsException | NumberFormatException e) {
throw new WrongUsageException("commands.set_transformation.usage.invalid_level");
}
if (level < 0 || level > 10) {
throw new WrongUsageException("commands.set_transformation.usage.invalid_level");
}
BewitchmentAPI.getAPI().setTypeAndLevel((EntityPlayer) sender, transf, level, false);
sender.sendMessage(new TextComponentTranslation("commands.set_transformation.success", transf.getRegistryName().toString().toLowerCase(), level));
} else {
throw new WrongUsageException("commands.error.no_console");
}
}
use of net.minecraft.util.text.TextComponentTranslation in project Bewitchment by Um-Mitternacht.
the class TileEntityTarotsTable method read.
public void read(@Nonnull ItemStack tarotDeck, @Nonnull EntityPlayer reader) {
if (!reader.world.isRemote) {
if (checkDeck(tarotDeck) && consumePower(READ_COST, false)) {
reader.openGui(Bewitchment.instance, LibGui.TAROT.ordinal(), reader.world, pos.getX(), pos.getY(), pos.getZ());
NetworkHandler.HANDLER.sendTo(new TarotMessage(reader), (EntityPlayerMP) reader);
} else {
reader.sendStatusMessage(new TextComponentTranslation("item.tarots.error_reading"), true);
}
}
}
Aggregations