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));
}
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);
}
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);
}
}
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);
}
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");
}
Aggregations