use of net.minecraft.server.v1_16_R1.Item in project MyPet by xXKeyleXx.
the class ConfigItem method load.
public void load(MaterialHolder material, String data) {
MinecraftKey key = new MinecraftKey(material.getLegacyName().getName());
Item item = Item.REGISTRY.get(key);
if (item == null) {
return;
}
net.minecraft.server.v1_9_R2.ItemStack is = new net.minecraft.server.v1_9_R2.ItemStack(item, 1, material.getLegacyName().getData());
if (data != null) {
NBTTagCompound tag = null;
String nbtString = data.trim();
if (nbtString.startsWith("{") && nbtString.endsWith("}")) {
try {
tag = MojangsonParser.parse(nbtString);
} catch (Exception e) {
MyPetApi.getLogger().warning("Error" + ChatColor.RESET + " in config: " + ChatColor.UNDERLINE + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
MyPetApi.getLogger().warning(item.getName() + " " + nbtString);
}
if (tag != null) {
is.setTag(tag);
}
}
}
this.item = CraftItemStack.asCraftMirror(is);
}
use of net.minecraft.server.v1_16_R1.Item in project ORCID-Source by ORCID.
the class ProfileFundingManagerImpl method createItem.
private Item createItem(ProfileFundingEntity profileFundingEntity) {
Item item = new Item();
item.setItemName(profileFundingEntity.getTitle());
item.setItemType(ItemType.FUNDING);
item.setPutCode(String.valueOf(profileFundingEntity.getId()));
return item;
}
use of net.minecraft.server.v1_16_R1.Item in project MyPet by xXKeyleXx.
the class ConfigItem method load.
public void load(String data) {
NBTBase nbtBase = null;
if (data.contains("{")) {
String tagString = data.substring(data.indexOf("{"));
data = data.substring(0, data.indexOf("{"));
try {
nbtBase = MojangsonParser.parse(tagString);
} catch (Exception e) {
MyPetApi.getLogger().warning(ChatColor.RED + "Error" + ChatColor.RESET + " in config: " + ChatColor.YELLOW + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
MyPetApi.getLogger().warning(data + tagString);
}
}
String[] splitData = data.split("\\s+");
if (splitData.length == 0) {
return;
}
Item item = null;
if (splitData.length >= 1) {
if (Util.isInt(splitData[0])) {
int itemId = Integer.parseInt(splitData[0]);
item = Item.getById(itemId);
} else {
item = (Item) Item.REGISTRY.get(splitData[0]);
}
}
if (item != null) {
int itemDamage = 0;
if (splitData.length >= 2) {
if (splitData[1].startsWith("<")) {
this.durabilityMode = DurabilityMode.Smaller;
splitData[1] = splitData[1].substring(1);
} else if (splitData[1].startsWith(">")) {
this.durabilityMode = DurabilityMode.Bigger;
splitData[1] = splitData[1].substring(1);
} else {
this.durabilityMode = DurabilityMode.Equal;
}
if (Util.isInt(splitData[1])) {
itemDamage = Integer.parseInt(splitData[1]);
}
}
net.minecraft.server.v1_7_R4.ItemStack is = new net.minecraft.server.v1_7_R4.ItemStack(item, 1, itemDamage);
if (nbtBase != null) {
is.setTag((NBTTagCompound) nbtBase);
}
this.item = CraftItemStack.asBukkitCopy(is);
}
}
use of net.minecraft.server.v1_16_R1.Item in project ORCID-Source by ORCID.
the class WorkEntityFactory method create.
@Override
public NotificationWorkEntity create(Object source, MappingContext mappingContext) {
mappingContext.getSourceObjects();
NotificationWorkEntity nwe = new NotificationWorkEntity();
String putCode = ((Item) source).getPutCode();
if (putCode != null) {
WorkEntity work = workDao.find(Long.valueOf(putCode));
nwe.setWork(work);
}
return nwe;
}
use of net.minecraft.server.v1_16_R1.Item in project ORCID-Source by ORCID.
the class WorkManagerImpl method createItem.
private Item createItem(WorkEntity workEntity) {
Item item = new Item();
item.setItemName(workEntity.getTitle());
item.setItemType(ItemType.WORK);
item.setPutCode(String.valueOf(workEntity.getId()));
return item;
}
Aggregations