use of net.minecraft.nbt.NBTBase in project ArsMagica2 by Mithion.
the class AMClientEventHandler method onItemTooltip.
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
ItemStack stack = event.itemStack;
if (stack != null && stack.getItem() instanceof ItemArmor) {
double xp = 0;
int armorLevel = 0;
String[] effects = new String[0];
if (stack.hasTagCompound()) {
NBTTagCompound armorCompound = (NBTTagCompound) stack.stackTagCompound.getTag(AMArmor.NBT_KEY_AMPROPS);
if (armorCompound != null) {
xp = armorCompound.getDouble(AMArmor.NBT_KEY_TOTALXP);
armorLevel = armorCompound.getInteger(AMArmor.NBT_KEY_ARMORLEVEL);
String effectsList = armorCompound.getString(AMArmor.NBT_KEY_EFFECTS);
if (effectsList != null && effectsList != "") {
effects = effectsList.split(AMArmor.INFUSION_DELIMITER);
}
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
event.toolTip.add(StatCollector.translateToLocalFormatted("am2.tooltip.armorxp", String.format("%.2f", xp)));
event.toolTip.add(String.format(StatCollector.translateToLocal("am2.tooltip.armorlevel"), armorLevel));
for (String s : effects) {
event.toolTip.add(StatCollector.translateToLocal("am2.tooltip." + s));
}
} else {
event.toolTip.add(StatCollector.translateToLocal("am2.tooltip.shiftForDetails"));
}
} else if (stack.getItem() instanceof ItemBlock) {
if (((ItemBlock) stack.getItem()).field_150939_a == BlocksCommonProxy.manaBattery) {
if (stack.hasTagCompound()) {
NBTTagList list = stack.stackTagCompound.getTagList("Lore", Constants.NBT.TAG_COMPOUND);
if (list != null) {
for (int i = 0; i < list.tagCount(); ++i) {
NBTBase tag = list.getCompoundTagAt(i);
if (tag instanceof NBTTagString) {
event.toolTip.add((((NBTTagString) tag).func_150285_a_()));
}
}
}
}
}
}
}
use of net.minecraft.nbt.NBTBase in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EntityFallingUpBlock method onUpdate.
@Override
public void onUpdate() {
Block block = this.fallTile.getBlock();
if (this.fallTile.getMaterial() == Material.AIR) {
this.setDead();
} else {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.fallTime++ == 0) {
BlockPos blockpos = new BlockPos(this);
if (this.worldObj.getBlockState(blockpos).getBlock() == block) {
this.worldObj.setBlockToAir(blockpos);
} else if (!this.worldObj.isRemote) {
this.setDead();
return;
}
}
if (!this.hasNoGravity()) {
this.motionY += 0.03999999910593033D;
}
CallRunner.onEntityMove(this, this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
if (!this.worldObj.isRemote) {
BlockPos blockpos1 = new BlockPos(this);
if (!onGround && isCollidedVertically) {
IBlockState iblockstate = this.worldObj.getBlockState(blockpos1);
if (// Forge: Don't indent below.
this.worldObj.isAirBlock(new BlockPos(this.posX, this.posY + 1.009999999776482582D, this.posZ)))
if (BlockFalling.canFallThrough(this.worldObj.getBlockState(new BlockPos(this.posX, this.posY + 1.009999999776482582D, this.posZ)))) {
this.isCollidedVertically = false;
return;
}
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
this.motionY *= -0.5D;
if (iblockstate.getBlock() != Blocks.PISTON_EXTENSION) {
this.setDead();
if (!this.canSetAsBlock) {
if (this.worldObj.canBlockBePlaced(block, blockpos1, true, EnumFacing.UP, (Entity) null, (ItemStack) null) && !BlockFalling.canFallThrough(this.worldObj.getBlockState(blockpos1.up())) && worldObj.setBlockState(blockpos1, this.fallTile, 3)) {
if (block instanceof BlockFalling) {
((BlockFalling) block).onEndFalling(this.worldObj, blockpos1);
}
if (this.tileEntityData != null && block instanceof ITileEntityProvider) {
TileEntity tileentity = this.worldObj.getTileEntity(blockpos1);
if (tileentity != null) {
NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
for (String s : this.tileEntityData.getKeySet()) {
NBTBase nbtbase = this.tileEntityData.getTag(s);
if (!"x".equals(s) && !"y".equals(s) && !"z".equals(s)) {
nbttagcompound.setTag(s, nbtbase.copy());
}
}
tileentity.readFromNBT(nbttagcompound);
tileentity.markDirty();
}
}
} else if (this.shouldDropItem && this.worldObj.getGameRules().getBoolean("doEntityDrops")) {
this.entityDropItem(new ItemStack(block, 1, block.damageDropped(this.fallTile)), 0.0F);
}
}
}
} else if (this.fallTime > 100 && !this.worldObj.isRemote && (blockpos1.getY() < 1 || blockpos1.getY() > 256) || this.fallTime > 600) {
if (this.shouldDropItem && this.worldObj.getGameRules().getBoolean("doEntityDrops")) {
this.entityDropItem(new ItemStack(block, 1, block.damageDropped(this.fallTile)), 0.0F);
}
this.setDead();
}
}
}
}
use of net.minecraft.nbt.NBTBase in project Engine by VoltzEngine-Project.
the class EffectLayer method trigger.
public void trigger(World world, double x, double y, double z, double mx, double my, double mz, boolean endPoint, NBTTagCompound nbt) {
VisualEffectProvider provider = VisualEffectRegistry.main.get(effectKey);
if (provider != null) {
NBTTagCompound usedNBT;
if (nbt != null && !nbt.hasNoTags()) {
usedNBT = (NBTTagCompound) nbt.copy();
//Merges base NBT with server nbt
if (this.getNbt() != null) {
for (Object o : getNbt().func_150296_c()) {
if (o instanceof String) {
String key = (String) o;
NBTBase tag = getNbt().getTag(key);
if (tag != null) {
usedNBT.setTag(key, tag);
}
}
}
}
} else if (this.getNbt() != null) {
usedNBT = nbt;
} else {
usedNBT = new NBTTagCompound();
}
Pos renderOffset = this.renderOffset;
if (renderOffset != Pos.zero && (usedNBT.hasKey("yaw") || usedNBT.hasKey("pitch"))) {
float yaw = usedNBT.getFloat("yaw");
float pitch = usedNBT.getFloat("pitch");
angle.set(yaw, pitch, 0);
renderOffset = (Pos) angle.transform(renderOffset);
}
provider.displayEffect(world, x + renderOffset.x(), y + renderOffset.y(), z + renderOffset.z(), mx, my, mz, endPoint, usedNBT);
} else {
Engine.logger().error("Failed to find a visual effect provider for key '" + effectKey + "'");
}
}
use of net.minecraft.nbt.NBTBase in project RecurrentComplex by Ivorforce.
the class TableDataSourceNBTList method getEntryActions.
public List<TableCell> getEntryActions(int index) {
boolean enabled = true;
NBTBase cellNBT = nbt.get(index);
TableCell entryCell = TableDataSourceNBT.cell(cellNBT, delegate, navigator);
TableCellButton earlier = new TableCellButton("", "earlier", getEarlierTitle(), index > 0 && enabled);
earlier.addAction(() -> {
nbt.set(index, nbt.get(index - 1));
nbt.set(index - 1, cellNBT);
delegate.reloadData();
});
TableCellButton later = new TableCellButton("", "later", getLaterTitle(), index < nbt.tagCount() - 1 && enabled);
later.addAction(() -> {
nbt.set(index, nbt.get(index + 1));
nbt.set(index + 1, cellNBT);
delegate.reloadData();
});
TableCellButton delete = new TableCellButton("", "delete", getDeleteTitle(), enabled);
delete.addAction(() -> {
nbt.removeTag(index);
delegate.reloadData();
});
return Arrays.asList(entryCell, earlier, later, delete);
}
use of net.minecraft.nbt.NBTBase in project BetterStorage by copygirl.
the class TileEntityArmorStand method read.
public void read(NBTTagCompound compound) {
rotation = compound.getByte("rotation");
clearItems();
NBTBase itemsTag = compound.getTag("Items");
if (itemsTag instanceof NBTTagList) {
// Backward compatibility.
NBTTagList items = (NBTTagList) itemsTag;
for (int i = 0; i < items.tagCount(); i++) {
NBTTagCompound item = items.getCompoundTagAt(i);
int slot = item.getByte("Slot") & 255;
if ((slot < 0) || (slot >= EnumArmorStandRegion.values().length))
continue;
EnumArmorStandRegion region = EnumArmorStandRegion.values()[slot];
ArmorStandEquipHandler handler = BetterStorageArmorStand.getEquipHandler(region, VanillaArmorStandEquipHandler.ID);
if (handler != null)
setItem(handler, ItemStack.loadItemStackFromNBT(item));
}
} else {
NBTTagCompound items = (NBTTagCompound) itemsTag;
for (EnumArmorStandRegion region : EnumArmorStandRegion.values()) {
NBTTagCompound regionItems = items.getCompoundTag(region.toString());
for (String id : (Set<String>) regionItems.func_150296_c()) {
ItemStack item = ItemStack.loadItemStackFromNBT(regionItems.getCompoundTag(id));
ArmorStandEquipHandler handler = BetterStorageArmorStand.getEquipHandler(region, id);
setItem(handler, item);
}
}
}
}
Aggregations