net.minecraft.world.storage.loot.conditions.LootCondition Java Examples
The following examples show how to use
net.minecraft.world.storage.loot.conditions.LootCondition.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LootTableHelper.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public LootEntry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonobject = JsonUtils.getJsonObject(json, "loot item"); String type = JsonUtils.getString(jsonobject, "type"); if (serializerMap.containsKey(type)) { int weight = JsonUtils.getInt(jsonobject, "weight", 1); int quality = JsonUtils.getInt(jsonobject, "quality", 0); LootCondition[] lootConditions; if (jsonobject.has("conditions")) { lootConditions = JsonUtils.deserializeClass(jsonobject, "conditions", context, LootCondition[].class); } else { lootConditions = new LootCondition[0]; } LootTableEntrySerializer serializer = serializerMap.get(type); return serializer.deserialize(jsonobject, context, weight, quality, lootConditions); } return delegatedDeserializer.deserialize(json, typeOfT, context); }
Example #2
Source File: LootTableHelper.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public JsonElement serialize(LootEntry src, Type typeOfSrc, JsonSerializationContext context) { if (src instanceof SerializableLootEntry) { SerializableLootEntry entry = (SerializableLootEntry) src; JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("weight", entry.getWeight()); jsonObject.addProperty("quality", entry.getQuality()); LootCondition[] conditions = entry.getConditions(); if (conditions.length > 0) { jsonObject.add("conditions", context.serialize(entry.getConditions())); } jsonObject.addProperty("type", entry.getType()); entry.serializeEntry(jsonObject, context); return jsonObject; } return delegatedSerializer.serialize(src, typeOfSrc, context); }
Example #3
Source File: SakuraEventLoader.java From Sakura_mod with MIT License | 5 votes |
public static void addFishingLoot(ItemStack stack,int weight){ LootCondition[] lootConditions = new LootCondition[0]; LootFunction[] setMeta = new LootFunction[] { new SetMetadata(lootConditions, new RandomValueRange(stack.getMetadata())) }; LootEntry entry = new LootEntryItem(stack.getItem(), weight, 0, setMeta, lootConditions, stack.getUnlocalizedName()); FishinglootPools.add(entry); }
Example #4
Source File: LootEntryMetaItem.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static LootEntryMetaItem deserialize(JsonObject object, JsonDeserializationContext context, int weight, int quality, LootCondition[] conditions) { String entryName = net.minecraftforge.common.ForgeHooks.readLootEntryName(object, "item"); LootFunction[] lootFunctions; if (object.has("functions")) { lootFunctions = JsonUtils.deserializeClass(object, "functions", context, LootFunction[].class); } else { lootFunctions = new LootFunction[0]; } String metaItemName = JsonUtils.getString(object, "name"); MetaValueItem metaValueItem = getMetaItem(metaItemName); if (metaValueItem == null) { throw new IllegalArgumentException("Unknown meta item: '" + metaItemName + "'"); } return new LootEntryMetaItem(metaValueItem, weight, quality, lootFunctions, conditions, entryName); }
Example #5
Source File: LootEntryOreDict.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static LootEntryOreDict deserialize(JsonObject object, JsonDeserializationContext context, int weight, int quality, LootCondition[] conditions) { String entryName = net.minecraftforge.common.ForgeHooks.readLootEntryName(object, "item"); LootFunction[] lootFunctions; if (object.has("functions")) { lootFunctions = JsonUtils.deserializeClass(object, "functions", context, LootFunction[].class); } else { lootFunctions = new LootFunction[0]; } String oreDictName = JsonUtils.getString(object, "name"); return new LootEntryOreDict(oreDictName, weight, quality, lootFunctions, conditions, entryName); }
Example #6
Source File: LootEntryMetaItem.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
protected LootEntryMetaItem(MetaValueItem metaValueItem, int weightIn, int qualityIn, LootFunction[] functionsIn, LootCondition[] conditionsIn, String entryName) { super(weightIn, qualityIn, functionsIn, conditionsIn, entryName); this.metaValueItem = metaValueItem; }
Example #7
Source File: AbstractItemLootEntry.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
protected AbstractItemLootEntry(int weightIn, int qualityIn, LootFunction[] functionsIn, LootCondition[] conditionsIn, String entryName) { super(weightIn, qualityIn, conditionsIn, entryName); this.functions = functionsIn; }
Example #8
Source File: LootEntryOreDict.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
protected LootEntryOreDict(String oreDictName, int weightIn, int qualityIn, LootFunction[] functionsIn, LootCondition[] conditionsIn, String entryName) { super(weightIn, qualityIn, functionsIn, conditionsIn, entryName); this.oreDictName = oreDictName; }
Example #9
Source File: LootTableHelper.java From GregTech with GNU Lesser General Public License v3.0 | votes |
T deserialize(JsonObject object, JsonDeserializationContext deserializationContext, int weightIn, int qualityIn, LootCondition[] conditionsIn);
Example #10
Source File: LootTableHelper.java From GregTech with GNU Lesser General Public License v3.0 | votes |
LootCondition[] getConditions();
Example #11
Source File: AbstractItemLootEntry.java From GregTech with GNU Lesser General Public License v3.0 | votes |
AbstractItemLootEntry create(JsonObject jsonObject, int weightIn, int qualityIn, LootFunction[] functionsIn, LootCondition[] conditionsIn, String entryName);