Search in sources :

Example 96 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project BloodMagic by WayofTime.

the class TileMimic method performSpecialAbility.

public boolean performSpecialAbility(EntityPlayer player, EnumFacing sideHit) {
    switch(this.getBlockMetadata()) {
        case BlockMimic.sentientMimicMeta:
            if (player.capabilities.isCreativeMode) {
                if (player.isSneaking()) {
                    playerCheckRadius = Math.max(playerCheckRadius - 1, 0);
                    ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.down", playerCheckRadius));
                } else {
                    playerCheckRadius++;
                    ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.up", playerCheckRadius));
                }
                return false;
            }
            return spawnMimicEntity(player);
        default:
            if (!player.capabilities.isCreativeMode) {
                return false;
            }
            if (player.getActiveItemStack().isEmpty() && !getStackInSlot(1).isEmpty()) {
                switch(sideHit) {
                    // When the block is clicked on the EAST or WEST side, potionSpawnRadius is edited.
                    case EAST:
                    case WEST:
                        if (player.isSneaking()) {
                            potionSpawnRadius = Math.max(potionSpawnRadius - 1, 0);
                            ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionSpawnRadius.down", potionSpawnRadius));
                        } else {
                            potionSpawnRadius++;
                            ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionSpawnRadius.up", potionSpawnRadius));
                        }
                        break;
                    // When the block is clicked on the NORTH or SOUTH side, detectRadius is edited.
                    case NORTH:
                    case SOUTH:
                        if (player.isSneaking()) {
                            playerCheckRadius = Math.max(playerCheckRadius - 1, 0);
                            ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.down", playerCheckRadius));
                        } else {
                            playerCheckRadius++;
                            ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.up", playerCheckRadius));
                        }
                        break;
                    // When the block is clicked on the UP or DOWN side, potionSpawnInterval is edited.
                    case UP:
                    case DOWN:
                        if (player.isSneaking()) {
                            potionSpawnInterval = Math.max(potionSpawnInterval - 1, 1);
                            ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionInterval.down", potionSpawnInterval));
                        } else {
                            potionSpawnInterval++;
                            ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionInterval.up", potionSpawnInterval));
                        }
                        break;
                    default:
                        break;
                }
                return true;
            }
    }
    return false;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 97 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project BloodMagic by WayofTime.

the class TileMasterRitualStone method activateRitual.

@Override
public boolean activateRitual(ItemStack activationCrystal, @Nullable EntityPlayer activator, Ritual ritual) {
    if (PlayerHelper.isFakePlayer(activator))
        return false;
    Binding binding = ((IBindable) activationCrystal.getItem()).getBinding(activationCrystal);
    if (binding != null && ritual != null) {
        if (activationCrystal.getItem() instanceof ItemActivationCrystal) {
            int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal);
            if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) {
                if (!getWorld().isRemote) {
                    SoulNetwork network = NetworkHelper.getSoulNetwork(binding);
                    if (!isRedstoned() && network.getCurrentEssence() < ritual.getActivationCost() && (activator != null && !activator.capabilities.isCreativeMode)) {
                        activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.weak"), true);
                        return false;
                    }
                    if (currentRitual != null)
                        currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE);
                    RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, binding.getOwnerId(), ritual, activator, activationCrystal, crystalLevel);
                    if (MinecraftForge.EVENT_BUS.post(event)) {
                        if (activator != null)
                            activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.prevent"), true);
                        return false;
                    }
                    if (ritual.activateRitual(this, activator, binding.getOwnerId())) {
                        if (!isRedstoned() && (activator != null && !activator.capabilities.isCreativeMode))
                            network.syphon(ritual.getActivationCost());
                        if (activator != null)
                            activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.activate"), true);
                        this.active = true;
                        this.owner = binding.getOwnerId();
                        this.cachedNetwork = network;
                        this.currentRitual = ritual;
                        notifyUpdate();
                        return true;
                    }
                }
                notifyUpdate();
                return true;
            }
        }
    } else {
        if (activator != null)
            activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.notValid"), true);
    }
    return false;
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) RitualEvent(WayofTime.bloodmagic.event.RitualEvent) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBindable(WayofTime.bloodmagic.iface.IBindable) SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) ItemActivationCrystal(WayofTime.bloodmagic.item.ItemActivationCrystal)

Example 98 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project BloodMagic by WayofTime.

the class TileMimic method onBlockActivated.

public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side) {
    if (!heldItem.isEmpty() && player.capabilities.isCreativeMode) {
        List<PotionEffect> list = PotionUtils.getEffectsFromStack(heldItem);
        if (!list.isEmpty()) {
            if (!world.isRemote) {
                setInventorySlotContents(1, heldItem.copy());
                world.notifyBlockUpdate(pos, state, state, 3);
                ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionSet"));
            }
            return true;
        } else if (heldItem.getItem() == RegistrarBloodMagicItems.POTION_FLASK) {
            // The potion flask is empty, therefore we have to reset the stored potion.
            if (!world.isRemote) {
                setInventorySlotContents(1, ItemStack.EMPTY);
                world.notifyBlockUpdate(pos, state, state, 3);
                ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionRemove"));
            }
            return true;
        }
    }
    if (performSpecialAbility(player, side)) {
        return true;
    }
    if (player.isSneaking())
        return false;
    if (!player.getHeldItem(hand).isEmpty() && player.getHeldItem(hand).getItem() == new ItemStack(RegistrarBloodMagicBlocks.MIMIC).getItem())
        return false;
    if (!getStackInSlot(0).isEmpty() && !player.getHeldItem(hand).isEmpty())
        return false;
    if (!dropItemsOnBreak && !player.capabilities.isCreativeMode)
        return false;
    Utils.insertItemToTile(this, player, 0);
    this.refreshTileEntity();
    if (player.capabilities.isCreativeMode) {
        dropItemsOnBreak = getStackInSlot(0).isEmpty();
    }
    world.notifyBlockUpdate(pos, state, state, 3);
    return true;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) PotionEffect(net.minecraft.potion.PotionEffect) ItemStack(net.minecraft.item.ItemStack)

