Search in sources :

Example 71 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Realistic-Terrain-Generation by Team-RTG.

the class MaterializerRecipes method getMaterializationResult.

public List<ItemStack> getMaterializationResult(ItemStack stack) {
    ItemStack[] inventory = null;
    if (stack.getTagCompound() == null)
        stack.setTagCompound(new NBTTagCompound());
    if (stack.getTagCompound().hasKey("ItemInventory")) {
        NBTTagList items = stack.getTagCompound().getTagList("ItemInventory", 10);
        inventory = new ItemStack[items.tagCount()];
        for (int i = 0; i < items.tagCount(); ++i) {
            NBTTagCompound item = items.getCompoundTagAt(i);
            byte slot = item.getByte("Slot");
            inventory[slot] = ItemStack.loadItemStackFromNBT(item);
        }
    }
    if (inventory == null)
        return null;
    for (ItemStack item : inventory) if (!APIUtils.isCrystal(item))
        return null;
    List<ItemStack> displayList = Lists.newArrayList();
    Iterator<Materialization> iterator = materializationList.iterator();
    Materialization entry;
    do {
        if (!iterator.hasNext())
            return displayList;
        entry = iterator.next();
        if (arrayContainsOtherArray(inventory, entry.input))
            displayList.add(entry.output);
    } while (!arrayContainsOtherArray(inventory, entry.input));
    return displayList;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 72 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Realistic-Terrain-Generation by Team-RTG.

the class NecronomiconCreationRitual method completeRitualClient.

@Override
protected void completeRitualClient(World world, BlockPos pos, EntityPlayer player) {
    TileEntity altar = world.getTileEntity(pos);
    NBTTagCompound compound = new NBTTagCompound();
    NBTTagCompound newItem = new NBTTagCompound();
    altar.writeToNBT(compound);
    NBTTagCompound nbtItem = compound.getCompoundTag("Item");
    if (ItemStack.loadItemStackFromNBT(nbtItem) == null || !ItemStack.loadItemStackFromNBT(nbtItem).isItemEqual(item)) {
        item.writeToNBT(newItem);
        compound.setTag("Item", newItem);
    }
    altar.readFromNBT(compound);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 73 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Realistic-Terrain-Generation by Team-RTG.

the class NecronomiconEnchantmentRitual method completeRitualClient.

@Override
protected void completeRitualClient(World world, BlockPos pos, EntityPlayer player) {
    TileEntity altar = world.getTileEntity(pos);
    NBTTagCompound compound = new NBTTagCompound();
    altar.writeToNBT(compound);
    NBTTagCompound nbtItem = compound.getCompoundTag("Item");
    if (canEnchant(ItemStack.loadItemStackFromNBT(nbtItem))) {
        ItemStack item = ItemStack.loadItemStackFromNBT(nbtItem);
        item.addEnchantment(enchantment.enchantmentobj, enchantment.enchantmentLevel);
        item.writeToNBT(nbtItem);
        compound.setTag("Item", nbtItem);
    }
    altar.readFromNBT(compound);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 74 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ItemSystemLinker method onItemUse.

@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    IBlockState state = worldIn.getBlockState(pos);
    Block block = state.getBlock();
    NBTTagCompound stackCompound = stack.getTagCompound();
    if (stackCompound == null) {
        stackCompound = new NBTTagCompound();
        stack.setTagCompound(stackCompound);
    }
    if (block instanceof BlockHovercraftController) {
        if (!worldIn.isRemote) {
            NBTUtils.writeBlockPosToNBT("controllerPos", pos, stackCompound);
            playerIn.addChatMessage(new TextComponentString("ControllerPos set <" + pos.getX() + ":" + pos.getY() + ":" + pos.getZ() + ">"));
        } else {
            return EnumActionResult.SUCCESS;
        }
    }
    if (block instanceof BlockEtherCompressor) {
        if (!worldIn.isRemote) {
            BlockPos controllerPos = NBTUtils.readBlockPosFromNBT("controllerPos", stackCompound);
            if (controllerPos.equals(BlockPos.ORIGIN)) {
                playerIn.addChatMessage(new TextComponentString("No selected Controller"));
            } else {
                PhysicsWrapperEntity controllerWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, controllerPos);
                PhysicsWrapperEntity engineWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
                if (controllerWrapper != engineWrapper) {
                    playerIn.addChatMessage(new TextComponentString("Controller and Engine are on seperate ships"));
                    return EnumActionResult.SUCCESS;
                }
                TileEntity worldTile = worldIn.getTileEntity(pos);
                if (worldTile instanceof TileEntityEtherCompressor) {
                    TileEntityEtherCompressor tileEntity = (TileEntityEtherCompressor) worldTile;
                    BlockPos gravControllerPos = tileEntity.controllerPos;
                    if (gravControllerPos.equals(BlockPos.ORIGIN)) {
                        playerIn.addChatMessage(new TextComponentString("Set Controller To " + controllerPos.toString()));
                    } else {
                        playerIn.addChatMessage(new TextComponentString("Replaced controller position from: " + gravControllerPos.toString() + " to: " + controllerPos.toString()));
                    }
                    tileEntity.setController(controllerPos);
                }
            }
        } else {
            return EnumActionResult.SUCCESS;
        }
    }
    return EnumActionResult.PASS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockHovercraftController(ValkyrienWarfareControl.Block.BlockHovercraftController) BlockEtherCompressor(ValkyrienWarfareBase.API.Block.EtherCompressor.BlockEtherCompressor) IBlockState(net.minecraft.block.state.IBlockState) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) TileEntityEtherCompressor(ValkyrienWarfareBase.API.Block.EtherCompressor.TileEntityEtherCompressor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 75 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Engine by VoltzEngine-Project.

the class VEProviderShockWave method spawnEffect.

public static void spawnEffect(World world, double x, double y, double z, double motionX, double motionY, double motionZ, float red, float green, float blue, float scale, float distance) {
    PacketSpawnParticle packet = new PacketSpawnParticle("VEP_shockwave", world.provider.dimensionId, x, y, z, motionX, motionY, motionZ);
    packet.otherData = new NBTTagCompound();
    packet.otherData.setFloat("red", red);
    packet.otherData.setFloat("green", green);
    packet.otherData.setFloat("blue", blue);
    packet.otherData.setFloat("scale", scale);
    packet.otherData.setFloat("distance", distance);
    Engine.instance.packetHandler.sendToAllAround(packet, world, x, y, z, 100);
}
Also used : PacketSpawnParticle(com.builtbroken.mc.core.network.packet.PacketSpawnParticle) 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