本文整理汇总了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);
}
}
}
}
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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());
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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));
}
}
}
示例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));
}
示例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());
}
}
}
示例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();
}
}
}