Search in sources :

Example 61 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Witchworks by Um-Mitternacht.

the class RitualHolder method readNBT.

@SuppressWarnings("unchecked")
public void readNBT(NBTTagCompound cmp) {
    NBTTagCompound tag = cmp.getCompoundTag("ritual_data");
    ritual = KettleRegistry.getRituals().get(tag.getInteger("ritual"));
    energy_left = tag.getInteger("energy_left");
    ticks = tag.getInteger("ticks");
    fail = tag.getBoolean("fail");
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 62 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound 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();
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITileEntityProvider(net.minecraft.block.ITileEntityProvider) IBlockState(net.minecraft.block.state.IBlockState) NBTBase(net.minecraft.nbt.NBTBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) Block(net.minecraft.block.Block) BlockFalling(net.minecraft.block.BlockFalling) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 63 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Witchworks by Um-Mitternacht.

the class TileKettle method potionCustomLogic.

public void potionCustomLogic(EntityPlayer player, EnumHand hand, ItemStack stack) {
    ItemStack brew = new ItemStack(ModItems.BREW_PHIAL_DRINK);
    NBTTagCompound tag = getBrewData();
    if (tag != null) {
        brew.setTagCompound(tag);
        brew.setCount(1 + getBrewMultiplier(player));
        giveItem(player, hand, stack, brew);
        inv.setFluid(null);
        onLiquidChange();
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 64 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Witchworks by Um-Mitternacht.

the class TileKettle method saveItems.

private void saveItems(NBTTagCompound cmp) {
    NBTTagList nbttaglist = new NBTTagList();
    for (int i = 0; i < ingredients.length; ++i) {
        if (!ingredients[i].isEmpty()) {
            NBTTagCompound tag = new NBTTagCompound();
            tag.setByte("slot", (byte) i);
            ingredients[i].writeToNBT(tag);
            nbttaglist.appendTag(tag);
        }
    }
    cmp.setTag(TAG_INGREDIENTS, nbttaglist);
    if (!container.isEmpty()) {
        NBTTagCompound tag = new NBTTagCompound();
        container.writeToNBT(tag);
        cmp.setTag(TAG_CONTAINER, tag);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 65 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Witchworks by Um-Mitternacht.

the class TileMod method writeToNBT.

@Override
public NBTTagCompound writeToNBT(NBTTagCompound par1nbtTagCompound) {
    final NBTTagCompound ret = super.writeToNBT(par1nbtTagCompound);
    writeDataNBT(ret);
    return ret;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3985 NBTTagList (net.minecraft.nbt.NBTTagList)1052 ItemStack (net.minecraft.item.ItemStack)883 BlockPos (net.minecraft.util.math.BlockPos)229 TileEntity (net.minecraft.tileentity.TileEntity)173 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)148 ArrayList (java.util.ArrayList)99 Block (net.minecraft.block.Block)98 ResourceLocation (net.minecraft.util.ResourceLocation)96 IBlockState (net.minecraft.block.state.IBlockState)92 EntityPlayer (net.minecraft.entity.player.EntityPlayer)81 NBTTagString (net.minecraft.nbt.NBTTagString)79 Nonnull (javax.annotation.Nonnull)74 Map (java.util.Map)71 UUID (java.util.UUID)69 NBTBase (net.minecraft.nbt.NBTBase)66 HashMap (java.util.HashMap)64 EnumFacing (net.minecraft.util.EnumFacing)61 NotNull (org.jetbrains.annotations.NotNull)60 Item (net.minecraft.item.Item)55