mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-28 15:56:02 +00:00
Forge 1.19
* Bump pack.mcmeta formats * 1.19 biome modifiers * Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable * Add docs and package-info to client extension interfaces package * Move RenderBlockOverlayEvent hooks to ForgeHooksClient * Add package-infos to client events package * Rename SoundLoadEvent to SoundEngineLoadEvent This reduces confusion from consumers which may think the name SoundLoadEvent refers to an individual sound being loaded rather than the sound engine. * Document and change SoundLoadEvent to fire on mod bus Previously, it fired on both the mod bus and the Forge bus, which is confusing for consumers. * Delete SoundSetupEvent Looking at its original implementation shows that there isn't an appropriate place in the new sound code to reinsert the event, and the place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent. * Perform some cleanup on client events - Removed nullable annotations from ClientPlayerNetworkEvent - Renamed #getPartialTicks methods to #getPartialTick, to be consistent with vanilla's naming of the partial tick - Cleanup documentation to remove line breaks, use the spelling 'cancelled' over 'canceled', and improve docs on existing and new methods. * Remove EntityEvent.CanUpdate Closes MinecraftForge/MinecraftForge#6394 * Switch to Jetbrains nullability annotations * New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent * Remove ForgeWorldPresetScreens * Remove IForgeRegistryEntry * Remove use of List<Throwable> in FML's CompletableFutures * Add docs to mod loading stages, stages, and phases * Gradle 7.4.2 * Use SLF4J in FMLLoader and other subprojects * Switch dynamic versions in subprojects to pinned ones * Switch ForgeRoot and MDK to FG plugin markers * Configure Forge javadoc task The task now uses a custom stylesheet with MCForge elements, and configured to combine the generation from the four FML subprojects (fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project into the javadoc output. * Update docs/md files, for 1.19 update and the move away from IRC to Discord. * Make "Potentially dangerous alternative prefix" a debug warning, not info. Co-authored-by: Curle <[email protected]> Co-authored-by: sciwhiz12 <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
270e778ac5
commit
4ed9117799
1485 files changed
+14960
-15446
No files matched your search
@@ -16,8 +16,8 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType;
|
||||
import net.minecraftforge.common.ToolAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -33,12 +33,12 @@ public class CanToolPerformAction implements LootItemCondition {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public LootItemConditionType getType() {
|
||||
return LOOT_CONDITION_TYPE;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public Set<LootContextParam<?>> getReferencedContextParams() {
|
||||
return ImmutableSet.of(LootContextParams.TOOL);
|
||||
}
|
||||
@@ -53,12 +53,12 @@ public class CanToolPerformAction implements LootItemCondition {
|
||||
}
|
||||
|
||||
public static class Serializer implements net.minecraft.world.level.storage.loot.Serializer<CanToolPerformAction> {
|
||||
public void serialize(JsonObject json, CanToolPerformAction itemCondition, @Nonnull JsonSerializationContext context) {
|
||||
public void serialize(JsonObject json, CanToolPerformAction itemCondition, @NotNull JsonSerializationContext context) {
|
||||
json.addProperty("action", itemCondition.action.name());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CanToolPerformAction deserialize(JsonObject json, @Nonnull JsonDeserializationContext context) {
|
||||
@NotNull
|
||||
public CanToolPerformAction deserialize(JsonObject json, @NotNull JsonDeserializationContext context) {
|
||||
return new CanToolPerformAction(ToolAction.get(json.get("action").getAsString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ import com.google.gson.JsonObject;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Abstract base deserializer for LootModifiers. Takes care of Forge registry things.<br/>
|
||||
@@ -19,28 +17,7 @@ import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
* <code>read</code> method to deserialize from json.
|
||||
* @param <T> the Type to deserialize
|
||||
*/
|
||||
public abstract class GlobalLootModifierSerializer<T extends IGlobalLootModifier> implements IForgeRegistryEntry<GlobalLootModifierSerializer<?>> {
|
||||
private ResourceLocation registryName = null;
|
||||
|
||||
public final GlobalLootModifierSerializer<T> setRegistryName(String name) {
|
||||
if (getRegistryName() != null)
|
||||
throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName());
|
||||
|
||||
this.registryName = GameData.checkPrefix(name, true);
|
||||
return this;
|
||||
}
|
||||
|
||||
//Helpers
|
||||
@Override
|
||||
public final GlobalLootModifierSerializer<T> setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); }
|
||||
|
||||
public final GlobalLootModifierSerializer<T> setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); }
|
||||
|
||||
@Override
|
||||
public final ResourceLocation getRegistryName() {
|
||||
return registryName;
|
||||
}
|
||||
|
||||
public abstract class GlobalLootModifierSerializer<T extends IGlobalLootModifier> {
|
||||
/**
|
||||
* Most mods will likely not need more than<br/>
|
||||
* <code>return new MyModifier(conditionsIn)</code><br/>
|
||||
@@ -68,18 +45,4 @@ public abstract class GlobalLootModifierSerializer<T extends IGlobalLootModifier
|
||||
json.add("conditions", SerializationContext.INSTANCE.serializeConditions(conditions));
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by Forge's registry system.
|
||||
*/
|
||||
@Override
|
||||
public final Class<GlobalLootModifierSerializer<?>> getRegistryType() {
|
||||
return castClass(GlobalLootModifierSerializer.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // Need this wrapper, because generics
|
||||
private static <G> Class<G> castClass(Class<?> cls)
|
||||
{
|
||||
return (Class<G>)cls;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,10 @@
|
||||
|
||||
package net.minecraftforge.common.loot;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implementation that defines what a global loot modifier must implement in order to be functional.
|
||||
@@ -25,6 +23,6 @@ public interface IGlobalLootModifier {
|
||||
* @param context the LootContext, identical to what is passed to loot tables
|
||||
* @return modified loot drops
|
||||
*/
|
||||
@Nonnull
|
||||
List<ItemStack> apply(List<ItemStack> generatedLoot, LootContext context);
|
||||
@NotNull
|
||||
ObjectArrayList<ItemStack> apply(ObjectArrayList<ItemStack> generatedLoot, LootContext context);
|
||||
}
|
||||
@@ -5,15 +5,14 @@
|
||||
|
||||
package net.minecraftforge.common.loot;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
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;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A base implementation of a Global Loot Modifier for modders to extend.
|
||||
@@ -23,7 +22,7 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemConditions;
|
||||
public abstract class LootModifier implements IGlobalLootModifier {
|
||||
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.
|
||||
@@ -32,13 +31,13 @@ public abstract class LootModifier implements IGlobalLootModifier {
|
||||
this.conditions = conditionsIn;
|
||||
this.combinedConditions = LootItemConditions.andConditions(conditionsIn);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public final List<ItemStack> apply(List<ItemStack> generatedLoot, LootContext context) {
|
||||
public final ObjectArrayList<ItemStack> apply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) {
|
||||
return this.combinedConditions.test(context) ? this.doApply(generatedLoot, context) : generatedLoot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies the modifier to the generated loot (all loot conditions have already been checked
|
||||
* and have returned true).
|
||||
@@ -46,6 +45,6 @@ public abstract class LootModifier implements IGlobalLootModifier {
|
||||
* @param context the LootContext, identical to what is passed to loot tables
|
||||
* @return modified loot drops
|
||||
*/
|
||||
@Nonnull
|
||||
protected abstract List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context);
|
||||
@NotNull
|
||||
protected abstract ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context);
|
||||
}
|
||||
@@ -68,32 +68,26 @@ public class LootModifierManager extends SimpleJsonResourceReloadListener {
|
||||
//new way
|
||||
ArrayList<ResourceLocation> finalLocations = new ArrayList<ResourceLocation>();
|
||||
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(Resource iresource : resourceManagerIn.getResources(resourcelocation)) {
|
||||
try ( InputStream inputstream = iresource.getInputStream();
|
||||
Reader reader = new BufferedReader(new InputStreamReader(inputstream, StandardCharsets.UTF_8));
|
||||
) {
|
||||
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();
|
||||
for(JsonElement entry : entryList) {
|
||||
String loc = entry.getAsString();
|
||||
ResourceLocation res = new ResourceLocation(loc);
|
||||
if(finalLocations.contains(res)) finalLocations.remove(res);
|
||||
finalLocations.add(res);
|
||||
}
|
||||
}
|
||||
|
||||
catch (RuntimeException | IOException ioexception) {
|
||||
LOGGER.error("Couldn't read global loot modifier list {} in data pack {}", resourcelocation, iresource.getSourceName(), ioexception);
|
||||
} finally {
|
||||
IOUtils.closeQuietly((Closeable)iresource);
|
||||
//read in all data files from forge:loot_modifiers/global_loot_modifiers in order to do layering
|
||||
for(Resource iresource : resourceManagerIn.getResourceStack(resourcelocation)) {
|
||||
try ( InputStream inputstream = iresource.open();
|
||||
Reader reader = new BufferedReader(new InputStreamReader(inputstream, StandardCharsets.UTF_8));
|
||||
) {
|
||||
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();
|
||||
for(JsonElement entry : entryList) {
|
||||
String loc = entry.getAsString();
|
||||
ResourceLocation res = new ResourceLocation(loc);
|
||||
if(finalLocations.contains(res)) finalLocations.remove(res);
|
||||
finalLocations.add(res);
|
||||
}
|
||||
}
|
||||
} catch (IOException ioexception1) {
|
||||
LOGGER.error("Couldn't read global loot modifier list from {}", resourcelocation, ioexception1);
|
||||
|
||||
catch (RuntimeException | IOException ioexception) {
|
||||
LOGGER.error("Couldn't read global loot modifier list {} in data pack {}", resourcelocation, iresource.sourcePackId(), ioexception);
|
||||
}
|
||||
}
|
||||
//use layered config to fetch modifier data files (modifiers missing from config are disabled)
|
||||
finalLocations.forEach(location -> {
|
||||
|
||||
Reference in new issue
Block a user