Example 99 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Ceramics by KnightMiner.

the class TileChannel method interact.

/**
 * Interacts with the tile entity, setting the side to show or hide
 * @param side  Side clicked
 * @return
 */
public boolean interact(EntityPlayer player, EnumFacing side) {
    // if placed below a channel, connect it to us
    TileEntity te = world.getTileEntity(pos.offset(side));
    // if the TE is a channel, note that for later
    boolean isChannel = false;
    if (te instanceof TileChannel) {
        isChannel = true;
    // otherwise ensure we can actually connect on that side
    } else if (te == null || !te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) {
        // if it is already none, no reason to set it back to none
        if (this.getConnection(side) == ChannelConnection.NONE) {
            // but for sides lets try again with the bottom connection
            if (side != EnumFacing.DOWN) {
                return this.interact(player, EnumFacing.DOWN);
            }
        } else {
            this.setConnection(side, ChannelConnection.NONE);
            this.updateBlock(pos);
        }
        return false;
    }
    // if down, just reverse the connection
    String message;
    if (side == EnumFacing.DOWN) {
        this.connectedDown = !this.connectedDown;
        this.updateBlock(pos);
        message = this.connectedDown ? "channel.connected_down.allow" : "channel.connected_down.disallow";
    } else {
        // otherwise, we rotate though connections
        ChannelConnection newConnect = this.getConnection(side).getNext(player.isSneaking());
        this.setConnection(side, newConnect);
        // if we have a neighbor, update them as well
        BlockPos offset = this.pos.offset(side);
        if (isChannel) {
            ((TileChannel) te).setConnection(side.getOpposite(), newConnect.getOpposite());
        }
        // block updates
        this.updateBlock(pos);
        this.updateBlock(offset);
        switch(newConnect) {
            case OUT:
                message = "channel.connected.out";
                break;
            case IN:
                message = "channel.connected.in";
                break;
            default:
                message = "channel.connected.none";
        }
    }
    player.sendStatusMessage(new TextComponentTranslation(Util.prefix(message)), true);
    return true;
}
Also used : SPacketUpdateTileEntity(net.minecraft.network.play.server.SPacketUpdateTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) BlockPos(net.minecraft.util.math.BlockPos)

Example 100 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Solar by ArekkuusuJerii.

the class ItemBoundPhoton method pickSource.

@SubscribeEvent(priority = EventPriority.LOWEST)
public void pickSource(PlayerInteractEvent.RightClickBlock event) {
    ItemStack stack = event.getItemStack();
    if (stack.getItem() == this) {
        if (!event.getWorld().isRemote) {
            TileEntity tile = event.getWorld().getTileEntity(event.getPos());
            if (tile instanceof INBTDataTransferable) {
                NBTTagCompound compound = stack.getOrCreateSubCompound(Constants.NBT_BOUND);
                String key = ((INBTDataTransferable) tile).group();
                NBTTagCompound tag = compound.getCompoundTag(key);
                if (!compound.hasKey(key))
                    compound.setTag(key, tag);
                EnumActionResult result = ((INBTDataTransferable) tile).init(tag);
                if (result != EnumActionResult.FAIL) {
                    TextComponentTranslation bound = new TextComponentTranslation("tlp." + key + ".group", TextFormatting.DARK_GRAY);
                    TextComponentTranslation action = new TextComponentTranslation("status.bound", bound, TextFormatting.BLACK);
                    event.getEntityPlayer().sendStatusMessage(action, true);
                }
            }
        }
        event.setCanceled(true);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumActionResult(net.minecraft.util.EnumActionResult) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) INBTDataTransferable(arekkuusu.implom.api.capability.INBTDataTransferable) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)461 ItemStack (net.minecraft.item.ItemStack)119 ITextComponent (net.minecraft.util.text.ITextComponent)73 BlockPos (net.minecraft.util.math.BlockPos)63 EntityPlayer (net.minecraft.entity.player.EntityPlayer)60 TextComponentString (net.minecraft.util.text.TextComponentString)59 Style (net.minecraft.util.text.Style)54 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)48 TileEntity (net.minecraft.tileentity.TileEntity)43 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)31 ArrayList (java.util.ArrayList)30 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)29 World (net.minecraft.world.World)27 EnumFacing (net.minecraft.util.EnumFacing)26 IBlockState (net.minecraft.block.state.IBlockState)24 CommandException (net.minecraft.command.CommandException)23 Nonnull (javax.annotation.Nonnull)18 Block (net.minecraft.block.Block)17 WrongUsageException (net.minecraft.command.WrongUsageException)17 EnumActionResult (net.minecraft.util.EnumActionResult)17