mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
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:
1 parent
b687180e12
commit
bf9158172f
109 files changed
+1597
-2275
No files matched your search
@@ -23,8 +23,6 @@ import javax.annotation.Nonnull;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraftforge.client.resource.IResourceType;
|
||||
import net.minecraftforge.client.resource.VanillaResourceType;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -47,7 +45,9 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.client.resource.ISelectiveResourceReloadListener;
|
||||
import net.minecraftforge.resource.IResourceType;
|
||||
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
||||
import net.minecraftforge.resource.VanillaResourceType;
|
||||
|
||||
public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
{
|
||||
|
||||
@@ -70,6 +70,7 @@ import net.minecraft.client.renderer.block.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
@@ -122,10 +123,6 @@ import net.minecraftforge.client.event.sound.PlaySoundEvent;
|
||||
import net.minecraftforge.client.model.ModelDynBucket;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.animation.Animation;
|
||||
import net.minecraftforge.client.resource.IResourceType;
|
||||
import net.minecraftforge.client.resource.ReloadRequirements;
|
||||
import net.minecraftforge.client.resource.SelectiveReloadStateHandler;
|
||||
import net.minecraftforge.client.resource.VanillaResourceType;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -134,6 +131,10 @@ import net.minecraftforge.common.model.ITransformation;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.resource.IResourceType;
|
||||
import net.minecraftforge.resource.ReloadRequirements;
|
||||
import net.minecraftforge.resource.SelectiveReloadStateHandler;
|
||||
import net.minecraftforge.resource.VanillaResourceType;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -669,11 +670,6 @@ public class ForgeHooksClient
|
||||
return from.getItem().shouldCauseReequipAnimation(from, to, changed);
|
||||
}
|
||||
|
||||
public static boolean shouldCauseBlockBreakReset(@Nonnull ItemStack from, @Nonnull ItemStack to)
|
||||
{
|
||||
return from.getItem().shouldCauseBlockBreakReset(from, to);
|
||||
}
|
||||
|
||||
public static BlockFaceUV applyUVLock(BlockFaceUV blockFaceUV, EnumFacing originalSide, ITransformation rotation)
|
||||
{
|
||||
TRSRTransformation global = new TRSRTransformation(rotation.getMatrixVec());
|
||||
@@ -729,7 +725,7 @@ public class ForgeHooksClient
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(new RenderGameOverlayEvent(Animation.getPartialTickTime(), res), BOSSINFO));
|
||||
}
|
||||
|
||||
public static ScreenshotEvent onScreenshot(BufferedImage image, File screenshotFile)
|
||||
public static ScreenshotEvent onScreenshot(NativeImage image, File screenshotFile)
|
||||
{
|
||||
ScreenshotEvent event = new ScreenshotEvent(image, screenshotFile);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
@@ -757,28 +753,6 @@ public class ForgeHooksClient
|
||||
return texture;
|
||||
}
|
||||
|
||||
public static boolean shouldUseVanillaReloadableListener(IResourceManagerReloadListener listener)
|
||||
{
|
||||
Predicate<IResourceType> predicate = SelectiveReloadStateHandler.INSTANCE.get();
|
||||
|
||||
if (listener instanceof ModelManager || listener instanceof ItemRenderer)
|
||||
return predicate.test(VanillaResourceType.MODELS);
|
||||
else if (listener instanceof BlockRendererDispatcher || listener instanceof RenderGlobal)
|
||||
return predicate.test(VanillaResourceType.MODELS);
|
||||
else if (listener instanceof TextureManager || listener instanceof FontRenderer)
|
||||
return predicate.test(VanillaResourceType.TEXTURES);
|
||||
else if (listener instanceof FoliageColorReloadListener || listener instanceof GrassColorReloadListener)
|
||||
return predicate.test(VanillaResourceType.TEXTURES);
|
||||
else if (listener instanceof SoundHandler)
|
||||
return predicate.test(VanillaResourceType.SOUNDS);
|
||||
else if (listener instanceof EntityRenderer)
|
||||
return predicate.test(VanillaResourceType.SHADERS);
|
||||
else if (listener instanceof LanguageManager || listener instanceof SearchTreeManager)
|
||||
return predicate.test(VanillaResourceType.LANGUAGES);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void refreshResources(Minecraft mc, VanillaResourceType... types) {
|
||||
SelectiveReloadStateHandler.INSTANCE.beginReload(ReloadRequirements.include(types));
|
||||
mc.refreshResources();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -37,23 +38,23 @@ import java.io.File;
|
||||
* {@link #resultMessage} contains the {@link ITextComponent} to be returned. If {@code null}, the default vanilla message will be used instead
|
||||
*/
|
||||
@Cancelable
|
||||
public class ScreenshotEvent extends net.minecraftforge.eventbus.api.Event
|
||||
public class ScreenshotEvent extends Event
|
||||
{
|
||||
|
||||
public static final ITextComponent DEFAULT_CANCEL_REASON = new TextComponentString("Screenshot canceled");
|
||||
|
||||
private BufferedImage image;
|
||||
private NativeImage image;
|
||||
private File screenshotFile;
|
||||
|
||||
private ITextComponent resultMessage = null;
|
||||
|
||||
public ScreenshotEvent(BufferedImage image, File screenshotFile)
|
||||
public ScreenshotEvent(NativeImage image, File screenshotFile)
|
||||
{
|
||||
this.image = image;
|
||||
this.screenshotFile = screenshotFile;
|
||||
}
|
||||
|
||||
public BufferedImage getImage()
|
||||
public NativeImage getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ package net.minecraftforge.client.model;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraftforge.client.resource.IResourceType;
|
||||
import net.minecraftforge.client.resource.ISelectiveResourceReloadListener;
|
||||
import net.minecraftforge.client.resource.VanillaResourceType;
|
||||
import net.minecraft.client.renderer.block.model.IUnbakedModel;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.resource.IResourceType;
|
||||
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
||||
import net.minecraftforge.resource.VanillaResourceType;
|
||||
|
||||
public interface ICustomModelLoader extends ISelectiveResourceReloadListener
|
||||
{
|
||||
@@ -52,4 +52,11 @@ public interface ICustomModelLoader extends ISelectiveResourceReloadListener
|
||||
* loads (or reloads) specified model
|
||||
*/
|
||||
IUnbakedModel loadModel(ResourceLocation modelLocation) throws Exception;
|
||||
|
||||
|
||||
@Override
|
||||
default IResourceType getResourceType()
|
||||
{
|
||||
return VanillaResourceType.MODELS;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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.client.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
|
||||
{
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* 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.client.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.client.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);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* 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.client.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;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* 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.client.resource;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.client.resource;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
/**
|
||||
* An enum of all {@link IResourceType}s used by the Vanilla game. These should be used if handling vanilla-related
|
||||
* resources.
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
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,
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* 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.client.resource;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
Reference in new issue
Block a user