当前位置: 首页>>代码示例>>Java>>正文


Java TagUtil类代码示例

本文整理汇总了Java中slimeknights.tconstruct.library.utils.TagUtil的典型用法代码示例。如果您正苦于以下问题:Java TagUtil类的具体用法?Java TagUtil怎么用?Java TagUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TagUtil类属于slimeknights.tconstruct.library.utils包,在下文中一共展示了TagUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEntityKill

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@SubscribeEvent
public void onEntityKill(LivingDeathEvent e) {
    BlockPos pos = e.getEntity().getPosition();
    World w = e.getEntity().getEntityWorld();
    if (!w.isRemote && e.getSource().getTrueSource() != null) {
        if (e.getSource().getTrueSource() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
            if (random.nextFloat() <= chance && TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand()), identifier)) {
                int id = e.getEntity().getEntityId();
                Entity ent = EntityList.createEntityByID(id, w);
                if (ent != null) {
                    ent.setPosition(pos.getX(), pos.getY(), pos.getZ());
                    w.spawnEntity(ent);
                    e.getSource().getTrueSource().playSound(SoundEvents.AMBIENT_CAVE, 1.0F, 1.0F);
                }
            }
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:19,代码来源:TraitReviving.java

示例2: onUpdate

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@Override
public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, boolean isSelected) {
    // every 3.6 seconds we distribute one stat. This means 1h = 1000 applications
    if (entity.ticksExisted % TICK_PER_STAT > 0) {
        return;
    }

    // we don't update if the player is currently breaking a block because that'd reset it
    if (playerIsBreakingBlock(entity)) {
        return;
    }

    NBTTagCompound tag = TagUtil.getExtraTag(tool);
    Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
    if (data.brokenblocks > 0)
        data.brokenblocks -= 1;
    data.write(tag);
    TagUtil.setExtraTag(tool, tag);
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:20,代码来源:TraitSuperHeavy.java

示例3: onUpdate

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@Override
public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, boolean isSelected) {

    if (entity instanceof FakePlayer || entity.world.isRemote) {
        return;
    }
    if (entity.ticksExisted % TICK_PER_STAT > 0) {
        return;
    }

    NBTTagCompound tag = TagUtil.getExtraTag(tool);
    Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
    data.radius += random.nextFloat() * 0.5f;
    if (data.radius >= 1) {
        TagUtil.setEnchantEffect(tool, true);
    }
    data.write(tag);
    TagUtil.setExtraTag(tool, tag);
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:20,代码来源:TraitWhirl.java

示例4: onTargetKilled

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@SubscribeEvent
public void onTargetKilled(LivingDeathEvent event) {
    if (event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityLiving) {
        World w = event.getSource().getTrueSource().world;
        ItemStack tool = ((EntityPlayer) event.getSource().getTrueSource()).getHeldItemMainhand();
        if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
            NBTTagCompound tag = TagUtil.getExtraTag(tool);
            Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
            float health = ((EntityLiving) event.getEntity()).getMaxHealth();
            data.killcount += 1;
            data.health = health;
            float bonus = Math.round(random.nextFloat() * health * 100) / divisor;
            data.bonus += bonus;
            data.bonus = (float) Math.round(data.bonus * 100f) / 100f;
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:20,代码来源:TraitSoulEater.java

示例5: onEntityKill

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@SubscribeEvent
public void onEntityKill(LivingDeathEvent e) {
    if (e.getSource().getTrueSource() instanceof EntityPlayer && !e.getSource().getTrueSource().world.isRemote && e.getEntity() instanceof EntityCreature) {
        if (TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand()), identifier)) {
            ItemStack tool = ((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand();
            String name = e.getEntity().getName();
            NBTTagCompound tag = TagUtil.getExtraTag(tool);
            Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
            if (!data.name.isEmpty()) {
                return;
            }
            data.name = name;
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:18,代码来源:TraitCongenial.java

示例6: blockHarvestDrops

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@Override
public void blockHarvestDrops(ItemStack tool, BlockEvent.HarvestDropsEvent event) {
    World w = event.getWorld();
    if (!w.isRemote) {
        if (event.getState().getBlock().equals(tiberiumOre)) {
            event.getDrops().clear();
            NBTTagCompound tag = TagUtil.getExtraTag(tool);
            Data data = Data.read(tag);
            if (data.amount >= max_charges) {
                return;
            }
            data.amount += (0.25f + Utils.round2(random.nextDouble() / 4));
            if (data.amount >= max_charges) {
                TagUtil.setEnchantEffect(tool, true);
                if (event.getHarvester() instanceof EntityPlayerMP) {
                    Sounds.PlaySoundForPlayer(event.getHarvester(), Sounds.shocking_discharge, 1f, 0.8f + .2f * random.nextFloat());
                }
            }
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:24,代码来源:TraitTantrum.java

示例7: RightClickItem

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@SubscribeEvent
public void RightClickItem(PlayerInteractEvent.RightClickItem event) {
    World w = event.getWorld();
    BlockPos pos = event.getPos();
    ItemStack tool = event.getEntityPlayer().getHeldItemMainhand();
    if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
        NBTTagCompound tag = TagUtil.getExtraTag(tool);
        Data data = Data.read(tag);
        if (data.amount > 1f) {
            double d = Math.min(Utils.round2(random.nextDouble() * data.amount), max_power);
            w.newExplosion(event.getEntityPlayer(), pos.getX(), pos.getY(), pos.getZ(), (float) Math.pow((double) 1.2f, d), false, true);
            data.amount -= d;
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
            TagUtil.setEnchantEffect(tool, false);
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:19,代码来源:TraitTantrum.java

示例8: applyEffect

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@Override
public void applyEffect(NBTTagCompound rootCompound, NBTTagCompound modifierTag)
{
    super.applyEffect(rootCompound, modifierTag);
    
    ToolNBT data = TagUtil.getToolStats(rootCompound);
    
    data.durability += 500;
    data.attack += 1.0F;
    
    if (data.harvestLevel < HarvestLevels.OBSIDIAN)
    {
        data.harvestLevel = HarvestLevels.OBSIDIAN;
    }
    
    TagUtil.setToolTag(rootCompound, data.get());
}
 
开发者ID:MikeLydeamore,项目名称:ExNihiloAdscensio,代码行数:18,代码来源:ModifierSmashing.java

示例9: miningSpeed

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@Override
public void miningSpeed(ItemStack tool, PlayerInteractEvent.BreakSpeed event) {
    NBTTagCompound tag = TagUtil.getExtraTag(tool);
    Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
    if (!data.active) return;
    event.setNewSpeed(event.getNewSpeed() * 4);
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:8,代码来源:TraitBerserk.java

示例10: onUpdate

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@Override
public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, boolean isSelected) {
    if (!world.isRemote) {
        NBTTagCompound tag = TagUtil.getExtraTag(tool);
        EntityLivingBase player = (EntityLivingBase) entity;
        Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
        NBTTagCompound root = TagUtil.getTagSafe(tool);
        StatNBT distributed = getBonus(root);
        if (data.active) {
            TagUtil.setEnchantEffect(root, true);
            if (entity instanceof FakePlayer) {
                return;
            }
            if (entity.ticksExisted % TICK_PER_STAT > 0) {
                return;
            }

            ToolNBT stat = TagUtil.getToolStats(tool);
            if (random.nextFloat() > .80f) {
                stat.durability -= 1;
                distributed.durability -= 1;
            } else
                ToolHelper.damageTool(tool, 1, player);
            TagUtil.setToolTag(root, stat.get());
            setBonus(root, distributed);
        } else TagUtil.setEnchantEffect(root, false);
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:29,代码来源:TraitBerserk.java

示例11: onRightClickItem

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@SubscribeEvent
public void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
    World w = event.getWorld();
    ItemStack tool = event.getEntityPlayer().getHeldItemMainhand();
    if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
        NBTTagCompound tag = TagUtil.getExtraTag(tool);
        Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
        NBTTagCompound root = TagUtil.getTagSafe(tool);
        StatNBT distributed = getBonus(root);
        ToolNBT stat = TagUtil.getToolStats(tool);
        if (data.active) {
            data.active = false;
            TagUtil.setEnchantEffect(root, false);
            TagUtil.setExtraTag(root, tag);
            data.write(tag);

        } else {
            stat.durability -= 10;
            distributed.durability -= 10;
            TagUtil.setToolTag(root, stat.get());
            setBonus(root, distributed);
            data.active = true;
            data.write(tag);

            TagUtil.setExtraTag(root, tag);
            data.write(tag);
        }

    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:31,代码来源:TraitBerserk.java

示例12: onMobDrops

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@SubscribeEvent
public void onMobDrops(LivingDropsEvent event) {
    World w = event.getEntity().getEntityWorld();
    if (random.nextFloat() < 0.05 && !w.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        if (event.getEntity() instanceof EntityMob && TinkerUtil.hasTrait(TagUtil.getTagSafe(player.getHeldItemMainhand()), identifier)) {
            ItemStack i = new ItemStack(Items.GUNPOWDER, random.nextInt(2));
            event.getDrops().add(0, new EntityItem(w, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, i));
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:12,代码来源:TraitInstable.java

示例13: getExtraInfo

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@Override
public List<String> getExtraInfo(ItemStack tool, NBTTagCompound modifierTag) {
    StatNBT pool = getBonus(TagUtil.getTagSafe(tool));

    return ImmutableList.of(HeadMaterialStats.formatDurability(pool.durability),
            HeadMaterialStats.formatMiningSpeed(pool.speed),
            HeadMaterialStats.formatAttack(pool.attack));
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:9,代码来源:TraitDecay.java

示例14: onEntityKill

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@SubscribeEvent
public void onEntityKill(LivingDeathEvent e) {
    World w = e.getEntity().getEntityWorld();
    if (!w.isRemote && e.getSource().getTrueSource() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
        if (TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand()), identifier)) {
            String name = EntityList.getEntityString(e.getEntity());
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:10,代码来源:TraitTraditional.java

示例15: onMobDrops

import slimeknights.tconstruct.library.utils.TagUtil; //导入依赖的package包/类
@SubscribeEvent
public void onMobDrops(LivingDropsEvent event) {
    World w = event.getEntity().getEntityWorld();
    if (!w.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        if (random.nextFloat() <= 0.9 && event.getEntity() instanceof EntityMob && TinkerUtil.hasTrait(TagUtil.getTagSafe(player.getHeldItemMainhand()), identifier)) {
            event.getDrops().clear();
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:11,代码来源:TraitHollow.java


注:本文中的slimeknights.tconstruct.library.utils.TagUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。