mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +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
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
|
||||
/**
|
||||
* Use {@link ICloudRenderHandler} instead.
|
||||
*
|
||||
* todo: remove in 1.17
|
||||
*/
|
||||
@Deprecated
|
||||
public interface CloudRenderHandler extends IRenderHandler {
|
||||
@Override
|
||||
default void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc) {}
|
||||
|
||||
void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
|
||||
|
||||
public abstract class EffectRenderer
|
||||
{
|
||||
public static final EffectRenderer DUMMY = new EffectRenderer()
|
||||
{
|
||||
@Override
|
||||
public void renderInventoryEffect(MobEffectInstance effect, EffectRenderingInventoryScreen<?> gui, PoseStack mStack, int x, int y, float z)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHUDEffect(MobEffectInstance effect, GuiComponent gui, PoseStack mStack, int x, int y, float z, float alpha)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* If the Potion effect should be displayed in the players inventory
|
||||
*
|
||||
* @param effect the active PotionEffect
|
||||
* @return true to display it (default), false to hide it.
|
||||
*/
|
||||
public boolean shouldRender(MobEffectInstance effect)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the standard PotionEffect text (name and duration) should be drawn when this potion is active.
|
||||
*
|
||||
* @param effect the active PotionEffect
|
||||
* @return true to draw the standard text
|
||||
*/
|
||||
public boolean shouldRenderInvText(MobEffectInstance effect)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Potion effect should be displayed in the player's ingame HUD
|
||||
*
|
||||
* @param effect the active PotionEffect
|
||||
* @return true to display it (default), false to hide it.
|
||||
*/
|
||||
public boolean shouldRenderHUD(MobEffectInstance effect)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to draw the this Potion onto the player's inventory when it's active.
|
||||
* This can be used to e.g. render Potion icons from your own texture.
|
||||
*
|
||||
* @param effect the active PotionEffect
|
||||
* @param gui the gui instance
|
||||
* @param mStack The PoseStack
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z level
|
||||
*/
|
||||
public abstract void renderInventoryEffect(MobEffectInstance effect, EffectRenderingInventoryScreen<?> gui, PoseStack mStack, int x, int y, float z);
|
||||
|
||||
/**
|
||||
* Called to draw the this Potion onto the player's ingame HUD when it's active.
|
||||
* This can be used to e.g. render Potion icons from your own texture.
|
||||
*
|
||||
* @param effect the active PotionEffect
|
||||
* @param gui the gui instance
|
||||
* @param mStack The PoseStack
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z level
|
||||
* @param alpha the alpha value, blinks when the potion is about to run out
|
||||
*/
|
||||
public abstract void renderHUDEffect(MobEffectInstance effect, GuiComponent gui, PoseStack mStack, int x, int y, float z, float alpha);
|
||||
}
|
||||
@@ -21,11 +21,11 @@ package net.minecraftforge.client;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
public class FluidContainerColorer implements IItemColor
|
||||
public class FluidContainerColorer implements ItemColor
|
||||
{
|
||||
@Override
|
||||
public int getColor(@Nonnull ItemStack stack, int tintIndex)
|
||||
|
||||
@@ -20,68 +20,69 @@
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MainWindow;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHelper;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.ClientBossInfo;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens;
|
||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.network.play.NetworkPlayerInfo;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldPreset;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogType;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.entity.model.BipedModel;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.model.RenderMaterial;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.Usage;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.RecipeManager;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.MovementInput;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement.Usage;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.client.player.Input;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraftforge.client.event.*;
|
||||
import net.minecraftforge.client.event.sound.PlaySoundEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
@@ -93,11 +94,10 @@ import net.minecraftforge.common.model.TransformationHelper;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||
import net.minecraftforge.fmlclient.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.StartupMessageManager;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.resource.ReloadRequirements;
|
||||
import net.minecraftforge.resource.SelectiveReloadStateHandler;
|
||||
import net.minecraftforge.resource.VanillaResourceType;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -125,54 +125,58 @@ import static net.minecraftforge.fml.VersionChecker.Status.BETA_OUTDATED;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL20.*;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
|
||||
public class ForgeHooksClient
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
//private static final ResourceLocation ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
||||
|
||||
public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EquipmentSlotType slot, String type)
|
||||
public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EquipmentSlot slot, String type)
|
||||
{
|
||||
String result = armor.getItem().getArmorTexture(armor, entity, slot, type);
|
||||
return result != null ? result : _default;
|
||||
}
|
||||
|
||||
//TODO: Rename to onDrawHighlight
|
||||
public static boolean onDrawBlockHighlight(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
|
||||
public static boolean onDrawBlockHighlight(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers)
|
||||
{
|
||||
switch (target.getType()) {
|
||||
case BLOCK:
|
||||
if (!(target instanceof BlockRayTraceResult)) return false;
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightBlock(context, info, target, partialTicks, matrix, buffers));
|
||||
if (!(target instanceof BlockHitResult)) return false;
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawSelectionEvent.HighlightBlock(context, info, target, partialTicks, matrix, buffers));
|
||||
case ENTITY:
|
||||
if (!(target instanceof EntityRayTraceResult)) return false;
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightEntity(context, info, target, partialTicks, matrix, buffers));
|
||||
if (!(target instanceof EntityHitResult)) return false;
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawSelectionEvent.HighlightEntity(context, info, target, partialTicks, matrix, buffers));
|
||||
default:
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent(context, info, target, partialTicks, matrix, buffers));
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawSelectionEvent(context, info, target, partialTicks, matrix, buffers));
|
||||
}
|
||||
}
|
||||
|
||||
public static void dispatchRenderLast(WorldRenderer context, MatrixStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano)
|
||||
public static void dispatchRenderLast(LevelRenderer context, PoseStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new RenderWorldLastEvent(context, mat, partialTicks, projectionMatrix, finishTimeNano));
|
||||
}
|
||||
|
||||
public static boolean renderSpecificFirstPersonHand(Hand hand, MatrixStack mat, IRenderTypeBuffer buffers, int light, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
|
||||
public static boolean renderSpecificFirstPersonHand(InteractionHand hand, PoseStack mat, MultiBufferSource buffers, int light, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(hand, mat, buffers, light, partialTicks, interpPitch, swingProgress, equipProgress, stack));
|
||||
}
|
||||
|
||||
public static void onTextureStitchedPre(AtlasTexture map, Set<ResourceLocation> resourceLocations)
|
||||
public static void onTextureStitchedPre(TextureAtlas map, Set<ResourceLocation> resourceLocations)
|
||||
{
|
||||
StartupMessageManager.mcLoaderConsumer().ifPresent(c->c.accept("Atlas Stitching : "+map.location().toString()));
|
||||
ModLoader.get().postEvent(new TextureStitchEvent.Pre(map, resourceLocations));
|
||||
// ModelLoader.White.INSTANCE.register(map); // TODO Custom TAS
|
||||
Atlases.SIGN_MATERIALS.values().stream()
|
||||
Sheets.SIGN_MATERIALS.values().stream()
|
||||
.filter(rm -> rm.atlasLocation().equals(map.location()))
|
||||
.forEach(rm -> resourceLocations.add(rm.texture()));
|
||||
}
|
||||
|
||||
public static void onTextureStitchedPost(AtlasTexture map)
|
||||
public static void onTextureStitchedPost(TextureAtlas map)
|
||||
{
|
||||
ModLoader.get().postEvent(new TextureStitchEvent.Post(map));
|
||||
}
|
||||
@@ -194,9 +198,9 @@ public class ForgeHooksClient
|
||||
renderLayer.set(layer);
|
||||
}
|
||||
|
||||
public static <A extends BipedModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType slot, A _default)
|
||||
public static <A extends HumanoidModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot slot, A _default)
|
||||
{
|
||||
A model = itemStack.getItem().getArmorModel(entityLiving, itemStack, slot, _default);
|
||||
A model = RenderProperties.get(itemStack).getArmorModel(entityLiving, itemStack, slot, _default);
|
||||
return model == null ? _default : model;
|
||||
}
|
||||
|
||||
@@ -226,14 +230,14 @@ public class ForgeHooksClient
|
||||
return MinecraftForge.EVENT_BUS.post(new MouseEvent());
|
||||
}
|
||||
*/
|
||||
public static float getOffsetFOV(PlayerEntity entity, float fov)
|
||||
public static float getOffsetFOV(Player entity, float fov)
|
||||
{
|
||||
FOVUpdateEvent fovUpdateEvent = new FOVUpdateEvent(entity, fov);
|
||||
MinecraftForge.EVENT_BUS.post(fovUpdateEvent);
|
||||
return fovUpdateEvent.getNewfov();
|
||||
}
|
||||
|
||||
public static double getFOVModifier(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, double fov) {
|
||||
public static double getFOVModifier(GameRenderer renderer, Camera info, double renderPartialTicks, double fov) {
|
||||
EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, info, renderPartialTicks, fov);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getFOV();
|
||||
@@ -248,22 +252,16 @@ public class ForgeHooksClient
|
||||
//RenderingRegistry.registerBlockHandler(RenderBlockFluid.instance);
|
||||
}
|
||||
|
||||
@Deprecated // TODO: Remove in 1.17
|
||||
public static void renderMainMenu(MainMenuScreen gui, MatrixStack mStack, FontRenderer font, int width, int height)
|
||||
{
|
||||
renderMainMenu(gui, mStack, font, width, height, -1);
|
||||
}
|
||||
|
||||
public static void renderMainMenu(MainMenuScreen gui, MatrixStack mStack, FontRenderer font, int width, int height, int alpha)
|
||||
public static void renderMainMenu(TitleScreen gui, PoseStack mStack, Font font, int width, int height, int alpha)
|
||||
{
|
||||
VersionChecker.Status status = ForgeVersion.getStatus();
|
||||
if (status == BETA || status == BETA_OUTDATED)
|
||||
{
|
||||
// render a warning at the top of the screen,
|
||||
ITextComponent line = new TranslationTextComponent("forge.update.beta.1", TextFormatting.RED, TextFormatting.RESET).withStyle(TextFormatting.RED);
|
||||
AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (0 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
|
||||
line = new TranslationTextComponent("forge.update.beta.2");
|
||||
AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (1 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
|
||||
Component line = new TranslatableComponent("forge.update.beta.1", ChatFormatting.RED, ChatFormatting.RESET).withStyle(ChatFormatting.RED);
|
||||
GuiComponent.drawCenteredString(mStack, font, line, width / 2, 4 + (0 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
|
||||
line = new TranslatableComponent("forge.update.beta.2");
|
||||
GuiComponent.drawCenteredString(mStack, font, line, width / 2, 4 + (1 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
|
||||
}
|
||||
|
||||
String line = null;
|
||||
@@ -281,7 +279,7 @@ public class ForgeHooksClient
|
||||
}
|
||||
|
||||
public static String forgeStatusLine;
|
||||
public static ISound playSound(SoundEngine manager, ISound sound)
|
||||
public static SoundInstance playSound(SoundEngine manager, SoundInstance sound)
|
||||
{
|
||||
PlaySoundEvent e = new PlaySoundEvent(manager, sound);
|
||||
MinecraftForge.EVENT_BUS.post(e);
|
||||
@@ -296,33 +294,33 @@ public class ForgeHooksClient
|
||||
return worldRenderPass;
|
||||
}
|
||||
|
||||
public static void drawScreen(Screen screen, MatrixStack mStack, int mouseX, int mouseY, float partialTicks)
|
||||
public static void drawScreen(Screen screen, PoseStack mStack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if (!MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Pre(screen, mStack, mouseX, mouseY, partialTicks)))
|
||||
screen.render(mStack, mouseX, mouseY, partialTicks);
|
||||
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(screen, mStack, mouseX, mouseY, partialTicks));
|
||||
}
|
||||
|
||||
public static float getFogDensity(FogType type, ActiveRenderInfo info, float partial, float density)
|
||||
public static float getFogDensity(FogMode type, Camera info, float partial, float density)
|
||||
{
|
||||
EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(type, info, partial, density);
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return event.getDensity();
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void onFogRender(FogType type, ActiveRenderInfo info, float partial, float distance)
|
||||
public static void onFogRender(FogMode type, Camera info, float partial, float distance)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(type, info, partial, distance));
|
||||
}
|
||||
|
||||
public static EntityViewRenderEvent.CameraSetup onCameraSetup(GameRenderer renderer, ActiveRenderInfo info, float partial)
|
||||
public static EntityViewRenderEvent.CameraSetup onCameraSetup(GameRenderer renderer, Camera info, float partial)
|
||||
{
|
||||
EntityViewRenderEvent.CameraSetup event = new EntityViewRenderEvent.CameraSetup(renderer, info, partial, info.getYRot(), info.getXRot(), 0);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void onModelBake(ModelManager modelManager, Map<ResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
|
||||
public static void onModelBake(ModelManager modelManager, Map<ResourceLocation, BakedModel> modelRegistry, ModelLoader modelLoader)
|
||||
{
|
||||
ModLoader.get().postEvent(new ModelBakeEvent(modelManager, modelRegistry, modelLoader));
|
||||
modelLoader.onPostBakeEvent(modelRegistry);
|
||||
@@ -335,9 +333,9 @@ public class ForgeHooksClient
|
||||
flipXNormal = new Matrix3f(flipX);
|
||||
}
|
||||
|
||||
public static IBakedModel handleCameraTransforms(MatrixStack matrixStack, IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType, boolean leftHandHackery)
|
||||
public static BakedModel handleCameraTransforms(PoseStack matrixStack, BakedModel model, ItemTransforms.TransformType cameraTransformType, boolean leftHandHackery)
|
||||
{
|
||||
MatrixStack stack = new MatrixStack();
|
||||
PoseStack stack = new PoseStack();
|
||||
model = model.handlePerspective(cameraTransformType, stack);
|
||||
|
||||
// If the stack is not empty, the code has added a matrix for us to use.
|
||||
@@ -466,24 +464,24 @@ public class ForgeHooksClient
|
||||
}*/
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static TextureAtlasSprite[] getFluidSprites(IBlockDisplayReader world, BlockPos pos, FluidState fluidStateIn)
|
||||
public static TextureAtlasSprite[] getFluidSprites(BlockAndTintGetter world, BlockPos pos, FluidState fluidStateIn)
|
||||
{
|
||||
ResourceLocation overlayTexture = fluidStateIn.getType().getAttributes().getOverlayTexture();
|
||||
return new TextureAtlasSprite[] {
|
||||
Minecraft.getInstance().getTextureAtlas(AtlasTexture.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getStillTexture(world, pos)),
|
||||
Minecraft.getInstance().getTextureAtlas(AtlasTexture.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getFlowingTexture(world, pos)),
|
||||
overlayTexture == null ? null : Minecraft.getInstance().getTextureAtlas(AtlasTexture.LOCATION_BLOCKS).apply(overlayTexture),
|
||||
Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getStillTexture(world, pos)),
|
||||
Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getFlowingTexture(world, pos)),
|
||||
overlayTexture == null ? null : Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(overlayTexture),
|
||||
};
|
||||
}
|
||||
|
||||
public static void gatherFluidTextures(Set<RenderMaterial> textures)
|
||||
public static void gatherFluidTextures(Set<Material> textures)
|
||||
{
|
||||
ForgeRegistries.FLUIDS.getValues().stream()
|
||||
.flatMap(ForgeHooksClient::getFluidMaterials)
|
||||
.forEach(textures::add);
|
||||
}
|
||||
|
||||
public static Stream<RenderMaterial> getFluidMaterials(Fluid fluid)
|
||||
public static Stream<Material> getFluidMaterials(Fluid fluid)
|
||||
{
|
||||
return fluid.getAttributes().getTextures()
|
||||
.filter(Objects::nonNull)
|
||||
@@ -491,9 +489,9 @@ public class ForgeHooksClient
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static RenderMaterial getBlockMaterial(ResourceLocation loc)
|
||||
public static Material getBlockMaterial(ResourceLocation loc)
|
||||
{
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, loc);
|
||||
return new Material(TextureAtlas.LOCATION_BLOCKS, loc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -565,7 +563,7 @@ public class ForgeHooksClient
|
||||
return from.getItem().shouldCauseReequipAnimation(from, to, changed);
|
||||
}
|
||||
|
||||
public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(MatrixStack mStack, MainWindow res, ClientBossInfo bossInfo, int x, int y, int increment)
|
||||
public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(PoseStack mStack, Window res, LerpingBossEvent bossInfo, int x, int y, int increment)
|
||||
{
|
||||
RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(mStack, new RenderGameOverlayEvent(mStack, Animation.getPartialTickTime(), res),
|
||||
BOSSINFO, bossInfo, x, y, increment);
|
||||
@@ -573,7 +571,7 @@ public class ForgeHooksClient
|
||||
return evt;
|
||||
}
|
||||
|
||||
public static void bossBarRenderPost(MatrixStack mStack, MainWindow res)
|
||||
public static void bossBarRenderPost(PoseStack mStack, Window res)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(mStack, new RenderGameOverlayEvent(mStack, Animation.getPartialTickTime(), res), BOSSINFO));
|
||||
}
|
||||
@@ -585,7 +583,7 @@ public class ForgeHooksClient
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void onClientChangeGameMode(NetworkPlayerInfo info, GameType currentGameMode, GameType newGameMode)
|
||||
public static void onClientChangeGameMode(PlayerInfo info, GameType currentGameMode, GameType newGameMode)
|
||||
{
|
||||
if (currentGameMode != newGameMode)
|
||||
{
|
||||
@@ -595,24 +593,22 @@ public class ForgeHooksClient
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static IBakedModel handlePerspective(IBakedModel model, ItemCameraTransforms.TransformType type, MatrixStack stack)
|
||||
public static BakedModel handlePerspective(BakedModel model, ItemTransforms.TransformType type, PoseStack stack)
|
||||
{
|
||||
TransformationMatrix tr = TransformationHelper.toTransformation(model.getTransforms().getTransform(type));
|
||||
Transformation tr = TransformationHelper.toTransformation(model.getTransforms().getTransform(type));
|
||||
if(!tr.isIdentity()) {
|
||||
tr.push(stack);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public static void onInputUpdate(PlayerEntity player, MovementInput movementInput)
|
||||
public static void onInputUpdate(Player player, Input movementInput)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new InputUpdateEvent(player, movementInput));
|
||||
}
|
||||
|
||||
public static void refreshResources(Minecraft mc, VanillaResourceType... types) {
|
||||
SelectiveReloadStateHandler.INSTANCE.beginReload(ReloadRequirements.include(types));
|
||||
mc.reloadResourcePacks();
|
||||
SelectiveReloadStateHandler.INSTANCE.endReload();
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button)
|
||||
@@ -651,18 +647,18 @@ public class ForgeHooksClient
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseScrollPre(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta)
|
||||
public static boolean onGuiMouseScrollPre(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta)
|
||||
{
|
||||
MainWindow mainWindow = guiScreen.getMinecraft().getWindow();
|
||||
Window mainWindow = guiScreen.getMinecraft().getWindow();
|
||||
double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth();
|
||||
double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight();
|
||||
Event event = new GuiScreenEvent.MouseScrollEvent.Pre(guiScreen, mouseX, mouseY, scrollDelta);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseScrollPost(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta)
|
||||
public static boolean onGuiMouseScrollPost(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta)
|
||||
{
|
||||
MainWindow mainWindow = guiScreen.getMinecraft().getWindow();
|
||||
Window mainWindow = guiScreen.getMinecraft().getWindow();
|
||||
double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth();
|
||||
double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight();
|
||||
Event event = new GuiScreenEvent.MouseScrollEvent.Post(guiScreen, mouseX, mouseY, scrollDelta);
|
||||
@@ -741,9 +737,9 @@ public class ForgeHooksClient
|
||||
MinecraftForge.EVENT_BUS.post(new InputEvent.KeyInputEvent(key, scanCode, action, modifiers));
|
||||
}
|
||||
|
||||
public static boolean onMouseScroll(MouseHelper mouseHelper, double scrollDelta)
|
||||
public static boolean onMouseScroll(MouseHandler mouseHelper, double scrollDelta)
|
||||
{
|
||||
Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftPressed(), mouseHelper.isMiddleDown(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos());
|
||||
Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftPressed(), mouseHelper.isMiddlePressed(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos());
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@@ -752,22 +748,22 @@ public class ForgeHooksClient
|
||||
return MinecraftForge.EVENT_BUS.post(new InputEvent.RawMouseEvent(button, action, mods));
|
||||
}
|
||||
|
||||
public static InputEvent.ClickInputEvent onClickInput(int button, KeyBinding keyBinding, Hand hand)
|
||||
public static InputEvent.ClickInputEvent onClickInput(int button, KeyMapping keyBinding, InteractionHand hand)
|
||||
{
|
||||
InputEvent.ClickInputEvent event = new InputEvent.ClickInputEvent(button, keyBinding, hand);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void drawItemLayered(ItemRenderer renderer, IBakedModel modelIn, ItemStack itemStackIn, MatrixStack matrixStackIn,
|
||||
IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn, boolean fabulous)
|
||||
public static void drawItemLayered(ItemRenderer renderer, BakedModel modelIn, ItemStack itemStackIn, PoseStack matrixStackIn,
|
||||
MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn, boolean fabulous)
|
||||
{
|
||||
for(com.mojang.datafixers.util.Pair<IBakedModel,RenderType> layerModel : modelIn.getLayerModels(itemStackIn, fabulous))
|
||||
for(com.mojang.datafixers.util.Pair<BakedModel,RenderType> layerModel : modelIn.getLayerModels(itemStackIn, fabulous))
|
||||
{
|
||||
IBakedModel layer = layerModel.getFirst();
|
||||
BakedModel layer = layerModel.getFirst();
|
||||
RenderType rendertype = layerModel.getSecond();
|
||||
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(rendertype); // neded for compatibility with MultiLayerModels
|
||||
IVertexBuilder ivertexbuilder;
|
||||
VertexConsumer ivertexbuilder;
|
||||
if (fabulous)
|
||||
{
|
||||
ivertexbuilder = ItemRenderer.getFoilBufferDirect(bufferIn, rendertype, true, itemStackIn.hasFoil());
|
||||
@@ -781,7 +777,7 @@ public class ForgeHooksClient
|
||||
|
||||
public static boolean isNameplateInRenderDistance(Entity entity, double squareDistance) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
final ModifiableAttributeInstance attribute = ((LivingEntity) entity).getAttribute(ForgeMod.NAMETAG_DISTANCE.get());
|
||||
final AttributeInstance attribute = ((LivingEntity) entity).getAttribute(ForgeMod.NAMETAG_DISTANCE.get());
|
||||
if (attribute != null) {
|
||||
return !(squareDistance > (attribute.getValue() * attribute.getValue()));
|
||||
}
|
||||
@@ -789,13 +785,13 @@ public class ForgeHooksClient
|
||||
return !(squareDistance > 4096.0f);
|
||||
}
|
||||
|
||||
public static void renderPistonMovedBlocks(BlockPos pos, BlockState state, MatrixStack stack, IRenderTypeBuffer buffer, World world, boolean checkSides, int combinedOverlay, BlockRendererDispatcher blockRenderer) {
|
||||
public static void renderPistonMovedBlocks(BlockPos pos, BlockState state, PoseStack stack, MultiBufferSource buffer, Level world, boolean checkSides, int combinedOverlay, BlockRenderDispatcher blockRenderer) {
|
||||
RenderType.chunkBufferLayers().stream()
|
||||
.filter(t -> RenderTypeLookup.canRenderInLayer(state, t))
|
||||
.filter(t -> ItemBlockRenderTypes.canRenderInLayer(state, t))
|
||||
.forEach(rendertype ->
|
||||
{
|
||||
setRenderLayer(rendertype);
|
||||
IVertexBuilder ivertexbuilder = buffer.getBuffer(rendertype == RenderType.translucent() ? RenderType.translucentMovingBlock() : rendertype);
|
||||
VertexConsumer ivertexbuilder = buffer.getBuffer(rendertype == RenderType.translucent() ? RenderType.translucentMovingBlock() : rendertype);
|
||||
blockRenderer.getModelRenderer().tesselateBlock(world, blockRenderer.getBlockModel(state), state, pos, stack, ivertexbuilder, checkSides, new Random(), state.getSeed(pos), combinedOverlay);
|
||||
});
|
||||
setRenderLayer(null);
|
||||
@@ -806,37 +802,42 @@ public class ForgeHooksClient
|
||||
ForgeWorldTypeScreens.registerTypes();
|
||||
}
|
||||
|
||||
public static BiomeGeneratorTypeScreens.IFactory getBiomeGeneratorTypeScreenFactory(Optional<BiomeGeneratorTypeScreens> generator, @Nullable BiomeGeneratorTypeScreens.IFactory biomegeneratortypescreens$ifactory)
|
||||
public static WorldPreset.PresetEditor getBiomeGeneratorTypeScreenFactory(Optional<WorldPreset> generator, @Nullable WorldPreset.PresetEditor biomegeneratortypescreens$ifactory)
|
||||
{
|
||||
return ForgeWorldTypeScreens.getGeneratorScreenFactory(generator, biomegeneratortypescreens$ifactory);
|
||||
}
|
||||
|
||||
public static boolean hasBiomeGeneratorSettingsOptionsScreen(Optional<BiomeGeneratorTypeScreens> generator)
|
||||
public static boolean hasBiomeGeneratorSettingsOptionsScreen(Optional<WorldPreset> generator)
|
||||
{
|
||||
return getBiomeGeneratorTypeScreenFactory(generator, null) != null;
|
||||
}
|
||||
|
||||
public static Optional<BiomeGeneratorTypeScreens> getWorldTypeFromGenerator(DimensionGeneratorSettings dimensionGeneratorSettings)
|
||||
public static Optional<WorldPreset> getWorldTypeFromGenerator(WorldGenSettings dimensionGeneratorSettings)
|
||||
{
|
||||
return BiomeGeneratorTypeScreens.of(dimensionGeneratorSettings);
|
||||
return WorldPreset.of(dimensionGeneratorSettings);
|
||||
}
|
||||
|
||||
public static Optional<BiomeGeneratorTypeScreens> getDefaultWorldType()
|
||||
public static Optional<WorldPreset> getDefaultWorldType()
|
||||
{
|
||||
return Optional.of(ForgeWorldTypeScreens.getDefaultGenerator());
|
||||
}
|
||||
|
||||
public static boolean shouldRender(MobEffectInstance effectInstance)
|
||||
{
|
||||
return RenderProperties.getEffectRenderer(effectInstance).shouldRender(effectInstance);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static TextureAtlasSprite loadTextureAtlasSprite(
|
||||
AtlasTexture atlasTexture,
|
||||
IResourceManager resourceManager, TextureAtlasSprite.Info textureInfo,
|
||||
IResource resource,
|
||||
TextureAtlas textureAtlas,
|
||||
ResourceManager resourceManager, TextureAtlasSprite.Info textureInfo,
|
||||
Resource resource,
|
||||
int atlasWidth, int atlasHeight,
|
||||
int spriteX, int spriteY, int mipmapLevel,
|
||||
NativeImage image
|
||||
)
|
||||
{
|
||||
ForgeTextureMetadata metadata = ForgeTextureMetadata.forResource(resource);
|
||||
return metadata.getLoader() == null ? null : metadata.getLoader().load(atlasTexture, resourceManager, textureInfo, resource, atlasWidth, atlasHeight, spriteX, spriteY, mipmapLevel, image);
|
||||
return metadata.getLoader() == null ? null : metadata.getLoader().load(textureAtlas, resourceManager, textureInfo, resource, atlasWidth, atlasHeight, spriteX, spriteY, mipmapLevel, image);
|
||||
}
|
||||
}
|
||||
@@ -21,15 +21,14 @@ package net.minecraftforge.client;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderState;
|
||||
import net.minecraft.client.renderer.RenderState.TextureState;
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
import net.minecraft.client.renderer.RenderStateShard.TextureStateShard;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderType.State;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.common.util.NonNullLazy;
|
||||
import net.minecraftforge.common.util.NonNullSupplier;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -38,13 +37,13 @@ import java.util.function.Supplier;
|
||||
@SuppressWarnings("deprecation")
|
||||
public enum ForgeRenderTypes
|
||||
{
|
||||
ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(AtlasTexture.LOCATION_BLOCKS)),
|
||||
ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(AtlasTexture.LOCATION_BLOCKS)),
|
||||
ITEM_LAYERED_CUTOUT_MIPPED(()-> getItemLayeredCutoutMipped(AtlasTexture.LOCATION_BLOCKS)),
|
||||
ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(AtlasTexture.LOCATION_BLOCKS)),
|
||||
ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(AtlasTexture.LOCATION_BLOCKS)),
|
||||
ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(AtlasTexture.LOCATION_BLOCKS)),
|
||||
ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(AtlasTexture.LOCATION_BLOCKS, false));
|
||||
ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(TextureAtlas.LOCATION_BLOCKS)),
|
||||
ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(TextureAtlas.LOCATION_BLOCKS)),
|
||||
ITEM_LAYERED_CUTOUT_MIPPED(()-> getItemLayeredCutoutMipped(TextureAtlas.LOCATION_BLOCKS)),
|
||||
ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(TextureAtlas.LOCATION_BLOCKS)),
|
||||
ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(TextureAtlas.LOCATION_BLOCKS)),
|
||||
ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(TextureAtlas.LOCATION_BLOCKS)),
|
||||
ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(TextureAtlas.LOCATION_BLOCKS, false));
|
||||
|
||||
public static boolean enableTextTextureLinearFiltering = false;
|
||||
|
||||
@@ -150,7 +149,7 @@ public enum ForgeRenderTypes
|
||||
|
||||
private static class Internal extends RenderType
|
||||
{
|
||||
private Internal(String name, VertexFormat fmt, int glMode, int size, boolean doCrumbling, boolean depthSorting, Runnable onEnable, Runnable onDisable)
|
||||
private Internal(String name, VertexFormat fmt, VertexFormat.Mode glMode, int size, boolean doCrumbling, boolean depthSorting, Runnable onEnable, Runnable onDisable)
|
||||
{
|
||||
super(name, fmt, glMode, size, doCrumbling, depthSorting, onEnable, onDisable);
|
||||
throw new IllegalStateException("This class must not be instantiated");
|
||||
@@ -159,102 +158,102 @@ public enum ForgeRenderTypes
|
||||
public static RenderType unsortedTranslucent(ResourceLocation textureLocation)
|
||||
{
|
||||
final boolean sortingEnabled = false;
|
||||
State renderState = State.builder()
|
||||
.setTextureState(new TextureState(textureLocation, false, false))
|
||||
CompositeState renderState = CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(textureLocation, false, false))
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setDiffuseLightingState(DIFFUSE_LIGHTING)
|
||||
.setAlphaState(DEFAULT_ALPHA)
|
||||
// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO
|
||||
// .setAlphaState(DEFAULT_ALPHA) //TODO
|
||||
.setCullState(NO_CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true);
|
||||
return create("forge_entity_unsorted_translucent", DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, sortingEnabled, renderState);
|
||||
return create("forge_entity_unsorted_translucent", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, sortingEnabled, renderState);
|
||||
}
|
||||
|
||||
public static RenderType unlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled)
|
||||
{
|
||||
State renderState = State.builder()
|
||||
.setTextureState(new TextureState(textureLocation, false, false))
|
||||
CompositeState renderState = CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(textureLocation, false, false))
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setAlphaState(DEFAULT_ALPHA)
|
||||
// .setAlphaState(DEFAULT_ALPHA) //TODO
|
||||
.setCullState(NO_CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true);
|
||||
return create("forge_entity_unlit_translucent", DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, sortingEnabled, renderState);
|
||||
return create("forge_entity_unlit_translucent", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, sortingEnabled, renderState);
|
||||
}
|
||||
|
||||
public static RenderType layeredItemSolid(ResourceLocation locationIn) {
|
||||
RenderType.State rendertype$state = RenderType.State.builder()
|
||||
.setTextureState(new RenderState.TextureState(locationIn, false, false))
|
||||
RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder()
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false))
|
||||
.setTransparencyState(NO_TRANSPARENCY)
|
||||
.setDiffuseLightingState(DIFFUSE_LIGHTING)
|
||||
// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true);
|
||||
return create("forge_item_entity_solid", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, false, rendertype$state);
|
||||
return create("forge_item_entity_solid", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state);
|
||||
}
|
||||
|
||||
public static RenderType layeredItemCutout(ResourceLocation locationIn) {
|
||||
RenderType.State rendertype$state = RenderType.State.builder()
|
||||
.setTextureState(new RenderState.TextureState(locationIn, false, false))
|
||||
RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder()
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false))
|
||||
.setTransparencyState(NO_TRANSPARENCY)
|
||||
.setDiffuseLightingState(DIFFUSE_LIGHTING)
|
||||
.setAlphaState(DEFAULT_ALPHA)
|
||||
// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO
|
||||
// .setAlphaState(DEFAULT_ALPHA) //TODO
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true);
|
||||
return create("forge_item_entity_cutout", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, false, rendertype$state);
|
||||
return create("forge_item_entity_cutout", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state);
|
||||
}
|
||||
|
||||
public static RenderType layeredItemCutoutMipped(ResourceLocation locationIn) {
|
||||
RenderType.State rendertype$state = RenderType.State.builder()
|
||||
.setTextureState(new RenderState.TextureState(locationIn, false, true))
|
||||
RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder()
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, true))
|
||||
.setTransparencyState(NO_TRANSPARENCY)
|
||||
.setDiffuseLightingState(DIFFUSE_LIGHTING)
|
||||
.setAlphaState(DEFAULT_ALPHA)
|
||||
// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO
|
||||
// .setAlphaState(DEFAULT_ALPHA) //TODO
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true);
|
||||
return create("forge_item_entity_cutout_mipped", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, false, rendertype$state);
|
||||
return create("forge_item_entity_cutout_mipped", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state);
|
||||
}
|
||||
|
||||
public static RenderType layeredItemTranslucent(ResourceLocation locationIn) {
|
||||
RenderType.State rendertype$state = RenderType.State.builder()
|
||||
.setTextureState(new RenderState.TextureState(locationIn, false, false))
|
||||
RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder()
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false))
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setDiffuseLightingState(DIFFUSE_LIGHTING)
|
||||
.setAlphaState(DEFAULT_ALPHA)
|
||||
// .setDiffuseLightingState(DIFFUSE_LIGHTING) //TODO
|
||||
// .setAlphaState(DEFAULT_ALPHA) //TODO
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true);
|
||||
return create("forge_item_entity_translucent_cull", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, true, rendertype$state);
|
||||
return create("forge_item_entity_translucent_cull", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, rendertype$state);
|
||||
}
|
||||
|
||||
public static RenderType getText(ResourceLocation locationIn) {
|
||||
RenderType.State rendertype$state = RenderType.State.builder()
|
||||
RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder()
|
||||
.setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false))
|
||||
.setAlphaState(DEFAULT_ALPHA)
|
||||
// .setAlphaState(DEFAULT_ALPHA) //TODO
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.createCompositeState(false);
|
||||
return create("forge_text", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, 7, 256, false, true, rendertype$state);
|
||||
return create("forge_text", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state);
|
||||
}
|
||||
|
||||
public static RenderType getTextSeeThrough(ResourceLocation locationIn) {
|
||||
RenderType.State rendertype$state = RenderType.State.builder()
|
||||
RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder()
|
||||
.setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false))
|
||||
.setAlphaState(DEFAULT_ALPHA)
|
||||
// .setAlphaState(DEFAULT_ALPHA) //TODO
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setDepthTestState(NO_DEPTH_TEST)
|
||||
.setWriteMaskState(COLOR_WRITE)
|
||||
.createCompositeState(false);
|
||||
return create("forge_text_see_through", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, 7, 256, false, true, rendertype$state);
|
||||
return create("forge_text_see_through", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state);
|
||||
}
|
||||
}
|
||||
|
||||
private static class CustomizableTextureState extends TextureState
|
||||
private static class CustomizableTextureState extends TextureStateShard
|
||||
{
|
||||
private CustomizableTextureState(ResourceLocation resLoc, Supplier<Boolean> blur, Supplier<Boolean> mipmap)
|
||||
{
|
||||
@@ -264,7 +263,7 @@ public enum ForgeRenderTypes
|
||||
this.mipmap = mipmap.get();
|
||||
RenderSystem.enableTexture();
|
||||
TextureManager texturemanager = Minecraft.getInstance().getTextureManager();
|
||||
texturemanager.bind(resLoc);
|
||||
texturemanager.bindForSetup(resLoc);
|
||||
texturemanager.getTexture(resLoc).setFilter(this.blur, this.mipmap);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens;
|
||||
import net.minecraft.util.registry.DynamicRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.gen.DimensionSettings;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldPreset;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraftforge.common.world.ForgeWorldType;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -41,10 +41,10 @@ public class ForgeWorldTypeScreens
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final Map<ForgeWorldType, BiomeGeneratorTypeScreens> GENERATORS = Maps.newHashMap();
|
||||
private static final Map<ForgeWorldType, BiomeGeneratorTypeScreens.IFactory> GENERATOR_SCREEN_FACTORIES = Maps.newHashMap();
|
||||
private static final Map<ForgeWorldType, WorldPreset> GENERATORS = Maps.newHashMap();
|
||||
private static final Map<ForgeWorldType, WorldPreset.PresetEditor> GENERATOR_SCREEN_FACTORIES = Maps.newHashMap();
|
||||
|
||||
public static synchronized void registerFactory(ForgeWorldType type, BiomeGeneratorTypeScreens.IFactory factory)
|
||||
public static synchronized void registerFactory(ForgeWorldType type, WorldPreset.PresetEditor factory)
|
||||
{
|
||||
if (GENERATOR_SCREEN_FACTORIES.containsKey(type))
|
||||
throw new IllegalStateException("Factory has already been registered for: " + type);
|
||||
@@ -52,25 +52,25 @@ public class ForgeWorldTypeScreens
|
||||
GENERATOR_SCREEN_FACTORIES.put(type, factory);
|
||||
}
|
||||
|
||||
static BiomeGeneratorTypeScreens getDefaultGenerator()
|
||||
static WorldPreset getDefaultGenerator()
|
||||
{
|
||||
ForgeWorldType def = ForgeWorldType.getDefaultWorldType();
|
||||
if (def == null)
|
||||
{
|
||||
return BiomeGeneratorTypeScreens.NORMAL;
|
||||
return WorldPreset.NORMAL;
|
||||
}
|
||||
|
||||
BiomeGeneratorTypeScreens gen = GENERATORS.get(def);
|
||||
WorldPreset gen = GENERATORS.get(def);
|
||||
if (gen == null)
|
||||
{
|
||||
LOGGER.error("The default world type '{}' has not been added to the GUI. Was it registered too late?", def.getRegistryName());
|
||||
return BiomeGeneratorTypeScreens.NORMAL;
|
||||
return WorldPreset.NORMAL;
|
||||
}
|
||||
|
||||
return gen;
|
||||
}
|
||||
|
||||
static BiomeGeneratorTypeScreens.IFactory getGeneratorScreenFactory(Optional<BiomeGeneratorTypeScreens> generator, @Nullable BiomeGeneratorTypeScreens.IFactory biomegeneratortypescreens$ifactory)
|
||||
static WorldPreset.PresetEditor getGeneratorScreenFactory(Optional<WorldPreset> generator, @Nullable WorldPreset.PresetEditor biomegeneratortypescreens$ifactory)
|
||||
{
|
||||
return generator.filter(gen -> gen instanceof GeneratorType)
|
||||
.map(type -> GENERATOR_SCREEN_FACTORIES.get(((GeneratorType)type).getWorldType()))
|
||||
@@ -82,11 +82,11 @@ public class ForgeWorldTypeScreens
|
||||
ForgeRegistries.WORLD_TYPES.forEach(wt -> {
|
||||
GeneratorType gen = new GeneratorType(wt);
|
||||
GENERATORS.put(wt, gen);
|
||||
BiomeGeneratorTypeScreens.registerGenerator(gen);
|
||||
WorldPreset.registerGenerator(gen);
|
||||
});
|
||||
}
|
||||
|
||||
private static class GeneratorType extends BiomeGeneratorTypeScreens
|
||||
private static class GeneratorType extends WorldPreset
|
||||
{
|
||||
private final ForgeWorldType worldType;
|
||||
|
||||
@@ -103,14 +103,14 @@ public class ForgeWorldTypeScreens
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DimensionGeneratorSettings create(@Nonnull DynamicRegistries.Impl dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest)
|
||||
public WorldGenSettings create(@Nonnull RegistryAccess.RegistryHolder dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest)
|
||||
{
|
||||
return worldType.createSettings(dynamicRegistries, seed, generateStructures, bonusChest, "");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ChunkGenerator generator(@Nonnull Registry<Biome> p_241869_1_, @Nonnull Registry<DimensionSettings> p_241869_2_, long p_241869_3_)
|
||||
protected ChunkGenerator generator(@Nonnull Registry<Biome> p_241869_1_, @Nonnull Registry<NoiseGeneratorSettings> p_241869_2_, long p_241869_3_)
|
||||
{
|
||||
return worldType.createChunkGenerator(p_241869_1_, p_241869_2_, p_241869_3_, "");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import com.mojang.math.Vector3d;
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
|
||||
public interface IBlockRenderProperties
|
||||
{
|
||||
IBlockRenderProperties DUMMY = new IBlockRenderProperties()
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* Spawn a digging particle effect in the Level, this is a wrapper
|
||||
* around EffectRenderer.addBlockHitEffects to allow the block more
|
||||
* control over the particles. Useful when you have entirely different
|
||||
* texture sheets for different sides/locations in the Level.
|
||||
*
|
||||
* @param state The current state
|
||||
* @param Level The current Level
|
||||
* @param target The target the player is looking at {x/y/z/side/sub}
|
||||
* @param manager A reference to the current particle manager.
|
||||
* @return True to prevent vanilla digging particles form spawning.
|
||||
*/
|
||||
default boolean addHitEffects(BlockState state, Level Level, HitResult target, ParticleEngine manager)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn particles for when the block is destroyed. Due to the nature
|
||||
* of how this is invoked, the x/y/z locations are not always guaranteed
|
||||
* to host your block. So be sure to do proper sanity checks before assuming
|
||||
* that the location is this block.
|
||||
*
|
||||
* @param Level The current Level
|
||||
* @param pos Position to spawn the particle
|
||||
* @param manager A reference to the current particle manager.
|
||||
* @return True to prevent vanilla break particles from spawning.
|
||||
*/
|
||||
default boolean addDestroyEffects(BlockState state, Level Level, BlockPos pos, ParticleEngine manager)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* NOT CURRENTLY IMPLEMENTED
|
||||
* <p>
|
||||
* Use this to change the fog color used when the entity is "inside" a material.
|
||||
* Vec3d is used here as "r/g/b" 0 - 1 values.
|
||||
*
|
||||
* @param Level The Level.
|
||||
* @param pos The position at the entity viewport.
|
||||
* @param state The state at the entity viewport.
|
||||
* @param entity the entity
|
||||
* @param originalColor The current fog color, You are not expected to use this, Return as the default if applicable.
|
||||
* @return The new fog color.
|
||||
*/
|
||||
default Vector3d getFogColor(BlockState state, LevelReader Level, BlockPos pos, Entity entity, Vector3d originalColor, float partialTicks)
|
||||
{
|
||||
if (state.getMaterial() == Material.WATER)
|
||||
{
|
||||
float f12 = 0.0F;
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
LivingEntity ent = (LivingEntity) entity;
|
||||
f12 = (float) EnchantmentHelper.getRespiration(ent) * 0.2F;
|
||||
|
||||
if (ent.hasEffect(MobEffects.WATER_BREATHING))
|
||||
{
|
||||
f12 = f12 * 0.3F + 0.6F;
|
||||
}
|
||||
}
|
||||
return new Vector3d(0.02F + f12, 0.02F + f12, 0.2F + f12);
|
||||
}
|
||||
else if (state.getMaterial() == Material.LAVA)
|
||||
{
|
||||
return new Vector3d(0.6F, 0.1F, 0.0F);
|
||||
}
|
||||
return originalColor;
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
/**
|
||||
* Call {@link net.minecraft.client.world.DimensionRenderInfo#setCloudRenderHandler(ICloudRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all cloud rendering with your own.
|
||||
@@ -29,5 +29,5 @@ import net.minecraft.client.world.ClientWorld;
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ICloudRenderHandler {
|
||||
void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc, double viewEntityX, double viewEntityY, double viewEntityZ);
|
||||
void render(int ticks, float partialTicks, PoseStack matrixStack, ClientLevel world, Minecraft mc, double viewEntityX, double viewEntityY, double viewEntityZ);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public interface IItemRenderProperties
|
||||
{
|
||||
IItemRenderProperties DUMMY = new IItemRenderProperties()
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the font renderer used to render tooltips and overlays for this item.
|
||||
* Returning null will use the standard font renderer.
|
||||
*
|
||||
* @param stack The current item stack
|
||||
* @return A instance of FontRenderer or null to use default
|
||||
*/
|
||||
default Font getFont(ItemStack stack)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to have an item handle its own armor rendering.
|
||||
*
|
||||
* @param entityLiving The entity wearing the armor
|
||||
* @param itemStack The itemStack to render the model of
|
||||
* @param armorSlot The slot the armor is in
|
||||
* @param _default Original armor model. Will have attributes set.
|
||||
* @return A ModelBiped to render instead of the default
|
||||
*/
|
||||
default <A extends HumanoidModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, A _default)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the client starts rendering the HUD, for whatever item the player
|
||||
* currently has as a helmet. This is where pumpkins would render there overlay.
|
||||
*
|
||||
* @param stack The ItemStack that is equipped
|
||||
* @param player Reference to the current client entity
|
||||
* @param width Viewport width
|
||||
* @param height Viewport height
|
||||
* @param partialTicks Partial ticks for the renderer, useful for interpolation
|
||||
*/
|
||||
default void renderHelmetOverlay(ItemStack stack, Player player, int width, int height, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return This Item's renderer, or the default instance if it does not have
|
||||
* one.
|
||||
*/
|
||||
default BlockEntityWithoutLevelRenderer getItemStackRenderer()
|
||||
{
|
||||
return Minecraft.getInstance().getItemRenderer().getBlockEntityRenderer();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
/**
|
||||
* Use one of {@link IWeatherRenderHandler}, {@link ICloudRenderHandler} or {@link ISkyRenderHandler} instead.
|
||||
*
|
||||
* todo: remove in 1.17
|
||||
*/
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
public interface IRenderHandler
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc);
|
||||
}
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
/**
|
||||
* Call {@link net.minecraft.client.world.DimensionRenderInfo#setSkyRenderHandler(ISkyRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all sky rendering with your own.
|
||||
@@ -29,5 +29,5 @@ import net.minecraft.client.world.ClientWorld;
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ISkyRenderHandler {
|
||||
void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc);
|
||||
void render(int ticks, float partialTicks, PoseStack matrixStack, ClientLevel world, Minecraft mc);
|
||||
}
|
||||
@@ -20,8 +20,8 @@
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
/**
|
||||
* Call {@link net.minecraft.client.world.DimensionRenderInfo#setWeatherParticleRenderHandler(net.minecraftforge.client.IWeatherParticleRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all weather particle rendering with your own.
|
||||
@@ -30,5 +30,5 @@ import net.minecraft.client.world.ClientWorld;
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IWeatherParticleRenderHandler {
|
||||
void render(int ticks, ClientWorld world, Minecraft mc, ActiveRenderInfo activeRenderInfoIn);
|
||||
void render(int ticks, ClientLevel world, Minecraft mc, Camera activeRenderInfoIn);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
/**
|
||||
* Call {@link net.minecraft.client.world.DimensionRenderInfo#setWeatherRenderHandler(IWeatherRenderHandler)}, obtained from a {@link ClientWorld} with an implementation of this to override all weather rendering with your own.
|
||||
@@ -29,5 +29,5 @@ import net.minecraft.client.world.ClientWorld;
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IWeatherRenderHandler {
|
||||
void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc, LightTexture lightmapIn, double xIn, double yIn, double zIn);
|
||||
void render(int ticks, float partialTicks, ClientLevel world, Minecraft mc, LightTexture lightmapIn, double xIn, double yIn, double zIn);
|
||||
}
|
||||
@@ -26,22 +26,22 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.client.renderer.ItemModelShaper;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
/**
|
||||
* Wrapper around ItemModeMesher that cleans up the internal maps to respect ID remapping.
|
||||
*/
|
||||
public class ItemModelMesherForge extends ItemModelMesher
|
||||
public class ItemModelMesherForge extends ItemModelShaper
|
||||
{
|
||||
final Map<IRegistryDelegate<Item>, ModelResourceLocation> locations = Maps.newHashMap();
|
||||
final Map<IRegistryDelegate<Item>, IBakedModel> models = Maps.newHashMap();
|
||||
final Map<IRegistryDelegate<Item>, BakedModel> models = Maps.newHashMap();
|
||||
|
||||
public ItemModelMesherForge(ModelManager manager)
|
||||
{
|
||||
@@ -50,7 +50,7 @@ public class ItemModelMesherForge extends ItemModelMesher
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IBakedModel getItemModel(Item item)
|
||||
public BakedModel getItemModel(Item item)
|
||||
{
|
||||
return models.get(item.delegate);
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderCache;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunkRegion;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader;
|
||||
|
||||
public class MinecraftForgeClient
|
||||
@@ -102,20 +102,20 @@ public class MinecraftForgeClient
|
||||
}
|
||||
}
|
||||
|
||||
private static final LoadingCache<Pair<World, BlockPos>, Optional<ChunkRenderCache>> regionCache = CacheBuilder.newBuilder()
|
||||
private static final LoadingCache<Pair<Level, BlockPos>, Optional<RenderChunkRegion>> regionCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(500)
|
||||
.concurrencyLevel(5)
|
||||
.expireAfterAccess(1, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<Pair<World, BlockPos>, Optional<ChunkRenderCache>>()
|
||||
.build(new CacheLoader<Pair<Level, BlockPos>, Optional<RenderChunkRegion>>()
|
||||
{
|
||||
@Override
|
||||
public Optional<ChunkRenderCache> load(Pair<World, BlockPos> key)
|
||||
public Optional<RenderChunkRegion> load(Pair<Level, BlockPos> key)
|
||||
{
|
||||
return Optional.ofNullable(ChunkRenderCache.createIfNotEmpty(key.getLeft(), key.getRight().offset(-1, -1, -1), key.getRight().offset(16, 16, 16), 1));
|
||||
return Optional.ofNullable(RenderChunkRegion.createIfNotEmpty(key.getLeft(), key.getRight().offset(-1, -1, -1), key.getRight().offset(16, 16, 16), 1));
|
||||
}
|
||||
});
|
||||
|
||||
public static void onRebuildChunk(World world, BlockPos position, ChunkRenderCache cache)
|
||||
public static void onRebuildChunk(Level world, BlockPos position, RenderChunkRegion cache)
|
||||
{
|
||||
if (cache == null)
|
||||
regionCache.invalidate(Pair.of(world, position));
|
||||
@@ -124,12 +124,12 @@ public class MinecraftForgeClient
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ChunkRenderCache getRegionRenderCache(World world, BlockPos pos)
|
||||
public static RenderChunkRegion getRegionRenderCache(Level world, BlockPos pos)
|
||||
{
|
||||
return getRegionRenderCacheOptional(world, pos).orElse(null);
|
||||
}
|
||||
|
||||
public static Optional<ChunkRenderCache> getRegionRenderCacheOptional(World world, BlockPos pos)
|
||||
public static Optional<RenderChunkRegion> getRegionRenderCacheOptional(Level world, BlockPos pos)
|
||||
{
|
||||
int x = pos.getX() & ~0xF;
|
||||
int y = pos.getY() & ~0xF;
|
||||
@@ -150,13 +150,13 @@ public class MinecraftForgeClient
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static NativeImage getImageLayer(ResourceLocation resourceLocation, IResourceManager resourceManager) throws IOException
|
||||
public static NativeImage getImageLayer(ResourceLocation resourceLocation, ResourceManager resourceManager) throws IOException
|
||||
{
|
||||
Supplier<NativeImage> supplier = bufferedImageSuppliers.get(resourceLocation);
|
||||
if (supplier != null)
|
||||
return supplier.get();
|
||||
|
||||
IResource iresource1 = resourceManager.getResource(resourceLocation);
|
||||
Resource iresource1 = resourceManager.getResource(resourceLocation);
|
||||
return NativeImage.read(iresource1.getInputStream());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class RenderProperties
|
||||
{
|
||||
public static EffectRenderer getEffectRenderer(MobEffectInstance effectInstance)
|
||||
{
|
||||
return getEffectRenderer(effectInstance.getEffect());
|
||||
}
|
||||
|
||||
public static EffectRenderer getEffectRenderer(MobEffect effect)
|
||||
{
|
||||
return effect.getEffectRendererInternal() instanceof EffectRenderer r ? r : EffectRenderer.DUMMY;
|
||||
}
|
||||
|
||||
public static IItemRenderProperties get(ItemStack stack)
|
||||
{
|
||||
return get(stack.getItem());
|
||||
}
|
||||
|
||||
public static IItemRenderProperties get(Item item)
|
||||
{
|
||||
return item.getRenderPropertiesInternal() instanceof IItemRenderProperties props ? props : IItemRenderProperties.DUMMY;
|
||||
}
|
||||
|
||||
public static IBlockRenderProperties get(BlockState state)
|
||||
{
|
||||
return get(state.getBlock());
|
||||
}
|
||||
|
||||
public static IBlockRenderProperties get(Block block)
|
||||
{
|
||||
return block.getRenderPropertiesInternal() instanceof IBlockRenderProperties props ? props : IBlockRenderProperties.DUMMY;
|
||||
}
|
||||
|
||||
private RenderProperties()
|
||||
{
|
||||
// Not instantiable.
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
|
||||
/**
|
||||
* Use {@link ISkyRenderHandler} instead.
|
||||
*
|
||||
* todo: remove in 1.17
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SkyRenderHandler extends IRenderHandler {
|
||||
@Override
|
||||
default void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc) {}
|
||||
|
||||
void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc);
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Use {@link IWeatherRenderHandler} instead.
|
||||
*
|
||||
* todo: remove in 1.17
|
||||
*/
|
||||
@Deprecated
|
||||
public interface WeatherRenderHandler extends IRenderHandler {
|
||||
}
|
||||
@@ -22,8 +22,6 @@ package net.minecraftforge.client.event;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* ClientChatEvent is fired whenever the client is about to send a chat message or command to the server. <br>
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.util.text.ChatType;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@@ -35,24 +35,24 @@ import java.util.UUID;
|
||||
@Cancelable
|
||||
public class ClientChatReceivedEvent extends Event
|
||||
{
|
||||
private ITextComponent message;
|
||||
private Component message;
|
||||
private final ChatType type;
|
||||
@Nullable
|
||||
private final UUID senderUUID;
|
||||
|
||||
public ClientChatReceivedEvent(ChatType type, ITextComponent message, @Nullable UUID senderUUID)
|
||||
public ClientChatReceivedEvent(ChatType type, Component message, @Nullable UUID senderUUID)
|
||||
{
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
this.senderUUID = senderUUID;
|
||||
}
|
||||
|
||||
public ITextComponent getMessage()
|
||||
public Component getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(ITextComponent message)
|
||||
public void setMessage(Component message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.network.play.NetworkPlayerInfo;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
@@ -28,18 +28,18 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
*/
|
||||
public class ClientPlayerChangeGameModeEvent extends Event
|
||||
{
|
||||
private final NetworkPlayerInfo info;
|
||||
private final PlayerInfo info;
|
||||
private final GameType currentGameMode;
|
||||
private final GameType newGameMode;
|
||||
|
||||
public ClientPlayerChangeGameModeEvent(NetworkPlayerInfo info, GameType currentGameMode, GameType newGameMode)
|
||||
public ClientPlayerChangeGameModeEvent(PlayerInfo info, GameType currentGameMode, GameType newGameMode)
|
||||
{
|
||||
this.info = info;
|
||||
this.currentGameMode = currentGameMode;
|
||||
this.newGameMode = newGameMode;
|
||||
}
|
||||
|
||||
public NetworkPlayerInfo getInfo()
|
||||
public PlayerInfo getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.multiplayer.PlayerController;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -30,15 +30,15 @@ import javax.annotation.Nullable;
|
||||
* Client side player connectivity events.
|
||||
*/
|
||||
public class ClientPlayerNetworkEvent extends Event {
|
||||
private final PlayerController controller;
|
||||
private final ClientPlayerEntity player;
|
||||
private final NetworkManager networkManager;
|
||||
private final MultiPlayerGameMode controller;
|
||||
private final LocalPlayer player;
|
||||
private final Connection networkManager;
|
||||
|
||||
/**
|
||||
* @return the player controller for the client side
|
||||
*/
|
||||
@Nullable
|
||||
public PlayerController getController() {
|
||||
public MultiPlayerGameMode getController() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ClientPlayerNetworkEvent extends Event {
|
||||
* @return the player instance (if present - may be null)
|
||||
*/
|
||||
@Nullable
|
||||
public ClientPlayerEntity getPlayer() {
|
||||
public LocalPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ public class ClientPlayerNetworkEvent extends Event {
|
||||
* @return the network connection (if present - may be null)
|
||||
*/
|
||||
@Nullable
|
||||
public NetworkManager getNetworkManager() {
|
||||
public Connection getNetworkManager() {
|
||||
return networkManager;
|
||||
}
|
||||
|
||||
ClientPlayerNetworkEvent(final PlayerController controller, final ClientPlayerEntity player, final NetworkManager networkManager) {
|
||||
ClientPlayerNetworkEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) {
|
||||
this.controller = controller;
|
||||
this.player = player;
|
||||
this.networkManager = networkManager;
|
||||
@@ -69,7 +69,7 @@ public class ClientPlayerNetworkEvent extends Event {
|
||||
*/
|
||||
public static class LoggedInEvent extends ClientPlayerNetworkEvent {
|
||||
|
||||
public LoggedInEvent(final PlayerController controller, final ClientPlayerEntity player, final NetworkManager networkManager) {
|
||||
public LoggedInEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) {
|
||||
super(controller, player, networkManager);
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class ClientPlayerNetworkEvent extends Event {
|
||||
*/
|
||||
public static class LoggedOutEvent extends ClientPlayerNetworkEvent {
|
||||
|
||||
public LoggedOutEvent(final PlayerController controller, final ClientPlayerEntity player, final NetworkManager networkManager) {
|
||||
public LoggedOutEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) {
|
||||
super(controller, player, networkManager);
|
||||
}
|
||||
}
|
||||
@@ -88,18 +88,18 @@ public class ClientPlayerNetworkEvent extends Event {
|
||||
* Fired when the player object respawns, such as dimension changes.
|
||||
*/
|
||||
public static class RespawnEvent extends ClientPlayerNetworkEvent {
|
||||
private final ClientPlayerEntity oldPlayer;
|
||||
private final LocalPlayer oldPlayer;
|
||||
|
||||
public RespawnEvent(final PlayerController pc, final ClientPlayerEntity oldPlayer, final ClientPlayerEntity newPlayer, final NetworkManager networkManager) {
|
||||
public RespawnEvent(final MultiPlayerGameMode pc, final LocalPlayer oldPlayer, final LocalPlayer newPlayer, final Connection networkManager) {
|
||||
super(pc, newPlayer, networkManager);
|
||||
this.oldPlayer = oldPlayer;
|
||||
}
|
||||
|
||||
public ClientPlayerEntity getOldPlayer() {
|
||||
public LocalPlayer getOldPlayer() {
|
||||
return oldPlayer;
|
||||
}
|
||||
|
||||
public ClientPlayerEntity getNewPlayer() {
|
||||
public LocalPlayer getNewPlayer() {
|
||||
return super.getPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
/**
|
||||
* Use these events to register block/item
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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.event;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
|
||||
/**
|
||||
* An event called whenever the selection highlight around blocks is about to be rendered.
|
||||
* Canceling this event stops the selection highlight from being rendered.
|
||||
*
|
||||
* TODO: Rename to DrawSelectionEvent
|
||||
*/
|
||||
@Cancelable
|
||||
public class DrawHighlightEvent extends Event
|
||||
{
|
||||
private final WorldRenderer context;
|
||||
private final ActiveRenderInfo info;
|
||||
private final RayTraceResult target;
|
||||
private final float partialTicks;
|
||||
private final MatrixStack matrix;
|
||||
private final IRenderTypeBuffer buffers;
|
||||
|
||||
public DrawHighlightEvent(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
|
||||
{
|
||||
this.context = context;
|
||||
this.info = info;
|
||||
this.target = target;
|
||||
this.partialTicks= partialTicks;
|
||||
this.matrix = matrix;
|
||||
this.buffers = buffers;
|
||||
}
|
||||
|
||||
public WorldRenderer getContext() { return context; }
|
||||
public ActiveRenderInfo getInfo() { return info; }
|
||||
public RayTraceResult getTarget() { return target; }
|
||||
public float getPartialTicks() { return partialTicks; }
|
||||
public MatrixStack getMatrix() { return matrix; }
|
||||
public IRenderTypeBuffer getBuffers() { return buffers; }
|
||||
|
||||
/**
|
||||
* A variant of the DrawHighlightEvent only called when a block is highlighted.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class HighlightBlock extends DrawHighlightEvent
|
||||
{
|
||||
public HighlightBlock(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
|
||||
{
|
||||
super(context, info, target, partialTicks, matrix, buffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRayTraceResult getTarget()
|
||||
{
|
||||
return (BlockRayTraceResult) super.target;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A variant of the DrawHighlightEvent only called when an entity is highlighted.
|
||||
* Canceling this event has no effect.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class HighlightEntity extends DrawHighlightEvent
|
||||
{
|
||||
public HighlightEntity(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
|
||||
{
|
||||
super(context, info, target, partialTicks, matrix, buffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRayTraceResult getTarget()
|
||||
{
|
||||
return (EntityRayTraceResult) super.target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
|
||||
/**
|
||||
* An event called whenever the selection highlight around a block or entity is about to be rendered.
|
||||
* Canceling this event stops the selection highlight from being rendered.
|
||||
*/
|
||||
@Cancelable
|
||||
public class DrawSelectionEvent extends Event
|
||||
{
|
||||
private final LevelRenderer context;
|
||||
private final Camera info;
|
||||
private final HitResult target;
|
||||
private final float partialTicks;
|
||||
private final PoseStack matrix;
|
||||
private final MultiBufferSource buffers;
|
||||
|
||||
public DrawSelectionEvent(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers)
|
||||
{
|
||||
this.context = context;
|
||||
this.info = info;
|
||||
this.target = target;
|
||||
this.partialTicks= partialTicks;
|
||||
this.matrix = matrix;
|
||||
this.buffers = buffers;
|
||||
}
|
||||
|
||||
public LevelRenderer getContext() { return context; }
|
||||
public Camera getInfo() { return info; }
|
||||
public HitResult getTarget() { return target; }
|
||||
public float getPartialTicks() { return partialTicks; }
|
||||
public PoseStack getMatrix() { return matrix; }
|
||||
public MultiBufferSource getBuffers() { return buffers; }
|
||||
|
||||
/**
|
||||
* A variant of the DrawSelectionEvent only called when a block is highlighted.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class HighlightBlock extends DrawSelectionEvent
|
||||
{
|
||||
public HighlightBlock(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers)
|
||||
{
|
||||
super(context, info, target, partialTicks, matrix, buffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockHitResult getTarget()
|
||||
{
|
||||
return (BlockHitResult) super.target;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A variant of the DrawSelectionEvent only called when an entity is highlighted.
|
||||
* Canceling this event has no effect.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class HighlightEntity extends DrawSelectionEvent
|
||||
{
|
||||
public HighlightEntity(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers)
|
||||
{
|
||||
super(context, info, target, partialTicks, matrix, buffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityHitResult getTarget()
|
||||
{
|
||||
return (EntityHitResult) super.target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,8 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogType;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
|
||||
@@ -34,10 +34,10 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
|
||||
public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final GameRenderer renderer;
|
||||
private final ActiveRenderInfo info;
|
||||
private final Camera info;
|
||||
private final double renderPartialTicks;
|
||||
|
||||
public EntityViewRenderEvent(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks)
|
||||
public EntityViewRenderEvent(GameRenderer renderer, Camera info, double renderPartialTicks)
|
||||
{
|
||||
this.renderer = renderer;
|
||||
this.info = info;
|
||||
@@ -49,7 +49,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
return renderer;
|
||||
}
|
||||
|
||||
public ActiveRenderInfo getInfo()
|
||||
public Camera getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
@@ -61,15 +61,15 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
|
||||
private static class FogEvent extends EntityViewRenderEvent
|
||||
{
|
||||
private final FogType type;
|
||||
private final FogMode type;
|
||||
@SuppressWarnings("resource")
|
||||
protected FogEvent(FogType type, ActiveRenderInfo info, double renderPartialTicks)
|
||||
protected FogEvent(FogMode type, Camera info, double renderPartialTicks)
|
||||
{
|
||||
super(Minecraft.getInstance().gameRenderer, info, renderPartialTicks);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public FogType getType() { return type; }
|
||||
public FogMode getType() { return type; }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
{
|
||||
private float density;
|
||||
|
||||
public FogDensity(FogType type, ActiveRenderInfo info, float partialTicks, float density)
|
||||
public FogDensity(FogMode type, Camera info, float partialTicks, float density)
|
||||
{
|
||||
super(type, info, partialTicks);
|
||||
this.setDensity(density);
|
||||
@@ -106,7 +106,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
{
|
||||
private final float farPlaneDistance;
|
||||
|
||||
public RenderFogEvent(FogType type, ActiveRenderInfo info, float partialTicks, float distance)
|
||||
public RenderFogEvent(FogMode type, Camera info, float partialTicks, float distance)
|
||||
{
|
||||
super(type, info, partialTicks);
|
||||
this.farPlaneDistance = distance;
|
||||
@@ -129,7 +129,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
private float blue;
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public FogColors(ActiveRenderInfo info, float partialTicks, float red, float green, float blue)
|
||||
public FogColors(Camera info, float partialTicks, float red, float green, float blue)
|
||||
{
|
||||
super(Minecraft.getInstance().gameRenderer, info, partialTicks);
|
||||
this.setRed(red);
|
||||
@@ -154,7 +154,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
private float pitch;
|
||||
private float roll;
|
||||
|
||||
public CameraSetup(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, float yaw, float pitch, float roll)
|
||||
public CameraSetup(GameRenderer renderer, Camera info, double renderPartialTicks, float yaw, float pitch, float roll)
|
||||
{
|
||||
super(renderer, info, renderPartialTicks);
|
||||
this.setYaw(yaw);
|
||||
@@ -178,7 +178,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
{
|
||||
private double fov;
|
||||
|
||||
public FOVModifier(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, double fov) {
|
||||
public FOVModifier(GameRenderer renderer, Camera info, double renderPartialTicks, double fov) {
|
||||
super(renderer, info, renderPartialTicks);
|
||||
this.setFOV(fov);
|
||||
}
|
||||
|
||||
@@ -20,24 +20,24 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class FOVUpdateEvent extends Event
|
||||
{
|
||||
private final PlayerEntity entity;
|
||||
private final Player entity;
|
||||
private final float fov;
|
||||
private float newfov;
|
||||
|
||||
public FOVUpdateEvent(PlayerEntity entity, float fov)
|
||||
public FOVUpdateEvent(Player entity, float fov)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.fov = fov;
|
||||
this.setNewfov(MathHelper.lerp(Minecraft.getInstance().options.fovEffectScale, 1.0F, fov));
|
||||
this.setNewfov(Mth.lerp(Minecraft.getInstance().options.fovEffectScale, 1.0F, fov));
|
||||
}
|
||||
|
||||
public PlayerEntity getEntity()
|
||||
public Player getEntity()
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
@@ -29,14 +29,14 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
public class GuiContainerEvent extends Event
|
||||
{
|
||||
|
||||
private final ContainerScreen guiContainer;
|
||||
private final AbstractContainerScreen guiContainer;
|
||||
|
||||
public GuiContainerEvent(ContainerScreen guiContainer)
|
||||
public GuiContainerEvent(AbstractContainerScreen guiContainer)
|
||||
{
|
||||
this.guiContainer = guiContainer;
|
||||
}
|
||||
|
||||
public ContainerScreen getGuiContainer()
|
||||
public AbstractContainerScreen getGuiContainer()
|
||||
{
|
||||
return guiContainer;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class GuiContainerEvent extends Event
|
||||
*/
|
||||
public static class DrawForeground extends GuiContainerEvent
|
||||
{
|
||||
private final MatrixStack mStack;
|
||||
private final PoseStack mStack;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class GuiContainerEvent extends Event
|
||||
* @param mouseX The current X position of the players mouse.
|
||||
* @param mouseY The current Y position of the players mouse.
|
||||
*/
|
||||
public DrawForeground(ContainerScreen guiContainer, MatrixStack mStack, int mouseX, int mouseY)
|
||||
public DrawForeground(AbstractContainerScreen guiContainer, PoseStack mStack, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer);
|
||||
this.mStack = mStack;
|
||||
@@ -69,7 +69,7 @@ public class GuiContainerEvent extends Event
|
||||
this.mouseY = mouseY;
|
||||
}
|
||||
|
||||
public MatrixStack getMatrixStack()
|
||||
public PoseStack getMatrixStack()
|
||||
{
|
||||
return mStack;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class GuiContainerEvent extends Event
|
||||
*/
|
||||
public static class DrawBackground extends GuiContainerEvent
|
||||
{
|
||||
private final MatrixStack mStack;
|
||||
private final PoseStack mStack;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
|
||||
@@ -103,7 +103,7 @@ public class GuiContainerEvent extends Event
|
||||
* @param mouseX The current X position of the players mouse.
|
||||
* @param mouseY The current Y position of the players mouse.
|
||||
*/
|
||||
public DrawBackground(ContainerScreen guiContainer, MatrixStack mStack, int mouseX, int mouseY)
|
||||
public DrawBackground(AbstractContainerScreen guiContainer, PoseStack mStack, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer);
|
||||
this.mStack = mStack;
|
||||
@@ -111,7 +111,7 @@ public class GuiContainerEvent extends Event
|
||||
this.mouseY = mouseY;
|
||||
}
|
||||
|
||||
public MatrixStack getMatrixStack()
|
||||
public PoseStack getMatrixStack()
|
||||
{
|
||||
return mStack;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
|
||||
/**
|
||||
* This event is called before any Gui will open.
|
||||
|
||||
@@ -19,26 +19,21 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* Event classes for GuiScreen events.
|
||||
*
|
||||
@@ -64,12 +59,12 @@ public class GuiScreenEvent extends Event
|
||||
|
||||
public static class InitGuiEvent extends GuiScreenEvent
|
||||
{
|
||||
private Consumer<Widget> add;
|
||||
private Consumer<Widget> remove;
|
||||
private Consumer<GuiEventListener> add;
|
||||
private Consumer<GuiEventListener> remove;
|
||||
|
||||
private List<Widget> list;
|
||||
private List<GuiEventListener> list;
|
||||
|
||||
public InitGuiEvent(Screen gui, List<Widget> list, Consumer<Widget> add, Consumer<Widget> remove)
|
||||
public InitGuiEvent(Screen gui, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
{
|
||||
super(gui);
|
||||
this.list = Collections.unmodifiableList(list);
|
||||
@@ -80,17 +75,17 @@ public class GuiScreenEvent extends Event
|
||||
/**
|
||||
* Unmodifiable reference to the list of buttons on the {@link #gui}.
|
||||
*/
|
||||
public List<Widget> getWidgetList()
|
||||
public List<GuiEventListener> getWidgetList()
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
public void addWidget(Widget button)
|
||||
public void addWidget(GuiEventListener button)
|
||||
{
|
||||
add.accept(button);
|
||||
}
|
||||
|
||||
public void removeWidget(Widget button)
|
||||
public void removeWidget(GuiEventListener button)
|
||||
{
|
||||
remove.accept(button);
|
||||
}
|
||||
@@ -107,7 +102,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends InitGuiEvent
|
||||
{
|
||||
public Pre(Screen gui, List<Widget> list, Consumer<Widget> add, Consumer<Widget> remove)
|
||||
public Pre(Screen gui, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
{
|
||||
super(gui, list, add, remove);
|
||||
}
|
||||
@@ -119,7 +114,7 @@ public class GuiScreenEvent extends Event
|
||||
*/
|
||||
public static class Post extends InitGuiEvent
|
||||
{
|
||||
public Post(Screen gui, List<Widget> list, Consumer<Widget> add, Consumer<Widget> remove)
|
||||
public Post(Screen gui, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
{
|
||||
super(gui, list, add, remove);
|
||||
}
|
||||
@@ -128,12 +123,12 @@ public class GuiScreenEvent extends Event
|
||||
|
||||
public static class DrawScreenEvent extends GuiScreenEvent
|
||||
{
|
||||
private final MatrixStack mStack;
|
||||
private final PoseStack mStack;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
private final float renderPartialTicks;
|
||||
|
||||
public DrawScreenEvent(Screen gui, MatrixStack mStack, int mouseX, int mouseY, float renderPartialTicks)
|
||||
public DrawScreenEvent(Screen gui, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks)
|
||||
{
|
||||
super(gui);
|
||||
this.mStack = mStack;
|
||||
@@ -145,7 +140,7 @@ public class GuiScreenEvent extends Event
|
||||
/**
|
||||
* The MatrixStack to render with.
|
||||
*/
|
||||
public MatrixStack getMatrixStack()
|
||||
public PoseStack getMatrixStack()
|
||||
{
|
||||
return mStack;
|
||||
}
|
||||
@@ -181,7 +176,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends DrawScreenEvent
|
||||
{
|
||||
public Pre(Screen gui, MatrixStack mStack, int mouseX, int mouseY, float renderPartialTicks)
|
||||
public Pre(Screen gui, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks)
|
||||
{
|
||||
super(gui, mStack, mouseX, mouseY, renderPartialTicks);
|
||||
}
|
||||
@@ -192,7 +187,7 @@ public class GuiScreenEvent extends Event
|
||||
*/
|
||||
public static class Post extends DrawScreenEvent
|
||||
{
|
||||
public Post(Screen gui, MatrixStack mStack, int mouseX, int mouseY, float renderPartialTicks)
|
||||
public Post(Screen gui, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks)
|
||||
{
|
||||
super(gui, mStack, mouseX, mouseY, renderPartialTicks);
|
||||
}
|
||||
@@ -205,9 +200,9 @@ public class GuiScreenEvent extends Event
|
||||
*/
|
||||
public static class BackgroundDrawnEvent extends GuiScreenEvent
|
||||
{
|
||||
private final MatrixStack mStack;
|
||||
private final PoseStack mStack;
|
||||
|
||||
public BackgroundDrawnEvent(Screen gui, MatrixStack mStack)
|
||||
public BackgroundDrawnEvent(Screen gui, PoseStack mStack)
|
||||
{
|
||||
super(gui);
|
||||
this.mStack = mStack;
|
||||
@@ -216,7 +211,7 @@ public class GuiScreenEvent extends Event
|
||||
/**
|
||||
* The MatrixStack to render with.
|
||||
*/
|
||||
public MatrixStack getMatrixStack()
|
||||
public PoseStack getMatrixStack()
|
||||
{
|
||||
return mStack;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,11 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class InputEvent extends Event
|
||||
{
|
||||
/**
|
||||
@@ -267,10 +264,10 @@ public class InputEvent extends Event
|
||||
public static class ClickInputEvent extends InputEvent
|
||||
{
|
||||
private final int button;
|
||||
private final KeyBinding keyBinding;
|
||||
private final Hand hand;
|
||||
private final KeyMapping keyBinding;
|
||||
private final InteractionHand hand;
|
||||
private boolean handSwing = true;
|
||||
public ClickInputEvent(int button, KeyBinding keyBinding, Hand hand)
|
||||
public ClickInputEvent(int button, KeyMapping keyBinding, InteractionHand hand)
|
||||
{
|
||||
this.button = button;
|
||||
this.keyBinding = keyBinding;
|
||||
@@ -297,7 +294,7 @@ public class InputEvent extends Event
|
||||
* of if either gets canceled.
|
||||
* Will always be MAIN_HAND if this is an attack or pick block input.
|
||||
*/
|
||||
public Hand getHand()
|
||||
public InteractionHand getHand()
|
||||
{
|
||||
return hand;
|
||||
}
|
||||
@@ -317,7 +314,7 @@ public class InputEvent extends Event
|
||||
return button == 2;
|
||||
}
|
||||
|
||||
public KeyBinding getKeyBinding()
|
||||
public KeyMapping getKeyBinding()
|
||||
{
|
||||
return keyBinding;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.MovementInput;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.client.player.Input;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
@@ -29,15 +29,15 @@ import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
*/
|
||||
public class InputUpdateEvent extends PlayerEvent
|
||||
{
|
||||
private final MovementInput movementInput;
|
||||
private final Input movementInput;
|
||||
|
||||
public InputUpdateEvent(PlayerEntity player, MovementInput movementInput)
|
||||
public InputUpdateEvent(Player player, Input movementInput)
|
||||
{
|
||||
super(player);
|
||||
this.movementInput = movementInput;
|
||||
}
|
||||
|
||||
public MovementInput getMovementInput()
|
||||
public Input getMovementInput()
|
||||
{
|
||||
return movementInput;
|
||||
}
|
||||
|
||||
@@ -21,13 +21,12 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
/**
|
||||
* Fired when the ModelManager is notified of the resource manager reloading.
|
||||
@@ -37,10 +36,10 @@ import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||
public class ModelBakeEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final ModelManager modelManager;
|
||||
private final Map<ResourceLocation, IBakedModel> modelRegistry;
|
||||
private final Map<ResourceLocation, BakedModel> modelRegistry;
|
||||
private final ModelLoader modelLoader;
|
||||
|
||||
public ModelBakeEvent(ModelManager modelManager, Map<ResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
|
||||
public ModelBakeEvent(ModelManager modelManager, Map<ResourceLocation, BakedModel> modelRegistry, ModelLoader modelLoader)
|
||||
{
|
||||
this.modelManager = modelManager;
|
||||
this.modelRegistry = modelRegistry;
|
||||
@@ -52,7 +51,7 @@ public class ModelBakeEvent extends Event implements IModBusEvent
|
||||
return modelManager;
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, IBakedModel> getModelRegistry()
|
||||
public Map<ResourceLocation, BakedModel> getModelRegistry()
|
||||
{
|
||||
return modelRegistry;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
/**
|
||||
* Fired when the {@link net.minecraftforge.client.model.ModelLoader} is ready to register model loaders
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
/**
|
||||
* Fired when you should call {@link net.minecraft.client.particle.ParticleManager#registerFactory}.
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.item.crafting.RecipeManager;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@@ -38,13 +38,13 @@ public class RenderBlockOverlayEvent extends Event
|
||||
FIRE, BLOCK, WATER
|
||||
}
|
||||
|
||||
private final PlayerEntity player;
|
||||
private final MatrixStack mat;
|
||||
private final Player player;
|
||||
private final PoseStack mat;
|
||||
private final OverlayType overlayType;
|
||||
private final BlockState blockForOverlay;
|
||||
private final BlockPos blockPos;
|
||||
|
||||
public RenderBlockOverlayEvent(PlayerEntity player, MatrixStack mat, OverlayType type, BlockState block, BlockPos blockPos)
|
||||
public RenderBlockOverlayEvent(Player player, PoseStack mat, OverlayType type, BlockState block, BlockPos blockPos)
|
||||
{
|
||||
this.player = player;
|
||||
this.mat = mat;
|
||||
@@ -57,8 +57,8 @@ public class RenderBlockOverlayEvent extends Event
|
||||
/**
|
||||
* The player which the overlay will apply to
|
||||
*/
|
||||
public PlayerEntity getPlayer() { return player; }
|
||||
public MatrixStack getMatrixStack() { return mat; }
|
||||
public Player getPlayer() { return player; }
|
||||
public PoseStack getMatrixStack() { return mat; }
|
||||
/**
|
||||
* The type of overlay to occur
|
||||
*/
|
||||
|
||||
@@ -21,16 +21,17 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraftforge.client.gui.IIngameOverlay;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.MainWindow;
|
||||
import net.minecraft.client.gui.ClientBossInfo;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
|
||||
@Cancelable
|
||||
public class RenderGameOverlayEvent extends Event
|
||||
{
|
||||
public MatrixStack getMatrixStack()
|
||||
public PoseStack getMatrixStack()
|
||||
{
|
||||
return mStack;
|
||||
}
|
||||
@@ -40,7 +41,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
return partialTicks;
|
||||
}
|
||||
|
||||
public MainWindow getWindow()
|
||||
public Window getWindow()
|
||||
{
|
||||
return window;
|
||||
}
|
||||
@@ -53,35 +54,20 @@ public class RenderGameOverlayEvent extends Event
|
||||
public static enum ElementType
|
||||
{
|
||||
ALL,
|
||||
HELMET,
|
||||
PORTAL,
|
||||
CROSSHAIRS,
|
||||
BOSSHEALTH, // All boss bars
|
||||
LAYER,
|
||||
BOSSINFO, // Individual boss bar
|
||||
ARMOR,
|
||||
HEALTH,
|
||||
FOOD,
|
||||
AIR,
|
||||
HOTBAR,
|
||||
EXPERIENCE,
|
||||
TEXT,
|
||||
HEALTHMOUNT,
|
||||
JUMPBAR,
|
||||
CHAT,
|
||||
PLAYER_LIST,
|
||||
DEBUG,
|
||||
POTION_ICONS,
|
||||
SUBTITLES,
|
||||
FPS_GRAPH,
|
||||
VIGNETTE
|
||||
DEBUG
|
||||
}
|
||||
|
||||
private final MatrixStack mStack;
|
||||
private final PoseStack mStack;
|
||||
private final float partialTicks;
|
||||
private final MainWindow window;
|
||||
private final Window window;
|
||||
private final ElementType type;
|
||||
|
||||
public RenderGameOverlayEvent(MatrixStack mStack, float partialTicks, MainWindow window)
|
||||
public RenderGameOverlayEvent(PoseStack mStack, float partialTicks, Window window)
|
||||
{
|
||||
this.mStack = mStack;
|
||||
this.partialTicks = partialTicks;
|
||||
@@ -89,7 +75,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
this.type = null;
|
||||
}
|
||||
|
||||
private RenderGameOverlayEvent(MatrixStack mStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
private RenderGameOverlayEvent(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
{
|
||||
this.mStack = mStack;
|
||||
this.partialTicks = parent.getPartialTicks();
|
||||
@@ -99,7 +85,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
|
||||
public static class Pre extends RenderGameOverlayEvent
|
||||
{
|
||||
public Pre(MatrixStack mStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
public Pre(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
{
|
||||
super(mStack, parent, type);
|
||||
}
|
||||
@@ -107,20 +93,52 @@ public class RenderGameOverlayEvent extends Event
|
||||
|
||||
public static class Post extends RenderGameOverlayEvent
|
||||
{
|
||||
public Post(MatrixStack mStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
public Post(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
{
|
||||
super(mStack, parent, type);
|
||||
}
|
||||
@Override public boolean isCancelable(){ return false; }
|
||||
}
|
||||
|
||||
public static class PreLayer extends Pre
|
||||
{
|
||||
private final IIngameOverlay overlay;
|
||||
|
||||
public PreLayer(PoseStack mStack, RenderGameOverlayEvent parent, IIngameOverlay overlay)
|
||||
{
|
||||
super(mStack, parent, ElementType.LAYER);
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
public IIngameOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PostLayer extends Post
|
||||
{
|
||||
private final IIngameOverlay overlay;
|
||||
|
||||
public PostLayer(PoseStack mStack, RenderGameOverlayEvent parent, IIngameOverlay overlay)
|
||||
{
|
||||
super(mStack, parent, ElementType.LAYER);
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
public IIngameOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BossInfo extends Pre
|
||||
{
|
||||
private final ClientBossInfo bossInfo;
|
||||
private final LerpingBossEvent bossInfo;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private int increment;
|
||||
public BossInfo(MatrixStack mStack, RenderGameOverlayEvent parent, ElementType type, ClientBossInfo bossInfo, int x, int y, int increment)
|
||||
public BossInfo(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type, LerpingBossEvent bossInfo, int x, int y, int increment)
|
||||
{
|
||||
super(mStack, parent, type);
|
||||
this.bossInfo = bossInfo;
|
||||
@@ -130,9 +148,9 @@ public class RenderGameOverlayEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The {@link BossInfoClient} currently being rendered
|
||||
* @return The {@link ClientBossInfo} currently being rendered
|
||||
*/
|
||||
public ClientBossInfo getBossInfo()
|
||||
public LerpingBossEvent getBossInfo()
|
||||
{
|
||||
return bossInfo;
|
||||
}
|
||||
@@ -175,7 +193,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
{
|
||||
private final ArrayList<String> left;
|
||||
private final ArrayList<String> right;
|
||||
public Text(MatrixStack mStack, RenderGameOverlayEvent parent, ArrayList<String> left, ArrayList<String> right)
|
||||
public Text(PoseStack mStack, RenderGameOverlayEvent parent, ArrayList<String> left, ArrayList<String> right)
|
||||
{
|
||||
super(mStack, parent, ElementType.TEXT);
|
||||
this.left = left;
|
||||
@@ -198,7 +216,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
private int posX;
|
||||
private int posY;
|
||||
|
||||
public Chat(MatrixStack mStack, RenderGameOverlayEvent parent, int posX, int posY)
|
||||
public Chat(PoseStack mStack, RenderGameOverlayEvent parent, int posX, int posY)
|
||||
{
|
||||
super(mStack, parent, ElementType.CHAT);
|
||||
this.setPosX(posX);
|
||||
|
||||
@@ -21,11 +21,11 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@@ -37,9 +37,9 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
@Cancelable
|
||||
public class RenderHandEvent extends Event
|
||||
{
|
||||
private final Hand hand;
|
||||
private final MatrixStack mat;
|
||||
private final IRenderTypeBuffer buffers;
|
||||
private final InteractionHand hand;
|
||||
private final PoseStack mat;
|
||||
private final MultiBufferSource buffers;
|
||||
private final int light;
|
||||
private final float partialTicks;
|
||||
private final float interpolatedPitch;
|
||||
@@ -48,7 +48,7 @@ public class RenderHandEvent extends Event
|
||||
@Nonnull
|
||||
private final ItemStack stack;
|
||||
|
||||
public RenderHandEvent(Hand hand, MatrixStack mat, IRenderTypeBuffer buffers, int light,
|
||||
public RenderHandEvent(InteractionHand hand, PoseStack mat, MultiBufferSource buffers, int light,
|
||||
float partialTicks, float interpolatedPitch,
|
||||
float swingProgress, float equipProgress, @Nonnull ItemStack stack)
|
||||
{
|
||||
@@ -63,17 +63,17 @@ public class RenderHandEvent extends Event
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public Hand getHand()
|
||||
public InteractionHand getHand()
|
||||
{
|
||||
return hand;
|
||||
}
|
||||
|
||||
public MatrixStack getMatrixStack()
|
||||
public PoseStack getMatrixStack()
|
||||
{
|
||||
return mat;
|
||||
}
|
||||
|
||||
public IRenderTypeBuffer getBuffers() {
|
||||
public MultiBufferSource getBuffers() {
|
||||
return buffers;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
|
||||
import net.minecraft.entity.item.ItemFrameEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.entity.decoration.ItemFrame;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@@ -38,14 +38,14 @@ import javax.annotation.Nonnull;
|
||||
public class RenderItemInFrameEvent extends Event
|
||||
{
|
||||
private final ItemStack item;
|
||||
private final ItemFrameEntity entityItemFrame;
|
||||
private final ItemFrame entityItemFrame;
|
||||
private final ItemFrameRenderer renderer;
|
||||
private final MatrixStack matrix;
|
||||
private final IRenderTypeBuffer buffers;
|
||||
private final PoseStack matrix;
|
||||
private final MultiBufferSource buffers;
|
||||
private final int light;
|
||||
|
||||
public RenderItemInFrameEvent(ItemFrameEntity itemFrame, ItemFrameRenderer renderItemFrame, MatrixStack matrix,
|
||||
IRenderTypeBuffer buffers, int light)
|
||||
public RenderItemInFrameEvent(ItemFrame itemFrame, ItemFrameRenderer renderItemFrame, PoseStack matrix,
|
||||
MultiBufferSource buffers, int light)
|
||||
{
|
||||
item = itemFrame.getItem();
|
||||
entityItemFrame = itemFrame;
|
||||
@@ -61,7 +61,7 @@ public class RenderItemInFrameEvent extends Event
|
||||
return item;
|
||||
}
|
||||
|
||||
public ItemFrameEntity getEntityItemFrame()
|
||||
public ItemFrame getEntityItemFrame()
|
||||
{
|
||||
return entityItemFrame;
|
||||
}
|
||||
@@ -71,11 +71,11 @@ public class RenderItemInFrameEvent extends Event
|
||||
return renderer;
|
||||
}
|
||||
|
||||
public MatrixStack getMatrix() {
|
||||
public PoseStack getMatrix() {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public IRenderTypeBuffer getBuffers() {
|
||||
public MultiBufferSource getBuffers() {
|
||||
return buffers;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,26 +19,26 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.entity.LivingRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
public abstract class RenderLivingEvent<T extends LivingEntity, M extends EntityModel<T>> extends Event
|
||||
{
|
||||
|
||||
private final LivingEntity entity;
|
||||
private final LivingRenderer<T, M> renderer;
|
||||
private final LivingEntityRenderer<T, M> renderer;
|
||||
private final float partialRenderTick;
|
||||
private final MatrixStack matrixStack;
|
||||
private final IRenderTypeBuffer buffers;
|
||||
private final PoseStack matrixStack;
|
||||
private final MultiBufferSource buffers;
|
||||
private final int light;
|
||||
|
||||
public RenderLivingEvent(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack,
|
||||
IRenderTypeBuffer buffers, int light)
|
||||
public RenderLivingEvent(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialRenderTick, PoseStack matrixStack,
|
||||
MultiBufferSource buffers, int light)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.renderer = renderer;
|
||||
@@ -49,23 +49,23 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
|
||||
}
|
||||
|
||||
public LivingEntity getEntity() { return entity; }
|
||||
public LivingRenderer<T, M> getRenderer() { return renderer; }
|
||||
public LivingEntityRenderer<T, M> getRenderer() { return renderer; }
|
||||
public float getPartialRenderTick() { return partialRenderTick; }
|
||||
public MatrixStack getMatrixStack() { return matrixStack; }
|
||||
public IRenderTypeBuffer getBuffers() { return buffers; }
|
||||
public PoseStack getMatrixStack() { return matrixStack; }
|
||||
public MultiBufferSource getBuffers() { return buffers; }
|
||||
public int getLight() { return light; }
|
||||
|
||||
@Cancelable
|
||||
public static class Pre<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
public Pre(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack, IRenderTypeBuffer buffers, int light) {
|
||||
public Pre(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialRenderTick, PoseStack matrixStack, MultiBufferSource buffers, int light) {
|
||||
super(entity, renderer, partialRenderTick, matrixStack, buffers, light);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Post<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
public Post(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack, IRenderTypeBuffer buffers, int light) {
|
||||
public Post(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialRenderTick, PoseStack matrixStack, MultiBufferSource buffers, int light) {
|
||||
super(entity, renderer, partialRenderTick, matrixStack, buffers, light);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@@ -53,15 +52,15 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
public class RenderNameplateEvent extends EntityEvent
|
||||
{
|
||||
|
||||
private ITextComponent nameplateContent;
|
||||
private final ITextComponent originalContent;
|
||||
private Component nameplateContent;
|
||||
private final Component originalContent;
|
||||
private final EntityRenderer<?> entityRenderer;
|
||||
private final MatrixStack matrixStack;
|
||||
private final IRenderTypeBuffer renderTypeBuffer;
|
||||
private final PoseStack matrixStack;
|
||||
private final MultiBufferSource renderTypeBuffer;
|
||||
private final int packedLight;
|
||||
private final float partialTicks;
|
||||
|
||||
public RenderNameplateEvent(Entity entity, ITextComponent content, EntityRenderer<?> entityRenderer, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int packedLight, float partialTicks)
|
||||
public RenderNameplateEvent(Entity entity, Component content, EntityRenderer<?> entityRenderer, PoseStack matrixStack, MultiBufferSource renderTypeBuffer, int packedLight, float partialTicks)
|
||||
{
|
||||
super(entity);
|
||||
this.originalContent = content;
|
||||
@@ -76,7 +75,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
/**
|
||||
* Sets the content that is to be rendered on the name plate/tag
|
||||
*/
|
||||
public void setContent(ITextComponent contents)
|
||||
public void setContent(Component contents)
|
||||
{
|
||||
this.nameplateContent = contents;
|
||||
}
|
||||
@@ -84,7 +83,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
/**
|
||||
* The content being rendered on the name plate/tag
|
||||
*/
|
||||
public ITextComponent getContent()
|
||||
public Component getContent()
|
||||
{
|
||||
return this.nameplateContent;
|
||||
}
|
||||
@@ -92,7 +91,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
/**
|
||||
* The original content being rendered on the name plate/tag
|
||||
*/
|
||||
public ITextComponent getOriginalContent()
|
||||
public Component getOriginalContent()
|
||||
{
|
||||
return this.originalContent;
|
||||
}
|
||||
@@ -108,7 +107,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
/**
|
||||
* The matrix stack used during the rendering of the name plate/tag
|
||||
*/
|
||||
public MatrixStack getMatrixStack()
|
||||
public PoseStack getMatrixStack()
|
||||
{
|
||||
return this.matrixStack;
|
||||
}
|
||||
@@ -116,7 +115,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
/**
|
||||
* The render type buffer used during the rendering of the name plate/tag
|
||||
*/
|
||||
public IRenderTypeBuffer getRenderTypeBuffer()
|
||||
public MultiBufferSource getRenderTypeBuffer()
|
||||
{
|
||||
return this.renderTypeBuffer;
|
||||
}
|
||||
|
||||
@@ -19,22 +19,22 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraft.client.renderer.entity.PlayerRenderer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
{
|
||||
private final PlayerRenderer renderer;
|
||||
private final float partialRenderTick;
|
||||
private final MatrixStack stack;
|
||||
private final IRenderTypeBuffer buffers;
|
||||
private final PoseStack stack;
|
||||
private final MultiBufferSource buffers;
|
||||
private final int light;
|
||||
|
||||
public RenderPlayerEvent(PlayerEntity player, PlayerRenderer renderer, float partialRenderTick, MatrixStack stack, IRenderTypeBuffer buffers, int light)
|
||||
public RenderPlayerEvent(Player player, PlayerRenderer renderer, float partialRenderTick, PoseStack stack, MultiBufferSource buffers, int light)
|
||||
{
|
||||
super(player);
|
||||
this.renderer = renderer;
|
||||
@@ -46,21 +46,21 @@ public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
|
||||
public PlayerRenderer getRenderer() { return renderer; }
|
||||
public float getPartialRenderTick() { return partialRenderTick; }
|
||||
public MatrixStack getMatrixStack() { return stack; }
|
||||
public IRenderTypeBuffer getBuffers() { return buffers; }
|
||||
public PoseStack getMatrixStack() { return stack; }
|
||||
public MultiBufferSource getBuffers() { return buffers; }
|
||||
public int getLight() { return light; }
|
||||
|
||||
@Cancelable
|
||||
public static class Pre extends RenderPlayerEvent
|
||||
{
|
||||
public Pre(PlayerEntity player, PlayerRenderer renderer, float tick, MatrixStack stack, IRenderTypeBuffer buffers, int light) {
|
||||
public Pre(Player player, PlayerRenderer renderer, float tick, PoseStack stack, MultiBufferSource buffers, int light) {
|
||||
super(player, renderer, tick, stack, buffers, light);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Post extends RenderPlayerEvent
|
||||
{
|
||||
public Post(PlayerEntity player, PlayerRenderer renderer, float tick, MatrixStack stack, IRenderTypeBuffer buffers, int light) {
|
||||
public Post(Player player, PlayerRenderer renderer, float tick, PoseStack stack, MultiBufferSource buffers, int light) {
|
||||
super(player, renderer, tick, stack, buffers, light);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,10 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextProperties;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
|
||||
/**
|
||||
* A set of events which are fired at various points during tooltip rendering.
|
||||
@@ -48,13 +45,13 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
{
|
||||
@Nonnull
|
||||
protected final ItemStack stack;
|
||||
protected final List<? extends ITextProperties> lines;
|
||||
protected final MatrixStack matrixStack;
|
||||
protected final List<? extends FormattedText> lines;
|
||||
protected final PoseStack matrixStack;
|
||||
protected int x;
|
||||
protected int y;
|
||||
protected FontRenderer fr;
|
||||
protected Font fr;
|
||||
|
||||
public RenderTooltipEvent(@Nonnull ItemStack stack, @Nonnull List<? extends ITextProperties> lines, MatrixStack matrixStack, int x, int y, @Nonnull FontRenderer fr)
|
||||
public RenderTooltipEvent(@Nonnull ItemStack stack, @Nonnull List<? extends FormattedText> lines, PoseStack matrixStack, int x, int y, @Nonnull Font fr)
|
||||
{
|
||||
this.stack = stack;
|
||||
this.lines = Collections.unmodifiableList(lines); // Leave editing to ItemTooltipEvent
|
||||
@@ -79,7 +76,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
* @return An <i>unmodifiable</i> list of strings. Use {@link ItemTooltipEvent} to modify tooltip text.
|
||||
*/
|
||||
@Nonnull
|
||||
public List<? extends ITextProperties> getLines()
|
||||
public List<? extends FormattedText> getLines()
|
||||
{
|
||||
return lines;
|
||||
}
|
||||
@@ -87,7 +84,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
/**
|
||||
* @return The MatrixStack of the current rendering context
|
||||
*/
|
||||
public MatrixStack getMatrixStack()
|
||||
public PoseStack getMatrixStack()
|
||||
{
|
||||
return matrixStack;
|
||||
}
|
||||
@@ -112,7 +109,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
* @return The {@link FontRenderer} instance the current render is using.
|
||||
*/
|
||||
@Nonnull
|
||||
public FontRenderer getFontRenderer()
|
||||
public Font getFontRenderer()
|
||||
{
|
||||
return fr;
|
||||
}
|
||||
@@ -129,7 +126,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
private int screenHeight;
|
||||
private int maxWidth;
|
||||
|
||||
public Pre(@Nonnull ItemStack stack, @Nonnull List<? extends ITextProperties> lines, MatrixStack matrixStack, int x, int y, int screenWidth, int screenHeight, int maxWidth, @Nonnull FontRenderer fr)
|
||||
public Pre(@Nonnull ItemStack stack, @Nonnull List<? extends FormattedText> lines, PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, int maxWidth, @Nonnull Font fr)
|
||||
{
|
||||
super(stack, lines, matrixStack, x, y, fr);
|
||||
this.screenWidth = screenWidth;
|
||||
@@ -176,7 +173,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
/**
|
||||
* Sets the {@link FontRenderer} to be used to render text.
|
||||
*/
|
||||
public void setFontRenderer(@Nonnull FontRenderer fr)
|
||||
public void setFontRenderer(@Nonnull Font fr)
|
||||
{
|
||||
this.fr = fr;
|
||||
}
|
||||
@@ -212,7 +209,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public Post(@Nonnull ItemStack stack, @Nonnull List<? extends ITextProperties> textLines, MatrixStack matrixStack,int x, int y, @Nonnull FontRenderer fr, int width, int height)
|
||||
public Post(@Nonnull ItemStack stack, @Nonnull List<? extends FormattedText> textLines, PoseStack matrixStack,int x, int y, @Nonnull Font fr, int width, int height)
|
||||
{
|
||||
super(stack, textLines, matrixStack, x, y, fr);
|
||||
this.width = width;
|
||||
@@ -241,7 +238,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
*/
|
||||
public static class PostBackground extends Post
|
||||
{
|
||||
public PostBackground(@Nonnull ItemStack stack, @Nonnull List<? extends ITextProperties> textLines, MatrixStack matrixStack, int x, int y, @Nonnull FontRenderer fr, int width, int height)
|
||||
public PostBackground(@Nonnull ItemStack stack, @Nonnull List<? extends FormattedText> textLines, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int width, int height)
|
||||
{ super(stack, textLines, matrixStack, x, y, fr, width, height); }
|
||||
}
|
||||
|
||||
@@ -250,7 +247,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
*/
|
||||
public static class PostText extends Post
|
||||
{
|
||||
public PostText(@Nonnull ItemStack stack, @Nonnull List<? extends ITextProperties> textLines, MatrixStack matrixStack, int x, int y, @Nonnull FontRenderer fr, int width, int height)
|
||||
public PostText(@Nonnull ItemStack stack, @Nonnull List<? extends FormattedText> textLines, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int width, int height)
|
||||
{ super(stack, textLines, matrixStack, x, y, fr, width, height); }
|
||||
}
|
||||
|
||||
@@ -266,7 +263,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
private int borderStart;
|
||||
private int borderEnd;
|
||||
|
||||
public Color(@Nonnull ItemStack stack, @Nonnull List<? extends ITextProperties> textLines, MatrixStack matrixStack, int x, int y, @Nonnull FontRenderer fr, int background, int borderStart,
|
||||
public Color(@Nonnull ItemStack stack, @Nonnull List<? extends FormattedText> textLines, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int background, int borderStart,
|
||||
int borderEnd)
|
||||
{
|
||||
super(stack, textLines, matrixStack, x, y, fr);
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
|
||||
public class RenderWorldLastEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final WorldRenderer context;
|
||||
private final MatrixStack mat;
|
||||
private final LevelRenderer context;
|
||||
private final PoseStack mat;
|
||||
private final float partialTicks;
|
||||
private final Matrix4f projectionMatrix;
|
||||
private final long finishTimeNano;
|
||||
|
||||
public RenderWorldLastEvent(WorldRenderer context, MatrixStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano)
|
||||
public RenderWorldLastEvent(LevelRenderer context, PoseStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano)
|
||||
{
|
||||
this.context = context;
|
||||
this.mat = mat;
|
||||
@@ -41,12 +41,12 @@ public class RenderWorldLastEvent extends net.minecraftforge.eventbus.api.Event
|
||||
this.finishTimeNano = finishTimeNano;
|
||||
}
|
||||
|
||||
public WorldRenderer getContext()
|
||||
public LevelRenderer getContext()
|
||||
{
|
||||
return context;
|
||||
}
|
||||
|
||||
public MatrixStack getMatrixStack()
|
||||
public PoseStack getMatrixStack()
|
||||
{
|
||||
return mat;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@@ -41,12 +41,12 @@ import java.io.IOException;
|
||||
public class ScreenshotEvent extends Event
|
||||
{
|
||||
|
||||
public static final ITextComponent DEFAULT_CANCEL_REASON = new StringTextComponent("Screenshot canceled");
|
||||
public static final Component DEFAULT_CANCEL_REASON = new TextComponent("Screenshot canceled");
|
||||
|
||||
private NativeImage image;
|
||||
private File screenshotFile;
|
||||
|
||||
private ITextComponent resultMessage = null;
|
||||
private Component resultMessage = null;
|
||||
|
||||
public ScreenshotEvent(NativeImage image, File screenshotFile)
|
||||
{
|
||||
@@ -72,17 +72,17 @@ public class ScreenshotEvent extends Event
|
||||
this.screenshotFile = screenshotFile;
|
||||
}
|
||||
|
||||
public ITextComponent getResultMessage()
|
||||
public Component getResultMessage()
|
||||
{
|
||||
return resultMessage;
|
||||
}
|
||||
|
||||
public void setResultMessage(ITextComponent resultMessage)
|
||||
public void setResultMessage(Component resultMessage)
|
||||
{
|
||||
this.resultMessage = resultMessage;
|
||||
}
|
||||
|
||||
public ITextComponent getCancelMessage()
|
||||
public Component getCancelMessage()
|
||||
{
|
||||
return getResultMessage() != null ? getResultMessage() : DEFAULT_CANCEL_REASON;
|
||||
}
|
||||
|
||||
@@ -19,24 +19,24 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final AtlasTexture map;
|
||||
private final TextureAtlas map;
|
||||
|
||||
public TextureStitchEvent(AtlasTexture map)
|
||||
public TextureStitchEvent(TextureAtlas map)
|
||||
{
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public AtlasTexture getMap()
|
||||
public TextureAtlas getMap()
|
||||
{
|
||||
return map;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Set<ResourceLocation> sprites;
|
||||
|
||||
public Pre(AtlasTexture map, Set<ResourceLocation> sprites)
|
||||
public Pre(TextureAtlas map, Set<ResourceLocation> sprites)
|
||||
{
|
||||
super(map);
|
||||
this.sprites = sprites;
|
||||
@@ -70,6 +70,6 @@ public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
*/
|
||||
public static class Post extends TextureStitchEvent
|
||||
{
|
||||
public Post(AtlasTexture map){ super(map); }
|
||||
public Post(TextureAtlas map){ super(map); }
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
|
||||
/***
|
||||
* Raised when the SoundManager tries to play a normal sound.
|
||||
@@ -31,10 +31,10 @@ import net.minecraft.client.audio.SoundEngine;
|
||||
public class PlaySoundEvent extends SoundEvent
|
||||
{
|
||||
private final String name;
|
||||
private final ISound sound;
|
||||
private ISound result;
|
||||
private final SoundInstance sound;
|
||||
private SoundInstance result;
|
||||
|
||||
public PlaySoundEvent(SoundEngine manager, ISound sound)
|
||||
public PlaySoundEvent(SoundEngine manager, SoundInstance sound)
|
||||
{
|
||||
super(manager);
|
||||
this.sound = sound;
|
||||
@@ -47,17 +47,17 @@ public class PlaySoundEvent extends SoundEvent
|
||||
return name;
|
||||
}
|
||||
|
||||
public ISound getSound()
|
||||
public SoundInstance getSound()
|
||||
{
|
||||
return sound;
|
||||
}
|
||||
|
||||
public ISound getResultSound()
|
||||
public SoundInstance getResultSound()
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResultSound(ISound result)
|
||||
public void setResultSound(SoundInstance result)
|
||||
{
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.audio.SoundSource;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
|
||||
public class PlaySoundSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
public PlaySoundSourceEvent(SoundEngine manager, ISound sound, SoundSource source)
|
||||
public PlaySoundSourceEvent(SoundEngine manager, SoundInstance sound, Channel source)
|
||||
{
|
||||
super(manager, sound, source);
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.audio.SoundSource;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
|
||||
public class PlayStreamingSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
public PlayStreamingSourceEvent(SoundEngine manager, ISound sound, SoundSource source)
|
||||
public PlayStreamingSourceEvent(SoundEngine manager, SoundInstance sound, Channel source)
|
||||
{
|
||||
super(manager, sound, source);
|
||||
}
|
||||
|
||||
@@ -19,10 +19,9 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.audio.SoundSource;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
|
||||
public class SoundEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
@@ -39,11 +38,11 @@ public class SoundEvent extends net.minecraftforge.eventbus.api.Event
|
||||
|
||||
public static class SoundSourceEvent extends SoundEvent
|
||||
{
|
||||
private final ISound sound;
|
||||
private final SoundSource source;
|
||||
private final SoundInstance sound;
|
||||
private final Channel source;
|
||||
private final String name;
|
||||
|
||||
public SoundSourceEvent(SoundEngine manager, ISound sound, SoundSource source)
|
||||
public SoundSourceEvent(SoundEngine manager, SoundInstance sound, Channel source)
|
||||
{
|
||||
super(manager);
|
||||
this.name = sound.getLocation().getPath();
|
||||
@@ -51,12 +50,12 @@ public class SoundEvent extends net.minecraftforge.eventbus.api.Event
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public ISound getSound()
|
||||
public SoundInstance getSound()
|
||||
{
|
||||
return sound;
|
||||
}
|
||||
|
||||
public SoundSource getSource()
|
||||
public Channel getSource()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
/**
|
||||
* Raised by the SoundManager.loadSoundSettings, this would be a good place for
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
|
||||
/**
|
||||
* This event is raised by the SoundManager when it does its first setup of the
|
||||
|
||||
@@ -26,36 +26,36 @@ import java.util.Random;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
public interface IForgeBakedModel
|
||||
{
|
||||
default IBakedModel getBakedModel()
|
||||
private BakedModel self()
|
||||
{
|
||||
return (IBakedModel) this;
|
||||
return (BakedModel) this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
default List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData)
|
||||
{
|
||||
return getBakedModel().getQuads(state, side, rand);
|
||||
return self().getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
default boolean isAmbientOcclusion(BlockState state) { return getBakedModel().useAmbientOcclusion(); }
|
||||
default boolean isAmbientOcclusion(BlockState state) { return self().useAmbientOcclusion(); }
|
||||
|
||||
/**
|
||||
* Override to tell the new model loader that it shouldn't wrap this model
|
||||
@@ -66,19 +66,19 @@ public interface IForgeBakedModel
|
||||
* Returns the pair of the model for the given perspective, and the matrix that
|
||||
* should be applied to the GL state before rendering it (matrix may be null).
|
||||
*/
|
||||
default IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat)
|
||||
default BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack)
|
||||
{
|
||||
return net.minecraftforge.client.ForgeHooksClient.handlePerspective(getBakedModel(), cameraTransformType, mat);
|
||||
return net.minecraftforge.client.ForgeHooksClient.handlePerspective(self(), cameraTransformType, poseStack);
|
||||
}
|
||||
|
||||
default @Nonnull IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
default @Nonnull IModelData getModelData(@Nonnull BlockAndTintGetter world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
{
|
||||
return tileData;
|
||||
}
|
||||
|
||||
default TextureAtlasSprite getParticleTexture(@Nonnull IModelData data)
|
||||
default TextureAtlasSprite getParticleIcon(@Nonnull IModelData data)
|
||||
{
|
||||
return getBakedModel().getParticleIcon();
|
||||
return self().getParticleIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,8 +92,8 @@ public interface IForgeBakedModel
|
||||
/**
|
||||
* If {@see isLayered()} returns true, this is called to get the list of layers to draw.
|
||||
*/
|
||||
default List<Pair<IBakedModel, RenderType>> getLayerModels(ItemStack itemStack, boolean fabulous)
|
||||
default List<Pair<BakedModel, RenderType>> getLayerModels(ItemStack itemStack, boolean fabulous)
|
||||
{
|
||||
return Collections.singletonList(Pair.of(getBakedModel(), RenderTypeLookup.getRenderType(itemStack, fabulous)));
|
||||
return Collections.singletonList(Pair.of(self(), ItemBlockRenderTypes.getRenderType(itemStack, fabulous)));
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -21,28 +21,28 @@ package net.minecraftforge.client.extensions;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraftforge.client.settings.IKeyConflictContext;
|
||||
import net.minecraftforge.client.settings.KeyModifier;
|
||||
|
||||
public interface IForgeKeybinding
|
||||
public interface IForgeKeyMapping
|
||||
{
|
||||
default KeyBinding getKeyBinding() { return (KeyBinding) this; }
|
||||
private KeyMapping self() { return (KeyMapping) this; }
|
||||
|
||||
@Nonnull InputMappings.Input getKey();
|
||||
@Nonnull InputConstants.Key getKey();
|
||||
|
||||
/**
|
||||
* Checks that the key conflict context and modifier are active, and that the keyCode matches this binding.
|
||||
*/
|
||||
default boolean isActiveAndMatches(InputMappings.Input keyCode)
|
||||
default boolean isActiveAndMatches(InputConstants.Key keyCode)
|
||||
{
|
||||
return keyCode != InputMappings.UNKNOWN && keyCode.equals(getKey()) && getKeyConflictContext().isActive() && getKeyModifier().isActive(getKeyConflictContext());
|
||||
return keyCode != InputConstants.UNKNOWN && keyCode.equals(getKey()) && getKeyConflictContext().isActive() && getKeyModifier().isActive(getKeyConflictContext());
|
||||
}
|
||||
|
||||
default void setToDefault()
|
||||
{
|
||||
setKeyModifierAndCode(getKeyModifierDefault(), getKeyBinding().getDefaultKey());
|
||||
setKeyModifierAndCode(getKeyModifierDefault(), self().getDefaultKey());
|
||||
}
|
||||
|
||||
void setKeyConflictContext(IKeyConflictContext keyConflictContext);
|
||||
@@ -53,7 +53,7 @@ public interface IForgeKeybinding
|
||||
|
||||
KeyModifier getKeyModifier();
|
||||
|
||||
void setKeyModifierAndCode(KeyModifier keyModifier, InputMappings.Input keyCode);
|
||||
void setKeyModifierAndCode(KeyModifier keyModifier, InputConstants.Key keyCode);
|
||||
|
||||
default boolean isConflictContextAndModifierActive()
|
||||
{
|
||||
@@ -63,7 +63,7 @@ public interface IForgeKeybinding
|
||||
/**
|
||||
* Returns true when one of the bindings' key codes conflicts with the other's modifier.
|
||||
*/
|
||||
default boolean hasKeyCodeModifierConflict(KeyBinding other)
|
||||
default boolean hasKeyCodeModifierConflict(KeyMapping other)
|
||||
{
|
||||
if (getKeyConflictContext().conflicts(other.getKeyConflictContext()) || other.getKeyConflictContext().conflicts(getKeyConflictContext()))
|
||||
{
|
||||
+4
-4
@@ -19,13 +19,13 @@
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import com.mojang.math.Transformation;
|
||||
|
||||
/**
|
||||
* An {@code IModelState} is a function from model part to a transformation that should be applied
|
||||
* when that part is baked, thus representing the current "state" of the model and its parts.
|
||||
*/
|
||||
public interface IForgeModelTransform
|
||||
public interface IForgeModelState
|
||||
{
|
||||
/**
|
||||
* @param part Part of the model we are wanting to transform. An empty optional means
|
||||
@@ -33,8 +33,8 @@ public interface IForgeModelTransform
|
||||
* @return A transformation to apply to the part, if any. The coordinate system of the transform
|
||||
* is determined by the part type.
|
||||
*/
|
||||
default TransformationMatrix getPartTransformation(Object part)
|
||||
default Transformation getPartTransformation(Object part)
|
||||
{
|
||||
return TransformationMatrix.identity();
|
||||
return Transformation.identity();
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderCache;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunkRegion;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public interface IForgeRenderChunk
|
||||
{
|
||||
@@ -38,8 +38,8 @@ public interface IForgeRenderChunk
|
||||
* the cache a 20x20x20 cube, for a total of 8000 states in the cache.
|
||||
* @return new RegionRenderCache instance
|
||||
*/
|
||||
default ChunkRenderCache createRegionRenderCache(World world, BlockPos from, BlockPos to, int subtract)
|
||||
default RenderChunkRegion createRegionRenderCache(Level world, BlockPos from, BlockPos to, int subtract)
|
||||
{
|
||||
return ChunkRenderCache.createIfNotEmpty(world, from, to, subtract);
|
||||
return RenderChunkRegion.createIfNotEmpty(world, from, to, subtract);
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ import java.util.function.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface IForgeTextureAtlasSprite
|
||||
{
|
||||
@@ -35,7 +35,7 @@ public interface IForgeTextureAtlasSprite
|
||||
* @deprecated See {@link net.minecraftforge.client.textures.ITextureAtlasSpriteLoader}
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean hasCustomLoader(IResourceManager manager, ResourceLocation location)
|
||||
default boolean hasCustomLoader(ResourceManager manager, ResourceLocation location)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public interface IForgeTextureAtlasSprite
|
||||
* @deprecated See {@link net.minecraftforge.client.textures.ITextureAtlasSpriteLoader}
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean load(IResourceManager manager, ResourceLocation location, Function<ResourceLocation, TextureAtlasSprite> textureGetter)
|
||||
default boolean load(ResourceManager manager, ResourceLocation location, Function<ResourceLocation, TextureAtlasSprite> textureGetter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
+25
-42
@@ -19,79 +19,62 @@
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.*;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
/*
|
||||
* Replacement interface for ModelRotation to allow custom transformations of vanilla models.
|
||||
* You should probably use TRSRTransformation directly.
|
||||
*/
|
||||
public interface IForgeTransformationMatrix
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector4f;
|
||||
|
||||
public interface IForgeTransformation
|
||||
{
|
||||
default TransformationMatrix getTransformaion()
|
||||
private Transformation self()
|
||||
{
|
||||
return (TransformationMatrix)this;
|
||||
return (Transformation)this;
|
||||
}
|
||||
|
||||
default boolean isIdentity()
|
||||
{
|
||||
return getTransformaion().equals(TransformationMatrix.identity());
|
||||
return self().equals(Transformation.identity());
|
||||
}
|
||||
|
||||
default void push(MatrixStack stack)
|
||||
default void push(PoseStack stack)
|
||||
{
|
||||
stack.pushPose();
|
||||
|
||||
Vector3f trans = getTransformaion().getTranslation();
|
||||
Vector3f trans = self().getTranslation();
|
||||
stack.translate(trans.x(), trans.y(), trans.z());
|
||||
|
||||
stack.mulPose(getTransformaion().getLeftRotation());
|
||||
stack.mulPose(self().getLeftRotation());
|
||||
|
||||
Vector3f scale = getTransformaion().getScale();
|
||||
Vector3f scale = self().getScale();
|
||||
stack.scale(scale.x(), scale.y(), scale.z());
|
||||
|
||||
stack.mulPose(getTransformaion().getRightRot());
|
||||
stack.mulPose(self().getRightRotation());
|
||||
|
||||
}
|
||||
|
||||
default TransformationMatrix compose(TransformationMatrix other)
|
||||
{
|
||||
if (getTransformaion().isIdentity()) return other;
|
||||
if (other.isIdentity()) return getTransformaion();
|
||||
Matrix4f m = getTransformaion().getMatrix();
|
||||
m.multiply(other.getMatrix());
|
||||
return new TransformationMatrix(m);
|
||||
}
|
||||
|
||||
default TransformationMatrix inverse()
|
||||
{
|
||||
if (isIdentity()) return getTransformaion();
|
||||
Matrix4f m = getTransformaion().getMatrix().copy();
|
||||
m.invert();
|
||||
return new TransformationMatrix(m);
|
||||
}
|
||||
|
||||
default void transformPosition(Vector4f position)
|
||||
{
|
||||
position.transform(getTransformaion().getMatrix());
|
||||
position.transform(self().getMatrix());
|
||||
}
|
||||
|
||||
default void transformNormal(Vector3f normal)
|
||||
{
|
||||
normal.transform(getTransformaion().getNormalMatrix());
|
||||
normal.transform(self().getNormalMatrix());
|
||||
normal.normalize();
|
||||
}
|
||||
|
||||
default Direction rotateTransform(Direction facing)
|
||||
{
|
||||
return Direction.rotate(getTransformaion().getMatrix(), facing);
|
||||
return Direction.rotate(self().getMatrix(), facing);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert transformation from assuming center-block system to opposing-corner-block system
|
||||
*/
|
||||
default TransformationMatrix blockCenterToCorner()
|
||||
default Transformation blockCenterToCorner()
|
||||
{
|
||||
return applyOrigin(new Vector3f(.5f, .5f, .5f));
|
||||
}
|
||||
@@ -99,7 +82,7 @@ public interface IForgeTransformationMatrix
|
||||
/**
|
||||
* convert transformation from assuming opposing-corner-block system to center-block system
|
||||
*/
|
||||
default TransformationMatrix blockCornerToCenter()
|
||||
default Transformation blockCornerToCenter()
|
||||
{
|
||||
return applyOrigin(new Vector3f(-.5f, -.5f, -.5f));
|
||||
}
|
||||
@@ -109,9 +92,9 @@ public interface IForgeTransformationMatrix
|
||||
* Can be used for switching between coordinate systems.
|
||||
* Parameter is relative to the current origin.
|
||||
*/
|
||||
default TransformationMatrix applyOrigin(Vector3f origin) {
|
||||
TransformationMatrix transform = getTransformaion();
|
||||
if (transform.isIdentity()) return TransformationMatrix.identity();
|
||||
default Transformation applyOrigin(Vector3f origin) {
|
||||
Transformation transform = self();
|
||||
if (transform.isIdentity()) return Transformation.identity();
|
||||
|
||||
Matrix4f ret = transform.getMatrix();
|
||||
Matrix4f tmp = Matrix4f.createTranslateMatrix(origin.x(), origin.y(), origin.z());
|
||||
@@ -119,6 +102,6 @@ public interface IForgeTransformationMatrix
|
||||
tmp.setIdentity();
|
||||
tmp.setTranslation(-origin.x(), -origin.y(), -origin.z());
|
||||
ret.multiply(tmp);
|
||||
return new TransformationMatrix(ret);
|
||||
return new Transformation(ret);
|
||||
}
|
||||
}
|
||||
+26
-24
@@ -19,13 +19,11 @@
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.math.vector.*;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
@@ -34,37 +32,41 @@ import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public interface IForgeVertexBuilder
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
||||
public interface IForgeVertexConsumer
|
||||
{
|
||||
default IVertexBuilder getVertexBuilder() { return (IVertexBuilder)this; }
|
||||
|
||||
// Copy of addQuad, but enables tinting and per-vertex alpha
|
||||
default void addVertexData(MatrixStack.Entry matrixStack, BakedQuad bakedQuad, float red, float green, float blue, int lightmapCoord, int overlayColor, boolean readExistingColor) {
|
||||
addVertexData(matrixStack, bakedQuad, red, green, blue, 1.0f, lightmapCoord, overlayColor, readExistingColor);
|
||||
// Copy of putBulkData, but enables tinting and per-vertex alpha
|
||||
default void putBulkData(PoseStack.Pose matrixStack, BakedQuad bakedQuad, float red, float green, float blue, int lightmapCoord, int overlayColor, boolean readExistingColor) {
|
||||
putBulkData(matrixStack, bakedQuad, red, green, blue, 1.0f, lightmapCoord, overlayColor, readExistingColor);
|
||||
}
|
||||
|
||||
// Copy of addQuad with alpha support
|
||||
default void addVertexData(MatrixStack.Entry matrixEntry, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int lightmapCoord, int overlayColor) {
|
||||
addVertexData(matrixEntry, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{lightmapCoord, lightmapCoord, lightmapCoord, lightmapCoord}, overlayColor, false);
|
||||
// Copy of putBulkData with alpha support
|
||||
default void putBulkData(PoseStack.Pose matrixEntry, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int lightmapCoord, int overlayColor) {
|
||||
putBulkData(matrixEntry, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{lightmapCoord, lightmapCoord, lightmapCoord, lightmapCoord}, overlayColor, false);
|
||||
}
|
||||
|
||||
// Copy of addQuad with alpha support
|
||||
default void addVertexData(MatrixStack.Entry matrixEntry, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int lightmapCoord, int overlayColor, boolean readExistingColor) {
|
||||
addVertexData(matrixEntry, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{lightmapCoord, lightmapCoord, lightmapCoord, lightmapCoord}, overlayColor, readExistingColor);
|
||||
// Copy of putBulkData with alpha support
|
||||
default void putBulkData(PoseStack.Pose matrixEntry, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int lightmapCoord, int overlayColor, boolean readExistingColor) {
|
||||
putBulkData(matrixEntry, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{lightmapCoord, lightmapCoord, lightmapCoord, lightmapCoord}, overlayColor, readExistingColor);
|
||||
}
|
||||
|
||||
// Copy of addQuad with alpha support
|
||||
default void addVertexData(MatrixStack.Entry matrixEntry, BakedQuad bakedQuad, float[] baseBrightness, float red, float green, float blue, float alpha, int[] lightmapCoords, int overlayCoords, boolean readExistingColor) {
|
||||
// Copy of putBulkData with alpha support
|
||||
default void putBulkData(PoseStack.Pose matrixEntry, BakedQuad bakedQuad, float[] baseBrightness, float red, float green, float blue, float alpha, int[] lightmapCoords, int overlayCoords, boolean readExistingColor) {
|
||||
int[] aint = bakedQuad.getVertices();
|
||||
Vector3i faceNormal = bakedQuad.getDirection().getNormal();
|
||||
Vec3i faceNormal = bakedQuad.getDirection().getNormal();
|
||||
Vector3f normal = new Vector3f((float)faceNormal.getX(), (float)faceNormal.getY(), (float)faceNormal.getZ());
|
||||
Matrix4f matrix4f = matrixEntry.pose();
|
||||
normal.transform(matrixEntry.normal());
|
||||
int intSize = DefaultVertexFormats.BLOCK.getIntegerSize();
|
||||
int intSize = DefaultVertexFormat.BLOCK.getIntegerSize();
|
||||
int vertexCount = aint.length / intSize;
|
||||
|
||||
try (MemoryStack memorystack = MemoryStack.stackPush()) {
|
||||
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getVertexSize());
|
||||
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormat.BLOCK.getVertexSize());
|
||||
IntBuffer intbuffer = bytebuffer.asIntBuffer();
|
||||
|
||||
for(int v = 0; v < vertexCount; ++v) {
|
||||
@@ -99,7 +101,7 @@ public interface IForgeVertexBuilder
|
||||
Vector4f pos = new Vector4f(f, f1, f2, 1.0F);
|
||||
pos.transform(matrix4f);
|
||||
applyBakedNormals(normal, bytebuffer, matrixEntry.normal());
|
||||
((IVertexBuilder)this).vertex(pos.x(), pos.y(), pos.z(), cr, cg, cb, ca, f9, f10, overlayCoords, lightmapCoord, normal.x(), normal.y(), normal.z());
|
||||
((VertexConsumer)this).vertex(pos.x(), pos.y(), pos.z(), cr, cg, cb, ca, f9, f10, overlayCoords, lightmapCoord, normal.x(), normal.y(), normal.z());
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
+4
-4
@@ -17,11 +17,11 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml.common;
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import net.minecraft.crash.ICrashReportDetail;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
public interface ICrashCallable extends ICrashReportDetail<String>
|
||||
public interface IIngameOverlay
|
||||
{
|
||||
String getLabel();
|
||||
void render(ForgeIngameGui gui, PoseStack mStack, float partialTicks, int width, int height);
|
||||
}
|
||||
@@ -19,20 +19,19 @@
|
||||
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.fml.client.ClientModLoader;
|
||||
import net.minecraftforge.fmlclient.ClientModLoader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -47,7 +46,7 @@ public class NotificationModUpdateScreen extends Screen
|
||||
|
||||
public NotificationModUpdateScreen(Button modButton)
|
||||
{
|
||||
super(new TranslationTextComponent("forge.menu.updatescreen.title"));
|
||||
super(new TranslatableComponent("forge.menu.updatescreen.title"));
|
||||
this.modButton = modButton;
|
||||
}
|
||||
|
||||
@@ -66,15 +65,14 @@ public class NotificationModUpdateScreen extends Screen
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void render(MatrixStack mStack, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(PoseStack mStack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if (showNotification == null || !showNotification.shouldDraw() || !FMLConfig.runVersionCheck())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bind(VERSION_CHECK_ICONS);
|
||||
RenderSystem.color4f(1, 1, 1, 1);
|
||||
RenderSystem.setShaderTexture(0, VERSION_CHECK_ICONS);
|
||||
|
||||
int x = modButton.x;
|
||||
int y = modButton.y;
|
||||
@@ -84,7 +82,7 @@ public class NotificationModUpdateScreen extends Screen
|
||||
blit(mStack, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16);
|
||||
}
|
||||
|
||||
public static NotificationModUpdateScreen init(MainMenuScreen guiMainMenu, Button modButton)
|
||||
public static NotificationModUpdateScreen init(TitleScreen guiMainMenu, Button modButton)
|
||||
{
|
||||
NotificationModUpdateScreen notificationModUpdateScreen = new NotificationModUpdateScreen(modButton);
|
||||
notificationModUpdateScreen.resize(guiMainMenu.getMinecraft(), guiMainMenu.width, guiMainMenu.height);
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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.gui;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class OverlayRegistry
|
||||
{
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed at the beginning of the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayBottom(@Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(-1, null, displayName, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed before the {@code other} parameter in the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param other The overlay to insert before. The overlay must be registered.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayBelow(@Nonnull IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(-1, other, displayName, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed after the {@code other} parameter in the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param other The overlay to insert after. The overlay must be registered.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayAbove(@Nonnull IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(1, other, displayName, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed at the end of the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayTop(@Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(1, null, displayName, overlay);
|
||||
}
|
||||
|
||||
private static IIngameOverlay registerOverlay(int sort, @Nullable IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
OverlayEntry entry = overlays.get(overlay);
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
overlaysOrdered.remove(entry);
|
||||
}
|
||||
|
||||
int insertAt = overlays.size();
|
||||
if (other == null)
|
||||
{
|
||||
if (sort < 0)
|
||||
insertAt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < overlaysOrdered.size(); i++)
|
||||
{
|
||||
OverlayEntry ov = overlaysOrdered.get(i);
|
||||
if (ov.getOverlay() == other)
|
||||
{
|
||||
if (sort < 0) insertAt = i;
|
||||
else insertAt = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entry = new OverlayEntry(overlay, displayName);
|
||||
|
||||
overlaysOrdered.add(insertAt, entry);
|
||||
overlays.put(overlay, entry);
|
||||
|
||||
return overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables an overlay. This is preferred over removing overlays.
|
||||
* @param overlay The overlay object to enable or disable
|
||||
* @param enable The new state
|
||||
*/
|
||||
public static synchronized void enableOverlay(@Nonnull IIngameOverlay overlay, boolean enable)
|
||||
{
|
||||
OverlayEntry entry = overlays.get(overlay);
|
||||
if (entry != null)
|
||||
{
|
||||
entry.setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the information on a registered overlay.
|
||||
* @param overlay The overlay to obtain the information for.
|
||||
* @return The registration entry for this overlay.
|
||||
*/
|
||||
@Nullable
|
||||
public static synchronized OverlayEntry getEntry(@Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return overlays.get(overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns an unmodifiable view of the ordered list of entries.
|
||||
*/
|
||||
public static List<OverlayEntry> orderedEntries()
|
||||
{
|
||||
return Collections.unmodifiableList(overlaysOrdered);
|
||||
}
|
||||
|
||||
private static final Map<IIngameOverlay, OverlayEntry> overlays = Maps.newHashMap();
|
||||
private static final List<OverlayEntry> overlaysOrdered = Lists.newArrayList();
|
||||
|
||||
public static class OverlayEntry {
|
||||
private final IIngameOverlay overlay;
|
||||
private final String displayName;
|
||||
private boolean enabled = true;
|
||||
|
||||
public OverlayEntry(IIngameOverlay overlay, String displayName)
|
||||
{
|
||||
this.overlay = overlay;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the overlay renderer.
|
||||
*/
|
||||
public IIngameOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the debug name for this entry.
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns true if the entry will be rendered.
|
||||
*/
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* For internal use. Call via {@link #enableOverlay(IIngameOverlay, boolean)}.
|
||||
*/
|
||||
private void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,22 +22,20 @@ package net.minecraftforge.client.gui;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.FocusableGui;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraft.client.gui.IRenderable;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraftforge.fmlclient.gui.GuiUtils;
|
||||
|
||||
public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
public abstract class ScrollPanel extends AbstractContainerEventHandler implements Widget
|
||||
{
|
||||
private final Minecraft client;
|
||||
protected final int width;
|
||||
@@ -76,7 +74,7 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
* @param mouseY
|
||||
* @param mouseX
|
||||
*/
|
||||
protected abstract void drawPanel(MatrixStack mStack, int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY);
|
||||
protected abstract void drawPanel(PoseStack mStack, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY);
|
||||
|
||||
protected boolean clickPanel(double mouseX, double mouseY, int button) { return false; }
|
||||
|
||||
@@ -184,11 +182,11 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void render(MatrixStack matrix, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.drawBackground();
|
||||
|
||||
Tessellator tess = Tessellator.getInstance();
|
||||
Tesselator tess = Tesselator.getInstance();
|
||||
BufferBuilder worldr = tess.getBuilder();
|
||||
|
||||
double scale = client.getWindow().getGuiScale();
|
||||
@@ -202,12 +200,10 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
}
|
||||
else // Draw dark dirt background
|
||||
{
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.disableFog();
|
||||
this.client.getTextureManager().bind(AbstractGui.BACKGROUND_LOCATION);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem.setShaderTexture(0, GuiComponent.BACKGROUND_LOCATION);
|
||||
final float texScale = 32.0F;
|
||||
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(this.left, this.bottom, 0.0D).uv(this.left / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
worldr.vertex(this.right, this.bottom, 0.0D).uv(this.right / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
worldr.vertex(this.right, this.top, 0.0D).uv(this.right / texScale, (this.top + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
@@ -231,20 +227,21 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
barTop = this.top;
|
||||
}
|
||||
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem.disableTexture();
|
||||
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(barLeft, this.bottom, 0.0D).uv(0.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth, this.bottom, 0.0D).uv(1.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth, this.top, 0.0D).uv(1.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft, this.top, 0.0D).uv(0.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
|
||||
tess.end();
|
||||
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(barLeft, barTop + barHeight, 0.0D).uv(0.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth, barTop + barHeight, 0.0D).uv(1.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth, barTop, 0.0D).uv(1.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft, barTop, 0.0D).uv(0.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
|
||||
tess.end();
|
||||
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(barLeft, barTop + barHeight - 1, 0.0D).uv(0.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0D).uv(1.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth - 1, barTop, 0.0D).uv(1.0F, 0.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
|
||||
@@ -253,19 +250,17 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
}
|
||||
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.shadeModel(GL11.GL_FLAT);
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.disableBlend();
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
protected void drawGradientRect(MatrixStack mStack, int left, int top, int right, int bottom, int color1, int color2)
|
||||
protected void drawGradientRect(PoseStack mStack, int left, int top, int right, int bottom, int color1, int color2)
|
||||
{
|
||||
GuiUtils.drawGradientRect(mStack.last().pose(), 0, left, top, right, bottom, color1, color2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends IGuiEventListener> children()
|
||||
public List<? extends GuiEventListener> children()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -26,26 +26,26 @@ import java.util.Random;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
public class BakedItemModel implements IBakedModel
|
||||
public class BakedItemModel implements BakedModel
|
||||
{
|
||||
protected final ImmutableList<BakedQuad> quads;
|
||||
protected final TextureAtlasSprite particle;
|
||||
protected final ImmutableMap<TransformType, TransformationMatrix> transforms;
|
||||
protected final ItemOverrideList overrides;
|
||||
protected final IBakedModel guiModel;
|
||||
protected final ImmutableMap<TransformType, Transformation> transforms;
|
||||
protected final ItemOverrides overrides;
|
||||
protected final BakedModel guiModel;
|
||||
protected final boolean isSideLit;
|
||||
|
||||
public BakedItemModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, ImmutableMap<TransformType, TransformationMatrix> transforms, ItemOverrideList overrides, boolean untransformed, boolean isSideLit)
|
||||
public BakedItemModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, ImmutableMap<TransformType, Transformation> transforms, ItemOverrides overrides, boolean untransformed, boolean isSideLit)
|
||||
{
|
||||
this.quads = quads;
|
||||
this.particle = particle;
|
||||
@@ -55,9 +55,9 @@ public class BakedItemModel implements IBakedModel
|
||||
this.guiModel = untransformed && hasGuiIdentity(transforms) ? new BakedGuiItemModel<>(this) : null;
|
||||
}
|
||||
|
||||
private static boolean hasGuiIdentity(ImmutableMap<TransformType, TransformationMatrix> transforms)
|
||||
private static boolean hasGuiIdentity(ImmutableMap<TransformType, Transformation> transforms)
|
||||
{
|
||||
TransformationMatrix guiTransform = transforms.get(TransformType.GUI);
|
||||
Transformation guiTransform = transforms.get(TransformType.GUI);
|
||||
return guiTransform == null || guiTransform.isIdentity();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class BakedItemModel implements IBakedModel
|
||||
@Override public boolean usesBlockLight() { return isSideLit; }
|
||||
@Override public boolean isCustomRenderer() { return false; }
|
||||
@Override public TextureAtlasSprite getParticleIcon() { return particle; }
|
||||
@Override public ItemOverrideList getOverrides() { return overrides; }
|
||||
@Override public ItemOverrides getOverrides() { return overrides; }
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand)
|
||||
@@ -79,13 +79,13 @@ public class BakedItemModel implements IBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(TransformType type, MatrixStack mat)
|
||||
public BakedModel handlePerspective(TransformType type, PoseStack poseStack)
|
||||
{
|
||||
if (type == TransformType.GUI && this.guiModel != null)
|
||||
{
|
||||
return this.guiModel.handlePerspective(type, mat);
|
||||
return this.guiModel.handlePerspective(type, poseStack);
|
||||
}
|
||||
return PerspectiveMapWrapper.handlePerspective(this, transforms, type, mat);
|
||||
return PerspectiveMapWrapper.handlePerspective(this, transforms, type, poseStack);
|
||||
}
|
||||
|
||||
public static class BakedGuiItemModel<T extends BakedItemModel> extends BakedModelWrapper<T>
|
||||
@@ -123,13 +123,13 @@ public class BakedItemModel implements IBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(TransformType type, MatrixStack mat)
|
||||
public BakedModel handlePerspective(TransformType type, PoseStack poseStack)
|
||||
{
|
||||
if (type == TransformType.GUI)
|
||||
{
|
||||
return PerspectiveMapWrapper.handlePerspective(this, originalModel.transforms, type, mat);
|
||||
return PerspectiveMapWrapper.handlePerspective(this, originalModel.transforms, type, poseStack);
|
||||
}
|
||||
return this.originalModel.handlePerspective(type, mat);
|
||||
return this.originalModel.handlePerspective(type, poseStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,19 +24,19 @@ import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
public abstract class BakedModelWrapper<T extends IBakedModel> implements IBakedModel
|
||||
public abstract class BakedModelWrapper<T extends BakedModel> implements BakedModel
|
||||
{
|
||||
protected final T originalModel;
|
||||
|
||||
@@ -88,13 +88,13 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getTransforms()
|
||||
public ItemTransforms getTransforms()
|
||||
{
|
||||
return originalModel.getTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
public ItemOverrides getOverrides()
|
||||
{
|
||||
return originalModel.getOverrides();
|
||||
}
|
||||
@@ -106,15 +106,15 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat)
|
||||
public BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack)
|
||||
{
|
||||
return originalModel.handlePerspective(cameraTransformType, mat);
|
||||
return originalModel.handlePerspective(cameraTransformType, poseStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture(@Nonnull IModelData data)
|
||||
public TextureAtlasSprite getParticleIcon(@Nonnull IModelData data)
|
||||
{
|
||||
return originalModel.getParticleTexture(data);
|
||||
return originalModel.getParticleIcon(data);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -126,7 +126,7 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
public IModelData getModelData(@Nonnull BlockAndTintGetter world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
{
|
||||
return originalModel.getModelData(world, pos, state, tileData);
|
||||
}
|
||||
|
||||
@@ -20,9 +20,8 @@
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometryPart;
|
||||
|
||||
@@ -30,6 +29,15 @@ import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
public class BlockModelConfiguration implements IModelConfiguration
|
||||
{
|
||||
public final BlockModel owner;
|
||||
@@ -37,7 +45,7 @@ public class BlockModelConfiguration implements IModelConfiguration
|
||||
@Nullable
|
||||
private IModelGeometry<?> customGeometry;
|
||||
@Nullable
|
||||
private IModelTransform customModelState;
|
||||
private ModelState customModelState;
|
||||
|
||||
public BlockModelConfiguration(BlockModel owner)
|
||||
{
|
||||
@@ -46,7 +54,7 @@ public class BlockModelConfiguration implements IModelConfiguration
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IUnbakedModel getOwnerModel()
|
||||
public UnbakedModel getOwnerModel()
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
@@ -74,12 +82,12 @@ public class BlockModelConfiguration implements IModelConfiguration
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IModelTransform getCustomModelState()
|
||||
public ModelState getCustomModelState()
|
||||
{
|
||||
return owner.parent != null && customModelState == null ? owner.parent.customData.getCustomModelState() : customModelState;
|
||||
}
|
||||
|
||||
public void setCustomModelState(IModelTransform modelState)
|
||||
public void setCustomModelState(ModelState modelState)
|
||||
{
|
||||
this.customModelState = modelState;
|
||||
}
|
||||
@@ -99,7 +107,7 @@ public class BlockModelConfiguration implements IModelConfiguration
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderMaterial resolveTexture(String name)
|
||||
public Material resolveTexture(String name)
|
||||
{
|
||||
return owner.getMaterial(name);
|
||||
}
|
||||
@@ -122,19 +130,19 @@ public class BlockModelConfiguration implements IModelConfiguration
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getCameraTransforms()
|
||||
public ItemTransforms getCameraTransforms()
|
||||
{
|
||||
return owner.getTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelTransform getCombinedTransform()
|
||||
public ModelState getCombinedTransform()
|
||||
{
|
||||
IModelTransform state = getCustomModelState();
|
||||
ModelState state = getCustomModelState();
|
||||
|
||||
return state != null
|
||||
? new SimpleModelTransform(PerspectiveMapWrapper.getTransformsWithFallback(state, getCameraTransforms()), state.getRotation())
|
||||
: new SimpleModelTransform(PerspectiveMapWrapper.getTransforms(getCameraTransforms()));
|
||||
? new SimpleModelState(PerspectiveMapWrapper.getTransformsWithFallback(state, getCameraTransforms()), state.getRotation())
|
||||
: new SimpleModelState(PerspectiveMapWrapper.getTransforms(getCameraTransforms()));
|
||||
}
|
||||
|
||||
public void copyFrom(BlockModelConfiguration other)
|
||||
@@ -144,14 +152,14 @@ public class BlockModelConfiguration implements IModelConfiguration
|
||||
this.visibilityData.copyFrom(other.visibilityData);
|
||||
}
|
||||
|
||||
public Collection<RenderMaterial> getTextureDependencies(Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getTextureDependencies(Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
IModelGeometry<?> geometry = getCustomGeometry();
|
||||
return geometry == null ? Collections.emptySet() :
|
||||
geometry.getTextures(this, modelGetter, missingTextureErrors);
|
||||
}
|
||||
|
||||
public IBakedModel bake(ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> bakedTextureGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
public BakedModel bake(ModelBakery bakery, Function<Material, TextureAtlasSprite> bakedTextureGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
IModelGeometry<?> geometry = getCustomGeometry();
|
||||
if (geometry == null)
|
||||
|
||||
@@ -23,16 +23,15 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraftforge.client.model.data.*;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometryPart;
|
||||
import net.minecraftforge.client.model.geometry.IMultipartModelGeometry;
|
||||
@@ -42,17 +41,27 @@ import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
public class CompositeModel implements IDynamicBakedModel
|
||||
{
|
||||
private final ImmutableMap<String, IBakedModel> bakedParts;
|
||||
private final ImmutableMap<String, BakedModel> bakedParts;
|
||||
private final boolean isAmbientOcclusion;
|
||||
private final boolean isGui3d;
|
||||
private final boolean isSideLit;
|
||||
private final TextureAtlasSprite particle;
|
||||
private final ItemOverrideList overrides;
|
||||
private final IModelTransform transforms;
|
||||
private final ItemOverrides overrides;
|
||||
private final ModelState transforms;
|
||||
|
||||
public CompositeModel(boolean isGui3d, boolean isSideLit, boolean isAmbientOcclusion, TextureAtlasSprite particle, ImmutableMap<String, IBakedModel> bakedParts, IModelTransform combinedTransform, ItemOverrideList overrides)
|
||||
public CompositeModel(boolean isGui3d, boolean isSideLit, boolean isAmbientOcclusion, TextureAtlasSprite particle, ImmutableMap<String, BakedModel> bakedParts, ModelState combinedTransform, ItemOverrides overrides)
|
||||
{
|
||||
this.bakedParts = bakedParts;
|
||||
this.isAmbientOcclusion = isAmbientOcclusion;
|
||||
@@ -68,7 +77,7 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData)
|
||||
{
|
||||
List<BakedQuad> quads = new ArrayList<>();
|
||||
for(Map.Entry<String, IBakedModel> entry : bakedParts.entrySet())
|
||||
for(Map.Entry<String, BakedModel> entry : bakedParts.entrySet())
|
||||
{
|
||||
quads.addAll(entry.getValue().getQuads(state, side, rand, CompositeModelData.get(extraData, entry.getKey())));
|
||||
}
|
||||
@@ -77,10 +86,10 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
public IModelData getModelData(@Nonnull BlockAndTintGetter world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
{
|
||||
CompositeModelData composite = new CompositeModelData();
|
||||
for(Map.Entry<String, IBakedModel> entry : bakedParts.entrySet())
|
||||
for(Map.Entry<String, BakedModel> entry : bakedParts.entrySet())
|
||||
{
|
||||
composite.putSubmodelData(entry.getKey(), entry.getValue().getModelData(world, pos, state, ModelDataWrapper.wrap(tileData)));
|
||||
}
|
||||
@@ -118,7 +127,7 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
public ItemOverrides getOverrides()
|
||||
{
|
||||
return overrides;
|
||||
}
|
||||
@@ -130,13 +139,13 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat)
|
||||
public BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack)
|
||||
{
|
||||
return PerspectiveMapWrapper.handlePerspective(this, transforms, cameraTransformType, mat);
|
||||
return PerspectiveMapWrapper.handlePerspective(this, transforms, cameraTransformType, poseStack);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IBakedModel getPart(String name)
|
||||
public BakedModel getPart(String name)
|
||||
{
|
||||
return bakedParts.get(name);
|
||||
}
|
||||
@@ -145,9 +154,9 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
{
|
||||
private final String name;
|
||||
private final BlockModel model;
|
||||
private final IModelTransform modelTransform;
|
||||
private final ModelState modelTransform;
|
||||
|
||||
private Submodel(String name, BlockModel model, IModelTransform modelTransform)
|
||||
private Submodel(String name, BlockModel model, ModelState modelTransform)
|
||||
{
|
||||
this.name = name;
|
||||
this.model = model;
|
||||
@@ -161,19 +170,19 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addQuads(IModelConfiguration owner, IModelBuilder<?> modelBuilder, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
|
||||
public void addQuads(IModelConfiguration owner, IModelBuilder<?> modelBuilder, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation)
|
||||
{
|
||||
throw new UnsupportedOperationException("Attempted to call adQuads on a Submodel instance. Please don't.");
|
||||
}
|
||||
|
||||
public IBakedModel bakeModel(ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
|
||||
public BakedModel bakeModel(ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation)
|
||||
{
|
||||
return model.bake(bakery, spriteGetter, new ModelTransformComposition(this.modelTransform, modelTransform,
|
||||
return model.bake(bakery, spriteGetter, new CompositeModelState(this.modelTransform, modelTransform,
|
||||
this.modelTransform.isUvLocked() || modelTransform.isUvLocked()), modelLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
return model.getMaterials(modelGetter, missingTextureErrors);
|
||||
}
|
||||
@@ -201,12 +210,12 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
RenderMaterial particleLocation = owner.resolveTexture("particle");
|
||||
Material particleLocation = owner.resolveTexture("particle");
|
||||
TextureAtlasSprite particle = spriteGetter.apply(particleLocation);
|
||||
|
||||
ImmutableMap.Builder<String, IBakedModel> bakedParts = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<String, BakedModel> bakedParts = ImmutableMap.builder();
|
||||
for(Map.Entry<String, Submodel> part : parts.entrySet())
|
||||
{
|
||||
Submodel submodel = part.getValue();
|
||||
@@ -218,9 +227,9 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
Set<RenderMaterial> textures = new HashSet<>();
|
||||
Set<Material> textures = new HashSet<>();
|
||||
for(Submodel part : parts.values())
|
||||
{
|
||||
textures.addAll(part.getTextures(owner, modelGetter, missingTextureErrors));
|
||||
@@ -236,7 +245,7 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
private Loader() {}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
public void onResourceManagerReload(ResourceManager resourceManager)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -250,7 +259,7 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
for(Map.Entry<String, JsonElement> part : modelContents.get("parts").getAsJsonObject().entrySet())
|
||||
{
|
||||
// TODO: Allow customizing state? If so, how?
|
||||
IModelTransform modelTransform = SimpleModelTransform.IDENTITY;
|
||||
ModelState modelTransform = SimpleModelState.IDENTITY;
|
||||
parts.put(part.getKey(), new Submodel(
|
||||
part.getKey(),
|
||||
deserializationContext.deserialize(part.getValue(), BlockModel.class),
|
||||
|
||||
+10
-10
@@ -20,24 +20,24 @@
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
|
||||
/**
|
||||
* An {@link IModelTransform} that combines the transforms from two child {@link IModelTransform}.
|
||||
*/
|
||||
public class ModelTransformComposition implements IModelTransform
|
||||
public class CompositeModelState implements ModelState
|
||||
{
|
||||
private final IModelTransform first;
|
||||
private final IModelTransform second;
|
||||
private final ModelState first;
|
||||
private final ModelState second;
|
||||
private final boolean uvLock;
|
||||
|
||||
public ModelTransformComposition(IModelTransform first, IModelTransform second)
|
||||
public CompositeModelState(ModelState first, ModelState second)
|
||||
{
|
||||
this(first, second, false);
|
||||
}
|
||||
|
||||
public ModelTransformComposition(IModelTransform first, IModelTransform second, boolean uvLock)
|
||||
public CompositeModelState(ModelState first, ModelState second, boolean uvLock)
|
||||
{
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
@@ -51,13 +51,13 @@ public class ModelTransformComposition implements IModelTransform
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformationMatrix getRotation()
|
||||
public Transformation getRotation()
|
||||
{
|
||||
return first.getRotation().compose(second.getRotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformationMatrix getPartTransformation(Object part)
|
||||
public Transformation getPartTransformation(Object part)
|
||||
{
|
||||
return first.getPartTransformation(part).compose(second.getPartTransformation(part));
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class ModelTransformComposition implements IModelTransform
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ModelTransformComposition that = (ModelTransformComposition) o;
|
||||
CompositeModelState that = (CompositeModelState) o;
|
||||
return Objects.equal(first, that.first) && Objects.equal(second, that.second);
|
||||
}
|
||||
|
||||
@@ -23,19 +23,18 @@ import com.google.common.collect.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
@@ -51,6 +50,14 @@ import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
public final class DynamicBucketModel implements IModelGeometry<DynamicBucketModel>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -94,20 +101,20 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
RenderMaterial particleLocation = owner.isTexturePresent("particle") ? owner.resolveTexture("particle") : null;
|
||||
RenderMaterial baseLocation = owner.isTexturePresent("base") ? owner.resolveTexture("base") : null;
|
||||
RenderMaterial fluidMaskLocation = owner.isTexturePresent("fluid") ? owner.resolveTexture("fluid") : null;
|
||||
RenderMaterial coverLocation = owner.isTexturePresent("cover") ? owner.resolveTexture("cover") : null;
|
||||
Material particleLocation = owner.isTexturePresent("particle") ? owner.resolveTexture("particle") : null;
|
||||
Material baseLocation = owner.isTexturePresent("base") ? owner.resolveTexture("base") : null;
|
||||
Material fluidMaskLocation = owner.isTexturePresent("fluid") ? owner.resolveTexture("fluid") : null;
|
||||
Material coverLocation = owner.isTexturePresent("cover") ? owner.resolveTexture("cover") : null;
|
||||
|
||||
IModelTransform transformsFromModel = owner.getCombinedTransform();
|
||||
ModelState transformsFromModel = owner.getCombinedTransform();
|
||||
|
||||
TextureAtlasSprite fluidSprite = fluid != Fluids.EMPTY ? spriteGetter.apply(ForgeHooksClient.getBlockMaterial(fluid.getAttributes().getStillTexture())) : null;
|
||||
TextureAtlasSprite coverSprite = (coverLocation != null && (!coverIsMask || baseLocation != null)) ? spriteGetter.apply(coverLocation) : null;
|
||||
|
||||
ImmutableMap<TransformType, TransformationMatrix> transformMap =
|
||||
PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(transformsFromModel, modelTransform));
|
||||
ImmutableMap<TransformType, Transformation> transformMap =
|
||||
PerspectiveMapWrapper.getTransforms(new CompositeModelState(transformsFromModel, modelTransform));
|
||||
|
||||
TextureAtlasSprite particleSprite = particleLocation != null ? spriteGetter.apply(particleLocation) : null;
|
||||
|
||||
@@ -117,12 +124,12 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
|
||||
// if the fluid is lighter than air, will manipulate the initial state to be rotated 180deg to turn it upside down
|
||||
if (flipGas && fluid != Fluids.EMPTY && fluid.getAttributes().isLighterThanAir())
|
||||
{
|
||||
modelTransform = new SimpleModelTransform(
|
||||
modelTransform = new SimpleModelState(
|
||||
modelTransform.getRotation().blockCornerToCenter().compose(
|
||||
new TransformationMatrix(null, new Quaternion(0, 0, 1, 0), null, null)).blockCenterToCorner());
|
||||
new Transformation(null, new Quaternion(0, 0, 1, 0), null, null)).blockCenterToCorner());
|
||||
}
|
||||
|
||||
TransformationMatrix transform = modelTransform.getRotation();
|
||||
Transformation transform = modelTransform.getRotation();
|
||||
|
||||
ItemMultiLayerBakedModel.Builder builder = ItemMultiLayerBakedModel.builder(owner, particleSprite, new ContainedFluidOverrideHandler(overrides, bakery, owner, this), transformMap);
|
||||
|
||||
@@ -169,9 +176,9 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
Set<RenderMaterial> texs = Sets.newHashSet();
|
||||
Set<Material> texs = Sets.newHashSet();
|
||||
|
||||
if (owner.isTexturePresent("particle")) texs.add(owner.resolveTexture("particle"));
|
||||
if (owner.isTexturePresent("base")) texs.add(owner.resolveTexture("base"));
|
||||
@@ -192,13 +199,7 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
{
|
||||
// no need to clear cache since we create a new model instance
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager, Predicate<IResourceType> resourcePredicate)
|
||||
public void onResourceManagerReload(ResourceManager resourceManager)
|
||||
{
|
||||
// no need to clear cache since we create a new model instance
|
||||
}
|
||||
@@ -242,15 +243,15 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ContainedFluidOverrideHandler extends ItemOverrideList
|
||||
private static final class ContainedFluidOverrideHandler extends ItemOverrides
|
||||
{
|
||||
private final Map<String, IBakedModel> cache = Maps.newHashMap(); // contains all the baked models since they'll never change
|
||||
private final ItemOverrideList nested;
|
||||
private final Map<String, BakedModel> cache = Maps.newHashMap(); // contains all the baked models since they'll never change
|
||||
private final ItemOverrides nested;
|
||||
private final ModelBakery bakery;
|
||||
private final IModelConfiguration owner;
|
||||
private final DynamicBucketModel parent;
|
||||
|
||||
private ContainedFluidOverrideHandler(ItemOverrideList nested, ModelBakery bakery, IModelConfiguration owner, DynamicBucketModel parent)
|
||||
private ContainedFluidOverrideHandler(ItemOverrides nested, ModelBakery bakery, IModelConfiguration owner, DynamicBucketModel parent)
|
||||
{
|
||||
this.nested = nested;
|
||||
this.bakery = bakery;
|
||||
@@ -259,9 +260,9 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel resolve(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
|
||||
public BakedModel resolve(BakedModel originalModel, ItemStack stack, @Nullable ClientLevel world, @Nullable LivingEntity entity, int seed)
|
||||
{
|
||||
IBakedModel overriden = nested.resolve(originalModel, stack, world, entity);
|
||||
BakedModel overriden = nested.resolve(originalModel, stack, world, entity, seed);
|
||||
if (overriden != originalModel) return overriden;
|
||||
return FluidUtil.getFluidContained(stack)
|
||||
.map(fluidStack -> {
|
||||
@@ -271,7 +272,7 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
|
||||
if (!cache.containsKey(name))
|
||||
{
|
||||
DynamicBucketModel unbaked = this.parent.withFluid(fluid);
|
||||
IBakedModel bakedModel = unbaked.bake(owner, bakery, ModelLoader.defaultTextureGetter(), ModelRotation.X0_Y0, this, new ResourceLocation("forge:bucket_override"));
|
||||
BakedModel bakedModel = unbaked.bake(owner, bakery, ModelLoader.defaultTextureGetter(), BlockModelRotation.X0_Y0, this, new ResourceLocation("forge:bucket_override"));
|
||||
cache.put(name, bakedModel);
|
||||
return bakedModel;
|
||||
}
|
||||
|
||||
@@ -30,20 +30,19 @@ import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
@@ -59,6 +58,14 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
// TODO: Write a model loader and test/fix as needed
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
{
|
||||
public static final FluidModel WATER = new FluidModel(Fluids.WATER);
|
||||
@@ -72,13 +79,13 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
return ForgeHooksClient.getFluidMaterials(fluid).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
FluidAttributes attrs = fluid.getAttributes();
|
||||
return new CachingBakedFluid(
|
||||
@@ -121,7 +128,7 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
}
|
||||
});
|
||||
|
||||
public CachingBakedFluid(TransformationMatrix transformation, ImmutableMap<TransformType, TransformationMatrix> transforms, ResourceLocation modelLocation, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, Optional<TextureAtlasSprite> overlay, boolean gas, Optional<IModelData> stateOption)
|
||||
public CachingBakedFluid(Transformation transformation, ImmutableMap<TransformType, Transformation> transforms, ResourceLocation modelLocation, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, Optional<TextureAtlasSprite> overlay, boolean gas, Optional<IModelData> stateOption)
|
||||
{
|
||||
super(transformation, transforms, modelLocation, color, still, flowing, overlay, gas, stateOption.isPresent(), getCorners(stateOption), getFlow(stateOption), getOverlay(stateOption));
|
||||
}
|
||||
@@ -166,7 +173,7 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
if (flow == null) flow = -1000f;
|
||||
}
|
||||
int flowRound = (int) Math.round(Math.toDegrees(flow));
|
||||
flowRound = MathHelper.clamp(flowRound, -1000, 1000);
|
||||
flowRound = Mth.clamp(flowRound, -1000, 1000);
|
||||
return flowRound;
|
||||
}
|
||||
|
||||
@@ -226,14 +233,14 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
}
|
||||
}
|
||||
|
||||
private static class BakedFluid implements IBakedModel
|
||||
private static class BakedFluid implements BakedModel
|
||||
{
|
||||
private static final int x[] = { 0, 0, 1, 1 };
|
||||
private static final int z[] = { 0, 1, 1, 0 };
|
||||
private static final float eps = 1e-3f;
|
||||
|
||||
protected final TransformationMatrix transformation;
|
||||
protected final ImmutableMap<TransformType, TransformationMatrix> transforms;
|
||||
protected final Transformation transformation;
|
||||
protected final ImmutableMap<TransformType, Transformation> transforms;
|
||||
protected final ResourceLocation modelLocation;
|
||||
protected final int color;
|
||||
protected final TextureAtlasSprite still, flowing;
|
||||
@@ -241,7 +248,7 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
protected final boolean gas;
|
||||
protected final ImmutableMap<Direction, ImmutableList<BakedQuad>> faceQuads;
|
||||
|
||||
public BakedFluid(TransformationMatrix transformation, ImmutableMap<TransformType, TransformationMatrix> transforms, ResourceLocation modelLocation, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, Optional<TextureAtlasSprite> overlay, boolean gas, boolean statePresent, int[] cornerRound, int flowRound, boolean[] sideOverlays)
|
||||
public BakedFluid(Transformation transformation, ImmutableMap<TransformType, Transformation> transforms, ResourceLocation modelLocation, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, Optional<TextureAtlasSprite> overlay, boolean gas, boolean statePresent, int[] cornerRound, int flowRound, boolean[] sideOverlays)
|
||||
{
|
||||
this.transformation = transformation;
|
||||
this.transforms = transforms;
|
||||
@@ -281,8 +288,8 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
TextureAtlasSprite topSprite = isFlowing ? flowing : still;
|
||||
float scale = isFlowing ? 4f : 8f;
|
||||
|
||||
float c = MathHelper.cos(flow) * scale;
|
||||
float s = MathHelper.sin(flow) * scale;
|
||||
float c = Mth.cos(flow) * scale;
|
||||
float s = Mth.sin(flow) * scale;
|
||||
|
||||
// top
|
||||
Direction top = gas ? Direction.DOWN : Direction.UP;
|
||||
@@ -387,7 +394,7 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
|
||||
private void putVertex(IVertexConsumer consumer, Direction side, boolean offset, float x, float y, float z, float u, float v)
|
||||
{
|
||||
VertexFormat format = DefaultVertexFormats.BLOCK;
|
||||
VertexFormat format = DefaultVertexFormat.BLOCK;
|
||||
ImmutableList<VertexFormatElement> elements = format.getElements();
|
||||
for(int e = 0; e < elements.size(); e++)
|
||||
{
|
||||
@@ -463,9 +470,9 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
public ItemOverrides getOverrides()
|
||||
{
|
||||
return ItemOverrideList.EMPTY;
|
||||
return ItemOverrides.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -475,9 +482,9 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(TransformType type, MatrixStack mat)
|
||||
public BakedModel handlePerspective(TransformType type, PoseStack poseStack)
|
||||
{
|
||||
return PerspectiveMapWrapper.handlePerspective(this, transforms, type, mat);
|
||||
return PerspectiveMapWrapper.handlePerspective(this, transforms, type, poseStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,16 +19,16 @@
|
||||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.resources.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
public interface IModelBuilder<T extends IModelBuilder<T>>
|
||||
{
|
||||
static IModelBuilder<?> of(IModelConfiguration owner, ItemOverrideList overrides, TextureAtlasSprite particle)
|
||||
static IModelBuilder<?> of(IModelConfiguration owner, ItemOverrides overrides, TextureAtlasSprite particle)
|
||||
{
|
||||
return new Simple(new SimpleBakedModel.Builder(owner, overrides).particle(particle));
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
|
||||
T addFaceQuad(Direction facing, BakedQuad quad);
|
||||
T addGeneralQuad(BakedQuad quad);
|
||||
|
||||
IBakedModel build();
|
||||
BakedModel build();
|
||||
|
||||
class Simple implements IModelBuilder<Simple> {
|
||||
final SimpleBakedModel.Builder builder;
|
||||
@@ -61,7 +61,7 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel build()
|
||||
public BakedModel build()
|
||||
{
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.RenderMaterial;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometryPart;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -37,7 +37,7 @@ public interface IModelConfiguration {
|
||||
* If available, gets the owning model (usually BlockModel) of this configuration
|
||||
*/
|
||||
@Nullable
|
||||
IUnbakedModel getOwnerModel();
|
||||
UnbakedModel getOwnerModel();
|
||||
|
||||
/**
|
||||
* @return The name of the model being baked, for logging and cache purposes.
|
||||
@@ -55,7 +55,7 @@ public interface IModelConfiguration {
|
||||
* @param name The name of a texture channel.
|
||||
* @return The location of the texture, or the missing texture if not found.
|
||||
*/
|
||||
RenderMaterial resolveTexture(String name);
|
||||
Material resolveTexture(String name);
|
||||
|
||||
/**
|
||||
* @return True if the item is a 3D model, false if it's a generated item model.
|
||||
@@ -79,12 +79,12 @@ public interface IModelConfiguration {
|
||||
* Gets the vanilla camera transforms data.
|
||||
* Do not use for non-vanilla code. For general usage, prefer getCombinedState.
|
||||
*/
|
||||
ItemCameraTransforms getCameraTransforms();
|
||||
ItemTransforms getCameraTransforms();
|
||||
|
||||
/**
|
||||
* @return The combined transformation state including vanilla and forge transforms data.
|
||||
*/
|
||||
IModelTransform getCombinedTransform();
|
||||
ModelState getCombinedTransform();
|
||||
|
||||
/**
|
||||
* Queries the visibility information for the model parts.
|
||||
|
||||
@@ -21,33 +21,15 @@ package net.minecraftforge.client.model;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.resource.IResourceType;
|
||||
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
||||
import net.minecraftforge.resource.VanillaResourceType;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public interface IModelLoader<T extends IModelGeometry<T>> extends ISelectiveResourceReloadListener
|
||||
public interface IModelLoader<T extends IModelGeometry<T>> extends ResourceManagerReloadListener
|
||||
{
|
||||
@Override
|
||||
default IResourceType getResourceType()
|
||||
{
|
||||
return VanillaResourceType.MODELS;
|
||||
}
|
||||
|
||||
@Override
|
||||
void onResourceManagerReload(IResourceManager resourceManager);
|
||||
|
||||
@Override
|
||||
default void onResourceManagerReload(IResourceManager resourceManager, Predicate<IResourceType> resourcePredicate)
|
||||
{
|
||||
if (resourcePredicate.test(getResourceType()))
|
||||
{
|
||||
onResourceManagerReload(resourceManager);
|
||||
}
|
||||
}
|
||||
|
||||
T read(JsonDeserializationContext deserializationContext, JsonObject modelContents);
|
||||
}
|
||||
@@ -25,15 +25,14 @@ import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraftforge.client.ForgeRenderTypes;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
@@ -44,6 +43,15 @@ import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
/**
|
||||
* Forge reimplementation of vanilla {@link ItemModelGenerator}, i.e. builtin/generated models,
|
||||
* with the following changes:
|
||||
@@ -59,7 +67,7 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
private static final Direction[] HORIZONTALS = {Direction.UP, Direction.DOWN};
|
||||
private static final Direction[] VERTICALS = {Direction.WEST, Direction.EAST};
|
||||
|
||||
private ImmutableList<RenderMaterial> textures;
|
||||
private ImmutableList<Material> textures;
|
||||
private final ImmutableSet<Integer> fullbrightLayers;
|
||||
|
||||
public ItemLayerModel()
|
||||
@@ -67,20 +75,20 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
this(null, ImmutableSet.of());
|
||||
}
|
||||
|
||||
public ItemLayerModel(ImmutableList<RenderMaterial> textures)
|
||||
public ItemLayerModel(ImmutableList<Material> textures)
|
||||
{
|
||||
this(textures, ImmutableSet.of());
|
||||
}
|
||||
|
||||
public ItemLayerModel(@Nullable ImmutableList<RenderMaterial> textures, ImmutableSet<Integer> fullbrightLayers)
|
||||
public ItemLayerModel(@Nullable ImmutableList<Material> textures, ImmutableSet<Integer> fullbrightLayers)
|
||||
{
|
||||
this.textures = textures;
|
||||
this.fullbrightLayers = fullbrightLayers;
|
||||
}
|
||||
|
||||
private static ImmutableList<RenderMaterial> getTextures(IModelConfiguration model)
|
||||
private static ImmutableList<Material> getTextures(IModelConfiguration model)
|
||||
{
|
||||
ImmutableList.Builder<RenderMaterial> builder = ImmutableList.builder();
|
||||
ImmutableList.Builder<Material> builder = ImmutableList.builder();
|
||||
for(int i = 0; model.isTexturePresent("layer" + i); i++)
|
||||
{
|
||||
builder.add(model.resolveTexture("layer" + i));
|
||||
@@ -89,13 +97,13 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
|
||||
Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
|
||||
ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery,
|
||||
Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform,
|
||||
ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> transformMap =
|
||||
PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(owner.getCombinedTransform(), modelTransform));
|
||||
TransformationMatrix transform = modelTransform.getRotation();
|
||||
ImmutableMap<ItemTransforms.TransformType, Transformation> transformMap =
|
||||
PerspectiveMapWrapper.getTransforms(new CompositeModelState(owner.getCombinedTransform(), modelTransform));
|
||||
Transformation transform = modelTransform.getRotation();
|
||||
TextureAtlasSprite particle = spriteGetter.apply(
|
||||
owner.isTexturePresent("particle") ? owner.resolveTexture("particle") : textures.get(0)
|
||||
);
|
||||
@@ -116,12 +124,12 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
return isFullbright ? ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get() : ForgeRenderTypes.ITEM_UNSORTED_TRANSLUCENT.get();
|
||||
}
|
||||
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprites(List<RenderMaterial> textures, TransformationMatrix transform, Function<RenderMaterial, TextureAtlasSprite> spriteGetter)
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprites(List<Material> textures, Transformation transform, Function<Material, TextureAtlasSprite> spriteGetter)
|
||||
{
|
||||
return getQuadsForSprites(textures, transform, spriteGetter, Collections.emptySet());
|
||||
}
|
||||
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprites(List<RenderMaterial> textures, TransformationMatrix transform, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, Set<Integer> fullbrights)
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprites(List<Material> textures, Transformation transform, Function<Material, TextureAtlasSprite> spriteGetter, Set<Integer> fullbrights)
|
||||
{
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
for(int i = 0; i < textures.size(); i++)
|
||||
@@ -132,12 +140,12 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprite(int tint, TextureAtlasSprite sprite, TransformationMatrix transform)
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprite(int tint, TextureAtlasSprite sprite, Transformation transform)
|
||||
{
|
||||
return getQuadsForSprite(tint, sprite, transform, false);
|
||||
}
|
||||
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprite(int tint, TextureAtlasSprite sprite, TransformationMatrix transform, boolean fullbright)
|
||||
public static ImmutableList<BakedQuad> getQuadsForSprite(int tint, TextureAtlasSprite sprite, Transformation transform, boolean fullbright)
|
||||
{
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
|
||||
@@ -313,7 +321,7 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
textures = getTextures(owner);
|
||||
return textures;
|
||||
@@ -351,7 +359,7 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
}
|
||||
}
|
||||
|
||||
private static BakedQuad buildSideQuad(TransformationMatrix transform, Direction side, int tint, TextureAtlasSprite sprite, int u, int v, int size, boolean fullbright)
|
||||
private static BakedQuad buildSideQuad(Transformation transform, Direction side, int tint, TextureAtlasSprite sprite, int u, int v, int size, boolean fullbright)
|
||||
{
|
||||
final float eps = 1e-2f;
|
||||
|
||||
@@ -404,7 +412,7 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
return side.getAxis() == Direction.Axis.Y ? side.getOpposite() : side;
|
||||
}
|
||||
|
||||
private static BakedQuad buildQuad(TransformationMatrix transform, Direction side, TextureAtlasSprite sprite, int tint, boolean fullbright,
|
||||
private static BakedQuad buildQuad(Transformation transform, Direction side, TextureAtlasSprite sprite, int tint, boolean fullbright,
|
||||
float x0, float y0, float z0, float u0, float v0,
|
||||
float x1, float y1, float z1, float u1, float v1,
|
||||
float x2, float y2, float z2, float u2, float v2,
|
||||
@@ -473,7 +481,7 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
public static final Loader INSTANCE = new Loader();
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
public void onResourceManagerReload(ResourceManager resourceManager)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
@@ -484,7 +492,7 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
ImmutableSet.Builder<Integer> fullbrightLayers = ImmutableSet.builder();
|
||||
if (modelContents.has("fullbright_layers"))
|
||||
{
|
||||
JsonArray arr = JSONUtils.getAsJsonArray(modelContents, "fullbright_layers");
|
||||
JsonArray arr = GsonHelper.getAsJsonArray(modelContents, "fullbright_layers");
|
||||
for(int i=0;i<arr.size();i++)
|
||||
{
|
||||
fullbrightLayers.add(arr.get(i).getAsInt());
|
||||
|
||||
@@ -22,18 +22,18 @@ package net.minecraftforge.client.model;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.Direction;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
@@ -49,14 +49,14 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
|
||||
private final boolean shadedInGui;
|
||||
private final boolean sideLit;
|
||||
private final TextureAtlasSprite particle;
|
||||
private final ItemOverrideList overrides;
|
||||
private final ImmutableList<Pair<IBakedModel, RenderType>> layerModels;
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> cameraTransforms;
|
||||
private final ItemOverrides overrides;
|
||||
private final ImmutableList<Pair<BakedModel, RenderType>> layerModels;
|
||||
private final ImmutableMap<ItemTransforms.TransformType, Transformation> cameraTransforms;
|
||||
|
||||
public ItemMultiLayerBakedModel(boolean smoothLighting, boolean shadedInGui, boolean sideLit,
|
||||
TextureAtlasSprite particle, ItemOverrideList overrides,
|
||||
ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> cameraTransforms,
|
||||
ImmutableList<Pair<IBakedModel, RenderType>> layerModels)
|
||||
TextureAtlasSprite particle, ItemOverrides overrides,
|
||||
ImmutableMap<ItemTransforms.TransformType, Transformation> cameraTransforms,
|
||||
ImmutableList<Pair<BakedModel, RenderType>> layerModels)
|
||||
{
|
||||
this.smoothLighting = smoothLighting;
|
||||
this.shadedInGui = shadedInGui;
|
||||
@@ -106,7 +106,7 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
public ItemOverrides getOverrides()
|
||||
{
|
||||
return overrides;
|
||||
}
|
||||
@@ -118,9 +118,9 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat)
|
||||
public BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack)
|
||||
{
|
||||
return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType, mat);
|
||||
return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType, poseStack);
|
||||
}
|
||||
|
||||
//@Override
|
||||
@@ -130,29 +130,29 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
//@Override
|
||||
public List<Pair<IBakedModel, RenderType>> getLayerModels(ItemStack itemStack, boolean fabulous)
|
||||
public List<Pair<BakedModel, RenderType>> getLayerModels(ItemStack itemStack, boolean fabulous)
|
||||
{
|
||||
return layerModels;
|
||||
}
|
||||
|
||||
public static Builder builder(IModelConfiguration owner, TextureAtlasSprite particle, ItemOverrideList overrides,
|
||||
ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> cameraTransforms)
|
||||
public static Builder builder(IModelConfiguration owner, TextureAtlasSprite particle, ItemOverrides overrides,
|
||||
ImmutableMap<ItemTransforms.TransformType, Transformation> cameraTransforms)
|
||||
{
|
||||
return new Builder(owner, particle, overrides, cameraTransforms);
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
private final ImmutableList.Builder<Pair<IBakedModel, RenderType>> builder = ImmutableList.builder();
|
||||
private final ImmutableList.Builder<Pair<BakedModel, RenderType>> builder = ImmutableList.builder();
|
||||
private final List<BakedQuad> quads = Lists.newArrayList();
|
||||
private final ItemOverrideList overrides;
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> cameraTransforms;
|
||||
private final ItemOverrides overrides;
|
||||
private final ImmutableMap<ItemTransforms.TransformType, Transformation> cameraTransforms;
|
||||
private final IModelConfiguration owner;
|
||||
private TextureAtlasSprite particle;
|
||||
private RenderType lastRt = null;
|
||||
|
||||
private Builder(IModelConfiguration owner, TextureAtlasSprite particle, ItemOverrideList overrides,
|
||||
ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> cameraTransforms)
|
||||
private Builder(IModelConfiguration owner, TextureAtlasSprite particle, ItemOverrides overrides,
|
||||
ImmutableMap<ItemTransforms.TransformType, Transformation> cameraTransforms)
|
||||
{
|
||||
this.owner = owner;
|
||||
this.particle = particle;
|
||||
@@ -160,9 +160,9 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
|
||||
this.cameraTransforms = cameraTransforms;
|
||||
}
|
||||
|
||||
private void addLayer(ImmutableList.Builder<Pair<IBakedModel, RenderType>> builder, List<BakedQuad> quads, RenderType rt)
|
||||
private void addLayer(ImmutableList.Builder<Pair<BakedModel, RenderType>> builder, List<BakedQuad> quads, RenderType rt)
|
||||
{
|
||||
IBakedModel model = new BakedItemModel(ImmutableList.copyOf(quads), particle, ImmutableMap.of(), ItemOverrideList.EMPTY, true, owner.isSideLit());
|
||||
BakedModel model = new BakedItemModel(ImmutableList.copyOf(quads), particle, ImmutableMap.of(), ItemOverrides.EMPTY, true, owner.isSideLit());
|
||||
builder.add(Pair.of(model, rt));
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
|
||||
return this;
|
||||
}
|
||||
|
||||
public IBakedModel build()
|
||||
public BakedModel build()
|
||||
{
|
||||
if (quads.size() > 0)
|
||||
{
|
||||
|
||||
@@ -21,12 +21,12 @@ package net.minecraftforge.client.model;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import net.minecraft.core.Direction;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
|
||||
import net.minecraftforge.client.model.pipeline.TRSRTransformer;
|
||||
@@ -52,11 +52,11 @@ public final class ItemTextureQuadConverter
|
||||
* @param sprite The texture whose UVs shall be used
|
||||
* @return The generated quads.
|
||||
*/
|
||||
public static List<BakedQuad> convertTexture(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint)
|
||||
public static List<BakedQuad> convertTexture(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint)
|
||||
{
|
||||
return convertTexture(transform, template, sprite, z, facing, color, tint, 0);
|
||||
}
|
||||
public static List<BakedQuad> convertTexture(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity)
|
||||
public static List<BakedQuad> convertTexture(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity)
|
||||
{
|
||||
List<BakedQuad> horizontal = convertTextureHorizontal(transform, template, sprite, z, facing, color, tint, luminosity);
|
||||
List<BakedQuad> vertical = convertTextureVertical(transform, template, sprite, z, facing, color, tint, luminosity);
|
||||
@@ -68,11 +68,11 @@ public final class ItemTextureQuadConverter
|
||||
* Scans a texture and converts it into a list of horizontal strips stacked on top of each other.
|
||||
* The height of the strips is as big as possible.
|
||||
*/
|
||||
public static List<BakedQuad> convertTextureHorizontal(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint)
|
||||
public static List<BakedQuad> convertTextureHorizontal(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint)
|
||||
{
|
||||
return convertTextureHorizontal(transform, template, sprite, z, facing, color, tint, 0);
|
||||
}
|
||||
public static List<BakedQuad> convertTextureHorizontal(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity)
|
||||
public static List<BakedQuad> convertTextureHorizontal(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity)
|
||||
{
|
||||
int w = template.getWidth();
|
||||
int h = template.getHeight();
|
||||
@@ -150,11 +150,11 @@ public final class ItemTextureQuadConverter
|
||||
* Scans a texture and converts it into a list of vertical strips stacked next to each other from left to right.
|
||||
* The width of the strips is as big as possible.
|
||||
*/
|
||||
public static List<BakedQuad> convertTextureVertical(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint)
|
||||
public static List<BakedQuad> convertTextureVertical(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint)
|
||||
{
|
||||
return convertTextureVertical(transform, template, sprite, z, facing, color, tint, 0);
|
||||
}
|
||||
public static List<BakedQuad> convertTextureVertical(TransformationMatrix transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity)
|
||||
public static List<BakedQuad> convertTextureVertical(Transformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint, int luminosity)
|
||||
{
|
||||
int w = template.getWidth();
|
||||
int h = template.getHeight();
|
||||
@@ -237,11 +237,11 @@ public final class ItemTextureQuadConverter
|
||||
* Generates a Front/Back quad for an itemmodel. Therefore only supports facing NORTH and SOUTH.
|
||||
* Coordinates are [0,16] to match the usual coordinates used in TextureAtlasSprites
|
||||
*/
|
||||
public static BakedQuad genQuad(TransformationMatrix transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint)
|
||||
public static BakedQuad genQuad(Transformation transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint)
|
||||
{
|
||||
return genQuad(transform, x1, y1, x2, y2, z, sprite, facing, color, tint, 0);
|
||||
}
|
||||
public static BakedQuad genQuad(TransformationMatrix transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint, int luminosity)
|
||||
public static BakedQuad genQuad(Transformation transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint, int luminosity)
|
||||
{
|
||||
float u1 = sprite.getU(x1);
|
||||
float v1 = sprite.getV(y1);
|
||||
@@ -260,7 +260,7 @@ public final class ItemTextureQuadConverter
|
||||
return putQuad(transform, facing, sprite, color, tint, x1, y1, x2, y2, z, u1, v1, u2, v2, luminosity);
|
||||
}
|
||||
|
||||
private static BakedQuad putQuad(TransformationMatrix transform, Direction side, TextureAtlasSprite sprite, int color, int tint,
|
||||
private static BakedQuad putQuad(Transformation transform, Direction side, TextureAtlasSprite sprite, int color, int tint,
|
||||
float x1, float y1, float x2, float y2, float z,
|
||||
float u1, float v1, float u2, float v2, int luminosity)
|
||||
{
|
||||
|
||||
@@ -31,10 +31,10 @@ import javax.annotation.Nullable;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
@@ -45,13 +45,13 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
@EventBusSubscriber(modid = "forge", bus = Bus.FORGE, value = Dist.CLIENT)
|
||||
public class ModelDataManager
|
||||
{
|
||||
private static WeakReference<World> currentWorld = new WeakReference<>(null);
|
||||
private static WeakReference<Level> currentWorld = new WeakReference<>(null);
|
||||
|
||||
private static final Map<ChunkPos, Set<BlockPos>> needModelDataRefresh = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<ChunkPos, Map<BlockPos, IModelData>> modelDataCache = new ConcurrentHashMap<>();
|
||||
|
||||
private static void cleanCaches(World world)
|
||||
private static void cleanCaches(Level world)
|
||||
{
|
||||
Preconditions.checkNotNull(world, "World must not be null");
|
||||
Preconditions.checkArgument(world == Minecraft.getInstance().level, "Cannot use model data for a world other than the current client world");
|
||||
@@ -63,17 +63,17 @@ public class ModelDataManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void requestModelDataRefresh(TileEntity te)
|
||||
public static void requestModelDataRefresh(BlockEntity te)
|
||||
{
|
||||
Preconditions.checkNotNull(te, "Tile entity must not be null");
|
||||
World world = te.getLevel();
|
||||
Level world = te.getLevel();
|
||||
|
||||
cleanCaches(world);
|
||||
needModelDataRefresh.computeIfAbsent(new ChunkPos(te.getBlockPos()), $ -> Collections.synchronizedSet(new HashSet<>()))
|
||||
.add(te.getBlockPos());
|
||||
}
|
||||
|
||||
private static void refreshModelData(World world, ChunkPos chunk)
|
||||
private static void refreshModelData(Level world, ChunkPos chunk)
|
||||
{
|
||||
cleanCaches(world);
|
||||
Set<BlockPos> needUpdate = needModelDataRefresh.remove(chunk);
|
||||
@@ -83,7 +83,7 @@ public class ModelDataManager
|
||||
Map<BlockPos, IModelData> data = modelDataCache.computeIfAbsent(chunk, $ -> new ConcurrentHashMap<>());
|
||||
for (BlockPos pos : needUpdate)
|
||||
{
|
||||
TileEntity toUpdate = world.getBlockEntity(pos);
|
||||
BlockEntity toUpdate = world.getBlockEntity(pos);
|
||||
if (toUpdate != null && !toUpdate.isRemoved())
|
||||
{
|
||||
data.put(pos, toUpdate.getModelData());
|
||||
@@ -106,12 +106,12 @@ public class ModelDataManager
|
||||
modelDataCache.remove(chunk);
|
||||
}
|
||||
|
||||
public static @Nullable IModelData getModelData(World world, BlockPos pos)
|
||||
public static @Nullable IModelData getModelData(Level world, BlockPos pos)
|
||||
{
|
||||
return getModelData(world, new ChunkPos(pos)).get(pos);
|
||||
}
|
||||
|
||||
public static Map<BlockPos, IModelData> getModelData(World world, ChunkPos pos)
|
||||
public static Map<BlockPos, IModelData> getModelData(Level world, ChunkPos pos)
|
||||
{
|
||||
Preconditions.checkArgument(world.isClientSide, "Cannot request model data for server world");
|
||||
refreshModelData(world, pos);
|
||||
|
||||
@@ -23,15 +23,12 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.logging.ModelLoaderErrorMessage;
|
||||
|
||||
import java.util.function.Function;
|
||||
@@ -44,11 +41,17 @@ import javax.annotation.Nullable;
|
||||
|
||||
import static net.minecraftforge.fml.Logging.MODELLOADING;
|
||||
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final Map<ResourceLocation, Exception> loadingExceptions = Maps.newHashMap();
|
||||
private IUnbakedModel missingModel = null;
|
||||
private UnbakedModel missingModel = null;
|
||||
|
||||
private boolean isLoading = false;
|
||||
|
||||
@@ -65,7 +68,7 @@ public final class ModelLoader extends ModelBakery
|
||||
return isLoading;
|
||||
}
|
||||
|
||||
public ModelLoader(IResourceManager manager, BlockColors colours, IProfiler profiler, int maxMipmapLevel)
|
||||
public ModelLoader(ResourceManager manager, BlockColors colours, ProfilerFiller profiler, int maxMipmapLevel)
|
||||
{
|
||||
super(manager, colours, false);
|
||||
instance = this;
|
||||
@@ -107,7 +110,7 @@ public final class ModelLoader extends ModelBakery
|
||||
return new ResourceLocation(model.getNamespace(), model.getPath() + ".json");
|
||||
}
|
||||
|
||||
protected IUnbakedModel getMissingModel()
|
||||
protected UnbakedModel getMissingModel()
|
||||
{
|
||||
if (missingModel == null)
|
||||
{
|
||||
@@ -126,7 +129,7 @@ public final class ModelLoader extends ModelBakery
|
||||
/**
|
||||
* Use this if you don't care about the exception and want some model anyway.
|
||||
*/
|
||||
public IUnbakedModel getModelOrMissing(ResourceLocation location)
|
||||
public UnbakedModel getModelOrMissing(ResourceLocation location)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -141,7 +144,7 @@ public final class ModelLoader extends ModelBakery
|
||||
/**
|
||||
* Use this if you want the model, but need to log the error.
|
||||
*/
|
||||
public IUnbakedModel getModelOrLogError(ResourceLocation location, String error)
|
||||
public UnbakedModel getModelOrLogError(ResourceLocation location, String error)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -163,7 +166,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, LOCATION).sprite();
|
||||
instance = new Material(TextureAtlas.LOCATION_BLOCKS, LOCATION).sprite();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
@@ -228,9 +231,9 @@ public final class ModelLoader extends ModelBakery
|
||||
/**
|
||||
* Internal, do not use.
|
||||
*/
|
||||
public void onPostBakeEvent(Map<ResourceLocation, IBakedModel> modelRegistry)
|
||||
public void onPostBakeEvent(Map<ResourceLocation, BakedModel> modelRegistry)
|
||||
{
|
||||
IBakedModel missingModel = modelRegistry.get(MISSING_MODEL_LOCATION);
|
||||
BakedModel missingModel = modelRegistry.get(MISSING_MODEL_LOCATION);
|
||||
for(Map.Entry<ResourceLocation, Exception> entry : loadingExceptions.entrySet())
|
||||
{
|
||||
// ignoring pure ResourceLocation arguments, all things we care about pass ModelResourceLocation
|
||||
@@ -238,7 +241,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
LOGGER.debug(MODELLOADING, ()-> new ModelLoaderErrorMessage((ModelResourceLocation)entry.getKey(), entry.getValue()));
|
||||
final ModelResourceLocation location = (ModelResourceLocation)entry.getKey();
|
||||
final IBakedModel model = modelRegistry.get(location);
|
||||
final BakedModel model = modelRegistry.get(location);
|
||||
if(model == null)
|
||||
{
|
||||
modelRegistry.put(location, missingModel);
|
||||
@@ -258,17 +261,17 @@ public final class ModelLoader extends ModelBakery
|
||||
}
|
||||
*/
|
||||
|
||||
private static final Function<ResourceLocation, IUnbakedModel> DEFAULT_MODEL_GETTER = (rl) -> ModelLoader.instance().getModelOrMissing(rl);
|
||||
private static final Function<ResourceLocation, UnbakedModel> DEFAULT_MODEL_GETTER = (rl) -> ModelLoader.instance().getModelOrMissing(rl);
|
||||
|
||||
/**
|
||||
* Get the default texture getter the models will be baked with.
|
||||
*/
|
||||
public static Function<RenderMaterial, TextureAtlasSprite> defaultTextureGetter()
|
||||
public static Function<Material, TextureAtlasSprite> defaultTextureGetter()
|
||||
{
|
||||
return RenderMaterial::sprite;
|
||||
return Material::sprite;
|
||||
}
|
||||
|
||||
public static Function<ResourceLocation, IUnbakedModel> defaultModelGetter()
|
||||
public static Function<ResourceLocation, UnbakedModel> defaultModelGetter()
|
||||
{
|
||||
return DEFAULT_MODEL_GETTER;
|
||||
}
|
||||
|
||||
@@ -26,17 +26,15 @@ import com.google.common.collect.Sets;
|
||||
import com.google.gson.*;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.client.model.geometry.ISimpleModelGeometry;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
@@ -50,6 +48,20 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockElement;
|
||||
import net.minecraft.client.renderer.block.model.BlockElementFace;
|
||||
import net.minecraft.client.renderer.block.model.BlockFaceUV;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransform;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
/**
|
||||
* Central hub for custom model loaders.
|
||||
*/
|
||||
@@ -102,7 +114,7 @@ public class ModelLoaderRegistry
|
||||
synchronized(loaders)
|
||||
{
|
||||
loaders.put(id, loader);
|
||||
((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener(loader);
|
||||
((ReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener(loader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +145,7 @@ public class ModelLoaderRegistry
|
||||
return null;
|
||||
}
|
||||
|
||||
ResourceLocation loader = new ResourceLocation(JSONUtils.getAsString(object,"loader"));
|
||||
ResourceLocation loader = new ResourceLocation(GsonHelper.getAsString(object,"loader"));
|
||||
return getModel(loader, deserializationContext, object);
|
||||
}
|
||||
|
||||
@@ -153,7 +165,7 @@ public class ModelLoaderRegistry
|
||||
private static final Pattern FILESYSTEM_PATH_TO_RESLOC =
|
||||
Pattern.compile("(?:.*[\\\\/]assets[\\\\/](?<namespace>[a-z_-]+)[\\\\/]textures[\\\\/])?(?<path>[a-z_\\\\/-]+)\\.png");
|
||||
|
||||
public static RenderMaterial resolveTexture(@Nullable String tex, IModelConfiguration owner)
|
||||
public static Material resolveTexture(@Nullable String tex, IModelConfiguration owner)
|
||||
{
|
||||
if (tex == null)
|
||||
return blockMaterial(WHITE_TEXTURE);
|
||||
@@ -176,19 +188,19 @@ public class ModelLoaderRegistry
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static RenderMaterial blockMaterial(String location)
|
||||
public static Material blockMaterial(String location)
|
||||
{
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(location));
|
||||
return new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(location));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static RenderMaterial blockMaterial(ResourceLocation location)
|
||||
public static Material blockMaterial(ResourceLocation location)
|
||||
{
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, location);
|
||||
return new Material(TextureAtlas.LOCATION_BLOCKS, location);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IModelTransform deserializeModelTransforms(JsonDeserializationContext deserializationContext, JsonObject modelData)
|
||||
public static ModelState deserializeModelTransforms(JsonDeserializationContext deserializationContext, JsonObject modelData)
|
||||
{
|
||||
if (!modelData.has("transform"))
|
||||
return null;
|
||||
@@ -196,14 +208,14 @@ public class ModelLoaderRegistry
|
||||
return deserializeTransform(deserializationContext, modelData.get("transform")).orElse(null);
|
||||
}
|
||||
|
||||
public static Optional<IModelTransform> deserializeTransform(JsonDeserializationContext context, JsonElement transformData)
|
||||
public static Optional<ModelState> deserializeTransform(JsonDeserializationContext context, JsonElement transformData)
|
||||
{
|
||||
if (!transformData.isJsonObject())
|
||||
{
|
||||
try
|
||||
{
|
||||
TransformationMatrix base = context.deserialize(transformData, TransformationMatrix.class);
|
||||
return Optional.of(new SimpleModelTransform(ImmutableMap.of(), base.blockCenterToCorner()));
|
||||
Transformation base = context.deserialize(transformData, Transformation.class);
|
||||
return Optional.of(new SimpleModelState(ImmutableMap.of(), base.blockCenterToCorner()));
|
||||
}
|
||||
catch (JsonParseException e)
|
||||
{
|
||||
@@ -213,20 +225,20 @@ public class ModelLoaderRegistry
|
||||
else
|
||||
{
|
||||
JsonObject transform = transformData.getAsJsonObject();
|
||||
EnumMap<ItemCameraTransforms.TransformType, TransformationMatrix> transforms = Maps.newEnumMap(ItemCameraTransforms.TransformType.class);
|
||||
EnumMap<ItemTransforms.TransformType, Transformation> transforms = Maps.newEnumMap(ItemTransforms.TransformType.class);
|
||||
|
||||
deserializeTRSR(context, transforms, transform, "thirdperson", ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "thirdperson_righthand", ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "thirdperson_lefthand", ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "thirdperson", ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "thirdperson_righthand", ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "thirdperson_lefthand", ItemTransforms.TransformType.THIRD_PERSON_LEFT_HAND);
|
||||
|
||||
deserializeTRSR(context, transforms, transform, "firstperson", ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "firstperson_righthand", ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "firstperson_lefthand", ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "firstperson", ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "firstperson_righthand", ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND);
|
||||
deserializeTRSR(context, transforms, transform, "firstperson_lefthand", ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND);
|
||||
|
||||
deserializeTRSR(context, transforms, transform, "head", ItemCameraTransforms.TransformType.HEAD);
|
||||
deserializeTRSR(context, transforms, transform, "gui", ItemCameraTransforms.TransformType.GUI);
|
||||
deserializeTRSR(context, transforms, transform, "ground", ItemCameraTransforms.TransformType.GROUND);
|
||||
deserializeTRSR(context, transforms, transform, "fixed", ItemCameraTransforms.TransformType.FIXED);
|
||||
deserializeTRSR(context, transforms, transform, "head", ItemTransforms.TransformType.HEAD);
|
||||
deserializeTRSR(context, transforms, transform, "gui", ItemTransforms.TransformType.GUI);
|
||||
deserializeTRSR(context, transforms, transform, "ground", ItemTransforms.TransformType.GROUND);
|
||||
deserializeTRSR(context, transforms, transform, "fixed", ItemTransforms.TransformType.FIXED);
|
||||
|
||||
int k = transform.entrySet().size();
|
||||
if(transform.has("matrix")) k--;
|
||||
@@ -239,32 +251,32 @@ public class ModelLoaderRegistry
|
||||
{
|
||||
throw new JsonParseException("transform: allowed keys: 'thirdperson', 'firstperson', 'gui', 'head', 'matrix', 'translation', 'rotation', 'scale', 'post-rotation', 'origin'");
|
||||
}
|
||||
TransformationMatrix base = TransformationMatrix.identity();
|
||||
Transformation base = Transformation.identity();
|
||||
if(!transform.entrySet().isEmpty())
|
||||
{
|
||||
base = context.deserialize(transform, TransformationMatrix.class);
|
||||
base = context.deserialize(transform, Transformation.class);
|
||||
}
|
||||
IModelTransform state = new SimpleModelTransform(Maps.immutableEnumMap(transforms), base);
|
||||
ModelState state = new SimpleModelState(Maps.immutableEnumMap(transforms), base);
|
||||
return Optional.of(state);
|
||||
}
|
||||
}
|
||||
|
||||
private static void deserializeTRSR(JsonDeserializationContext context, EnumMap<ItemCameraTransforms.TransformType, TransformationMatrix> transforms, JsonObject transform, String name, ItemCameraTransforms.TransformType itemCameraTransform)
|
||||
private static void deserializeTRSR(JsonDeserializationContext context, EnumMap<ItemTransforms.TransformType, Transformation> transforms, JsonObject transform, String name, ItemTransforms.TransformType itemCameraTransform)
|
||||
{
|
||||
if(transform.has(name))
|
||||
{
|
||||
TransformationMatrix t = context.deserialize(transform.remove(name), TransformationMatrix.class);
|
||||
Transformation t = context.deserialize(transform.remove(name), Transformation.class);
|
||||
transforms.put(itemCameraTransform, t.blockCenterToCorner());
|
||||
}
|
||||
}
|
||||
|
||||
public static IBakedModel bakeHelper(BlockModel blockModel, ModelBakery modelBakery, BlockModel otherModel, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation, boolean guiLight3d)
|
||||
public static BakedModel bakeHelper(BlockModel blockModel, ModelBakery modelBakery, BlockModel otherModel, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation, boolean guiLight3d)
|
||||
{
|
||||
IBakedModel model;
|
||||
BakedModel model;
|
||||
IModelGeometry<?> customModel = blockModel.customData.getCustomGeometry();
|
||||
IModelTransform customModelState = blockModel.customData.getCustomModelState();
|
||||
ModelState customModelState = blockModel.customData.getCustomModelState();
|
||||
if (customModelState != null)
|
||||
modelTransform = new ModelTransformComposition(modelTransform, customModelState, modelTransform.isUvLocked());
|
||||
modelTransform = new CompositeModelState(modelTransform, customModelState, modelTransform.isUvLocked());
|
||||
|
||||
if (customModel != null)
|
||||
model = customModel.bake(blockModel.customData, modelBakery, spriteGetter, modelTransform, blockModel.getOverrides(modelBakery, otherModel, spriteGetter), modelLocation);
|
||||
@@ -288,19 +300,19 @@ public class ModelLoaderRegistry
|
||||
|
||||
public static class VanillaProxy implements ISimpleModelGeometry<VanillaProxy>
|
||||
{
|
||||
private final List<BlockPart> elements;
|
||||
private final List<BlockElement> elements;
|
||||
|
||||
public VanillaProxy(List<BlockPart> list)
|
||||
public VanillaProxy(List<BlockElement> list)
|
||||
{
|
||||
this.elements = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addQuads(IModelConfiguration owner, IModelBuilder<?> modelBuilder, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
|
||||
public void addQuads(IModelConfiguration owner, IModelBuilder<?> modelBuilder, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation)
|
||||
{
|
||||
for(BlockPart blockpart : elements) {
|
||||
for(BlockElement blockpart : elements) {
|
||||
for(Direction direction : blockpart.faces.keySet()) {
|
||||
BlockPartFace blockpartface = blockpart.faces.get(direction);
|
||||
BlockElementFace blockpartface = blockpart.faces.get(direction);
|
||||
TextureAtlasSprite textureatlassprite1 = spriteGetter.apply(owner.resolveTexture(blockpartface.texture));
|
||||
if (blockpartface.cullForDirection == null) {
|
||||
modelBuilder.addGeneralQuad(BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction, modelTransform, modelLocation));
|
||||
@@ -314,14 +326,14 @@ public class ModelLoaderRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
Set<RenderMaterial> textures = Sets.newHashSet();
|
||||
Set<Material> textures = Sets.newHashSet();
|
||||
|
||||
for(BlockPart part : elements) {
|
||||
for(BlockPartFace face : part.faces.values()) {
|
||||
RenderMaterial texture = owner.resolveTexture(face.texture);
|
||||
if (Objects.equals(texture, MissingTextureSprite.getLocation().toString())) {
|
||||
for(BlockElement part : elements) {
|
||||
for(BlockElementFace face : part.faces.values()) {
|
||||
Material texture = owner.resolveTexture(face.texture);
|
||||
if (Objects.equals(texture, MissingTextureAtlasSprite.getLocation().toString())) {
|
||||
missingTextureErrors.add(Pair.of(face.texture, owner.getModelName()));
|
||||
}
|
||||
|
||||
@@ -341,7 +353,7 @@ public class ModelLoaderRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
public void onResourceManagerReload(ResourceManager resourceManager)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -349,15 +361,15 @@ public class ModelLoaderRegistry
|
||||
@Override
|
||||
public VanillaProxy read(JsonDeserializationContext deserializationContext, JsonObject modelContents)
|
||||
{
|
||||
List<BlockPart> list = this.getModelElements(deserializationContext, modelContents);
|
||||
List<BlockElement> list = this.getModelElements(deserializationContext, modelContents);
|
||||
return new VanillaProxy(list);
|
||||
}
|
||||
|
||||
private List<BlockPart> getModelElements(JsonDeserializationContext deserializationContext, JsonObject object) {
|
||||
List<BlockPart> list = Lists.newArrayList();
|
||||
private List<BlockElement> getModelElements(JsonDeserializationContext deserializationContext, JsonObject object) {
|
||||
List<BlockElement> list = Lists.newArrayList();
|
||||
if (object.has("elements")) {
|
||||
for(JsonElement jsonelement : JSONUtils.getAsJsonArray(object, "elements")) {
|
||||
list.add(deserializationContext.deserialize(jsonelement, BlockPart.class));
|
||||
for(JsonElement jsonelement : GsonHelper.getAsJsonArray(object, "elements")) {
|
||||
list.add(deserializationContext.deserialize(jsonelement, BlockElement.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,13 +382,13 @@ public class ModelLoaderRegistry
|
||||
{
|
||||
public static final Gson INSTANCE = (new GsonBuilder())
|
||||
.registerTypeAdapter(BlockModel.class, new ExpandedBlockModelDeserializer())
|
||||
.registerTypeAdapter(BlockPart.class, new BlockPart.Deserializer())
|
||||
.registerTypeAdapter(BlockPartFace.class, new BlockPartFace.Deserializer())
|
||||
.registerTypeAdapter(BlockElement.class, new BlockElement.Deserializer())
|
||||
.registerTypeAdapter(BlockElementFace.class, new BlockElementFace.Deserializer())
|
||||
.registerTypeAdapter(BlockFaceUV.class, new BlockFaceUV.Deserializer())
|
||||
.registerTypeAdapter(ItemTransformVec3f.class, new ItemTransformVec3f.Deserializer())
|
||||
.registerTypeAdapter(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer())
|
||||
.registerTypeAdapter(ItemTransform.class, new ItemTransform.Deserializer())
|
||||
.registerTypeAdapter(ItemTransforms.class, new ItemTransforms.Deserializer())
|
||||
.registerTypeAdapter(ItemOverride.class, new ItemOverride.Deserializer())
|
||||
.registerTypeAdapter(TransformationMatrix.class, new TransformationHelper.Deserializer())
|
||||
.registerTypeAdapter(Transformation.class, new TransformationHelper.Deserializer())
|
||||
.create();
|
||||
|
||||
public BlockModel deserialize(JsonElement element, Type targetType, JsonDeserializationContext deserializationContext) throws JsonParseException {
|
||||
@@ -384,13 +396,13 @@ public class ModelLoaderRegistry
|
||||
JsonObject jsonobject = element.getAsJsonObject();
|
||||
IModelGeometry<?> geometry = deserializeGeometry(deserializationContext, jsonobject);
|
||||
|
||||
List<BlockPart> elements = model.getElements();
|
||||
List<BlockElement> elements = model.getElements();
|
||||
if (geometry != null) {
|
||||
elements.clear();
|
||||
model.customData.setCustomGeometry(geometry);
|
||||
}
|
||||
|
||||
IModelTransform modelState = deserializeModelTransforms(deserializationContext, jsonobject);
|
||||
ModelState modelState = deserializeModelTransforms(deserializationContext, jsonobject);
|
||||
if (modelState != null)
|
||||
{
|
||||
model.customData.setCustomModelState(modelState);
|
||||
@@ -398,7 +410,7 @@ public class ModelLoaderRegistry
|
||||
|
||||
if (jsonobject.has("visibility"))
|
||||
{
|
||||
JsonObject visibility = JSONUtils.getAsJsonObject(jsonobject, "visibility");
|
||||
JsonObject visibility = GsonHelper.getAsJsonObject(jsonobject, "visibility");
|
||||
for(Map.Entry<String, JsonElement> part : visibility.entrySet())
|
||||
{
|
||||
model.customData.visibilityData.setVisibilityState(part.getKey(), part.getValue().getAsBoolean());
|
||||
|
||||
@@ -27,20 +27,18 @@ import javax.annotation.Nullable;
|
||||
import com.google.common.collect.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeRenderTypes;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
@@ -52,6 +50,15 @@ import org.apache.logging.log4j.Logger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
/**
|
||||
* A model that can be rendered in multiple {@link RenderType}.
|
||||
*/
|
||||
@@ -59,35 +66,35 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final ImmutableList<Pair<RenderType, IUnbakedModel>> models;
|
||||
private final ImmutableList<Pair<RenderType, UnbakedModel>> models;
|
||||
private final boolean convertRenderTypes;
|
||||
|
||||
public MultiLayerModel(Map<RenderType, IUnbakedModel> models)
|
||||
public MultiLayerModel(Map<RenderType, UnbakedModel> models)
|
||||
{
|
||||
this(models.entrySet().stream().map(kv -> Pair.of(kv.getKey(), kv.getValue())).collect(ImmutableList.toImmutableList()), true);
|
||||
}
|
||||
|
||||
public MultiLayerModel(ImmutableList<Pair<RenderType, IUnbakedModel>> models, boolean convertRenderTypes)
|
||||
public MultiLayerModel(ImmutableList<Pair<RenderType, UnbakedModel>> models, boolean convertRenderTypes)
|
||||
{
|
||||
this.models = models;
|
||||
this.convertRenderTypes = convertRenderTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
Set<RenderMaterial> materials = Sets.newHashSet();
|
||||
Set<Material> materials = Sets.newHashSet();
|
||||
materials.add(owner.resolveTexture("particle"));
|
||||
for (Pair<RenderType, IUnbakedModel> m : models)
|
||||
for (Pair<RenderType, UnbakedModel> m : models)
|
||||
materials.addAll(m.getSecond().getMaterials(modelGetter, missingTextureErrors));
|
||||
return materials;
|
||||
}
|
||||
|
||||
private static ImmutableList<Pair<RenderType, IBakedModel>> buildModels(List<Pair<RenderType, IUnbakedModel>> models, IModelTransform modelTransform,
|
||||
ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, ResourceLocation modelLocation)
|
||||
private static ImmutableList<Pair<RenderType, BakedModel>> buildModels(List<Pair<RenderType, UnbakedModel>> models, ModelState modelTransform,
|
||||
ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ResourceLocation modelLocation)
|
||||
{
|
||||
ImmutableList.Builder<Pair<RenderType, IBakedModel>> builder = ImmutableList.builder();
|
||||
for(Pair<RenderType, IUnbakedModel> entry : models)
|
||||
ImmutableList.Builder<Pair<RenderType, BakedModel>> builder = ImmutableList.builder();
|
||||
for(Pair<RenderType, UnbakedModel> entry : models)
|
||||
{
|
||||
builder.add(Pair.of(entry.getFirst(), entry.getSecond().bake(bakery, spriteGetter, modelTransform, modelLocation)));
|
||||
}
|
||||
@@ -95,33 +102,33 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
return new MultiLayerBakedModel(
|
||||
owner.useSmoothLighting(), owner.isShadedInGui(), owner.isSideLit(),
|
||||
spriteGetter.apply(owner.resolveTexture("particle")), overrides, convertRenderTypes,
|
||||
buildModels(models, modelTransform, bakery, spriteGetter, modelLocation),
|
||||
PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(owner.getCombinedTransform(), modelTransform))
|
||||
PerspectiveMapWrapper.getTransforms(new CompositeModelState(owner.getCombinedTransform(), modelTransform))
|
||||
);
|
||||
}
|
||||
|
||||
private static final class MultiLayerBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
private final ImmutableMap<RenderType, IBakedModel> models;
|
||||
private final ImmutableMap<TransformType, TransformationMatrix> cameraTransforms;
|
||||
private final ImmutableMap<RenderType, BakedModel> models;
|
||||
private final ImmutableMap<TransformType, Transformation> cameraTransforms;
|
||||
protected final boolean ambientOcclusion;
|
||||
protected final boolean gui3d;
|
||||
protected final boolean isSideLit;
|
||||
protected final TextureAtlasSprite particle;
|
||||
protected final ItemOverrideList overrides;
|
||||
protected final ItemOverrides overrides;
|
||||
private final List<BakedQuad> missing = ImmutableList.of();
|
||||
private final boolean convertRenderTypes;
|
||||
private final List<Pair<IBakedModel, RenderType>> itemLayers;
|
||||
private final List<Pair<BakedModel, RenderType>> itemLayers;
|
||||
|
||||
public MultiLayerBakedModel(
|
||||
boolean ambientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrideList overrides,
|
||||
boolean convertRenderTypes, List<Pair<RenderType, IBakedModel>> models,
|
||||
ImmutableMap<TransformType, TransformationMatrix> cameraTransforms)
|
||||
boolean ambientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides,
|
||||
boolean convertRenderTypes, List<Pair<RenderType, BakedModel>> models,
|
||||
ImmutableMap<TransformType, Transformation> cameraTransforms)
|
||||
{
|
||||
this.isSideLit = isSideLit;
|
||||
this.cameraTransforms = cameraTransforms;
|
||||
@@ -146,7 +153,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
if (layer == null)
|
||||
{
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
for (IBakedModel model : models.values())
|
||||
for (BakedModel model : models.values())
|
||||
{
|
||||
builder.addAll(model.getQuads(state, side, rand, extraData));
|
||||
}
|
||||
@@ -204,15 +211,15 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(TransformType cameraTransformType, MatrixStack mat)
|
||||
public BakedModel handlePerspective(TransformType cameraTransformType, PoseStack poseStack)
|
||||
{
|
||||
return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType, mat);
|
||||
return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType, poseStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
public ItemOverrides getOverrides()
|
||||
{
|
||||
return ItemOverrideList.EMPTY;
|
||||
return ItemOverrides.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,18 +229,19 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<IBakedModel, RenderType>> getLayerModels(ItemStack itemStack, boolean fabulous)
|
||||
public List<Pair<BakedModel, RenderType>> getLayerModels(ItemStack itemStack, boolean fabulous)
|
||||
{
|
||||
return itemLayers;
|
||||
}
|
||||
|
||||
public static BiMap<RenderType, RenderType> ITEM_RENDER_TYPE_MAPPING = HashBiMap.create();
|
||||
static {
|
||||
// TODO ForgeRenderTypes
|
||||
/* static {
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.solid(), ForgeRenderTypes.ITEM_LAYERED_SOLID.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.cutout(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.cutoutMipped(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.translucent(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public static final class Loader implements IModelLoader<MultiLayerModel>
|
||||
@@ -251,7 +259,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
private Loader() {}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
public void onResourceManagerReload(ResourceManager resourceManager)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -259,17 +267,17 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
@Override
|
||||
public MultiLayerModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents)
|
||||
{
|
||||
ImmutableList.Builder<Pair<RenderType, IUnbakedModel>> builder = ImmutableList.builder();
|
||||
JsonObject layersObject = JSONUtils.getAsJsonObject(modelContents, "layers");
|
||||
ImmutableList.Builder<Pair<RenderType, UnbakedModel>> builder = ImmutableList.builder();
|
||||
JsonObject layersObject = GsonHelper.getAsJsonObject(modelContents, "layers");
|
||||
for(Map.Entry<String, RenderType> layer : BLOCK_LAYERS.entrySet()) // block layers
|
||||
{
|
||||
String layerName = layer.getKey(); // mc overrides toString to return the ID for the layer
|
||||
if(layersObject.has(layerName))
|
||||
{
|
||||
builder.add(Pair.of(layer.getValue(), deserializationContext.deserialize(JSONUtils.getAsJsonObject(layersObject, layerName), BlockModel.class)));
|
||||
builder.add(Pair.of(layer.getValue(), deserializationContext.deserialize(GsonHelper.getAsJsonObject(layersObject, layerName), BlockModel.class)));
|
||||
}
|
||||
}
|
||||
boolean convertRenderTypes = JSONUtils.getAsBoolean(modelContents, "convert_render_types", true);
|
||||
boolean convertRenderTypes = GsonHelper.getAsBoolean(modelContents, "convert_render_types", true);
|
||||
return new MultiLayerModel(builder.build(), convertRenderTypes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,16 +24,14 @@ import java.util.Random;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.Direction;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
@@ -41,29 +39,36 @@ import net.minecraftforge.common.model.TransformationHelper;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
|
||||
public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
{
|
||||
private final IBakedModel parent;
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> transforms;
|
||||
private final BakedModel parent;
|
||||
private final ImmutableMap<ItemTransforms.TransformType, Transformation> transforms;
|
||||
private final OverrideListWrapper overrides = new OverrideListWrapper();
|
||||
|
||||
public PerspectiveMapWrapper(IBakedModel parent, ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> transforms)
|
||||
public PerspectiveMapWrapper(BakedModel parent, ImmutableMap<ItemTransforms.TransformType, Transformation> transforms)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.transforms = transforms;
|
||||
}
|
||||
|
||||
public PerspectiveMapWrapper(IBakedModel parent, IModelTransform state)
|
||||
public PerspectiveMapWrapper(BakedModel parent, ModelState state)
|
||||
{
|
||||
this(parent, getTransforms(state));
|
||||
}
|
||||
|
||||
public static ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> getTransforms(IModelTransform state)
|
||||
public static ImmutableMap<ItemTransforms.TransformType, Transformation> getTransforms(ModelState state)
|
||||
{
|
||||
EnumMap<ItemCameraTransforms.TransformType, TransformationMatrix> map = new EnumMap<>(ItemCameraTransforms.TransformType.class);
|
||||
for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values())
|
||||
EnumMap<ItemTransforms.TransformType, Transformation> map = new EnumMap<>(ItemTransforms.TransformType.class);
|
||||
for(ItemTransforms.TransformType type : ItemTransforms.TransformType.values())
|
||||
{
|
||||
TransformationMatrix tr = state.getPartTransformation(type);
|
||||
Transformation tr = state.getPartTransformation(type);
|
||||
if(!tr.isIdentity())
|
||||
{
|
||||
map.put(type, tr);
|
||||
@@ -73,10 +78,10 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> getTransforms(ItemCameraTransforms transforms)
|
||||
public static ImmutableMap<ItemTransforms.TransformType, Transformation> getTransforms(ItemTransforms transforms)
|
||||
{
|
||||
EnumMap<ItemCameraTransforms.TransformType, TransformationMatrix> map = new EnumMap<>(ItemCameraTransforms.TransformType.class);
|
||||
for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values())
|
||||
EnumMap<ItemTransforms.TransformType, Transformation> map = new EnumMap<>(ItemTransforms.TransformType.class);
|
||||
for(ItemTransforms.TransformType type : ItemTransforms.TransformType.values())
|
||||
{
|
||||
if (transforms.hasTransform(type))
|
||||
{
|
||||
@@ -87,12 +92,12 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> getTransformsWithFallback(IModelTransform state, ItemCameraTransforms transforms)
|
||||
public static ImmutableMap<ItemTransforms.TransformType, Transformation> getTransformsWithFallback(ModelState state, ItemTransforms transforms)
|
||||
{
|
||||
EnumMap<ItemCameraTransforms.TransformType, TransformationMatrix> map = new EnumMap<>(ItemCameraTransforms.TransformType.class);
|
||||
for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values())
|
||||
EnumMap<ItemTransforms.TransformType, Transformation> map = new EnumMap<>(ItemTransforms.TransformType.class);
|
||||
for(ItemTransforms.TransformType type : ItemTransforms.TransformType.values())
|
||||
{
|
||||
TransformationMatrix tr = state.getPartTransformation(type);
|
||||
Transformation tr = state.getPartTransformation(type);
|
||||
if(!tr.isIdentity())
|
||||
{
|
||||
map.put(type, tr);
|
||||
@@ -105,9 +110,9 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
return ImmutableMap.copyOf(map);
|
||||
}
|
||||
|
||||
public static IBakedModel handlePerspective(IBakedModel model, ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> transforms, ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat)
|
||||
public static BakedModel handlePerspective(BakedModel model, ImmutableMap<ItemTransforms.TransformType, Transformation> transforms, ItemTransforms.TransformType cameraTransformType, PoseStack mat)
|
||||
{
|
||||
TransformationMatrix tr = transforms.getOrDefault(cameraTransformType, TransformationMatrix.identity());
|
||||
Transformation tr = transforms.getOrDefault(cameraTransformType, Transformation.identity());
|
||||
if (!tr.isIdentity())
|
||||
{
|
||||
tr.push(mat);
|
||||
@@ -115,9 +120,9 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
return model;
|
||||
}
|
||||
|
||||
public static IBakedModel handlePerspective(IBakedModel model, IModelTransform state, ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat)
|
||||
public static BakedModel handlePerspective(BakedModel model, ModelState state, ItemTransforms.TransformType cameraTransformType, PoseStack mat)
|
||||
{
|
||||
TransformationMatrix tr = state.getPartTransformation(cameraTransformType);
|
||||
Transformation tr = state.getPartTransformation(cameraTransformType);
|
||||
if (!tr.isIdentity())
|
||||
{
|
||||
tr.push(mat);
|
||||
@@ -132,14 +137,14 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
@Override public boolean isCustomRenderer() { return parent.isCustomRenderer(); }
|
||||
@Override public TextureAtlasSprite getParticleIcon() { return parent.getParticleIcon(); }
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override public ItemCameraTransforms getTransforms() { return parent.getTransforms(); }
|
||||
@Override public ItemTransforms getTransforms() { return parent.getTransforms(); }
|
||||
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData)
|
||||
{
|
||||
return parent.getQuads(state, side, rand, extraData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
public ItemOverrides getOverrides()
|
||||
{
|
||||
return overrides;
|
||||
}
|
||||
@@ -151,12 +156,12 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat)
|
||||
public BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack)
|
||||
{
|
||||
return handlePerspective(this, transforms, cameraTransformType, mat);
|
||||
return handlePerspective(this, transforms, cameraTransformType, poseStack);
|
||||
}
|
||||
|
||||
private class OverrideListWrapper extends ItemOverrideList
|
||||
private class OverrideListWrapper extends ItemOverrides
|
||||
{
|
||||
public OverrideListWrapper()
|
||||
{
|
||||
@@ -165,14 +170,14 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel resolve(IBakedModel model, ItemStack stack, @Nullable ClientWorld worldIn, @Nullable LivingEntity entityIn)
|
||||
public BakedModel resolve(BakedModel model, ItemStack stack, @Nullable ClientLevel worldIn, @Nullable LivingEntity entityIn, int seed)
|
||||
{
|
||||
model = parent.getOverrides().resolve(parent, stack, worldIn, entityIn);
|
||||
model = parent.getOverrides().resolve(parent, stack, worldIn, entityIn, seed);
|
||||
return new PerspectiveMapWrapper(model, transforms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ItemOverride> getOverrides()
|
||||
public ImmutableList<BakedOverride> getOverrides()
|
||||
{
|
||||
return parent.getOverrides().getOverrides();
|
||||
}
|
||||
|
||||
@@ -25,28 +25,28 @@ import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector4f;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
|
||||
public class QuadTransformer
|
||||
{
|
||||
private static final int POSITION = findPositionOffset(DefaultVertexFormats.BLOCK);
|
||||
private static final int NORMAL = findNormalOffset(DefaultVertexFormats.BLOCK);
|
||||
private final TransformationMatrix transform;
|
||||
private static final int POSITION = findPositionOffset(DefaultVertexFormat.BLOCK);
|
||||
private static final int NORMAL = findNormalOffset(DefaultVertexFormat.BLOCK);
|
||||
private final Transformation transform;
|
||||
|
||||
public QuadTransformer(TransformationMatrix transform)
|
||||
public QuadTransformer(Transformation transform)
|
||||
{
|
||||
this.transform = transform;
|
||||
}
|
||||
|
||||
private void processVertices(int[] inData, int[] outData)
|
||||
{
|
||||
int stride = DefaultVertexFormats.BLOCK.getVertexSize();
|
||||
int stride = DefaultVertexFormat.BLOCK.getVertexSize();
|
||||
int count = (inData.length * 4) / stride;
|
||||
for (int i=0;i<count;i++)
|
||||
{
|
||||
|
||||
@@ -25,34 +25,46 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspectiveModel>
|
||||
{
|
||||
private final BlockModel baseModel;
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, BlockModel> perspectives;
|
||||
private final ImmutableMap<ItemTransforms.TransformType, BlockModel> perspectives;
|
||||
|
||||
public SeparatePerspectiveModel(BlockModel baseModel, ImmutableMap<ItemCameraTransforms.TransformType, BlockModel> perspectives)
|
||||
public SeparatePerspectiveModel(BlockModel baseModel, ImmutableMap<ItemTransforms.TransformType, BlockModel> perspectives)
|
||||
{
|
||||
this.baseModel = baseModel;
|
||||
this.perspectives = perspectives;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation)
|
||||
public net.minecraft.client.resources.model.BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
return new BakedModel(
|
||||
owner.useSmoothLighting(), owner.isShadedInGui(), owner.isSideLit(),
|
||||
@@ -65,26 +77,26 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
Set<RenderMaterial> textures = Sets.newHashSet();
|
||||
Set<Material> textures = Sets.newHashSet();
|
||||
textures.addAll(baseModel.getMaterials(modelGetter, missingTextureErrors));
|
||||
for(BlockModel model : perspectives.values())
|
||||
textures.addAll(model.getMaterials(modelGetter, missingTextureErrors));
|
||||
return textures;
|
||||
}
|
||||
|
||||
public static class BakedModel implements IBakedModel
|
||||
public static class BakedModel implements net.minecraft.client.resources.model.BakedModel
|
||||
{
|
||||
private final boolean isAmbientOcclusion;
|
||||
private final boolean isGui3d;
|
||||
private final boolean isSideLit;
|
||||
private final TextureAtlasSprite particle;
|
||||
private final ItemOverrideList overrides;
|
||||
private final IBakedModel baseModel;
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, IBakedModel> perspectives;
|
||||
private final ItemOverrides overrides;
|
||||
private final net.minecraft.client.resources.model.BakedModel baseModel;
|
||||
private final ImmutableMap<ItemTransforms.TransformType, net.minecraft.client.resources.model.BakedModel> perspectives;
|
||||
|
||||
public BakedModel(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrideList overrides, IBakedModel baseModel, ImmutableMap<ItemCameraTransforms.TransformType, IBakedModel> perspectives)
|
||||
public BakedModel(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, net.minecraft.client.resources.model.BakedModel baseModel, ImmutableMap<ItemTransforms.TransformType, net.minecraft.client.resources.model.BakedModel> perspectives)
|
||||
{
|
||||
this.isAmbientOcclusion = isAmbientOcclusion;
|
||||
this.isGui3d = isGui3d;
|
||||
@@ -132,7 +144,7 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
public ItemOverrides getOverrides()
|
||||
{
|
||||
return overrides;
|
||||
}
|
||||
@@ -144,20 +156,20 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getTransforms()
|
||||
public ItemTransforms getTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.NO_TRANSFORMS;
|
||||
return ItemTransforms.NO_TRANSFORMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat)
|
||||
public net.minecraft.client.resources.model.BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack)
|
||||
{
|
||||
if (perspectives.containsKey(cameraTransformType))
|
||||
{
|
||||
IBakedModel p = perspectives.get(cameraTransformType);
|
||||
return p.handlePerspective(cameraTransformType, mat);
|
||||
net.minecraft.client.resources.model.BakedModel p = perspectives.get(cameraTransformType);
|
||||
return p.handlePerspective(cameraTransformType, poseStack);
|
||||
}
|
||||
return baseModel.handlePerspective(cameraTransformType, mat);
|
||||
return baseModel.handlePerspective(cameraTransformType, poseStack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,37 +177,36 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
{
|
||||
public static final Loader INSTANCE = new Loader();
|
||||
|
||||
public static final ImmutableBiMap<String, ItemCameraTransforms.TransformType> PERSPECTIVES = ImmutableBiMap.<String, ItemCameraTransforms.TransformType>builder()
|
||||
.put("none", ItemCameraTransforms.TransformType.NONE)
|
||||
.put("third_person_left_hand", ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND)
|
||||
.put("third_person_right_hand", ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND)
|
||||
.put("first_person_left_hand", ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND)
|
||||
.put("first_person_right_hand", ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND)
|
||||
.put("head", ItemCameraTransforms.TransformType.HEAD)
|
||||
.put("gui", ItemCameraTransforms.TransformType.GUI)
|
||||
.put("ground", ItemCameraTransforms.TransformType.GROUND)
|
||||
.put("fixed", ItemCameraTransforms.TransformType.FIXED)
|
||||
public static final ImmutableBiMap<String, ItemTransforms.TransformType> PERSPECTIVES = ImmutableBiMap.<String, ItemTransforms.TransformType>builder()
|
||||
.put("none", ItemTransforms.TransformType.NONE)
|
||||
.put("third_person_left_hand", ItemTransforms.TransformType.THIRD_PERSON_LEFT_HAND)
|
||||
.put("third_person_right_hand", ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND)
|
||||
.put("first_person_left_hand", ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND)
|
||||
.put("first_person_right_hand", ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND)
|
||||
.put("head", ItemTransforms.TransformType.HEAD)
|
||||
.put("gui", ItemTransforms.TransformType.GUI)
|
||||
.put("ground", ItemTransforms.TransformType.GROUND)
|
||||
.put("fixed", ItemTransforms.TransformType.FIXED)
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
{
|
||||
// Not used
|
||||
public void onResourceManagerReload(final ResourceManager p_10758_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SeparatePerspectiveModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents)
|
||||
{
|
||||
BlockModel baseModel = deserializationContext.deserialize(JSONUtils.getAsJsonObject(modelContents, "base"), BlockModel.class);
|
||||
BlockModel baseModel = deserializationContext.deserialize(GsonHelper.getAsJsonObject(modelContents, "base"), BlockModel.class);
|
||||
|
||||
JsonObject perspectiveData = JSONUtils.getAsJsonObject(modelContents, "perspectives");
|
||||
JsonObject perspectiveData = GsonHelper.getAsJsonObject(modelContents, "perspectives");
|
||||
|
||||
ImmutableMap.Builder<ItemCameraTransforms.TransformType, BlockModel> perspectives = ImmutableMap.builder();
|
||||
for(Map.Entry<String, ItemCameraTransforms.TransformType> perspective : PERSPECTIVES.entrySet())
|
||||
ImmutableMap.Builder<ItemTransforms.TransformType, BlockModel> perspectives = ImmutableMap.builder();
|
||||
for(Map.Entry<String, ItemTransforms.TransformType> perspective : PERSPECTIVES.entrySet())
|
||||
{
|
||||
if (perspectiveData.has(perspective.getKey()))
|
||||
{
|
||||
BlockModel perspectiveModel = deserializationContext.deserialize(JSONUtils.getAsJsonObject(perspectiveData, perspective.getKey()), BlockModel.class);
|
||||
BlockModel perspectiveModel = deserializationContext.deserialize(GsonHelper.getAsJsonObject(perspectiveData, perspective.getKey()), BlockModel.class);
|
||||
perspectives.put(perspective.getValue(), perspectiveModel);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -19,46 +19,46 @@
|
||||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import com.mojang.math.Transformation;
|
||||
|
||||
/**
|
||||
* Simple implementation of IModelState via a map and a default value.
|
||||
*/
|
||||
public final class SimpleModelTransform implements IModelTransform
|
||||
public final class SimpleModelState implements ModelState
|
||||
{
|
||||
public static final SimpleModelTransform IDENTITY = new SimpleModelTransform(TransformationMatrix.identity());
|
||||
public static final SimpleModelState IDENTITY = new SimpleModelState(Transformation.identity());
|
||||
|
||||
private final ImmutableMap<?, TransformationMatrix> map;
|
||||
private final TransformationMatrix base;
|
||||
private final ImmutableMap<?, Transformation> map;
|
||||
private final Transformation base;
|
||||
|
||||
public SimpleModelTransform(ImmutableMap<?, TransformationMatrix> map)
|
||||
public SimpleModelState(ImmutableMap<?, Transformation> map)
|
||||
{
|
||||
this(map, TransformationMatrix.identity());
|
||||
this(map, Transformation.identity());
|
||||
}
|
||||
|
||||
public SimpleModelTransform(TransformationMatrix base)
|
||||
public SimpleModelState(Transformation base)
|
||||
{
|
||||
this(ImmutableMap.of(), base);
|
||||
}
|
||||
|
||||
public SimpleModelTransform(ImmutableMap<?, TransformationMatrix> map, TransformationMatrix base)
|
||||
public SimpleModelState(ImmutableMap<?, Transformation> map, Transformation base)
|
||||
{
|
||||
this.map = map;
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformationMatrix getRotation()
|
||||
public Transformation getRotation()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformationMatrix getPartTransformation(Object part)
|
||||
public Transformation getPartTransformation(Object part)
|
||||
{
|
||||
return map.getOrDefault(part, TransformationMatrix.identity());
|
||||
return map.getOrDefault(part, Transformation.identity());
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.model.animation;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
@@ -30,12 +30,12 @@ public enum Animation
|
||||
private float clientPartialTickTime;
|
||||
|
||||
private static long epochTime;
|
||||
private static WeakReference<World> worldRef;
|
||||
private static WeakReference<Level> worldRef;
|
||||
|
||||
/**
|
||||
* Get the global world time for the current tick, in seconds.
|
||||
*/
|
||||
public static float getWorldTime(World world)
|
||||
public static float getWorldTime(Level world)
|
||||
{
|
||||
return getWorldTime(world, 0);
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public enum Animation
|
||||
/**
|
||||
* Get the global world time for the current tick + partial tick progress, in seconds.
|
||||
*/
|
||||
public static float getWorldTime(World world, float tickProgress)
|
||||
public static float getWorldTime(Level world, float tickProgress)
|
||||
{
|
||||
if (worldRef == null || worldRef.get() != world)
|
||||
{
|
||||
|
||||
+18
-23
@@ -21,19 +21,19 @@ package net.minecraftforge.client.model.animation;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.model.ModelDataManager;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
@@ -47,17 +47,12 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||
/**
|
||||
* Generic {@link TileGameRenderer} that works with the Forge model system and animations.
|
||||
*/
|
||||
public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntityRenderer<T> implements IEventHandler<T>
|
||||
public class AnimationBlockEntityRenderer<T extends BlockEntity> implements BlockEntityRenderer<T>, IEventHandler<T>
|
||||
{
|
||||
public TileEntityRendererAnimation(TileEntityRendererDispatcher rendererDispatcherIn)
|
||||
{
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
protected static BlockRendererDispatcher blockRenderer;
|
||||
protected static BlockRenderDispatcher blockRenderer;
|
||||
|
||||
@Override
|
||||
public void render(T te, float partialTick, MatrixStack mat, IRenderTypeBuffer renderer, int light, int otherlight)
|
||||
public void render(T te, float partialTick, PoseStack mat, MultiBufferSource renderer, int light, int otherlight)
|
||||
{
|
||||
LazyOptional<IAnimationStateMachine> cap = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY);
|
||||
if(!cap.isPresent())
|
||||
@@ -66,10 +61,10 @@ public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntit
|
||||
}
|
||||
if(blockRenderer == null) blockRenderer = Minecraft.getInstance().getBlockRenderer();
|
||||
BlockPos pos = te.getBlockPos();
|
||||
IBlockDisplayReader world = MinecraftForgeClient.getRegionRenderCacheOptional(te.getLevel(), pos)
|
||||
.map(IBlockDisplayReader.class::cast).orElseGet(() -> te.getLevel());
|
||||
BlockAndTintGetter world = MinecraftForgeClient.getRegionRenderCacheOptional(te.getLevel(), pos)
|
||||
.map(BlockAndTintGetter.class::cast).orElseGet(() -> te.getLevel());
|
||||
BlockState state = world.getBlockState(pos);
|
||||
IBakedModel model = blockRenderer.getBlockModelShaper().getBlockModel(state);
|
||||
BakedModel model = blockRenderer.getBlockModelShaper().getBlockModel(state);
|
||||
IModelData data = model.getModelData(world, pos, state, ModelDataManager.getModelData(te.getLevel(), pos));
|
||||
if (data.hasProperty(Properties.AnimationProperty))
|
||||
{
|
||||
@@ -82,7 +77,7 @@ public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntit
|
||||
|
||||
// TODO: caching?
|
||||
data.setData(Properties.AnimationProperty, pair.getLeft());
|
||||
blockRenderer.getModelRenderer().renderModel(world, model, state, pos, mat, renderer.getBuffer(Atlases.solidBlockSheet()), false, new Random(), 42, light, data);
|
||||
blockRenderer.getModelRenderer().tesselateBlock(world, model, state, pos, mat, renderer.getBuffer(Sheets.solidBlockSheet()), false, new Random(), 42, light, data);
|
||||
});
|
||||
}
|
||||
}
|
||||
+27
-17
@@ -25,33 +25,43 @@ import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelTransformComposition;
|
||||
import net.minecraftforge.client.model.CompositeModelState;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
|
||||
public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
import net.minecraft.client.renderer.block.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
public final class AnimationItemOverrideList extends ItemOverrides
|
||||
{
|
||||
private final ModelBakery bakery;
|
||||
private final IUnbakedModel model;
|
||||
private final UnbakedModel model;
|
||||
private final ResourceLocation modelLoc;
|
||||
private final IModelTransform state;
|
||||
private final ModelState state;
|
||||
|
||||
|
||||
private final Function<RenderMaterial, TextureAtlasSprite> bakedTextureGetter;
|
||||
private final Function<Material, TextureAtlasSprite> bakedTextureGetter;
|
||||
|
||||
public AnimationItemOverrideList(ModelBakery bakery, IUnbakedModel model, ResourceLocation modelLoc, IModelTransform state, Function<RenderMaterial, TextureAtlasSprite> bakedTextureGetter, ItemOverrideList overrides)
|
||||
//TODO, Mojang now bakes overrides, figure out how to reverse them.
|
||||
/*
|
||||
public AnimationItemOverrideList(ModelBakery bakery, UnbakedModel model, ResourceLocation modelLoc, ModelState state, Function<Material, TextureAtlasSprite> bakedTextureGetter, ItemOverrides overrides)
|
||||
{
|
||||
this(bakery, model, modelLoc, state, bakedTextureGetter, overrides.getOverrides().reverse());
|
||||
}
|
||||
*/
|
||||
|
||||
public AnimationItemOverrideList(ModelBakery bakery, IUnbakedModel model, ResourceLocation modelLoc, IModelTransform state, Function<RenderMaterial, TextureAtlasSprite> bakedTextureGetter, List<ItemOverride> overrides)
|
||||
public AnimationItemOverrideList(ModelBakery bakery, UnbakedModel model, ResourceLocation modelLoc, ModelState state, Function<Material, TextureAtlasSprite> bakedTextureGetter, List<ItemOverride> overrides)
|
||||
{
|
||||
super(bakery, model, ModelLoader.defaultModelGetter(), bakedTextureGetter, overrides);
|
||||
this.bakery = bakery;
|
||||
@@ -63,12 +73,12 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public IBakedModel resolve(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
|
||||
public BakedModel resolve(BakedModel originalModel, ItemStack stack, @Nullable ClientLevel world, @Nullable LivingEntity entity, int seed)
|
||||
{
|
||||
return stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)
|
||||
.map(asm ->
|
||||
{
|
||||
World w = world;
|
||||
Level w = world;
|
||||
// TODO caching?
|
||||
if(w == null && entity != null)
|
||||
{
|
||||
@@ -81,7 +91,7 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
return asm.apply(Animation.getWorldTime(world, Animation.getPartialTickTime())).getLeft();
|
||||
})
|
||||
// TODO where should uvlock data come from?
|
||||
.map(state -> model.bake(bakery, bakedTextureGetter, new ModelTransformComposition(state, this.state), modelLoc))
|
||||
.orElseGet(() -> super.resolve(originalModel, stack, world, entity));
|
||||
.map(state -> model.bake(bakery, bakedTextureGetter, new CompositeModelState(state, this.state), modelLoc))
|
||||
.orElseGet(() -> super.resolve(originalModel, stack, world, entity, seed));
|
||||
}
|
||||
}
|
||||
@@ -33,19 +33,19 @@ import java.util.TreeMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.renderer.model.BlockPart;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.client.renderer.block.model.BlockElement;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Interpolation;
|
||||
import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Type;
|
||||
import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Variable;
|
||||
@@ -326,7 +326,7 @@ public class ModelBlockAnimation
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformationMatrix apply(float time)
|
||||
public Transformation apply(float time)
|
||||
{
|
||||
time -= Math.floor(time);
|
||||
Vector3f translation = new Vector3f(0, 0, 0);
|
||||
@@ -338,7 +338,7 @@ public class ModelBlockAnimation
|
||||
{
|
||||
int length = loop ? var.samples.length : (var.samples.length - 1);
|
||||
float timeScaled = time * length;
|
||||
int s1 = MathHelper.clamp((int)Math.round(Math.floor(timeScaled)), 0, length - 1);
|
||||
int s1 = Mth.clamp((int)Math.round(Math.floor(timeScaled)), 0, length - 1);
|
||||
float progress = timeScaled - s1;
|
||||
int s2 = s1 + 1;
|
||||
if(s2 == length && loop) s2 = 0;
|
||||
@@ -409,10 +409,10 @@ public class ModelBlockAnimation
|
||||
}
|
||||
}
|
||||
Quaternion rot = new Quaternion(rotation_axis, rotation_angle, false);
|
||||
TransformationMatrix base = new TransformationMatrix(translation, rot, scale, null);
|
||||
Transformation base = new Transformation(translation, rot, scale, null);
|
||||
Vector3f negOrigin = origin.copy();
|
||||
negOrigin.mul(-1,-1,-1);
|
||||
base = new TransformationMatrix(origin, null, null, null).compose(base).compose(new TransformationMatrix(negOrigin, null, null, null));
|
||||
base = new Transformation(origin, null, null, null).compose(base).compose(new Transformation(negOrigin, null, null, null));
|
||||
return base.blockCenterToCorner();
|
||||
}
|
||||
}
|
||||
@@ -428,9 +428,9 @@ public class ModelBlockAnimation
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformationMatrix getInvBindPose()
|
||||
public Transformation getInvBindPose()
|
||||
{
|
||||
return TransformationMatrix.identity();
|
||||
return Transformation.identity();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -517,13 +517,13 @@ public class ModelBlockAnimation
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TransformationMatrix getPartTransform(IModelTransform state, BlockPart part, int i)
|
||||
public Transformation getPartTransform(ModelState state, BlockElement part, int i)
|
||||
{
|
||||
return getPartTransform(state, i);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TransformationMatrix getPartTransform(IModelTransform state, int i)
|
||||
public Transformation getPartTransform(ModelState state, int i)
|
||||
{
|
||||
ImmutableCollection<MBJointWeight> infos = getJoint(i);
|
||||
if(!infos.isEmpty())
|
||||
@@ -535,7 +535,7 @@ public class ModelBlockAnimation
|
||||
if(info.getWeights().containsKey(i))
|
||||
{
|
||||
ModelBlockAnimation.MBJoint joint = new ModelBlockAnimation.MBJoint(info.getName());
|
||||
TransformationMatrix trOp = state.getPartTransformation(joint);
|
||||
Transformation trOp = state.getPartTransformation(joint);
|
||||
if(!trOp.isIdentity())
|
||||
{
|
||||
float w = info.getWeights().get(i)[0];
|
||||
@@ -549,7 +549,7 @@ public class ModelBlockAnimation
|
||||
if(weight > 1e-5)
|
||||
{
|
||||
m.multiply(1f / weight);
|
||||
return new TransformationMatrix(m);
|
||||
return new Transformation(m);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -558,11 +558,11 @@ public class ModelBlockAnimation
|
||||
/**
|
||||
* Load armature associated with a vanilla model.
|
||||
*/
|
||||
public static ModelBlockAnimation loadVanillaAnimation(IResourceManager manager, ResourceLocation armatureLocation)
|
||||
public static ModelBlockAnimation loadVanillaAnimation(ResourceManager manager, ResourceLocation armatureLocation)
|
||||
{
|
||||
try
|
||||
{
|
||||
try (IResource resource = manager.getResource(armatureLocation))
|
||||
try (Resource resource = manager.getResource(armatureLocation))
|
||||
{
|
||||
ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), ModelBlockAnimation.class);
|
||||
//String json = mbaGson.toJson(mba);
|
||||
|
||||
@@ -21,5 +21,6 @@
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraftforge.client.model.animation;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.model.b3d;
|
||||
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraftforge.client.model.b3d.B3DLoader.NodeJoint;
|
||||
import net.minecraftforge.client.model.b3d.B3DModel.Key;
|
||||
import net.minecraftforge.client.model.b3d.B3DModel.Node;
|
||||
@@ -63,25 +63,25 @@ public enum B3DClip implements IClip
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformationMatrix apply(float time)
|
||||
public Transformation apply(float time)
|
||||
{
|
||||
TransformationMatrix ret = TransformationMatrix.identity();
|
||||
Transformation ret = Transformation.identity();
|
||||
if(node.getAnimation() == null)
|
||||
{
|
||||
return ret.compose(new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
return ret.compose(new Transformation(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
}
|
||||
int start = Math.max(1, (int)Math.round(Math.floor(time)));
|
||||
int end = Math.min(start + 1, (int)Math.round(Math.ceil(time)));
|
||||
float progress = time - (float)Math.floor(time);
|
||||
Key keyStart = node.getAnimation().getKeys().get(start, node);
|
||||
Key keyEnd = node.getAnimation().getKeys().get(end, node);
|
||||
TransformationMatrix startTr = keyStart == null ? null : new TransformationMatrix(keyStart.getPos(), keyStart.getRot(),keyStart.getScale(), null);
|
||||
TransformationMatrix endTr = keyEnd == null ? null : new TransformationMatrix(keyEnd.getPos(), keyEnd.getRot(),keyEnd.getScale(), null);
|
||||
Transformation startTr = keyStart == null ? null : new Transformation(keyStart.getPos(), keyStart.getRot(),keyStart.getScale(), null);
|
||||
Transformation endTr = keyEnd == null ? null : new Transformation(keyEnd.getPos(), keyEnd.getRot(),keyEnd.getScale(), null);
|
||||
if(keyStart == null)
|
||||
{
|
||||
if(keyEnd == null)
|
||||
{
|
||||
ret = ret.compose(new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
ret = ret.compose(new Transformation(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
}
|
||||
// TODO animated TRSRTransformation for speed?
|
||||
else
|
||||
|
||||
@@ -37,18 +37,16 @@ import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import net.minecraftforge.client.model.*;
|
||||
import net.minecraftforge.common.model.*;
|
||||
import net.minecraftforge.resource.IResourceType;
|
||||
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -64,14 +62,14 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.client.model.b3d.B3DModel.Animation;
|
||||
import net.minecraftforge.client.model.b3d.B3DModel.Face;
|
||||
import net.minecraftforge.client.model.b3d.B3DModel.Key;
|
||||
@@ -87,6 +85,14 @@ import net.minecraftforge.common.model.animation.IClip;
|
||||
import net.minecraftforge.common.model.animation.IJoint;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
||||
/*
|
||||
* Loader for Blitz3D models.
|
||||
* To enable for your mod call instance.addDomain(modId).
|
||||
@@ -94,30 +100,23 @@ import net.minecraftforge.common.property.Properties;
|
||||
*/
|
||||
// TODO: Implement as a new model loader
|
||||
@SuppressWarnings("unused")
|
||||
public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
public enum B3DLoader
|
||||
{
|
||||
INSTANCE;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private IResourceManager manager;
|
||||
private ResourceManager manager;
|
||||
|
||||
private final Set<String> enabledDomains = new HashSet<>();
|
||||
private final Map<ResourceLocation, B3DModel> cache = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager manager, Predicate<IResourceType> resourcePredicate)
|
||||
{
|
||||
this.manager = manager;
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
public IUnbakedModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
public UnbakedModel loadModel(ResourceLocation modelLocation) throws Exception
|
||||
{
|
||||
ResourceLocation file = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath());
|
||||
if(!cache.containsKey(file))
|
||||
{
|
||||
IResource resource = null;
|
||||
Resource resource = null;
|
||||
try
|
||||
{
|
||||
try
|
||||
@@ -155,7 +154,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
return new ModelWrapper(modelLocation, model, ImmutableSet.of(model.getRoot().getName()), true, true, true, 1);
|
||||
}
|
||||
|
||||
public static final class B3DState implements IModelTransform
|
||||
public static final class B3DState implements ModelState
|
||||
{
|
||||
@Nullable
|
||||
private final Animation animation;
|
||||
@@ -163,14 +162,14 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
private final int nextFrame;
|
||||
private final float progress;
|
||||
@Nullable
|
||||
private final IModelTransform parent;
|
||||
private final ModelState parent;
|
||||
|
||||
public B3DState(@Nullable Animation animation, int frame)
|
||||
{
|
||||
this(animation, frame, frame, 0);
|
||||
}
|
||||
|
||||
public B3DState(@Nullable Animation animation, int frame, IModelTransform parent)
|
||||
public B3DState(@Nullable Animation animation, int frame, ModelState parent)
|
||||
{
|
||||
this(animation, frame, frame, 0, parent);
|
||||
}
|
||||
@@ -180,17 +179,17 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
this(animation, frame, nextFrame, progress, null);
|
||||
}
|
||||
|
||||
public B3DState(@Nullable Animation animation, int frame, int nextFrame, float progress, @Nullable IModelTransform parent)
|
||||
public B3DState(@Nullable Animation animation, int frame, int nextFrame, float progress, @Nullable ModelState parent)
|
||||
{
|
||||
this.animation = animation;
|
||||
this.frame = frame;
|
||||
this.nextFrame = nextFrame;
|
||||
this.progress = MathHelper.clamp(progress, 0, 1);
|
||||
this.progress = Mth.clamp(progress, 0, 1);
|
||||
this.parent = getParent(parent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IModelTransform getParent(@Nullable IModelTransform parent)
|
||||
private ModelState getParent(@Nullable ModelState parent)
|
||||
{
|
||||
if (parent == null) return null;
|
||||
else if (parent instanceof B3DState) return ((B3DState)parent).parent;
|
||||
@@ -219,33 +218,33 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IModelTransform getParent()
|
||||
public ModelState getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TransformationMatrix getRotation()
|
||||
public Transformation getRotation()
|
||||
{
|
||||
if(parent != null)
|
||||
{
|
||||
return parent.getRotation();
|
||||
}
|
||||
return TransformationMatrix.identity();
|
||||
return Transformation.identity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformationMatrix getPartTransformation(Object part)
|
||||
public Transformation getPartTransformation(Object part)
|
||||
{
|
||||
// TODO make more use of Optional
|
||||
|
||||
if(!(part instanceof NodeJoint))
|
||||
{
|
||||
return TransformationMatrix.identity();
|
||||
return Transformation.identity();
|
||||
}
|
||||
Node<?> node = ((NodeJoint)part).getNode();
|
||||
TransformationMatrix nodeTransform;
|
||||
Transformation nodeTransform;
|
||||
if(progress < 1e-5 || frame == nextFrame)
|
||||
{
|
||||
nodeTransform = getNodeMatrix(node, frame);
|
||||
@@ -266,31 +265,31 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
return nodeTransform;
|
||||
}
|
||||
|
||||
private static LoadingCache<Triple<Animation, Node<?>, Integer>, TransformationMatrix> cache = CacheBuilder.newBuilder()
|
||||
private static LoadingCache<Triple<Animation, Node<?>, Integer>, Transformation> cache = CacheBuilder.newBuilder()
|
||||
.maximumSize(16384)
|
||||
.expireAfterAccess(2, TimeUnit.MINUTES)
|
||||
.build(new CacheLoader<Triple<Animation, Node<?>, Integer>, TransformationMatrix>()
|
||||
.build(new CacheLoader<Triple<Animation, Node<?>, Integer>, Transformation>()
|
||||
{
|
||||
@Override
|
||||
public TransformationMatrix load(Triple<Animation, Node<?>, Integer> key) throws Exception
|
||||
public Transformation load(Triple<Animation, Node<?>, Integer> key) throws Exception
|
||||
{
|
||||
return getNodeMatrix(key.getLeft(), key.getMiddle(), key.getRight());
|
||||
}
|
||||
});
|
||||
|
||||
public TransformationMatrix getNodeMatrix(Node<?> node)
|
||||
public Transformation getNodeMatrix(Node<?> node)
|
||||
{
|
||||
return getNodeMatrix(node, frame);
|
||||
}
|
||||
|
||||
public TransformationMatrix getNodeMatrix(Node<?> node, int frame)
|
||||
public Transformation getNodeMatrix(Node<?> node, int frame)
|
||||
{
|
||||
return cache.getUnchecked(Triple.of(animation, node, frame));
|
||||
}
|
||||
|
||||
public static TransformationMatrix getNodeMatrix(@Nullable Animation animation, Node<?> node, int frame)
|
||||
public static Transformation getNodeMatrix(@Nullable Animation animation, Node<?> node, int frame)
|
||||
{
|
||||
TransformationMatrix ret = TransformationMatrix.identity();
|
||||
Transformation ret = Transformation.identity();
|
||||
Key key = null;
|
||||
if(animation != null) key = animation.getKeys().get(frame, node);
|
||||
else if(node.getAnimation() != null) key = node.getAnimation().getKeys().get(frame, node);
|
||||
@@ -300,13 +299,13 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
if(parent != null)
|
||||
{
|
||||
// parent model-global current pose
|
||||
TransformationMatrix pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame));
|
||||
Transformation pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame));
|
||||
ret = ret.compose(pm);
|
||||
// joint offset in the parent coords
|
||||
ret = ret.compose(new TransformationMatrix(parent.getPos(), parent.getRot(), parent.getScale(), null));
|
||||
ret = ret.compose(new Transformation(parent.getPos(), parent.getRot(), parent.getScale(), null));
|
||||
}
|
||||
// current node local pose
|
||||
ret = ret.compose(new TransformationMatrix(key.getPos(), key.getRot(), key.getScale(), null));
|
||||
ret = ret.compose(new Transformation(key.getPos(), key.getRot(), key.getScale(), null));
|
||||
// this part moved inside the model
|
||||
// inverse bind of the current node
|
||||
/*Matrix4f rm = new TRSRTransformation(node.getPos(), node.getRot(), node.getScale(), null).getMatrix();
|
||||
@@ -320,7 +319,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
ret = ret.compose(new TRSRTransformation(rm));
|
||||
}*/
|
||||
// TODO cache
|
||||
TransformationMatrix invBind = new NodeJoint(node).getInvBindPose();
|
||||
Transformation invBind = new NodeJoint(node).getInvBindPose();
|
||||
ret = ret.compose(invBind);
|
||||
}
|
||||
else
|
||||
@@ -329,14 +328,14 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
if(parent != null)
|
||||
{
|
||||
// parent model-global current pose
|
||||
TransformationMatrix pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame));
|
||||
Transformation pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame));
|
||||
ret = ret.compose(pm);
|
||||
// joint offset in the parent coords
|
||||
ret = ret.compose(new TransformationMatrix(parent.getPos(), parent.getRot(), parent.getScale(), null));
|
||||
ret = ret.compose(new Transformation(parent.getPos(), parent.getRot(), parent.getScale(), null));
|
||||
}
|
||||
ret = ret.compose(new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
ret = ret.compose(new Transformation(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
// TODO cache
|
||||
TransformationMatrix invBind = new NodeJoint(node).getInvBindPose();
|
||||
Transformation invBind = new NodeJoint(node).getInvBindPose();
|
||||
ret = ret.compose(invBind);
|
||||
}
|
||||
return ret;
|
||||
@@ -353,15 +352,15 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformationMatrix getInvBindPose()
|
||||
public Transformation getInvBindPose()
|
||||
{
|
||||
Matrix4f m = new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null).getMatrix();
|
||||
Matrix4f m = new Transformation(node.getPos(), node.getRot(), node.getScale(), null).getMatrix();
|
||||
m.invert();
|
||||
TransformationMatrix pose = new TransformationMatrix(m);
|
||||
Transformation pose = new Transformation(m);
|
||||
|
||||
if(node.getParent() != null)
|
||||
{
|
||||
TransformationMatrix parent = new NodeJoint(node.getParent()).getInvBindPose();
|
||||
Transformation parent = new NodeJoint(node.getParent()).getInvBindPose();
|
||||
pose = pose.compose(parent);
|
||||
}
|
||||
return pose;
|
||||
@@ -397,7 +396,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ModelWrapper implements IUnbakedModel
|
||||
private static final class ModelWrapper implements UnbakedModel
|
||||
{
|
||||
private final ResourceLocation modelLocation;
|
||||
private final B3DModel model;
|
||||
@@ -447,10 +446,10 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Collection<RenderMaterial> getMaterials(Function<ResourceLocation, IUnbakedModel> modelGetter, Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors)
|
||||
public Collection<Material> getMaterials(Function<ResourceLocation, UnbakedModel> modelGetter, Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
return textures.values().stream().filter(loc -> !loc.startsWith("#"))
|
||||
.map(t -> new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(t)))
|
||||
.map(t -> new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(t)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -463,10 +462,10 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
@SuppressWarnings("deprecation")
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
|
||||
public BakedModel bake(ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation)
|
||||
{
|
||||
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
|
||||
TextureAtlasSprite missing = spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, MissingTextureSprite.getLocation()));
|
||||
TextureAtlasSprite missing = spriteGetter.apply(new Material(TextureAtlas.LOCATION_BLOCKS, MissingTextureAtlasSprite.getLocation()));
|
||||
for(Map.Entry<String, String> e : textures.entrySet())
|
||||
{
|
||||
if(e.getValue().startsWith("#"))
|
||||
@@ -476,7 +475,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.put(e.getKey(), spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(e.getValue()))));
|
||||
builder.put(e.getKey(), spriteGetter.apply(new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(e.getValue()))));
|
||||
}
|
||||
}
|
||||
builder.put("missingno", missing);
|
||||
@@ -570,7 +569,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public IModelTransform getDefaultState()
|
||||
public ModelState getDefaultState()
|
||||
{
|
||||
return new B3DState(model.getRoot().getAnimation(), defaultKey, defaultKey, 0);
|
||||
}
|
||||
@@ -597,7 +596,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
private static final class BakedWrapper implements IDynamicBakedModel
|
||||
{
|
||||
private final Node<?> node;
|
||||
private final IModelTransform state;
|
||||
private final ModelState state;
|
||||
private final boolean smooth;
|
||||
private final boolean gui3d;
|
||||
private final boolean isSideLit;
|
||||
@@ -607,7 +606,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
|
||||
private ImmutableList<BakedQuad> quads;
|
||||
|
||||
public BakedWrapper(final Node<?> node, final IModelTransform state, final boolean smooth, final boolean gui3d, boolean isSideLit, final ImmutableSet<String> meshes, final ImmutableMap<String, TextureAtlasSprite> textures)
|
||||
public BakedWrapper(final Node<?> node, final ModelState state, final boolean smooth, final boolean gui3d, boolean isSideLit, final ImmutableSet<String> meshes, final ImmutableMap<String, TextureAtlasSprite> textures)
|
||||
{
|
||||
this(node, state, smooth, gui3d, isSideLit, meshes, textures, CacheBuilder.newBuilder()
|
||||
.maximumSize(128)
|
||||
@@ -617,7 +616,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
@Override
|
||||
public B3DState load(Integer frame) throws Exception
|
||||
{
|
||||
IModelTransform parent = state;
|
||||
ModelState parent = state;
|
||||
Animation newAnimation = node.getAnimation();
|
||||
if(parent instanceof B3DState)
|
||||
{
|
||||
@@ -629,7 +628,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}));
|
||||
}
|
||||
|
||||
public BakedWrapper(Node<?> node, IModelTransform state, boolean smooth, boolean gui3d, boolean isSideLit, ImmutableSet<String> meshes, ImmutableMap<String, TextureAtlasSprite> textures, LoadingCache<Integer, B3DState> cache)
|
||||
public BakedWrapper(Node<?> node, ModelState state, boolean smooth, boolean gui3d, boolean isSideLit, ImmutableSet<String> meshes, ImmutableMap<String, TextureAtlasSprite> textures, LoadingCache<Integer, B3DState> cache)
|
||||
{
|
||||
this.node = node;
|
||||
this.state = state;
|
||||
@@ -645,12 +644,12 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData data)
|
||||
{
|
||||
if(side != null) return ImmutableList.of();
|
||||
IModelTransform modelState = this.state;
|
||||
IModelTransform newState = data.getData(Properties.AnimationProperty);
|
||||
ModelState modelState = this.state;
|
||||
ModelState newState = data.getData(Properties.AnimationProperty);
|
||||
if(newState != null)
|
||||
{
|
||||
// FIXME: should animation state handle the parent state, or should it remain here?
|
||||
IModelTransform parent = this.state;
|
||||
ModelState parent = this.state;
|
||||
if(parent instanceof B3DState)
|
||||
{
|
||||
B3DState ps = (B3DState)parent;
|
||||
@@ -662,7 +661,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}
|
||||
else
|
||||
{
|
||||
modelState = new ModelTransformComposition(parent, newState);
|
||||
modelState = new CompositeModelState(parent, newState);
|
||||
}
|
||||
}
|
||||
if(quads == null)
|
||||
@@ -681,7 +680,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
return quads;
|
||||
}
|
||||
|
||||
private void generateQuads(ImmutableList.Builder<BakedQuad> builder, Node<?> node, final IModelTransform state, ImmutableList<String> path)
|
||||
private void generateQuads(ImmutableList.Builder<BakedQuad> builder, Node<?> node, final ModelState state, ImmutableList<String> path)
|
||||
{
|
||||
ImmutableList.Builder<String> pathBuilder = ImmutableList.builder();
|
||||
pathBuilder.addAll(path);
|
||||
@@ -696,13 +695,13 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
Mesh mesh = (Mesh)node.getKind();
|
||||
Collection<Face> faces = mesh.bake(new Function<Node<?>, Matrix4f>()
|
||||
{
|
||||
private final TransformationMatrix global = state.getRotation();
|
||||
private final LoadingCache<Node<?>, TransformationMatrix> localCache = CacheBuilder.newBuilder()
|
||||
private final Transformation global = state.getRotation();
|
||||
private final LoadingCache<Node<?>, Transformation> localCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(32)
|
||||
.build(new CacheLoader<Node<?>, TransformationMatrix>()
|
||||
.build(new CacheLoader<Node<?>, Transformation>()
|
||||
{
|
||||
@Override
|
||||
public TransformationMatrix load(Node<?> node) throws Exception
|
||||
public Transformation load(Node<?> node) throws Exception
|
||||
{
|
||||
return state.getPartTransformation(new NodeJoint(node));
|
||||
}
|
||||
@@ -825,16 +824,16 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective(TransformType cameraTransformType, MatrixStack mat)
|
||||
public BakedModel handlePerspective(TransformType cameraTransformType, PoseStack poseStack)
|
||||
{
|
||||
return PerspectiveMapWrapper.handlePerspective(this, state, cameraTransformType, mat);
|
||||
return PerspectiveMapWrapper.handlePerspective(this, state, cameraTransformType, poseStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
public ItemOverrides getOverrides()
|
||||
{
|
||||
// TODO handle items
|
||||
return ItemOverrideList.EMPTY;
|
||||
return ItemOverrides.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,6 @@ import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.math.vector.*;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -58,6 +57,13 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
import com.google.common.collect.Table;
|
||||
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
|
||||
public class B3DModel
|
||||
{
|
||||
static final Logger logger = LogManager.getLogger(ForgeVersion.MOD_ID + ".B3DModel");
|
||||
@@ -248,8 +254,8 @@ public class B3DModel
|
||||
String path = readString();
|
||||
int flags = buf.getInt();
|
||||
int blend = buf.getInt();
|
||||
Vector2f pos = new Vector2f(buf.getFloat(), buf.getFloat());
|
||||
Vector2f scale = new Vector2f(buf.getFloat(), buf.getFloat());
|
||||
Vec2 pos = new Vec2(buf.getFloat(), buf.getFloat());
|
||||
Vec2 scale = new Vec2(buf.getFloat(), buf.getFloat());
|
||||
float rot = buf.getFloat();
|
||||
ret.add(new Texture(path, flags, blend, pos, scale, rot));
|
||||
}
|
||||
@@ -528,15 +534,15 @@ public class B3DModel
|
||||
|
||||
public static class Texture
|
||||
{
|
||||
public static final Texture White = new Texture("builtin/white", 0, 0, new Vector2f(0, 0), new Vector2f(1, 1), 0);
|
||||
public static final Texture White = new Texture("builtin/white", 0, 0, new Vec2(0, 0), new Vec2(1, 1), 0);
|
||||
private final String path;
|
||||
private final int flags;
|
||||
private final int blend;
|
||||
private final Vector2f pos;
|
||||
private final Vector2f scale;
|
||||
private final Vec2 pos;
|
||||
private final Vec2 scale;
|
||||
private final float rot;
|
||||
|
||||
public Texture(String path, int flags, int blend, Vector2f pos, Vector2f scale, float rot)
|
||||
public Texture(String path, int flags, int blend, Vec2 pos, Vec2 scale, float rot)
|
||||
{
|
||||
this.path = path;
|
||||
this.flags = flags;
|
||||
@@ -561,12 +567,12 @@ public class B3DModel
|
||||
return blend;
|
||||
}
|
||||
|
||||
public Vector2f getPos()
|
||||
public Vec2 getPos()
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
public Vector2f getScale()
|
||||
public Vec2 getScale()
|
||||
{
|
||||
return scale;
|
||||
}
|
||||
@@ -677,7 +683,7 @@ public class B3DModel
|
||||
else t.setIdentity();
|
||||
}
|
||||
|
||||
TransformationMatrix trsr = new TransformationMatrix(t);
|
||||
Transformation trsr = new Transformation(t);
|
||||
|
||||
// pos
|
||||
Vector4f pos = new Vector4f(this.pos);
|
||||
|
||||
@@ -21,5 +21,6 @@
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraftforge.client.model.b3d;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -25,15 +25,15 @@ import java.util.Random;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
/**
|
||||
* Convenience interface with default implementation of {@link IBakedModel#getQuads(net.minecraft.block.BlockState, net.minecraft.util.Direction, java.util.Random)}.
|
||||
*/
|
||||
public interface IDynamicBakedModel extends IBakedModel
|
||||
public interface IDynamicBakedModel extends BakedModel
|
||||
{
|
||||
@Override
|
||||
default @Nonnull List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand)
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
package net.minecraftforge.client.model.data;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -35,14 +35,14 @@ public class MultipartModelData implements IModelData
|
||||
{
|
||||
public static final ModelProperty<MultipartModelData> MULTIPART_DATA = new ModelProperty<>();
|
||||
|
||||
public static IModelData create(List<Pair<Predicate<BlockState>, IBakedModel>> selectors, IBlockDisplayReader world, BlockPos pos, BlockState state, IModelData tileData)
|
||||
public static IModelData create(List<Pair<Predicate<BlockState>, BakedModel>> selectors, BlockAndTintGetter world, BlockPos pos, BlockState state, IModelData tileData)
|
||||
{
|
||||
MultipartModelData multipartData = new MultipartModelData(tileData);
|
||||
for (Pair<Predicate<BlockState>, IBakedModel> selector : selectors)
|
||||
for (Pair<Predicate<BlockState>, BakedModel> selector : selectors)
|
||||
{
|
||||
if (selector.getLeft().test(state))
|
||||
{
|
||||
IBakedModel part = selector.getRight();
|
||||
BakedModel part = selector.getRight();
|
||||
IModelData partData = part.getModelData(world, pos, state, tileData);
|
||||
multipartData.setPartData(part, partData);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class MultipartModelData implements IModelData
|
||||
return multipartData;
|
||||
}
|
||||
|
||||
public static IModelData resolve(IBakedModel part, IModelData modelData)
|
||||
public static IModelData resolve(BakedModel part, IModelData modelData)
|
||||
{
|
||||
MultipartModelData multipartData = modelData.getData(MultipartModelData.MULTIPART_DATA);
|
||||
if (multipartData != null)
|
||||
@@ -59,20 +59,20 @@ public class MultipartModelData implements IModelData
|
||||
}
|
||||
|
||||
private final IModelData tileData;
|
||||
private final Map<IBakedModel, IModelData> partData = new HashMap<>();
|
||||
private final Map<BakedModel, IModelData> partData = new HashMap<>();
|
||||
|
||||
public MultipartModelData(IModelData tileData)
|
||||
{
|
||||
this.tileData = tileData;
|
||||
}
|
||||
|
||||
public void setPartData(IBakedModel part, IModelData data)
|
||||
public void setPartData(BakedModel part, IModelData data)
|
||||
{
|
||||
partData.put(part, data);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IModelData getPartData(IBakedModel part, final IModelData defaultData)
|
||||
public IModelData getPartData(BakedModel part, final IModelData defaultData)
|
||||
{
|
||||
return partData.getOrDefault(part, defaultData);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.model.generators;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,41 +42,41 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.DoorBlock;
|
||||
import net.minecraft.block.FenceBlock;
|
||||
import net.minecraft.block.FenceGateBlock;
|
||||
import net.minecraft.block.FourWayBlock;
|
||||
import net.minecraft.block.PaneBlock;
|
||||
import net.minecraft.block.RotatedPillarBlock;
|
||||
import net.minecraft.block.SixWayBlock;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
import net.minecraft.block.TrapDoorBlock;
|
||||
import net.minecraft.block.WallBlock;
|
||||
import net.minecraft.block.WallHeight;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.FenceBlock;
|
||||
import net.minecraft.world.level.block.FenceGateBlock;
|
||||
import net.minecraft.world.level.block.CrossCollisionBlock;
|
||||
import net.minecraft.world.level.block.IronBarsBlock;
|
||||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.world.level.block.PipeBlock;
|
||||
import net.minecraft.world.level.block.SlabBlock;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.WallBlock;
|
||||
import net.minecraft.world.level.block.state.properties.WallSide;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.DirectoryCache;
|
||||
import net.minecraft.data.IDataProvider;
|
||||
import net.minecraft.state.Property;
|
||||
import net.minecraft.state.properties.AttachFace;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.properties.DoorHingeSide;
|
||||
import net.minecraft.state.properties.DoubleBlockHalf;
|
||||
import net.minecraft.state.properties.Half;
|
||||
import net.minecraft.state.properties.SlabType;
|
||||
import net.minecraft.state.properties.StairsShape;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.data.HashCache;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
|
||||
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
||||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.level.block.state.properties.StairsShape;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Data provider for blockstate files. Extends {@link BlockModelProvider} so that
|
||||
* blockstates and their referenced models can be provided in tandem.
|
||||
*/
|
||||
public abstract class BlockStateProvider implements IDataProvider {
|
||||
public abstract class BlockStateProvider implements DataProvider {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||
@@ -101,7 +101,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(DirectoryCache cache) throws IOException {
|
||||
public void run(HashCache cache) throws IOException {
|
||||
models().clear();
|
||||
itemModels().clear();
|
||||
registeredBlocks.clear();
|
||||
@@ -292,35 +292,35 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
});
|
||||
}
|
||||
|
||||
public void stairsBlock(StairsBlock block, ResourceLocation texture) {
|
||||
public void stairsBlock(StairBlock block, ResourceLocation texture) {
|
||||
stairsBlock(block, texture, texture, texture);
|
||||
}
|
||||
|
||||
public void stairsBlock(StairsBlock block, String name, ResourceLocation texture) {
|
||||
public void stairsBlock(StairBlock block, String name, ResourceLocation texture) {
|
||||
stairsBlock(block, name, texture, texture, texture);
|
||||
}
|
||||
|
||||
public void stairsBlock(StairsBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) {
|
||||
public void stairsBlock(StairBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) {
|
||||
stairsBlockInternal(block, block.getRegistryName().toString(), side, bottom, top);
|
||||
}
|
||||
|
||||
public void stairsBlock(StairsBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) {
|
||||
public void stairsBlock(StairBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) {
|
||||
stairsBlockInternal(block, name + "_stairs", side, bottom, top);
|
||||
}
|
||||
|
||||
private void stairsBlockInternal(StairsBlock block, String baseName, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) {
|
||||
private void stairsBlockInternal(StairBlock block, String baseName, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) {
|
||||
ModelFile stairs = models().stairs(baseName, side, bottom, top);
|
||||
ModelFile stairsInner = models().stairsInner(baseName + "_inner", side, bottom, top);
|
||||
ModelFile stairsOuter = models().stairsOuter(baseName + "_outer", side, bottom, top);
|
||||
stairsBlock(block, stairs, stairsInner, stairsOuter);
|
||||
}
|
||||
|
||||
public void stairsBlock(StairsBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) {
|
||||
public void stairsBlock(StairBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) {
|
||||
getVariantBuilder(block)
|
||||
.forAllStatesExcept(state -> {
|
||||
Direction facing = state.getValue(StairsBlock.FACING);
|
||||
Half half = state.getValue(StairsBlock.HALF);
|
||||
StairsShape shape = state.getValue(StairsBlock.SHAPE);
|
||||
Direction facing = state.getValue(StairBlock.FACING);
|
||||
Half half = state.getValue(StairBlock.HALF);
|
||||
StairsShape shape = state.getValue(StairBlock.SHAPE);
|
||||
int yRot = (int) facing.getClockWise().toYRot(); // Stairs model is rotated 90 degrees clockwise for some reason
|
||||
if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) {
|
||||
yRot += 270; // Left facing stairs are rotated 90 degrees clockwise
|
||||
@@ -336,7 +336,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
.rotationY(yRot)
|
||||
.uvLock(uvlock)
|
||||
.build();
|
||||
}, StairsBlock.WATERLOGGED);
|
||||
}, StairBlock.WATERLOGGED);
|
||||
}
|
||||
|
||||
public void slabBlock(SlabBlock block, ResourceLocation doubleslab, ResourceLocation texture) {
|
||||
@@ -354,14 +354,14 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
.partialState().with(SlabBlock.TYPE, SlabType.DOUBLE).addModels(new ConfiguredModel(doubleslab));
|
||||
}
|
||||
|
||||
public void fourWayBlock(FourWayBlock block, ModelFile post, ModelFile side) {
|
||||
public void fourWayBlock(CrossCollisionBlock block, ModelFile post, ModelFile side) {
|
||||
MultiPartBlockStateBuilder builder = getMultipartBuilder(block)
|
||||
.part().modelFile(post).addModel().end();
|
||||
fourWayMultipart(builder, side);
|
||||
}
|
||||
|
||||
public void fourWayMultipart(MultiPartBlockStateBuilder builder, ModelFile side) {
|
||||
SixWayBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> {
|
||||
PipeBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> {
|
||||
Direction dir = e.getKey();
|
||||
if (dir.getAxis().isHorizontal()) {
|
||||
builder.part().modelFile(side).rotationY((((int) dir.toYRot()) + 180) % 360).uvLock(true).addModel()
|
||||
@@ -424,7 +424,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
wallBlock(block, models().wallPost(baseName + "_post", texture), models().wallSide(baseName + "_side", texture), models().wallSideTall(baseName + "_side_tall", texture));
|
||||
}
|
||||
|
||||
public static final ImmutableMap<Direction, Property<WallHeight>> WALL_PROPS = ImmutableMap.<Direction, Property<WallHeight>>builder()
|
||||
public static final ImmutableMap<Direction, Property<WallSide>> WALL_PROPS = ImmutableMap.<Direction, Property<WallSide>>builder()
|
||||
.put(Direction.EAST, BlockStateProperties.EAST_WALL)
|
||||
.put(Direction.NORTH, BlockStateProperties.NORTH_WALL)
|
||||
.put(Direction.SOUTH, BlockStateProperties.SOUTH_WALL)
|
||||
@@ -438,12 +438,12 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
WALL_PROPS.entrySet().stream()
|
||||
.filter(e -> e.getKey().getAxis().isHorizontal())
|
||||
.forEach(e -> {
|
||||
wallSidePart(builder, side, e, WallHeight.LOW);
|
||||
wallSidePart(builder, sideTall, e, WallHeight.TALL);
|
||||
wallSidePart(builder, side, e, WallSide.LOW);
|
||||
wallSidePart(builder, sideTall, e, WallSide.TALL);
|
||||
});
|
||||
}
|
||||
|
||||
private void wallSidePart(MultiPartBlockStateBuilder builder, ModelFile model, Map.Entry<Direction, Property<WallHeight>> entry, WallHeight height) {
|
||||
private void wallSidePart(MultiPartBlockStateBuilder builder, ModelFile model, Map.Entry<Direction, Property<WallSide>> entry, WallSide height) {
|
||||
builder.part()
|
||||
.modelFile(model)
|
||||
.rotationY((((int) entry.getKey().toYRot()) + 180) % 360)
|
||||
@@ -452,15 +452,15 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
.condition(entry.getValue(), height);
|
||||
}
|
||||
|
||||
public void paneBlock(PaneBlock block, ResourceLocation pane, ResourceLocation edge) {
|
||||
public void paneBlock(IronBarsBlock block, ResourceLocation pane, ResourceLocation edge) {
|
||||
paneBlockInternal(block, block.getRegistryName().toString(), pane, edge);
|
||||
}
|
||||
|
||||
public void paneBlock(PaneBlock block, String name, ResourceLocation pane, ResourceLocation edge) {
|
||||
public void paneBlock(IronBarsBlock block, String name, ResourceLocation pane, ResourceLocation edge) {
|
||||
paneBlockInternal(block, name + "_pane", pane, edge);
|
||||
}
|
||||
|
||||
private void paneBlockInternal(PaneBlock block, String baseName, ResourceLocation pane, ResourceLocation edge) {
|
||||
private void paneBlockInternal(IronBarsBlock block, String baseName, ResourceLocation pane, ResourceLocation edge) {
|
||||
ModelFile post = models().panePost(baseName + "_post", pane, edge);
|
||||
ModelFile side = models().paneSide(baseName + "_side", pane, edge);
|
||||
ModelFile sideAlt = models().paneSideAlt(baseName + "_side_alt", pane, edge);
|
||||
@@ -469,10 +469,10 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
paneBlock(block, post, side, sideAlt, noSide, noSideAlt);
|
||||
}
|
||||
|
||||
public void paneBlock(PaneBlock block, ModelFile post, ModelFile side, ModelFile sideAlt, ModelFile noSide, ModelFile noSideAlt) {
|
||||
public void paneBlock(IronBarsBlock block, ModelFile post, ModelFile side, ModelFile sideAlt, ModelFile noSide, ModelFile noSideAlt) {
|
||||
MultiPartBlockStateBuilder builder = getMultipartBuilder(block)
|
||||
.part().modelFile(post).addModel().end();
|
||||
SixWayBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> {
|
||||
PipeBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> {
|
||||
Direction dir = e.getKey();
|
||||
if (dir.getAxis().isHorizontal()) {
|
||||
boolean alt = dir == Direction.SOUTH;
|
||||
@@ -554,13 +554,13 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
}, TrapDoorBlock.POWERED, TrapDoorBlock.WATERLOGGED);
|
||||
}
|
||||
|
||||
private void saveBlockState(DirectoryCache cache, JsonObject stateJson, Block owner) {
|
||||
private void saveBlockState(HashCache cache, JsonObject stateJson, Block owner) {
|
||||
ResourceLocation blockName = Preconditions.checkNotNull(owner.getRegistryName());
|
||||
Path mainOutput = generator.getOutputFolder();
|
||||
String pathSuffix = "assets/" + blockName.getNamespace() + "/blockstates/" + blockName.getPath() + ".json";
|
||||
Path outputPath = mainOutput.resolve(pathSuffix);
|
||||
try {
|
||||
IDataProvider.save(GSON, cache, stateJson, outputPath);
|
||||
DataProvider.save(GSON, cache, stateJson, outputPath);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Couldn't save blockstate to {}", outputPath, e);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder.PartBuilder;
|
||||
import net.minecraftforge.client.model.generators.VariantBlockStateBuilder.PartialBlockstate;
|
||||
|
||||
@@ -135,7 +135,7 @@ public final class ConfiguredModel {
|
||||
}
|
||||
|
||||
static void checkRotation(int rotationX, int rotationY) {
|
||||
Preconditions.checkArgument(ModelRotation.by(rotationX, rotationY) != null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY);
|
||||
Preconditions.checkArgument(BlockModelRotation.by(rotationX, rotationY) != null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY);
|
||||
}
|
||||
|
||||
static void checkWeight(int weight) {
|
||||
@@ -166,7 +166,7 @@ public final class ConfiguredModel {
|
||||
return new Builder<>();
|
||||
}
|
||||
|
||||
static Builder<VariantBlockStateBuilder> builder(VariantBlockStateBuilder outer, VariantBlockStateBuilder.PartialBlockstate state) {
|
||||
static Builder<VariantBlockStateBuilder> builder(VariantBlockStateBuilder outer, PartialBlockstate state) {
|
||||
return new Builder<>(models -> outer.setModels(state, models), ImmutableList.of());
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 1990 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user