Search in sources :

Example 81 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Skree by Skelril.

the class SkyFeather method getDataFor.

private static Optional<Data> getDataFor(net.minecraft.item.ItemStack stack) {
    if (stack.getTagCompound() == null) {
        return Optional.empty();
    }
    if (!stack.getTagCompound().hasKey("skree_feather_data")) {
        return Optional.empty();
    }
    NBTTagCompound tag = stack.getTagCompound().getCompoundTag("skree_feather_data");
    int uses = tag.getInteger("uses");
    double radius = tag.getDouble("radius");
    double flight = tag.getDouble("flight");
    double pushBack = tag.getDouble("push_back");
    return Optional.of(new Data(uses, radius, flight, pushBack));
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 82 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Skree by Skelril.

the class RedFeather method getFeatherPower.

public Clause<Integer, Long> getFeatherPower(net.minecraft.item.ItemStack stack) {
    if (stack != null && stack.getItem() == this) {
        long coolDown = 0;
        if (stack.getTagCompound() == null) {
            stack.setTagCompound(new NBTTagCompound());
        }
        if (stack.getTagCompound().hasKey("skree_feather_data")) {
            NBTTagCompound tag = stack.getTagCompound().getCompoundTag("skree_feather_data");
            coolDown = tag.getLong("cool_down");
        }
        return new Clause<>((__getMaxUses() - stack.getItemDamage()) - 1, coolDown);
    }
    return new Clause<>(0, 0L);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Clause(com.skelril.nitro.Clause)

Example 83 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Skree by Skelril.

the class ZoneItemUtil method setMasterToZone.

public static void setMasterToZone(ItemStack stack, String zone) {
    Optional<ZoneService> optService = Sponge.getServiceManager().provide(ZoneService.class);
    if (optService.isPresent()) {
        ZoneService service = optService.get();
        if (stack.getTagCompound() == null) {
            stack.setTagCompound(new NBTTagCompound());
        }
        if (!stack.getTagCompound().hasKey("skree_zone_data")) {
            stack.getTagCompound().setTag("skree_zone_data", new NBTTagCompound());
        }
        NBTTagCompound tag = stack.getTagCompound().getCompoundTag("skree_zone_data");
        tag.setString("zone", zone);
        tag.setInteger("zone_player_count", 1);
        tag.setInteger("zone_max_players", service.getMaxGroupSize(zone).orElse(-1));
        tag.setString("zone_id", UUID.randomUUID().toString());
        attune(stack);
    }
}
Also used : ZoneService(com.skelril.skree.service.ZoneService) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 84 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Skree by Skelril.

the class ZoneItemUtil method createForMaster.

public static org.spongepowered.api.item.inventory.ItemStack createForMaster(org.spongepowered.api.item.inventory.ItemStack inStack, Player zoneOwner) {
    Validate.isTrue(isAttuned(inStack), "Can't create a slave from an unattuned master stack.");
    ItemStack stack = new ItemStack(CustomItemTypes.ZONE_SLAVE_ORB);
    if (stack.getTagCompound() == null) {
        stack.setTagCompound(new NBTTagCompound());
    }
    if (!stack.getTagCompound().hasKey("skree_zone_data")) {
        stack.getTagCompound().setTag("skree_zone_data", new NBTTagCompound());
    }
    NBTTagCompound tag = stack.getTagCompound().getCompoundTag("skree_zone_data");
    tag.setString("zone", getZone(inStack).get());
    tag.setString("zone_id", getZoneID(inStack).get().toString());
    tag.setString("owner_name", zoneOwner.getName());
    tag.setString("owner", zoneOwner.getUniqueId().toString());
    return tf(stack);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 85 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Skree by Skelril.

the class ZoneItemUtil method getGroupOwner.

public static Optional<Player> getGroupOwner(ItemStack stack) {
    if (isZoneSlaveItem(stack) && hasZoneData(stack)) {
        NBTTagCompound tag = stack.getTagCompound().getCompoundTag("skree_zone_data");
        UUID ownerID = UUID.fromString(tag.getString("owner"));
        return Sponge.getServer().getPlayer(ownerID);
    }
    throw new IllegalArgumentException("Invalid ItemStack provided");
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) UUID(java.util.UUID)

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