mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-28 07:55:53 +00:00
Update to 1.17
Update to Official classnames Patchwork Make the game compile and run Merge in the new HUD overlay API Merge in the new render properties API PEEL Use Gradle 7.2 snapshot to fix eclipse integration bug in 7.1, Would use 7.0 but FG needs 7.1 for some reason. New FML installer Update to 1.17.1 Co-authored-by: LexManos <[email protected]> Co-authored-by: SizableShrimp <[email protected]> Co-authored-by: cpw <[email protected]> Co-authored-by: Curle <[email protected]> Co-authored-by: Unnoen <[email protected]> Co-authored-by: covers1624 <[email protected]> Co-authored-by: DaemonUmbra <[email protected]> Co-authored-by: gigaherz <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
064ae6961b
commit
be5446b91c
1990 files changed
+35661
-37544
No files matched your search
@@ -21,9 +21,9 @@ package net.minecraftforge.common.loot;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.loot.ConditionArraySerializer;
|
||||
import net.minecraft.loot.conditions.ILootCondition;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.advancements.critereon.SerializationContext;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
@@ -63,7 +63,7 @@ public abstract class GlobalLootModifierSerializer<T extends IGlobalLootModifier
|
||||
* @param json The full json object (including ILootConditions)
|
||||
* @param conditionsIn An already deserialized list of ILootConditions
|
||||
*/
|
||||
public abstract T read(ResourceLocation location, JsonObject object, ILootCondition[] ailootcondition);
|
||||
public abstract T read(ResourceLocation location, JsonObject object, LootItemCondition[] ailootcondition);
|
||||
|
||||
/**
|
||||
* Write the serializer to json.
|
||||
@@ -77,9 +77,9 @@ public abstract class GlobalLootModifierSerializer<T extends IGlobalLootModifier
|
||||
* Helper to create the json object from the conditions.
|
||||
* Add any extra properties to the returned json.
|
||||
*/
|
||||
public JsonObject makeConditions(ILootCondition[] conditions) {
|
||||
public JsonObject makeConditions(LootItemCondition[] conditions) {
|
||||
JsonObject json = new JsonObject();
|
||||
json.add("conditions", ConditionArraySerializer.INSTANCE.serializeConditions(conditions));
|
||||
json.add("conditions", SerializationContext.INSTANCE.serializeConditions(conditions));
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
|
||||
/**
|
||||
* Implementation that defines what a global loot modifier must implement in order to be functional.
|
||||
|
||||
@@ -24,10 +24,10 @@ import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.loot.conditions.ILootCondition;
|
||||
import net.minecraft.loot.conditions.LootConditionManager;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemConditions;
|
||||
|
||||
/**
|
||||
* A base implementation of a Global Loot Modifier for modders to extend.
|
||||
@@ -35,16 +35,16 @@ import net.minecraft.loot.conditions.LootConditionManager;
|
||||
* implementation that takes care of Forge registry things.
|
||||
*/
|
||||
public abstract class LootModifier implements IGlobalLootModifier {
|
||||
protected final ILootCondition[] conditions;
|
||||
protected final LootItemCondition[] conditions;
|
||||
private final Predicate<LootContext> combinedConditions;
|
||||
|
||||
/**
|
||||
* Constructs a LootModifier.
|
||||
* @param conditionsIn the ILootConditions that need to be matched before the loot is modified.
|
||||
*/
|
||||
protected LootModifier(ILootCondition[] conditionsIn) {
|
||||
protected LootModifier(LootItemCondition[] conditionsIn) {
|
||||
this.conditions = conditionsIn;
|
||||
this.combinedConditions = LootConditionManager.andConditions(conditionsIn);
|
||||
this.combinedConditions = LootItemConditions.andConditions(conditionsIn);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -30,8 +30,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.loot.LootSerializers;
|
||||
import net.minecraft.loot.conditions.ILootCondition;
|
||||
import net.minecraft.world.level.storage.loot.Deserializers;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -43,17 +43,17 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.client.resources.JsonReloadListener;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class LootModifierManager extends JsonReloadListener {
|
||||
public class LootModifierManager extends SimpleJsonResourceReloadListener {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Gson GSON_INSTANCE = LootSerializers.createFunctionSerializer().create();
|
||||
private static final Gson GSON_INSTANCE = Deserializers.createFunctionSerializer().create();
|
||||
|
||||
private Map<ResourceLocation, IGlobalLootModifier> registeredLootModifiers = ImmutableMap.of();
|
||||
private static final String folder = "loot_modifiers";
|
||||
@@ -63,7 +63,7 @@ public class LootModifierManager extends JsonReloadListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply(Map<ResourceLocation, JsonElement> resourceList, IResourceManager resourceManagerIn, IProfiler profilerIn) {
|
||||
protected void apply(Map<ResourceLocation, JsonElement> resourceList, ResourceManager resourceManagerIn, ProfilerFiller profilerIn) {
|
||||
Builder<ResourceLocation, IGlobalLootModifier> builder = ImmutableMap.builder();
|
||||
//old way (for reference)
|
||||
/*Map<IGlobalLootModifier, ResourceLocation> toLocation = new HashMap<IGlobalLootModifier, ResourceLocation>();
|
||||
@@ -84,11 +84,11 @@ public class LootModifierManager extends JsonReloadListener {
|
||||
ResourceLocation resourcelocation = new ResourceLocation("forge","loot_modifiers/global_loot_modifiers.json");
|
||||
try {
|
||||
//read in all data files from forge:loot_modifiers/global_loot_modifiers in order to do layering
|
||||
for(IResource iresource : resourceManagerIn.getResources(resourcelocation)) {
|
||||
for(Resource iresource : resourceManagerIn.getResources(resourcelocation)) {
|
||||
try ( InputStream inputstream = iresource.getInputStream();
|
||||
Reader reader = new BufferedReader(new InputStreamReader(inputstream, StandardCharsets.UTF_8));
|
||||
) {
|
||||
JsonObject jsonobject = JSONUtils.fromJson(GSON_INSTANCE, reader, JsonObject.class);
|
||||
JsonObject jsonobject = GsonHelper.fromJson(GSON_INSTANCE, reader, JsonObject.class);
|
||||
boolean replace = jsonobject.get("replace").getAsBoolean();
|
||||
if(replace) finalLocations.clear();
|
||||
JsonArray entryList = jsonobject.get("entries").getAsJsonArray();
|
||||
@@ -126,14 +126,14 @@ public class LootModifierManager extends JsonReloadListener {
|
||||
private IGlobalLootModifier deserializeModifier(ResourceLocation location, JsonElement element) {
|
||||
if (!element.isJsonObject()) return null;
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
ILootCondition[] lootConditions = GSON_INSTANCE.fromJson(object.get("conditions"), ILootCondition[].class);
|
||||
LootItemCondition[] lootConditions = GSON_INSTANCE.fromJson(object.get("conditions"), LootItemCondition[].class);
|
||||
|
||||
// For backward compatibility with the initial implementation, fall back to using the location as the type.
|
||||
// TODO: Remove fallback in 1.16
|
||||
ResourceLocation serializer = location;
|
||||
if (object.has("type"))
|
||||
{
|
||||
serializer = new ResourceLocation(JSONUtils.getAsString(object, "type"));
|
||||
serializer = new ResourceLocation(GsonHelper.getAsString(object, "type"));
|
||||
}
|
||||
|
||||
return ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.getValue(serializer).read(location, object, lootConditions);
|
||||
|
||||
@@ -22,17 +22,17 @@ package net.minecraftforge.common.loot;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import net.minecraft.loot.ILootSerializer;
|
||||
import net.minecraft.loot.LootConditionType;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.loot.conditions.ILootCondition;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.level.storage.loot.Serializer;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class LootTableIdCondition implements ILootCondition
|
||||
public class LootTableIdCondition implements LootItemCondition
|
||||
{
|
||||
// TODO Forge Registry at some point?
|
||||
public static final LootConditionType LOOT_TABLE_ID = new LootConditionType(new LootTableIdCondition.Serializer());
|
||||
public static final LootItemConditionType LOOT_TABLE_ID = new LootItemConditionType(new LootTableIdCondition.Serializer());
|
||||
public static final ResourceLocation UNKNOWN_LOOT_TABLE = new ResourceLocation("forge", "unknown_loot_table");
|
||||
|
||||
private final ResourceLocation targetLootTableId;
|
||||
@@ -43,7 +43,7 @@ public class LootTableIdCondition implements ILootCondition
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootConditionType getType()
|
||||
public LootItemConditionType getType()
|
||||
{
|
||||
return LOOT_TABLE_ID;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class LootTableIdCondition implements ILootCondition
|
||||
return new Builder(targetLootTableId);
|
||||
}
|
||||
|
||||
public static class Builder implements ILootCondition.IBuilder
|
||||
public static class Builder implements LootItemCondition.Builder
|
||||
{
|
||||
private final ResourceLocation targetLootTableId;
|
||||
|
||||
@@ -70,13 +70,13 @@ public class LootTableIdCondition implements ILootCondition
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILootCondition build()
|
||||
public LootItemCondition build()
|
||||
{
|
||||
return new LootTableIdCondition(this.targetLootTableId);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Serializer implements ILootSerializer<LootTableIdCondition>
|
||||
public static class Serializer implements net.minecraft.world.level.storage.loot.Serializer<LootTableIdCondition>
|
||||
{
|
||||
@Override
|
||||
public void serialize(JsonObject object, LootTableIdCondition instance, JsonSerializationContext ctx)
|
||||
@@ -87,7 +87,7 @@ public class LootTableIdCondition implements ILootCondition
|
||||
@Override
|
||||
public LootTableIdCondition deserialize(JsonObject object, JsonDeserializationContext ctx)
|
||||
{
|
||||
return new LootTableIdCondition(new ResourceLocation(JSONUtils.getAsString(object, "loot_table_id")));
|
||||
return new LootTableIdCondition(new ResourceLocation(GsonHelper.getAsString(object, "loot_table_id")));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user