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