Most client patches done except the render pipeline.

Someone who has more in depth knowledge of that rendering system will need to do it.
This commit is contained in:
LexManos committed 2018-11-28 22:15:05 -08:00
1 parent b687180e12
commit bf9158172f
109 files changed
+1597 -2275

No files matched your search

@@ -0,0 +1,31 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.resource;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* Represents a generic type of reloadable resource. Used for resource reload filtering.
*/
@OnlyIn(Dist.CLIENT)
public interface IResourceType
{
}
@@ -0,0 +1,46 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.resource;
import java.util.function.Predicate;
import net.minecraft.resources.IResourceManager;
import net.minecraft.resources.IResourceManagerReloadListener;
public interface ISelectiveResourceReloadListener extends IResourceManagerReloadListener
{
@Override
default void onResourceManagerReload(IResourceManager resourceManager)
{
// For compatibility, call the selective version from the non-selective function
onResourceManagerReload(resourceManager, SelectiveReloadStateHandler.INSTANCE.get());
}
/**
* A version of onResourceManager that selectively chooses {@link net.minecraftforge.resource.IResourceType}s
* to reload.
* When using this, the given predicate should be called to ensure the relevant resources should
* be reloaded at this time.
*
* @param resourceManager the resource manager being reloaded
* @param resourcePredicate predicate to test whether any given resource type should be reloaded
*/
void onResourceManagerReload(IResourceManager resourceManager, Predicate<IResourceType> resourcePredicate);
}
@@ -0,0 +1,57 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.resource;
import java.util.Set;
import java.util.function.Predicate;
import com.google.common.collect.Sets;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* Holds methods to create standard predicates to select {@link IResourceType}s that should be reloaded.
*/
@OnlyIn(Dist.CLIENT)
public final class ReloadRequirements
{
/**
* Creates a reload predicate accepting all resource types.
*
* @return a predicate accepting all types
*/
public static Predicate<IResourceType> all()
{
return type -> true;
}
/**
* Creates an inclusive reload predicate. Only given resource types will be loaded along with this.
*
* @param inclusion the set of resource types to be included in the reload
* @return an inclusion predicate based on the given types
*/
public static Predicate<IResourceType> include(IResourceType... inclusion)
{
Set<IResourceType> inclusionSet = Sets.newHashSet(inclusion);
return inclusionSet::contains;
}
}
@@ -0,0 +1,86 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.resource;
import javax.annotation.Nullable;
import java.util.function.Predicate;
import net.minecraft.resources.IResourceManagerReloadListener;
import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.common.ForgeModContainer;
/**
* Handles reload parameters for selective loaders.
*/
public enum SelectiveReloadStateHandler
{
INSTANCE;
@Nullable
private Predicate<IResourceType> currentPredicate = null;
/***
* Pushes a resource type predicate for the current reload.
* Should only be called when initiating a resource reload.
* If a reload is already in progress when this is called, an exception will be thrown.
*
* @param resourcePredicate the resource requirement predicate for the current reload
*/
public void beginReload(Predicate<IResourceType> resourcePredicate)
{
if (this.currentPredicate != null)
{
throw new IllegalStateException("Recursive resource reloading detected");
}
this.currentPredicate = resourcePredicate;
}
/**
* Gets the current reload resource predicate for the initiated reload.
*
* @return the active reload resource predicate, or an accepting one if none in progress
*/
public Predicate<IResourceType> get()
{
if (this.currentPredicate == null && false) // TODO configs || !ForgeMod.selectiveResourceReloadEnabled)
{
return ReloadRequirements.all();
}
return this.currentPredicate;
}
/**
* Finishes the current reload and deletes the previously added reload predicate.
*/
public void endReload()
{
this.currentPredicate = null;
}
//Helpder function for testing if vanilla listeners should reload.
@SuppressWarnings("deprecation")
public boolean test(IResourceManagerReloadListener listener)
{
IResourceType type = listener.getResourceType();
return type == null || get() == null || get().test(type);
}
}
@@ -0,0 +1,54 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.resource;
/**
* An enum of all {@link IResourceType}s used by the Vanilla game. These should be used if handling vanilla-related
* resources.
*/
public enum VanillaResourceType implements IResourceType
{
/**
* Used when block and item models are reloaded and rebaked. This also includes the texture-stitching from that
* phase.
*/
MODELS,
/**
* Used when textures from the {@link net.minecraft.client.renderer.texture.TextureManager} are reloaded. Does not
* effect block or item textures on the texture atlas.
*/
TEXTURES,
/**
* Used when all game sounds are reloaded.
*/
SOUNDS,
/**
* Used when the current language is reloaded.
*/
LANGUAGES,
/**
* Used when all shaders are reloaded.
*/
SHADERS,
}
@@ -0,0 +1,26 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraftforge.resource;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;