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


Java TagUtil.setExtraTag方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: onUpdate

import slimeknights.tconstruct.library.utils.TagUtil; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, boolean isSelected) {
    NBTTagCompound tag = TagUtil.getExtraTag(tool);
    Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
    if (random.nextInt((chance + data.curse) / (data.curse + 1)) == 1) {
        if (isSelected) data.curse += 10;
        else data.curse++;
        entity.attackEntityFrom(new DamageSource("Curse"), random.nextFloat() * ((EntityPlayer) entity).getHealth() / 2);
    }

    data.write(tag);
    TagUtil.setExtraTag(tool, tag);
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:14,代码来源:TraitCursed.java

示例9: afterBlockBreak

import slimeknights.tconstruct.library.utils.TagUtil; //导入方法依赖的package包/类
@Override
public void afterBlockBreak(ItemStack tool, World world, IBlockState state, BlockPos pos, EntityLivingBase player, boolean wasEffective) {
    NBTTagCompound tag = TagUtil.getExtraTag(tool);
    Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
    data.brokenblocks += 1;
    data.write(tag);
    TagUtil.setExtraTag(tool, tag);
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:9,代码来源:TraitSuperHeavy.java

示例10: 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);
        if ((int) data.radius >= 1) {
            int r = Math.min((int) data.radius, 8);
            for (int x = -r; x <= r; x++) {
                for (int y = -r; y <= r; y++) {
                    for (int z = -r; z <= r; z++) {
                        if (MathHelper.sqrt(x * x + y * y + z * z) > r) {
                            continue;
                        }
                        BlockPos nPos = new BlockPos(event.getPos().getX() + x, event.getPos().getY() + y, event.getPos().getZ() + z);
                        if (!(event.getWorld().getBlockState(nPos).equals(Blocks.WATER.getDefaultState()) || event.getWorld().getBlockState(nPos).equals(Blocks.FLOWING_WATER.getDefaultState())))
                            continue;
                        event.getWorld().destroyBlock(nPos, false);
                    }
                }
            }
            data.radius -= r;
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
            TagUtil.setEnchantEffect(tool, false);
            ToolHelper.damageTool(tool, 2 * r, event.getEntityPlayer());
        }

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

示例11: killEntity

import slimeknights.tconstruct.library.utils.TagUtil; //导入方法依赖的package包/类
@SubscribeEvent
public void killEntity(LivingDeathEvent event) {
    if (!(event.getSource().getTrueSource() instanceof EntityPlayer))
        return;
    if (event.getEntityLiving() instanceof EntityPlayer || event.getEntityLiving() instanceof EntityPlayerMP)
        return;
    World w = event.getSource().getTrueSource().getEntityWorld();
    EntityPlayer p = (EntityPlayer) event.getSource().getTrueSource();
    EntityLivingBase target = event.getEntityLiving();
    NBTTagCompound tag = TagUtil.getExtraTag(p.getHeldItemMainhand());
    Data data = Data.read(tag);
    if (!data.mobClass.isEmpty())
        return;
    if (!w.isRemote && random.nextInt((int) target.getMaxHealth()) <= chance && target instanceof EntityLiving) {
        event.setCanceled(true);
        target.setDropItemsWhenDead(false);
        if (data.mobClass.isEmpty()) {
            data.mobClass = target.getClass().getName();
            data.mobName = target.getName();
            data.write(tag);
            TagUtil.setExtraTag(p.getHeldItemMainhand(), tag);
            p.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
            target.setDropItemsWhenDead(false);
            target.setDead();
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:28,代码来源:TraitCatcher.java

示例12: onRightClickItem

import slimeknights.tconstruct.library.utils.TagUtil; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
    World w = event.getWorld();
    BlockPos pos = event.getEntityPlayer().getPosition();
    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.mobClass.isEmpty()) {
            Entity ent = null;
            try {
                ent = (Entity) Class.forName(data.mobClass).getConstructor(World.class).newInstance(w);
            } catch (Exception e) {
                System.out.println(e.toString());
            }

            if (ent != null) {
                ent.setPosition(pos.getX(), pos.getY(), pos.getZ()); // TODO: set to player view target
                w.spawnEntity(ent);
                event.getEntityPlayer().playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
                data.mobClass = "";
                data.mobName = "";
                data.write(tag);
                TagUtil.setExtraTag(tool, tag);
                ToolHelper.damageTool(tool, random.nextInt((int) (ToolHelper.getCurrentDurability(tool) * costMulti)), event.getEntityPlayer());
            }
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:30,代码来源:TraitCatcher.java

示例13: setStats

import slimeknights.tconstruct.library.utils.TagUtil; //导入方法依赖的package包/类
protected static void setStats(NBTTagCompound root, StatNBT data, String key) {
    NBTTagCompound extra = TagUtil.getExtraTag(root);
    NBTTagCompound tag = new NBTTagCompound();
    data.write(tag);
    extra.setTag(key, tag);
    TagUtil.setExtraTag(root, extra);
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:8,代码来源:TraitProgressiveStats.java


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