mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 02:55:17 +00:00
Update to 1.14.2
This commit is contained in:
1 parent
d3e8804dbf
commit
a7df63e1a1
1010 files changed
+15254
-19520
No files matched your search
@@ -25,17 +25,19 @@ import java.util.function.Predicate;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.platform.GLX;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexBuffer;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.settings.CloudOption;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
@@ -68,7 +70,7 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
|
||||
private int displayList = -1;
|
||||
private VertexBuffer vbo;
|
||||
private int cloudMode = -1;
|
||||
private CloudOption cloudMode = CloudOption.OFF;
|
||||
private int renderDistance = -1;
|
||||
|
||||
private DynamicTexture COLOR_TEX = null;
|
||||
@@ -79,12 +81,12 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
public CloudRenderer()
|
||||
{
|
||||
// Resource manager should always be reloadable.
|
||||
((IReloadableResourceManager) mc.getResourceManager()).addReloadListener(this);
|
||||
((IReloadableResourceManager) mc.getResourceManager()).func_219534_a(this);
|
||||
}
|
||||
|
||||
private int getScale()
|
||||
{
|
||||
return cloudMode == 2 ? 12 : 8;
|
||||
return cloudMode == CloudOption.FANCY ? 12 : 8;
|
||||
}
|
||||
|
||||
private float ceilToScale(float value)
|
||||
@@ -95,7 +97,7 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
|
||||
private void vertices(BufferBuilder buffer)
|
||||
{
|
||||
boolean fancy = cloudMode == 2; // Defines whether to hide all but the bottom.
|
||||
boolean fancy = cloudMode == CloudOption.FANCY; // Defines whether to hide all but the bottom.
|
||||
|
||||
float scale = getScale();
|
||||
float CULL_DIST = 2 * scale;
|
||||
@@ -238,14 +240,14 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
Tessellator tess = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tess.getBuffer();
|
||||
|
||||
if (OpenGlHelper.useVbo())
|
||||
if (GLX.useVbo())
|
||||
vbo = new VertexBuffer(FORMAT);
|
||||
else
|
||||
GlStateManager.newList(displayList = GLAllocation.generateDisplayLists(1), GL11.GL_COMPILE);
|
||||
|
||||
vertices(buffer);
|
||||
|
||||
if (OpenGlHelper.useVbo())
|
||||
if (GLX.useVbo())
|
||||
{
|
||||
buffer.finishDrawing();
|
||||
buffer.reset();
|
||||
@@ -265,25 +267,25 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
|
||||
private boolean isBuilt()
|
||||
{
|
||||
return OpenGlHelper.useVbo() ? vbo != null : displayList >= 0;
|
||||
return GLX.useVbo() ? vbo != null : displayList >= 0;
|
||||
}
|
||||
|
||||
public void checkSettings()
|
||||
{
|
||||
boolean newEnabled = ForgeConfig.CLIENT.forgeCloudsEnabled.get()
|
||||
&& mc.gameSettings.shouldRenderClouds() != 0
|
||||
&& mc.gameSettings.func_216842_e() != CloudOption.OFF
|
||||
&& mc.world != null
|
||||
&& mc.world.dimension.isSurfaceWorld();
|
||||
|
||||
if (isBuilt()
|
||||
&& (!newEnabled
|
||||
|| mc.gameSettings.shouldRenderClouds() != cloudMode
|
||||
|| mc.gameSettings.func_216842_e() != cloudMode
|
||||
|| mc.gameSettings.renderDistanceChunks != renderDistance))
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
|
||||
cloudMode = mc.gameSettings.shouldRenderClouds();
|
||||
cloudMode = mc.gameSettings.func_216842_e();
|
||||
renderDistance = mc.gameSettings.renderDistanceChunks;
|
||||
|
||||
if (newEnabled && !isBuilt())
|
||||
@@ -310,7 +312,7 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
|
||||
int scale = getScale();
|
||||
|
||||
if (cloudMode == 2)
|
||||
if (cloudMode == CloudOption.FANCY)
|
||||
z += 0.33 * scale;
|
||||
|
||||
// Integer UVs to translate the texture matrix by.
|
||||
@@ -354,18 +356,18 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
| (int) (b * 255));
|
||||
COLOR_TEX.updateDynamicTexture();
|
||||
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE1);
|
||||
GlStateManager.activeTexture(GLX.GL_TEXTURE1);
|
||||
GlStateManager.bindTexture(COLOR_TEX.getGlTextureId());
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableTexture();
|
||||
|
||||
// Bind the clouds texture last so the shader's sampler2D is correct.
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE0);
|
||||
GlStateManager.activeTexture(GLX.GL_TEXTURE0);
|
||||
mc.textureManager.bindTexture(texture);
|
||||
|
||||
ByteBuffer buffer = Tessellator.getInstance().getBuffer().getByteBuffer();
|
||||
|
||||
// Set up pointers for the display list/VBO.
|
||||
if (OpenGlHelper.useVbo())
|
||||
if (GLX.useVbo())
|
||||
{
|
||||
vbo.bindBuffer();
|
||||
|
||||
@@ -387,7 +389,7 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
|
||||
// Depth pass to prevent insides rendering from the outside.
|
||||
GlStateManager.colorMask(false, false, false, false);
|
||||
if (OpenGlHelper.useVbo())
|
||||
if (GLX.useVbo())
|
||||
vbo.drawArrays(GL11.GL_QUADS);
|
||||
else
|
||||
GlStateManager.callList(displayList);
|
||||
@@ -400,20 +402,20 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
{
|
||||
GlStateManager.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
|
||||
GlStateManager.lineWidth(2.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableTexture();
|
||||
GlStateManager.depthMask(false);
|
||||
GlStateManager.disableFog();
|
||||
if (OpenGlHelper.useVbo())
|
||||
if (GLX.useVbo())
|
||||
vbo.drawArrays(GL11.GL_QUADS);
|
||||
else
|
||||
GlStateManager.callList(displayList);
|
||||
GlStateManager.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableTexture();
|
||||
GlStateManager.enableFog();
|
||||
}
|
||||
|
||||
if (OpenGlHelper.useVbo())
|
||||
if (GLX.useVbo())
|
||||
{
|
||||
vbo.drawArrays(GL11.GL_QUADS);
|
||||
vbo.unbindBuffer(); // Unbind buffer and disable pointers.
|
||||
@@ -429,9 +431,9 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
buffer.position(0);
|
||||
|
||||
// Disable our coloring.
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE1);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.activeTexture(OpenGlHelper.GL_TEXTURE0);
|
||||
GlStateManager.activeTexture(GLX.GL_TEXTURE1);
|
||||
GlStateManager.disableTexture();
|
||||
GlStateManager.activeTexture(GLX.GL_TEXTURE0);
|
||||
|
||||
// Reset texture matrix.
|
||||
GlStateManager.matrixMode(GL11.GL_TEXTURE);
|
||||
@@ -451,8 +453,8 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
if (mc.textureManager != null)
|
||||
{
|
||||
mc.textureManager.bindTexture(texture);
|
||||
texW = GlStateManager.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
|
||||
texH = GlStateManager.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT);
|
||||
texW = GlStateManager.getTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
|
||||
texH = GlStateManager.getTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,7 +480,7 @@ public class CloudRenderer implements ISelectiveResourceReloadListener
|
||||
getCloudRenderer().checkSettings();
|
||||
}
|
||||
|
||||
public static boolean renderClouds(int cloudTicks, float partialTicks, WorldClient world, Minecraft client)
|
||||
public static boolean renderClouds(int cloudTicks, float partialTicks, ClientWorld world, Minecraft client)
|
||||
{
|
||||
IRenderHandler renderer = world.dimension.getCloudRenderer();
|
||||
if (renderer != null)
|
||||
|
||||
@@ -34,6 +34,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.vecmath.Matrix3f;
|
||||
@@ -51,22 +53,24 @@ import org.apache.logging.log4j.core.impl.ReusableLogEventFactory;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import com.mojang.blaze3d.platform.GLX;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.client.MainWindow;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.gui.BossInfoClient;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.gui.ClientBossInfo;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
@@ -81,31 +85,31 @@ import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.model.SimpleBakedModel;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.entity.model.BipedModel;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.Usage;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
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.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.IEnviromentBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@@ -147,15 +151,15 @@ public class ForgeHooksClient
|
||||
|
||||
//private static final ResourceLocation ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
||||
|
||||
public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EntityEquipmentSlot slot, String type)
|
||||
public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EquipmentSlotType slot, String type)
|
||||
{
|
||||
String result = armor.getItem().getArmorTexture(armor, entity, slot, type);
|
||||
return result != null ? result : _default;
|
||||
}
|
||||
|
||||
public static boolean onDrawBlockHighlight(WorldRenderer context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks)
|
||||
public static boolean onDrawBlockHighlight(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, player, target, subID, partialTicks));
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, info, target, subID, partialTicks));
|
||||
}
|
||||
|
||||
public static void dispatchRenderLast(WorldRenderer context, float partialTicks)
|
||||
@@ -168,19 +172,19 @@ public class ForgeHooksClient
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(context, partialTicks));
|
||||
}
|
||||
|
||||
public static boolean renderSpecificFirstPersonHand(EnumHand hand, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
|
||||
public static boolean renderSpecificFirstPersonHand(Hand hand, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderSpecificHandEvent(hand, partialTicks, interpPitch, swingProgress, equipProgress, stack));
|
||||
}
|
||||
|
||||
public static void onTextureStitchedPre(TextureMap map)
|
||||
public static void onTextureStitchedPre(AtlasTexture map)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Pre(map));
|
||||
// ModelLoader.White.INSTANCE.register(map); // TODO Custom TAS
|
||||
ModelDynBucket.LoaderDynBucket.INSTANCE.register(map);
|
||||
}
|
||||
|
||||
public static void onTextureStitchedPost(TextureMap map)
|
||||
public static void onTextureStitchedPost(AtlasTexture map)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Post(map));
|
||||
}
|
||||
@@ -195,12 +199,6 @@ public class ForgeHooksClient
|
||||
MinecraftForge.EVENT_BUS.post(new ColorHandlerEvent.Item(itemColors, blockColors));
|
||||
}
|
||||
|
||||
static int renderPass = -1;
|
||||
public static void setRenderPass(int pass)
|
||||
{
|
||||
renderPass = pass;
|
||||
}
|
||||
|
||||
static final ThreadLocal<BlockRenderLayer> renderLayer = new ThreadLocal<BlockRenderLayer>();
|
||||
|
||||
public static void setRenderLayer(BlockRenderLayer layer)
|
||||
@@ -208,9 +206,9 @@ public class ForgeHooksClient
|
||||
renderLayer.set(layer);
|
||||
}
|
||||
|
||||
public static ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot slot, ModelBiped _default)
|
||||
public static <A extends BipedModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType slot, A _default)
|
||||
{
|
||||
ModelBiped model = itemStack.getItem().getArmorModel(entityLiving, itemStack, slot, _default);
|
||||
A model = itemStack.getItem().getArmorModel(entityLiving, itemStack, slot, _default);
|
||||
return model == null ? _default : model;
|
||||
}
|
||||
|
||||
@@ -240,15 +238,15 @@ public class ForgeHooksClient
|
||||
return MinecraftForge.EVENT_BUS.post(new MouseEvent());
|
||||
}
|
||||
*/
|
||||
public static float getOffsetFOV(EntityPlayer entity, float fov)
|
||||
public static float getOffsetFOV(PlayerEntity entity, float fov)
|
||||
{
|
||||
FOVUpdateEvent fovUpdateEvent = new FOVUpdateEvent(entity, fov);
|
||||
MinecraftForge.EVENT_BUS.post(fovUpdateEvent);
|
||||
return fovUpdateEvent.getNewfov();
|
||||
}
|
||||
|
||||
public static double getFOVModifier(GameRenderer renderer, Entity entity, IBlockState blockState, IFluidState fluidState, double renderPartialTicks, double fov) {
|
||||
EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, entity, blockState, fluidState, renderPartialTicks, fov);
|
||||
public static double getFOVModifier(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, double fov) {
|
||||
EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, info, renderPartialTicks, fov);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getFOV();
|
||||
}
|
||||
@@ -309,7 +307,7 @@ public class ForgeHooksClient
|
||||
//RenderingRegistry.registerBlockHandler(RenderBlockFluid.instance);
|
||||
}
|
||||
|
||||
public static void renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height)
|
||||
public static void renderMainMenu(MainMenuScreen gui, FontRenderer font, int width, int height)
|
||||
{
|
||||
VersionChecker.Status status = ForgeVersion.getStatus();
|
||||
if (status == BETA || status == BETA_OUTDATED)
|
||||
@@ -339,7 +337,7 @@ public class ForgeHooksClient
|
||||
}
|
||||
}
|
||||
|
||||
public static ISound playSound(SoundManager manager, ISound sound)
|
||||
public static ISound playSound(SoundEngine manager, ISound sound)
|
||||
{
|
||||
PlaySoundEvent e = new PlaySoundEvent(manager, sound);
|
||||
MinecraftForge.EVENT_BUS.post(e);
|
||||
@@ -354,23 +352,23 @@ public class ForgeHooksClient
|
||||
return worldRenderPass;
|
||||
}
|
||||
|
||||
public static void drawScreen(GuiScreen screen, int mouseX, int mouseY, float partialTicks)
|
||||
public static void drawScreen(Screen screen, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if (!MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Pre(screen, mouseX, mouseY, partialTicks)))
|
||||
screen.render(mouseX, mouseY, partialTicks);
|
||||
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(screen, mouseX, mouseY, partialTicks));
|
||||
}
|
||||
|
||||
public static float getFogDensity(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, float partial, float density)
|
||||
public static float getFogDensity(FogRenderer fogRenderer, GameRenderer renderer, ActiveRenderInfo info, float partial, float density)
|
||||
{
|
||||
EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(fogRenderer, renderer, entity, state, fluidState, partial, density);
|
||||
EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(fogRenderer, renderer, info, partial, density);
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return event.getDensity();
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void onFogRender(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, float partial, int mode, float distance)
|
||||
public static void onFogRender(FogRenderer fogRenderer, GameRenderer renderer, ActiveRenderInfo info, float partial, int mode, float distance)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(fogRenderer, renderer, entity, state, fluidState, partial, mode, distance));
|
||||
MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(fogRenderer, renderer, info, partial, mode, distance));
|
||||
}
|
||||
|
||||
public static void onModelBake(ModelManager modelManager, Map<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
|
||||
@@ -443,7 +441,7 @@ public class ForgeHooksClient
|
||||
|
||||
// moved and expanded from WorldVertexBufferUploader.draw
|
||||
|
||||
public static void preDraw(EnumUsage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
|
||||
public static void preDraw(Usage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
|
||||
{
|
||||
VertexFormatElement attr = format.getElement(element);
|
||||
int count = attr.getElementCount();
|
||||
@@ -468,10 +466,10 @@ public class ForgeHooksClient
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
break;
|
||||
case UV:
|
||||
OpenGlHelper.glClientActiveTexture(OpenGlHelper.GL_TEXTURE0 + attr.getIndex());
|
||||
GLX.glClientActiveTexture(GLX.GL_TEXTURE0 + attr.getIndex());
|
||||
glTexCoordPointer(count, constant, stride, buffer);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
OpenGlHelper.glClientActiveTexture(OpenGlHelper.GL_TEXTURE0);
|
||||
GLX.glClientActiveTexture(GLX.GL_TEXTURE0);
|
||||
break;
|
||||
case PADDING:
|
||||
break;
|
||||
@@ -484,7 +482,7 @@ public class ForgeHooksClient
|
||||
}
|
||||
}
|
||||
|
||||
public static void postDraw(EnumUsage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
|
||||
public static void postDraw(Usage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
|
||||
{
|
||||
VertexFormatElement attr = format.getElement(element);
|
||||
switch(attrType)
|
||||
@@ -498,12 +496,12 @@ public class ForgeHooksClient
|
||||
case COLOR:
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
// is this really needed?
|
||||
GlStateManager.resetColor();
|
||||
GlStateManager.clearCurrentColor();
|
||||
break;
|
||||
case UV:
|
||||
OpenGlHelper.glClientActiveTexture(OpenGlHelper.GL_TEXTURE0 + attr.getIndex());
|
||||
GLX.glClientActiveTexture(GLX.GL_TEXTURE0 + attr.getIndex());
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
OpenGlHelper.glClientActiveTexture(OpenGlHelper.GL_TEXTURE0);
|
||||
GLX.glClientActiveTexture(GLX.GL_TEXTURE0);
|
||||
break;
|
||||
case PADDING:
|
||||
break;
|
||||
@@ -525,7 +523,7 @@ public class ForgeHooksClient
|
||||
|
||||
public static Matrix4f getMatrix(ModelRotation modelRotation)
|
||||
{
|
||||
Matrix4f ret = new Matrix4f(TRSRTransformation.toVecmath(modelRotation.getMatrix()), new Vector3f(), 1), tmp = new Matrix4f();
|
||||
Matrix4f ret = new Matrix4f(TRSRTransformation.toVecmath(modelRotation.func_217650_a()), new Vector3f(), 1), tmp = new Matrix4f();
|
||||
tmp.setIdentity();
|
||||
tmp.m03 = tmp.m13 = tmp.m23 = .5f;
|
||||
ret.mul(tmp, ret);
|
||||
@@ -568,19 +566,19 @@ public class ForgeHooksClient
|
||||
|
||||
{ setVertexFormat(FORMAT); }
|
||||
|
||||
boolean hasLighting()
|
||||
boolean hasLighting()
|
||||
{
|
||||
return dataLength[1] >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processQuad()
|
||||
protected void processQuad()
|
||||
{
|
||||
// Reset light data
|
||||
blockLight = 0;
|
||||
skyLight = 0;
|
||||
// Compute average light for all 4 vertices
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
blockLight += (int) ((quadData[1][i][0] * 0xFFFF) / 0x20);
|
||||
skyLight += (int) ((quadData[1][i][1] * 0xFFFF) / 0x20);
|
||||
@@ -596,7 +594,7 @@ public class ForgeHooksClient
|
||||
public void setQuadTint(int tint) {}
|
||||
|
||||
@Override
|
||||
public void setQuadOrientation(EnumFacing orientation) {}
|
||||
public void setQuadOrientation(Direction orientation) {}
|
||||
|
||||
@Override
|
||||
public void setApplyDiffuseLighting(boolean diffuse) {}
|
||||
@@ -613,7 +611,7 @@ public class ForgeHooksClient
|
||||
Random random = new Random();
|
||||
long seed = 42L;
|
||||
|
||||
for (EnumFacing enumfacing : EnumFacing.values())
|
||||
for (Direction enumfacing : Direction.values())
|
||||
{
|
||||
random.setSeed(seed);
|
||||
allquads.addAll(model.getQuads(null, enumfacing, random));
|
||||
@@ -638,7 +636,7 @@ public class ForgeHooksClient
|
||||
// If the current segment contains lighting data
|
||||
boolean hasLighting = false;
|
||||
|
||||
for (int i = 0; i < allquads.size(); i++)
|
||||
for (int i = 0; i < allquads.size(); i++)
|
||||
{
|
||||
BakedQuad q = allquads.get(i);
|
||||
|
||||
@@ -660,7 +658,7 @@ public class ForgeHooksClient
|
||||
boolean shade = q.shouldApplyDiffuseLighting();
|
||||
|
||||
boolean lightingDirty = segmentBlockLight != bl || segmentSkyLight != sl;
|
||||
boolean shadeDirty = shade != segmentShading;
|
||||
boolean shadeDirty = shade != segmentShading;
|
||||
|
||||
// If lighting or color data has changed, draw the segment and flush it
|
||||
if (lightingDirty || shadeDirty)
|
||||
@@ -685,7 +683,7 @@ public class ForgeHooksClient
|
||||
// Clean up render state if necessary
|
||||
if (hasLighting)
|
||||
{
|
||||
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE0, OpenGlHelper.lastBrightnessX, OpenGlHelper.lastBrightnessY);
|
||||
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE0, GLX.lastBrightnessX, GLX.lastBrightnessY);
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
}
|
||||
@@ -695,8 +693,8 @@ public class ForgeHooksClient
|
||||
BufferBuilder bufferbuilder = Tessellator.getInstance().getBuffer();
|
||||
bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
|
||||
|
||||
float lastBl = OpenGlHelper.lastBrightnessX;
|
||||
float lastSl = OpenGlHelper.lastBrightnessY;
|
||||
float lastBl = GLX.lastBrightnessX;
|
||||
float lastSl = GLX.lastBrightnessY;
|
||||
|
||||
if (updateShading)
|
||||
{
|
||||
@@ -711,19 +709,19 @@ public class ForgeHooksClient
|
||||
GlStateManager.disableLighting();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (updateLighting)
|
||||
{
|
||||
// Force lightmap coords to simulate synthetic lighting
|
||||
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE0, Math.max(bl, lastBl), Math.max(sl, lastSl));
|
||||
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE0, Math.max(bl, lastBl), Math.max(sl, lastSl));
|
||||
}
|
||||
|
||||
ri.renderQuads(bufferbuilder, segment, baseColor, stack);
|
||||
Tessellator.getInstance().draw();
|
||||
|
||||
// Preserve this as it represents the "world" lighting
|
||||
OpenGlHelper.lastBrightnessX = lastBl;
|
||||
OpenGlHelper.lastBrightnessY = lastSl;
|
||||
GLX.lastBrightnessX = lastBl;
|
||||
GLX.lastBrightnessY = lastSl;
|
||||
|
||||
segment.clear();
|
||||
}
|
||||
@@ -731,7 +729,7 @@ public class ForgeHooksClient
|
||||
/**
|
||||
* internal, relies on fixed format of FaceBakery
|
||||
*/
|
||||
public static void fillNormal(int[] faceData, EnumFacing facing)
|
||||
public static void fillNormal(int[] faceData, Direction facing)
|
||||
{
|
||||
Vector3f v1 = getVertexPos(faceData, 3);
|
||||
Vector3f t = getVertexPos(faceData, 1);
|
||||
@@ -796,10 +794,10 @@ public class ForgeHooksClient
|
||||
}
|
||||
}
|
||||
|
||||
public static IBakedModel getDamageModel(IBakedModel ibakedmodel, TextureAtlasSprite texture, IBlockState state, IWorldReader world, BlockPos pos)
|
||||
public static IBakedModel getDamageModel(IBakedModel ibakedmodel, TextureAtlasSprite texture, BlockState state, IEnviromentBlockReader world, BlockPos pos, long randomPosition)
|
||||
{
|
||||
state = state.getBlock().getExtendedState(state, world, pos);
|
||||
return (new SimpleBakedModel.Builder(state, ibakedmodel, texture, new Random(), 42)).build();
|
||||
return (new SimpleBakedModel.Builder(state, ibakedmodel, texture, new Random(), randomPosition)).build();
|
||||
}
|
||||
|
||||
private static int slotMainHand = 0;
|
||||
@@ -821,7 +819,7 @@ public class ForgeHooksClient
|
||||
return from.getItem().shouldCauseReequipAnimation(from, to, changed);
|
||||
}
|
||||
|
||||
public static BlockFaceUV applyUVLock(BlockFaceUV blockFaceUV, EnumFacing originalSide, ITransformation rotation)
|
||||
public static BlockFaceUV applyUVLock(BlockFaceUV blockFaceUV, Direction originalSide, ITransformation rotation)
|
||||
{
|
||||
TRSRTransformation global = new TRSRTransformation(rotation.getMatrixVec());
|
||||
Matrix4f uv = global.getUVLockTransform(originalSide).getMatrixVec();
|
||||
@@ -863,7 +861,7 @@ public class ForgeHooksClient
|
||||
return new BlockFaceUV(new float[]{ uMin, vMin, uMax, vMax }, angle);
|
||||
}
|
||||
|
||||
public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(MainWindow res, BossInfoClient bossInfo, int x, int y, int increment)
|
||||
public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(MainWindow res, ClientBossInfo bossInfo, int x, int y, int increment)
|
||||
{
|
||||
RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(new RenderGameOverlayEvent(Animation.getPartialTickTime(), res),
|
||||
BOSSINFO, bossInfo, x, y, increment);
|
||||
@@ -892,102 +890,102 @@ public class ForgeHooksClient
|
||||
return Pair.of(model, mat);
|
||||
}
|
||||
|
||||
public static void onInputUpdate(EntityPlayer player, MovementInput movementInput)
|
||||
public static void onInputUpdate(PlayerEntity player, MovementInput movementInput)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new InputUpdateEvent(player, movementInput));
|
||||
}
|
||||
|
||||
public static void refreshResources(Minecraft mc, VanillaResourceType... types) {
|
||||
SelectiveReloadStateHandler.INSTANCE.beginReload(ReloadRequirements.include(types));
|
||||
mc.refreshResources();
|
||||
mc.func_213237_g();
|
||||
SelectiveReloadStateHandler.INSTANCE.endReload();
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseClickedPre(GuiScreen guiScreen, double mouseX, double mouseY, int button)
|
||||
public static boolean onGuiMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
Event event = new GuiScreenEvent.MouseClickedEvent.Pre(guiScreen, mouseX, mouseY, button);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseClickedPost(GuiScreen guiScreen, double mouseX, double mouseY, int button)
|
||||
public static boolean onGuiMouseClickedPost(Screen guiScreen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
Event event = new GuiScreenEvent.MouseClickedEvent.Post(guiScreen, mouseX, mouseY, button);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseReleasedPre(GuiScreen guiScreen, double mouseX, double mouseY, int button)
|
||||
public static boolean onGuiMouseReleasedPre(Screen guiScreen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
Event event = new GuiScreenEvent.MouseReleasedEvent.Pre(guiScreen, mouseX, mouseY, button);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseReleasedPost(GuiScreen guiScreen, double mouseX, double mouseY, int button)
|
||||
public static boolean onGuiMouseReleasedPost(Screen guiScreen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
Event event = new GuiScreenEvent.MouseReleasedEvent.Post(guiScreen, mouseX, mouseY, button);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseDragPre(GuiScreen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
public static boolean onGuiMouseDragPre(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
Event event = new GuiScreenEvent.MouseDragEvent.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseDragPost(GuiScreen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
public static boolean onGuiMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
Event event = new GuiScreenEvent.MouseDragEvent.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseScrollPre(MouseHelper mouseHelper, GuiScreen guiScreen, double scrollDelta)
|
||||
public static boolean onGuiMouseScrollPre(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta)
|
||||
{
|
||||
MainWindow mainWindow = guiScreen.mc.mainWindow;
|
||||
MainWindow mainWindow = guiScreen.getMinecraft().mainWindow;
|
||||
double mouseX = mouseHelper.getMouseX() * (double) mainWindow.getScaledWidth() / (double) mainWindow.getWidth();
|
||||
double mouseY = mouseHelper.getMouseY() * (double) mainWindow.getScaledHeight() / (double) mainWindow.getHeight();
|
||||
Event event = new GuiScreenEvent.MouseScrollEvent.Pre(guiScreen, mouseX, mouseY, scrollDelta);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiMouseScrollPost(MouseHelper mouseHelper, GuiScreen guiScreen, double scrollDelta)
|
||||
public static boolean onGuiMouseScrollPost(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta)
|
||||
{
|
||||
MainWindow mainWindow = guiScreen.mc.mainWindow;
|
||||
MainWindow mainWindow = guiScreen.getMinecraft().mainWindow;
|
||||
double mouseX = mouseHelper.getMouseX() * (double) mainWindow.getScaledWidth() / (double) mainWindow.getWidth();
|
||||
double mouseY = mouseHelper.getMouseY() * (double) mainWindow.getScaledHeight() / (double) mainWindow.getHeight();
|
||||
Event event = new GuiScreenEvent.MouseScrollEvent.Post(guiScreen, mouseX, mouseY, scrollDelta);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiKeyPressedPre(GuiScreen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
public static boolean onGuiKeyPressedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
Event event = new GuiScreenEvent.KeyboardKeyPressedEvent.Pre(guiScreen, keyCode, scanCode, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiKeyPressedPost(GuiScreen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
public static boolean onGuiKeyPressedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
Event event = new GuiScreenEvent.KeyboardKeyPressedEvent.Post(guiScreen, keyCode, scanCode, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiKeyReleasedPre(GuiScreen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
public static boolean onGuiKeyReleasedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
Event event = new GuiScreenEvent.KeyboardKeyReleasedEvent.Pre(guiScreen, keyCode, scanCode, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiKeyReleasedPost(GuiScreen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
public static boolean onGuiKeyReleasedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
Event event = new GuiScreenEvent.KeyboardKeyReleasedEvent.Post(guiScreen, keyCode, scanCode, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiCharTypedPre(GuiScreen guiScreen, char codePoint, int modifiers)
|
||||
public static boolean onGuiCharTypedPre(Screen guiScreen, char codePoint, int modifiers)
|
||||
{
|
||||
Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Pre(guiScreen, codePoint, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onGuiCharTypedPost(GuiScreen guiScreen, char codePoint, int modifiers)
|
||||
public static boolean onGuiCharTypedPost(Screen guiScreen, char codePoint, int modifiers)
|
||||
{
|
||||
Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Post(guiScreen, codePoint, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
+95
-89
@@ -26,20 +26,18 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiIngame;
|
||||
import net.minecraft.client.gui.GuiOverlayDebug;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.IngameGui;
|
||||
import net.minecraft.client.gui.overlay.DebugOverlayGui;
|
||||
import net.minecraft.client.network.play.ClientPlayNetHandler;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
@@ -51,16 +49,17 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceFluidMode;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiIngameForge extends GuiIngame
|
||||
public class ForgeIngameGui extends IngameGui
|
||||
{
|
||||
//private static final ResourceLocation VIGNETTE = new ResourceLocation("textures/misc/vignette.png");
|
||||
//private static final ResourceLocation WIDGITS = new ResourceLocation("textures/gui/widgets.png");
|
||||
@@ -74,6 +73,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
public static boolean renderVignette = true;
|
||||
public static boolean renderHelmet = true;
|
||||
public static boolean renderPortal = true;
|
||||
public static boolean renderSpectatorTooltip = true;
|
||||
public static boolean renderHotbar = true;
|
||||
public static boolean renderCrosshairs = true;
|
||||
public static boolean renderBossHealth = true;
|
||||
@@ -94,7 +94,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
//private static final String MC_VERSION = MinecraftForge.MC_VERSION;
|
||||
private GuiOverlayDebugForge debugOverlay;
|
||||
|
||||
public GuiIngameForge(Minecraft mc)
|
||||
public ForgeIngameGui(Minecraft mc)
|
||||
{
|
||||
super(mc);
|
||||
debugOverlay = new GuiOverlayDebugForge(mc);
|
||||
@@ -106,7 +106,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
this.scaledWidth = this.mc.mainWindow.getScaledWidth();
|
||||
this.scaledHeight = this.mc.mainWindow.getScaledHeight();
|
||||
eventParent = new RenderGameOverlayEvent(partialTicks, this.mc.mainWindow);
|
||||
renderHealthMount = mc.player.getRidingEntity() instanceof EntityLivingBase;
|
||||
renderHealthMount = mc.player.getRidingEntity() instanceof LivingEntity;
|
||||
renderFood = mc.player.getRidingEntity() == null;
|
||||
renderJumpBar = mc.player.isRidingHorse();
|
||||
|
||||
@@ -130,23 +130,30 @@ public class GuiIngameForge extends GuiIngame
|
||||
|
||||
if (renderHelmet) renderHelmet(partialTicks);
|
||||
|
||||
if (renderPortal && !mc.player.isPotionActive(MobEffects.NAUSEA))
|
||||
if (renderPortal && !mc.player.isPotionActive(Effects.NAUSEA))
|
||||
{
|
||||
renderPortal(partialTicks);
|
||||
}
|
||||
|
||||
if (renderHotbar) renderHotbar(partialTicks);
|
||||
if (this.mc.playerController.getCurrentGameType() == GameType.SPECTATOR)
|
||||
{
|
||||
if (renderSpectatorTooltip) spectatorGui.renderTooltip(partialTicks);
|
||||
}
|
||||
else if (!this.mc.gameSettings.hideGUI)
|
||||
{
|
||||
if (renderHotbar) renderHotbar(partialTicks);
|
||||
}
|
||||
|
||||
if (!this.mc.gameSettings.hideGUI) {
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
zLevel = -90.0F;
|
||||
blitOffset = -90;
|
||||
rand.setSeed((long)(ticks * 312871));
|
||||
|
||||
if (renderCrosshairs) renderAttackIndicator(partialTicks);
|
||||
if (renderCrosshairs) renderAttackIndicator();
|
||||
if (renderBossHealth) renderBossHealth();
|
||||
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
if (this.mc.playerController.shouldDrawHUD() && this.mc.getRenderViewEntity() instanceof EntityPlayer)
|
||||
if (this.mc.playerController.shouldDrawHUD() && this.mc.getRenderViewEntity() instanceof PlayerEntity)
|
||||
{
|
||||
if (renderHealth) renderHealth(this.scaledWidth, this.scaledHeight);
|
||||
if (renderArmor) renderArmor(this.scaledWidth, this.scaledHeight);
|
||||
@@ -212,13 +219,13 @@ public class GuiIngameForge extends GuiIngame
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderAttackIndicator(float partialTicks)
|
||||
protected void renderAttackIndicator()
|
||||
{
|
||||
if (pre(CROSSHAIRS)) return;
|
||||
bind(Gui.ICONS);
|
||||
bind(AbstractGui.GUI_ICONS_LOCATION);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.enableAlphaTest();
|
||||
super.renderAttackIndicator(partialTicks);
|
||||
super.renderAttackIndicator();
|
||||
post(CROSSHAIRS);
|
||||
}
|
||||
|
||||
@@ -237,17 +244,16 @@ public class GuiIngameForge extends GuiIngame
|
||||
post(SUBTITLES);
|
||||
}
|
||||
|
||||
//@Override
|
||||
protected void renderBossHealth()
|
||||
{
|
||||
if (pre(BOSSHEALTH)) return;
|
||||
bind(Gui.ICONS);
|
||||
bind(AbstractGui.GUI_ICONS_LOCATION);
|
||||
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
mc.profiler.startSection("bossHealth");
|
||||
mc.func_213239_aq().startSection("bossHealth");
|
||||
GlStateManager.enableBlend();
|
||||
this.overlayBoss.renderBossHealth();
|
||||
this.overlayBoss.render();
|
||||
GlStateManager.disableBlend();
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
post(BOSSHEALTH);
|
||||
}
|
||||
|
||||
@@ -290,7 +296,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
protected void renderArmor(int width, int height)
|
||||
{
|
||||
if (pre(ARMOR)) return;
|
||||
mc.profiler.startSection("armor");
|
||||
mc.func_213239_aq().startSection("armor");
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
int left = width / 2 - 91;
|
||||
@@ -301,22 +307,22 @@ public class GuiIngameForge extends GuiIngame
|
||||
{
|
||||
if (i < level)
|
||||
{
|
||||
drawTexturedModalRect(left, top, 34, 9, 9, 9);
|
||||
blit(left, top, 34, 9, 9, 9);
|
||||
}
|
||||
else if (i == level)
|
||||
{
|
||||
drawTexturedModalRect(left, top, 25, 9, 9, 9);
|
||||
blit(left, top, 25, 9, 9, 9);
|
||||
}
|
||||
else if (i > level)
|
||||
{
|
||||
drawTexturedModalRect(left, top, 16, 9, 9, 9);
|
||||
blit(left, top, 16, 9, 9, 9);
|
||||
}
|
||||
left += 8;
|
||||
}
|
||||
left_height += 10;
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
post(ARMOR);
|
||||
}
|
||||
|
||||
@@ -361,8 +367,8 @@ public class GuiIngameForge extends GuiIngame
|
||||
protected void renderAir(int width, int height)
|
||||
{
|
||||
if (pre(AIR)) return;
|
||||
mc.profiler.startSection("air");
|
||||
EntityPlayer player = (EntityPlayer)this.mc.getRenderViewEntity();
|
||||
mc.func_213239_aq().startSection("air");
|
||||
PlayerEntity player = (PlayerEntity)this.mc.getRenderViewEntity();
|
||||
GlStateManager.enableBlend();
|
||||
int left = width / 2 + 91;
|
||||
int top = height - right_height;
|
||||
@@ -375,24 +381,24 @@ public class GuiIngameForge extends GuiIngame
|
||||
|
||||
for (int i = 0; i < full + partial; ++i)
|
||||
{
|
||||
drawTexturedModalRect(left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
|
||||
blit(left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
|
||||
}
|
||||
right_height += 10;
|
||||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
post(AIR);
|
||||
}
|
||||
|
||||
public void renderHealth(int width, int height)
|
||||
{
|
||||
bind(ICONS);
|
||||
bind(GUI_ICONS_LOCATION);
|
||||
if (pre(HEALTH)) return;
|
||||
mc.profiler.startSection("health");
|
||||
mc.func_213239_aq().startSection("health");
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
EntityPlayer player = (EntityPlayer)this.mc.getRenderViewEntity();
|
||||
PlayerEntity player = (PlayerEntity)this.mc.getRenderViewEntity();
|
||||
int health = MathHelper.ceil(player.getHealth());
|
||||
boolean highlight = healthUpdateCounter > (long)ticks && (healthUpdateCounter - (long)ticks) / 3L %2L == 1L;
|
||||
|
||||
@@ -432,7 +438,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
if (rowHeight != 10) left_height += 10 - rowHeight;
|
||||
|
||||
int regen = -1;
|
||||
if (player.isPotionActive(MobEffects.REGENERATION))
|
||||
if (player.isPotionActive(Effects.REGENERATION))
|
||||
{
|
||||
regen = ticks % 25;
|
||||
}
|
||||
@@ -440,8 +446,8 @@ public class GuiIngameForge extends GuiIngame
|
||||
final int TOP = 9 * (mc.world.getWorldInfo().isHardcore() ? 5 : 0);
|
||||
final int BACKGROUND = (highlight ? 25 : 16);
|
||||
int MARGIN = 16;
|
||||
if (player.isPotionActive(MobEffects.POISON)) MARGIN += 36;
|
||||
else if (player.isPotionActive(MobEffects.WITHER)) MARGIN += 72;
|
||||
if (player.isPotionActive(Effects.POISON)) MARGIN += 36;
|
||||
else if (player.isPotionActive(Effects.WITHER)) MARGIN += 72;
|
||||
float absorbRemaining = absorb;
|
||||
|
||||
for (int i = MathHelper.ceil((healthMax + absorb) / 2.0F) - 1; i >= 0; --i)
|
||||
@@ -454,49 +460,49 @@ public class GuiIngameForge extends GuiIngame
|
||||
if (health <= 4) y += rand.nextInt(2);
|
||||
if (i == regen) y -= 2;
|
||||
|
||||
drawTexturedModalRect(x, y, BACKGROUND, TOP, 9, 9);
|
||||
blit(x, y, BACKGROUND, TOP, 9, 9);
|
||||
|
||||
if (highlight)
|
||||
{
|
||||
if (i * 2 + 1 < healthLast)
|
||||
drawTexturedModalRect(x, y, MARGIN + 54, TOP, 9, 9); //6
|
||||
blit(x, y, MARGIN + 54, TOP, 9, 9); //6
|
||||
else if (i * 2 + 1 == healthLast)
|
||||
drawTexturedModalRect(x, y, MARGIN + 63, TOP, 9, 9); //7
|
||||
blit(x, y, MARGIN + 63, TOP, 9, 9); //7
|
||||
}
|
||||
|
||||
if (absorbRemaining > 0.0F)
|
||||
{
|
||||
if (absorbRemaining == absorb && absorb % 2.0F == 1.0F)
|
||||
{
|
||||
drawTexturedModalRect(x, y, MARGIN + 153, TOP, 9, 9); //17
|
||||
blit(x, y, MARGIN + 153, TOP, 9, 9); //17
|
||||
absorbRemaining -= 1.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawTexturedModalRect(x, y, MARGIN + 144, TOP, 9, 9); //16
|
||||
blit(x, y, MARGIN + 144, TOP, 9, 9); //16
|
||||
absorbRemaining -= 2.0F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i * 2 + 1 < health)
|
||||
drawTexturedModalRect(x, y, MARGIN + 36, TOP, 9, 9); //4
|
||||
blit(x, y, MARGIN + 36, TOP, 9, 9); //4
|
||||
else if (i * 2 + 1 == health)
|
||||
drawTexturedModalRect(x, y, MARGIN + 45, TOP, 9, 9); //5
|
||||
blit(x, y, MARGIN + 45, TOP, 9, 9); //5
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
post(HEALTH);
|
||||
}
|
||||
|
||||
public void renderFood(int width, int height)
|
||||
{
|
||||
if (pre(FOOD)) return;
|
||||
mc.profiler.startSection("food");
|
||||
mc.func_213239_aq().startSection("food");
|
||||
|
||||
EntityPlayer player = (EntityPlayer)this.mc.getRenderViewEntity();
|
||||
PlayerEntity player = (PlayerEntity)this.mc.getRenderViewEntity();
|
||||
GlStateManager.enableBlend();
|
||||
int left = width / 2 + 91;
|
||||
int top = height - right_height;
|
||||
@@ -514,7 +520,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
int icon = 16;
|
||||
byte background = 0;
|
||||
|
||||
if (mc.player.isPotionActive(MobEffects.HUNGER))
|
||||
if (mc.player.isPotionActive(Effects.HUNGER))
|
||||
{
|
||||
icon += 36;
|
||||
background = 13;
|
||||
@@ -526,15 +532,15 @@ public class GuiIngameForge extends GuiIngame
|
||||
y = top + (rand.nextInt(3) - 1);
|
||||
}
|
||||
|
||||
drawTexturedModalRect(x, y, 16 + background * 9, 27, 9, 9);
|
||||
blit(x, y, 16 + background * 9, 27, 9, 9);
|
||||
|
||||
if (idx < level)
|
||||
drawTexturedModalRect(x, y, icon + 36, 27, 9, 9);
|
||||
blit(x, y, icon + 36, 27, 9, 9);
|
||||
else if (idx == level)
|
||||
drawTexturedModalRect(x, y, icon + 45, 27, 9, 9);
|
||||
blit(x, y, icon + 45, 27, 9, 9);
|
||||
}
|
||||
GlStateManager.disableBlend();
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
post(FOOD);
|
||||
}
|
||||
|
||||
@@ -542,7 +548,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
{
|
||||
if (mc.player.getSleepTimer() > 0)
|
||||
{
|
||||
mc.profiler.startSection("sleep");
|
||||
mc.func_213239_aq().startSection("sleep");
|
||||
GlStateManager.disableDepthTest();
|
||||
GlStateManager.disableAlphaTest();
|
||||
int sleepTime = mc.player.getSleepTimer();
|
||||
@@ -554,16 +560,16 @@ public class GuiIngameForge extends GuiIngame
|
||||
}
|
||||
|
||||
int color = (int)(220.0F * opacity) << 24 | 1052704;
|
||||
drawRect(0, 0, width, height, color);
|
||||
fill(0, 0, width, height, color);
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableDepthTest();
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderExperience(int x)
|
||||
{
|
||||
bind(ICONS);
|
||||
bind(GUI_ICONS_LOCATION);
|
||||
if (pre(EXPERIENCE)) return;
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableBlend();
|
||||
@@ -581,7 +587,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
@Override
|
||||
public void renderHorseJumpBar(int x)
|
||||
{
|
||||
bind(ICONS);
|
||||
bind(GUI_ICONS_LOCATION);
|
||||
if (pre(JUMPBAR)) return;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableBlend();
|
||||
@@ -589,7 +595,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
super.renderHorseJumpBar(x);
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
post(JUMPBAR);
|
||||
@@ -597,8 +603,8 @@ public class GuiIngameForge extends GuiIngame
|
||||
|
||||
protected void renderHUDText(int width, int height)
|
||||
{
|
||||
mc.profiler.startSection("forgeHudText");
|
||||
OpenGlHelper.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
mc.func_213239_aq().startSection("forgeHudText");
|
||||
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
ArrayList<String> listL = new ArrayList<String>();
|
||||
ArrayList<String> listR = new ArrayList<String>();
|
||||
|
||||
@@ -630,7 +636,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
for (String msg : listL)
|
||||
{
|
||||
if (msg == null) continue;
|
||||
drawRect(1, top - 1, 2 + fontrenderer.getStringWidth(msg) + 1, top + fontrenderer.FONT_HEIGHT - 1, -1873784752);
|
||||
fill(1, top - 1, 2 + fontrenderer.getStringWidth(msg) + 1, top + fontrenderer.FONT_HEIGHT - 1, -1873784752);
|
||||
fontrenderer.drawStringWithShadow(msg, 2, top, 14737632);
|
||||
top += fontrenderer.FONT_HEIGHT;
|
||||
}
|
||||
@@ -641,13 +647,13 @@ public class GuiIngameForge extends GuiIngame
|
||||
if (msg == null) continue;
|
||||
int w = fontrenderer.getStringWidth(msg);
|
||||
int left = width - 2 - w;
|
||||
drawRect(left - 1, top - 1, left + w + 1, top + fontrenderer.FONT_HEIGHT - 1, -1873784752);
|
||||
fill(left - 1, top - 1, left + w + 1, top + fontrenderer.FONT_HEIGHT - 1, -1873784752);
|
||||
fontrenderer.drawStringWithShadow(msg, left, top, 14737632);
|
||||
top += fontrenderer.FONT_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
post(TEXT);
|
||||
}
|
||||
|
||||
@@ -655,7 +661,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
{
|
||||
if (this.mc.gameSettings.showDebugInfo && this.mc.gameSettings.showLagometer && !pre(FPS_GRAPH))
|
||||
{
|
||||
this.debugOverlay.renderLagometer();
|
||||
this.debugOverlay.render();
|
||||
post(FPS_GRAPH);
|
||||
}
|
||||
}
|
||||
@@ -664,7 +670,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
{
|
||||
if (overlayMessageTime > 0)
|
||||
{
|
||||
mc.profiler.startSection("overlayMessage");
|
||||
mc.func_213239_aq().startSection("overlayMessage");
|
||||
float hue = (float)overlayMessageTime - partialTicks;
|
||||
int opacity = (int)(hue * 256.0F / 20.0F);
|
||||
if (opacity > 255) opacity = 255;
|
||||
@@ -681,7 +687,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +695,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
{
|
||||
if (titlesTimer > 0)
|
||||
{
|
||||
mc.profiler.startSection("titleAndSubtitle");
|
||||
mc.func_213239_aq().startSection("titleAndSubtitle");
|
||||
float age = (float)this.titlesTimer - partialTicks;
|
||||
int opacity = 255;
|
||||
|
||||
@@ -721,37 +727,37 @@ public class GuiIngameForge extends GuiIngame
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
this.mc.profiler.endSection();
|
||||
this.mc.func_213239_aq().endSection();
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderChat(int width, int height)
|
||||
{
|
||||
mc.profiler.startSection("chat");
|
||||
mc.func_213239_aq().startSection("chat");
|
||||
|
||||
RenderGameOverlayEvent.Chat event = new RenderGameOverlayEvent.Chat(eventParent, 0, height - 48);
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translatef((float) event.getPosX(), (float) event.getPosY(), 0.0F);
|
||||
persistantChatGUI.drawChat(ticks);
|
||||
persistantChatGUI.render(ticks);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
post(CHAT);
|
||||
|
||||
mc.profiler.endSection();
|
||||
mc.func_213239_aq().endSection();
|
||||
}
|
||||
|
||||
protected void renderPlayerList(int width, int height)
|
||||
{
|
||||
ScoreObjective scoreobjective = this.mc.world.getScoreboard().getObjectiveInDisplaySlot(0);
|
||||
NetHandlerPlayClient handler = mc.player.connection;
|
||||
ClientPlayNetHandler handler = mc.player.connection;
|
||||
|
||||
if (mc.gameSettings.keyBindPlayerList.isKeyDown() && (!mc.isIntegratedServerRunning() || handler.getPlayerInfoMap().size() > 1 || scoreobjective != null))
|
||||
{
|
||||
this.overlayPlayerList.setVisible(true);
|
||||
if (pre(PLAYER_LIST)) return;
|
||||
this.overlayPlayerList.renderPlayerlist(width, this.mc.world.getScoreboard(), scoreobjective);
|
||||
this.overlayPlayerList.render(width, this.mc.world.getScoreboard(), scoreobjective);
|
||||
post(PLAYER_LIST);
|
||||
}
|
||||
else
|
||||
@@ -762,20 +768,20 @@ public class GuiIngameForge extends GuiIngame
|
||||
|
||||
protected void renderHealthMount(int width, int height)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer)mc.getRenderViewEntity();
|
||||
PlayerEntity player = (PlayerEntity)mc.getRenderViewEntity();
|
||||
Entity tmp = player.getRidingEntity();
|
||||
if (!(tmp instanceof EntityLivingBase)) return;
|
||||
if (!(tmp instanceof LivingEntity)) return;
|
||||
|
||||
bind(ICONS);
|
||||
bind(GUI_ICONS_LOCATION);
|
||||
|
||||
if (pre(HEALTHMOUNT)) return;
|
||||
|
||||
boolean unused = false;
|
||||
int left_align = width / 2 + 91;
|
||||
|
||||
mc.profiler.endStartSection("mountHealth");
|
||||
mc.func_213239_aq().func_219895_b("mountHealth");
|
||||
GlStateManager.enableBlend();
|
||||
EntityLivingBase mount = (EntityLivingBase)tmp;
|
||||
LivingEntity mount = (LivingEntity)tmp;
|
||||
int health = (int)Math.ceil((double)mount.getHealth());
|
||||
float healthMax = mount.getMaxHealth();
|
||||
int hearts = (int)(healthMax + 0.5F) / 2;
|
||||
@@ -797,12 +803,12 @@ public class GuiIngameForge extends GuiIngame
|
||||
for (int i = 0; i < rowCount; ++i)
|
||||
{
|
||||
int x = left_align - i * 8 - 9;
|
||||
drawTexturedModalRect(x, top, BACKGROUND, 9, 9, 9);
|
||||
blit(x, top, BACKGROUND, 9, 9, 9);
|
||||
|
||||
if (i * 2 + 1 + heart < health)
|
||||
drawTexturedModalRect(x, top, FULL, 9, 9, 9);
|
||||
blit(x, top, FULL, 9, 9, 9);
|
||||
else if (i * 2 + 1 + heart == health)
|
||||
drawTexturedModalRect(x, top, HALF, 9, 9, 9);
|
||||
blit(x, top, HALF, 9, 9, 9);
|
||||
}
|
||||
|
||||
right_height += 10;
|
||||
@@ -825,7 +831,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
mc.getTextureManager().bindTexture(res);
|
||||
}
|
||||
|
||||
private class GuiOverlayDebugForge extends GuiOverlayDebug
|
||||
private class GuiOverlayDebugForge extends DebugOverlayGui
|
||||
{
|
||||
private Minecraft mc;
|
||||
private GuiOverlayDebugForge(Minecraft mc)
|
||||
@@ -836,8 +842,8 @@ public class GuiIngameForge extends GuiIngame
|
||||
public void update()
|
||||
{
|
||||
Entity entity = this.mc.getRenderViewEntity();
|
||||
this.rayTraceBlock = entity.rayTrace(20.0D, 0.0F, RayTraceFluidMode.NEVER);
|
||||
this.rayTraceFluid = entity.rayTrace(20.0D, 0.0F, RayTraceFluidMode.ALWAYS);
|
||||
this.rayTraceBlock = entity.func_213324_a(20.0D, 0.0F, false);
|
||||
this.rayTraceFluid = entity.func_213324_a(20.0D, 0.0F, true);
|
||||
}
|
||||
@Override protected void renderDebugInfoLeft(){}
|
||||
@Override protected void renderDebugInfoRight(){}
|
||||
@@ -21,12 +21,12 @@ package net.minecraftforge.client;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IRenderHandler
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract void render(float partialTicks, WorldClient world, Minecraft mc);
|
||||
public abstract void render(float partialTicks, ClientWorld world, Minecraft mc);
|
||||
}
|
||||
@@ -41,9 +41,8 @@ import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunkCache;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderCache;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
@@ -57,11 +56,6 @@ import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
public class MinecraftForgeClient
|
||||
{
|
||||
public static int getRenderPass()
|
||||
{
|
||||
return ForgeHooksClient.renderPass;
|
||||
}
|
||||
|
||||
public static BlockRenderLayer getRenderLayer()
|
||||
{
|
||||
return ForgeHooksClient.renderLayer.get();
|
||||
@@ -113,20 +107,20 @@ public class MinecraftForgeClient
|
||||
}
|
||||
}
|
||||
|
||||
private static final LoadingCache<Pair<World, BlockPos>, RenderChunkCache> regionCache = CacheBuilder.newBuilder()
|
||||
private static final LoadingCache<Pair<World, BlockPos>, ChunkRenderCache> regionCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(500)
|
||||
.concurrencyLevel(5)
|
||||
.expireAfterAccess(1, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<Pair<World, BlockPos>, RenderChunkCache>()
|
||||
.build(new CacheLoader<Pair<World, BlockPos>, ChunkRenderCache>()
|
||||
{
|
||||
@Override
|
||||
public RenderChunkCache load(Pair<World, BlockPos> key)
|
||||
public ChunkRenderCache load(Pair<World, BlockPos> key)
|
||||
{
|
||||
return RenderChunkCache.func_212397_a(key.getLeft(), key.getRight().add(-1, -1, -1), key.getRight().add(16, 16, 16), 1);
|
||||
return ChunkRenderCache.generateCache(key.getLeft(), key.getRight().add(-1, -1, -1), key.getRight().add(16, 16, 16), 1);
|
||||
}
|
||||
});
|
||||
|
||||
public static void onRebuildChunk(World world, BlockPos position, RenderChunkCache cache)
|
||||
public static void onRebuildChunk(World world, BlockPos position, ChunkRenderCache cache)
|
||||
{
|
||||
if (cache == null)
|
||||
regionCache.invalidate(Pair.of(world, position));
|
||||
@@ -134,7 +128,7 @@ public class MinecraftForgeClient
|
||||
regionCache.put(Pair.of(world, position), cache);
|
||||
}
|
||||
|
||||
public static RenderChunkCache getRegionRenderCache(World world, BlockPos pos)
|
||||
public static ChunkRenderCache getRegionRenderCache(World world, BlockPos pos)
|
||||
{
|
||||
int x = pos.getX() & ~0xF;
|
||||
int y = pos.getY() & ~0xF;
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
/**
|
||||
* ClientChatEvent is fired whenever the client is about to send a chat message or command to the server. <br>
|
||||
|
||||
@@ -21,30 +21,30 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
|
||||
@Cancelable
|
||||
public class DrawBlockHighlightEvent extends Event
|
||||
{
|
||||
private final WorldRenderer context;
|
||||
private final EntityPlayer player;
|
||||
private final ActiveRenderInfo info;
|
||||
private final RayTraceResult target;
|
||||
private final int subID;
|
||||
private final float partialTicks;
|
||||
|
||||
public DrawBlockHighlightEvent(WorldRenderer context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks)
|
||||
public DrawBlockHighlightEvent(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
|
||||
{
|
||||
this.context = context;
|
||||
this.player = player;
|
||||
this.info = info;
|
||||
this.target = target;
|
||||
this.subID = subID;
|
||||
this.partialTicks= partialTicks;
|
||||
}
|
||||
|
||||
public WorldRenderer getContext() { return context; }
|
||||
public EntityPlayer getPlayer() { return player; }
|
||||
public ActiveRenderInfo getInfo() { return info; }
|
||||
public RayTraceResult getTarget() { return target; }
|
||||
public int getSubID() { return subID; }
|
||||
public float getPartialTicks() { return partialTicks; }
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
@@ -36,59 +37,45 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
|
||||
public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final GameRenderer renderer;
|
||||
private final Entity entity;
|
||||
private final IBlockState state;
|
||||
private final IFluidState fluidState;
|
||||
private final ActiveRenderInfo info;
|
||||
private final double renderPartialTicks;
|
||||
|
||||
public EntityViewRenderEvent(GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks)
|
||||
public EntityViewRenderEvent(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks)
|
||||
{
|
||||
this.renderer = renderer;
|
||||
this.entity = entity;
|
||||
this.state = state;
|
||||
this.fluidState = fluidState;
|
||||
this.info = info;
|
||||
this.renderPartialTicks = renderPartialTicks;
|
||||
}
|
||||
|
||||
public GameRenderer getRenderer()
|
||||
{
|
||||
return renderer;
|
||||
}
|
||||
|
||||
public Entity getEntity()
|
||||
{
|
||||
return entity;
|
||||
return renderer;
|
||||
}
|
||||
|
||||
public IBlockState getBlockState()
|
||||
public ActiveRenderInfo getInfo()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
public IFluidState getFluidState()
|
||||
{
|
||||
return fluidState;
|
||||
return info;
|
||||
}
|
||||
|
||||
public double getRenderPartialTicks()
|
||||
{
|
||||
return renderPartialTicks;
|
||||
}
|
||||
|
||||
|
||||
private static class FogEvent extends EntityViewRenderEvent
|
||||
{
|
||||
private final FogRenderer fogRenderer;
|
||||
|
||||
protected FogEvent(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks)
|
||||
|
||||
protected FogEvent(FogRenderer fogRenderer, GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks)
|
||||
{
|
||||
super(renderer, entity, state, fluidState, renderPartialTicks);
|
||||
super(renderer, info, renderPartialTicks);
|
||||
this.fogRenderer = fogRenderer;
|
||||
}
|
||||
|
||||
|
||||
public FogRenderer getFogRenderer() { return fogRenderer; }
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Event that allows any feature to customize the fog density the player sees.
|
||||
* NOTE: In order to make this event have an effect, you must cancel the event
|
||||
*/
|
||||
@@ -97,9 +84,9 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
{
|
||||
private float density;
|
||||
|
||||
public FogDensity(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float density)
|
||||
public FogDensity(FogRenderer fogRenderer, GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, float density)
|
||||
{
|
||||
super(fogRenderer, renderer, entity, state, fluidState, renderPartialTicks);
|
||||
super(fogRenderer, renderer, info, renderPartialTicks);
|
||||
this.setDensity(density);
|
||||
}
|
||||
|
||||
@@ -123,9 +110,9 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
private final int fogMode;
|
||||
private final float farPlaneDistance;
|
||||
|
||||
public RenderFogEvent(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, int fogMode, float farPlaneDistance)
|
||||
public RenderFogEvent(FogRenderer fogRenderer, GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, int fogMode, float farPlaneDistance)
|
||||
{
|
||||
super(fogRenderer, renderer, entity, state, fluidState, renderPartialTicks);
|
||||
super(fogRenderer, renderer, info, renderPartialTicks);
|
||||
this.fogMode = fogMode;
|
||||
this.farPlaneDistance = farPlaneDistance;
|
||||
}
|
||||
@@ -146,14 +133,14 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
* NOTE: Any change made to one of the color variables will affect the result seen in-game.
|
||||
*/
|
||||
public static class FogColors extends FogEvent
|
||||
{
|
||||
{
|
||||
private float red;
|
||||
private float green;
|
||||
private float blue;
|
||||
|
||||
public FogColors(FogRenderer fogRenderer, GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float red, float green, float blue)
|
||||
public FogColors(FogRenderer fogRenderer, GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, float red, float green, float blue)
|
||||
{
|
||||
super(fogRenderer, renderer, entity, state, fluidState, renderPartialTicks);
|
||||
super(fogRenderer, renderer, info, renderPartialTicks);
|
||||
this.setRed(red);
|
||||
this.setGreen(green);
|
||||
this.setBlue(blue);
|
||||
@@ -166,8 +153,8 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
public float getBlue() { return blue; }
|
||||
public void setBlue(float blue) { this.blue = blue; }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Event that allows mods to alter the angles of the player's camera. Mainly useful for applying roll.
|
||||
*/
|
||||
public static class CameraSetup extends EntityViewRenderEvent
|
||||
@@ -176,9 +163,9 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
private float pitch;
|
||||
private float roll;
|
||||
|
||||
public CameraSetup(GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float yaw, float pitch, float roll)
|
||||
public CameraSetup(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, float yaw, float pitch, float roll)
|
||||
{
|
||||
super(renderer, entity, state, fluidState, renderPartialTicks);
|
||||
super(renderer, info, renderPartialTicks);
|
||||
this.setYaw(yaw);
|
||||
this.setPitch(pitch);
|
||||
this.setRoll(roll);
|
||||
@@ -191,7 +178,7 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
public float getRoll() { return roll; }
|
||||
public void setRoll(float roll) { this.roll = roll; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Event that allows mods to alter the raw FOV itself.
|
||||
* This directly affects to the FOV without being modified.
|
||||
@@ -199,9 +186,9 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
public static class FOVModifier extends EntityViewRenderEvent
|
||||
{
|
||||
private double fov;
|
||||
|
||||
public FOVModifier(GameRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, double fov) {
|
||||
super(renderer, entity, state, fluidState, renderPartialTicks);
|
||||
|
||||
public FOVModifier(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, double fov) {
|
||||
super(renderer, info, renderPartialTicks);
|
||||
this.setFOV(fov);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
@@ -28,18 +28,18 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
*/
|
||||
public class FOVUpdateEvent extends Event
|
||||
{
|
||||
private final EntityPlayer entity;
|
||||
private final PlayerEntity entity;
|
||||
private final float fov;
|
||||
private float newfov;
|
||||
|
||||
public FOVUpdateEvent(EntityPlayer entity, float fov)
|
||||
public FOVUpdateEvent(PlayerEntity entity, float fov)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.fov = fov;
|
||||
this.setNewfov(fov);
|
||||
}
|
||||
|
||||
public EntityPlayer getEntity()
|
||||
public PlayerEntity getEntity()
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
@@ -28,14 +28,14 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
public class GuiContainerEvent extends Event
|
||||
{
|
||||
|
||||
private final GuiContainer guiContainer;
|
||||
private final ContainerScreen guiContainer;
|
||||
|
||||
public GuiContainerEvent(GuiContainer guiContainer)
|
||||
public GuiContainerEvent(ContainerScreen guiContainer)
|
||||
{
|
||||
this.guiContainer = guiContainer;
|
||||
}
|
||||
|
||||
public GuiContainer getGuiContainer()
|
||||
public ContainerScreen getGuiContainer()
|
||||
{
|
||||
return guiContainer;
|
||||
}
|
||||
@@ -58,7 +58,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(GuiContainer guiContainer, int mouseX, int mouseY)
|
||||
public DrawForeground(ContainerScreen guiContainer, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer);
|
||||
this.mouseX = mouseX;
|
||||
@@ -92,7 +92,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(GuiContainer guiContainer, int mouseX, int mouseY)
|
||||
public DrawBackground(ContainerScreen guiContainer, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer);
|
||||
this.mouseX = mouseX;
|
||||
|
||||
@@ -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.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
/**
|
||||
* This event is called before any Gui will open.
|
||||
@@ -33,18 +33,18 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
@net.minecraftforge.eventbus.api.Cancelable
|
||||
public class GuiOpenEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private GuiScreen gui;
|
||||
public GuiOpenEvent(GuiScreen gui)
|
||||
private Screen gui;
|
||||
public GuiOpenEvent(Screen gui)
|
||||
{
|
||||
this.setGui(gui);
|
||||
}
|
||||
|
||||
public GuiScreen getGui()
|
||||
public Screen getGui()
|
||||
{
|
||||
return gui;
|
||||
}
|
||||
|
||||
public void setGui(GuiScreen gui)
|
||||
public void setGui(Screen gui)
|
||||
{
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@@ -26,12 +26,11 @@ import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraft.client.renderer.InventoryEffectRenderer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
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.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -47,9 +46,9 @@ import org.lwjgl.glfw.GLFW;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiScreenEvent extends Event
|
||||
{
|
||||
private final GuiScreen gui;
|
||||
private final Screen gui;
|
||||
|
||||
public GuiScreenEvent(GuiScreen gui)
|
||||
public GuiScreenEvent(Screen gui)
|
||||
{
|
||||
this.gui = gui;
|
||||
}
|
||||
@@ -57,42 +56,42 @@ public class GuiScreenEvent extends Event
|
||||
/**
|
||||
* The GuiScreen object generating this event.
|
||||
*/
|
||||
public GuiScreen getGui()
|
||||
public Screen getGui()
|
||||
{
|
||||
return gui;
|
||||
}
|
||||
|
||||
public static class InitGuiEvent extends GuiScreenEvent
|
||||
{
|
||||
private Consumer<GuiButton> addButton;
|
||||
private Consumer<GuiButton> removeButton;
|
||||
private Consumer<Widget> add;
|
||||
private Consumer<Widget> remove;
|
||||
|
||||
private List<GuiButton> buttonList;
|
||||
private List<Widget> list;
|
||||
|
||||
public InitGuiEvent(GuiScreen gui, List<GuiButton> buttonList, Consumer<GuiButton> addButton, Consumer<GuiButton> removeButton)
|
||||
public InitGuiEvent(Screen gui, List<Widget> list, Consumer<Widget> add, Consumer<Widget> remove)
|
||||
{
|
||||
super(gui);
|
||||
this.buttonList = Collections.unmodifiableList(buttonList);
|
||||
this.addButton = addButton;
|
||||
this.removeButton = removeButton;
|
||||
this.list = Collections.unmodifiableList(list);
|
||||
this.add = add;
|
||||
this.remove = remove;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmodifiable reference to the list of buttons on the {@link #gui}.
|
||||
*/
|
||||
public List<GuiButton> getButtonList()
|
||||
public List<Widget> getWidgetList()
|
||||
{
|
||||
return buttonList;
|
||||
return list;
|
||||
}
|
||||
|
||||
public void addButton(GuiButton button)
|
||||
public void addWidget(Widget button)
|
||||
{
|
||||
addButton.accept(button);
|
||||
add.accept(button);
|
||||
}
|
||||
|
||||
public void removeButton(GuiButton button)
|
||||
public void removeWidget(Widget button)
|
||||
{
|
||||
removeButton.accept(button);
|
||||
remove.accept(button);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,9 +106,9 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends InitGuiEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, List<GuiButton> buttonList, Consumer<GuiButton> addButton, Consumer<GuiButton> removeButton)
|
||||
public Pre(Screen gui, List<Widget> list, Consumer<Widget> add, Consumer<Widget> remove)
|
||||
{
|
||||
super(gui, buttonList, addButton, removeButton);
|
||||
super(gui, list, add, remove);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,9 +118,9 @@ public class GuiScreenEvent extends Event
|
||||
*/
|
||||
public static class Post extends InitGuiEvent
|
||||
{
|
||||
public Post(GuiScreen gui, List<GuiButton> buttonList, Consumer<GuiButton> addButton, Consumer<GuiButton> removeButton)
|
||||
public Post(Screen gui, List<Widget> list, Consumer<Widget> add, Consumer<Widget> remove)
|
||||
{
|
||||
super(gui, buttonList, addButton, removeButton);
|
||||
super(gui, list, add, remove);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +131,7 @@ public class GuiScreenEvent extends Event
|
||||
private final int mouseY;
|
||||
private final float renderPartialTicks;
|
||||
|
||||
public DrawScreenEvent(GuiScreen gui, int mouseX, int mouseY, float renderPartialTicks)
|
||||
public DrawScreenEvent(Screen gui, int mouseX, int mouseY, float renderPartialTicks)
|
||||
{
|
||||
super(gui);
|
||||
this.mouseX = mouseX;
|
||||
@@ -171,7 +170,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends DrawScreenEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, int mouseX, int mouseY, float renderPartialTicks)
|
||||
public Pre(Screen gui, int mouseX, int mouseY, float renderPartialTicks)
|
||||
{
|
||||
super(gui, mouseX, mouseY, renderPartialTicks);
|
||||
}
|
||||
@@ -182,7 +181,7 @@ public class GuiScreenEvent extends Event
|
||||
*/
|
||||
public static class Post extends DrawScreenEvent
|
||||
{
|
||||
public Post(GuiScreen gui, int mouseX, int mouseY, float renderPartialTicks)
|
||||
public Post(Screen gui, int mouseX, int mouseY, float renderPartialTicks)
|
||||
{
|
||||
super(gui, mouseX, mouseY, renderPartialTicks);
|
||||
}
|
||||
@@ -195,7 +194,7 @@ public class GuiScreenEvent extends Event
|
||||
*/
|
||||
public static class BackgroundDrawnEvent extends GuiScreenEvent
|
||||
{
|
||||
public BackgroundDrawnEvent(GuiScreen gui)
|
||||
public BackgroundDrawnEvent(Screen gui)
|
||||
{
|
||||
super(gui);
|
||||
}
|
||||
@@ -209,7 +208,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class PotionShiftEvent extends GuiScreenEvent
|
||||
{
|
||||
public PotionShiftEvent(GuiScreen gui)
|
||||
public PotionShiftEvent(Screen gui)
|
||||
{
|
||||
super(gui);
|
||||
}
|
||||
@@ -217,25 +216,25 @@ public class GuiScreenEvent extends Event
|
||||
|
||||
public static class ActionPerformedEvent extends GuiScreenEvent
|
||||
{
|
||||
private GuiButton button;
|
||||
private List<GuiButton> buttonList;
|
||||
private Button button;
|
||||
private List<Button> buttonList;
|
||||
|
||||
public ActionPerformedEvent(GuiScreen gui, GuiButton button, List<GuiButton> buttonList)
|
||||
public ActionPerformedEvent(Screen gui, Button button, List<Button> buttonList)
|
||||
{
|
||||
super(gui);
|
||||
this.setButton(button);
|
||||
this.setButtonList(new ArrayList<GuiButton>(buttonList));
|
||||
this.setButtonList(new ArrayList<Button>(buttonList));
|
||||
}
|
||||
|
||||
/**
|
||||
* The button that was clicked.
|
||||
*/
|
||||
public GuiButton getButton()
|
||||
public Button getButton()
|
||||
{
|
||||
return button;
|
||||
}
|
||||
|
||||
public void setButton(GuiButton button)
|
||||
public void setButton(Button button)
|
||||
{
|
||||
this.button = button;
|
||||
}
|
||||
@@ -243,12 +242,12 @@ public class GuiScreenEvent extends Event
|
||||
/**
|
||||
* A COPY of the {@link #buttonList} field from the GuiScreen referenced by {@link #gui}.
|
||||
*/
|
||||
public List<GuiButton> getButtonList()
|
||||
public List<Button> getButtonList()
|
||||
{
|
||||
return buttonList;
|
||||
}
|
||||
|
||||
public void setButtonList(List<GuiButton> buttonList)
|
||||
public void setButtonList(List<Button> buttonList)
|
||||
{
|
||||
this.buttonList = buttonList;
|
||||
}
|
||||
@@ -261,7 +260,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends ActionPerformedEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, GuiButton button, List<GuiButton> buttonList)
|
||||
public Pre(Screen gui, Button button, List<Button> buttonList)
|
||||
{
|
||||
super(gui, button, buttonList);
|
||||
}
|
||||
@@ -273,7 +272,7 @@ public class GuiScreenEvent extends Event
|
||||
*/
|
||||
public static class Post extends ActionPerformedEvent
|
||||
{
|
||||
public Post(GuiScreen gui, GuiButton button, List<GuiButton> buttonList)
|
||||
public Post(Screen gui, Button button, List<Button> buttonList)
|
||||
{
|
||||
super(gui, button, buttonList);
|
||||
}
|
||||
@@ -285,7 +284,7 @@ public class GuiScreenEvent extends Event
|
||||
private final double mouseX;
|
||||
private final double mouseY;
|
||||
|
||||
public MouseInputEvent(GuiScreen gui, double mouseX, double mouseY)
|
||||
public MouseInputEvent(Screen gui, double mouseX, double mouseY)
|
||||
{
|
||||
super(gui);
|
||||
this.mouseX = mouseX;
|
||||
@@ -307,7 +306,7 @@ public class GuiScreenEvent extends Event
|
||||
{
|
||||
private final int button;
|
||||
|
||||
public MouseClickedEvent(GuiScreen gui, double mouseX, double mouseY, int button)
|
||||
public MouseClickedEvent(Screen gui, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(gui, mouseX, mouseY);
|
||||
this.button = button;
|
||||
@@ -325,7 +324,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends MouseClickedEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, double mouseX, double mouseY, int button)
|
||||
public Pre(Screen gui, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(gui, mouseX, mouseY, button);
|
||||
}
|
||||
@@ -338,7 +337,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Post extends MouseClickedEvent
|
||||
{
|
||||
public Post(GuiScreen gui, double mouseX, double mouseY, int button)
|
||||
public Post(Screen gui, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(gui, mouseX, mouseY, button);
|
||||
}
|
||||
@@ -349,7 +348,7 @@ public class GuiScreenEvent extends Event
|
||||
{
|
||||
private final int button;
|
||||
|
||||
public MouseReleasedEvent(GuiScreen gui, double mouseX, double mouseY, int button)
|
||||
public MouseReleasedEvent(Screen gui, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(gui, mouseX, mouseY);
|
||||
this.button = button;
|
||||
@@ -367,7 +366,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends MouseReleasedEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, double mouseX, double mouseY, int button)
|
||||
public Pre(Screen gui, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(gui, mouseX, mouseY, button);
|
||||
}
|
||||
@@ -380,7 +379,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Post extends MouseReleasedEvent
|
||||
{
|
||||
public Post(GuiScreen gui, double mouseX, double mouseY, int button)
|
||||
public Post(Screen gui, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(gui, mouseX, mouseY, button);
|
||||
}
|
||||
@@ -393,7 +392,7 @@ public class GuiScreenEvent extends Event
|
||||
private final double dragX;
|
||||
private final double dragY;
|
||||
|
||||
public MouseDragEvent(GuiScreen gui, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
public MouseDragEvent(Screen gui, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
super(gui, mouseX, mouseY);
|
||||
this.mouseButton = mouseButton;
|
||||
@@ -423,7 +422,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends MouseDragEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
public Pre(Screen gui, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
super(gui, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
}
|
||||
@@ -436,7 +435,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Post extends MouseDragEvent
|
||||
{
|
||||
public Post(GuiScreen gui, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
public Post(Screen gui, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
super(gui, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
}
|
||||
@@ -447,7 +446,7 @@ public class GuiScreenEvent extends Event
|
||||
{
|
||||
private final double scrollDelta;
|
||||
|
||||
public MouseScrollEvent(GuiScreen gui, double mouseX, double mouseY, double scrollDelta)
|
||||
public MouseScrollEvent(Screen gui, double mouseX, double mouseY, double scrollDelta)
|
||||
{
|
||||
super(gui, mouseX, mouseY);
|
||||
this.scrollDelta = scrollDelta;
|
||||
@@ -465,7 +464,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends MouseScrollEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, double mouseX, double mouseY, double scrollDelta)
|
||||
public Pre(Screen gui, double mouseX, double mouseY, double scrollDelta)
|
||||
{
|
||||
super(gui, mouseX, mouseY, scrollDelta);
|
||||
}
|
||||
@@ -478,7 +477,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Post extends MouseScrollEvent
|
||||
{
|
||||
public Post(GuiScreen gui, double mouseX, double mouseY, double scrollDelta)
|
||||
public Post(Screen gui, double mouseX, double mouseY, double scrollDelta)
|
||||
{
|
||||
super(gui, mouseX, mouseY, scrollDelta);
|
||||
}
|
||||
@@ -491,7 +490,7 @@ public class GuiScreenEvent extends Event
|
||||
private final int scanCode;
|
||||
private final int modifiers;
|
||||
|
||||
public KeyboardKeyEvent(GuiScreen gui, int keyCode, int scanCode, int modifiers)
|
||||
public KeyboardKeyEvent(Screen gui, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(gui);
|
||||
this.keyCode = keyCode;
|
||||
@@ -540,7 +539,7 @@ public class GuiScreenEvent extends Event
|
||||
|
||||
public static abstract class KeyboardKeyPressedEvent extends KeyboardKeyEvent
|
||||
{
|
||||
public KeyboardKeyPressedEvent(GuiScreen gui, int keyCode, int scanCode, int modifiers)
|
||||
public KeyboardKeyPressedEvent(Screen gui, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(gui, keyCode, scanCode, modifiers);
|
||||
}
|
||||
@@ -552,7 +551,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends KeyboardKeyPressedEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, int keyCode, int scanCode, int modifiers)
|
||||
public Pre(Screen gui, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(gui, keyCode, scanCode, modifiers);
|
||||
}
|
||||
@@ -565,7 +564,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Post extends KeyboardKeyPressedEvent
|
||||
{
|
||||
public Post(GuiScreen gui, int keyCode, int scanCode, int modifiers)
|
||||
public Post(Screen gui, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(gui, keyCode, scanCode, modifiers);
|
||||
}
|
||||
@@ -574,7 +573,7 @@ public class GuiScreenEvent extends Event
|
||||
|
||||
public static abstract class KeyboardKeyReleasedEvent extends KeyboardKeyEvent
|
||||
{
|
||||
public KeyboardKeyReleasedEvent(GuiScreen gui, int keyCode, int scanCode, int modifiers)
|
||||
public KeyboardKeyReleasedEvent(Screen gui, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(gui, keyCode, scanCode, modifiers);
|
||||
}
|
||||
@@ -586,7 +585,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends KeyboardKeyReleasedEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, int keyCode, int scanCode, int modifiers)
|
||||
public Pre(Screen gui, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(gui, keyCode, scanCode, modifiers);
|
||||
}
|
||||
@@ -599,7 +598,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Post extends KeyboardKeyReleasedEvent
|
||||
{
|
||||
public Post(GuiScreen gui, int keyCode, int scanCode, int modifiers)
|
||||
public Post(Screen gui, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(gui, keyCode, scanCode, modifiers);
|
||||
}
|
||||
@@ -611,7 +610,7 @@ public class GuiScreenEvent extends Event
|
||||
private final char codePoint;
|
||||
private final int modifiers;
|
||||
|
||||
public KeyboardCharTypedEvent(GuiScreen gui, char codePoint, int modifiers)
|
||||
public KeyboardCharTypedEvent(Screen gui, char codePoint, int modifiers)
|
||||
{
|
||||
super(gui);
|
||||
this.codePoint = codePoint;
|
||||
@@ -646,7 +645,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends KeyboardCharTypedEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, char codePoint, int modifiers)
|
||||
public Pre(Screen gui, char codePoint, int modifiers)
|
||||
{
|
||||
super(gui, codePoint, modifiers);
|
||||
}
|
||||
@@ -659,7 +658,7 @@ public class GuiScreenEvent extends Event
|
||||
@Cancelable
|
||||
public static class Post extends KeyboardCharTypedEvent
|
||||
{
|
||||
public Post(GuiScreen gui, char codePoint, int modifiers)
|
||||
public Post(Screen gui, char codePoint, int modifiers)
|
||||
{
|
||||
super(gui, codePoint, modifiers);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.MovementInput;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class InputUpdateEvent extends PlayerEvent
|
||||
{
|
||||
private final MovementInput movementInput;
|
||||
|
||||
public InputUpdateEvent(EntityPlayer player, MovementInput movementInput)
|
||||
public InputUpdateEvent(PlayerEntity player, MovementInput movementInput)
|
||||
{
|
||||
super(player);
|
||||
this.movementInput = movementInput;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -36,7 +36,7 @@ public class PlayerSPPushOutOfBlocksEvent extends PlayerEvent
|
||||
{
|
||||
private AxisAlignedBB entityBoundingBox;
|
||||
|
||||
public PlayerSPPushOutOfBlocksEvent(EntityPlayer player, AxisAlignedBB entityBoundingBox)
|
||||
public PlayerSPPushOutOfBlocksEvent(PlayerEntity player, AxisAlignedBB entityBoundingBox)
|
||||
{
|
||||
super(player);
|
||||
this.entityBoundingBox = entityBoundingBox;
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -37,13 +37,13 @@ public class RenderBlockOverlayEvent extends net.minecraftforge.eventbus.api.Eve
|
||||
FIRE, BLOCK, WATER
|
||||
}
|
||||
|
||||
private final EntityPlayer player;
|
||||
private final PlayerEntity player;
|
||||
private final float renderPartialTicks;
|
||||
private final OverlayType overlayType;
|
||||
private final IBlockState blockForOverlay;
|
||||
private final BlockState blockForOverlay;
|
||||
private final BlockPos blockPos;
|
||||
|
||||
public RenderBlockOverlayEvent(EntityPlayer player, float renderPartialTicks, OverlayType type, IBlockState block, BlockPos blockPos)
|
||||
public RenderBlockOverlayEvent(PlayerEntity player, float renderPartialTicks, OverlayType type, BlockState block, BlockPos blockPos)
|
||||
{
|
||||
this.player = player;
|
||||
this.renderPartialTicks = renderPartialTicks;
|
||||
@@ -56,7 +56,7 @@ public class RenderBlockOverlayEvent extends net.minecraftforge.eventbus.api.Eve
|
||||
/**
|
||||
* The player which the overlay will apply to
|
||||
*/
|
||||
public EntityPlayer getPlayer() { return player; }
|
||||
public PlayerEntity getPlayer() { return player; }
|
||||
public float getRenderPartialTicks() { return renderPartialTicks; }
|
||||
/**
|
||||
* The type of overlay to occur
|
||||
@@ -65,6 +65,6 @@ public class RenderBlockOverlayEvent extends net.minecraftforge.eventbus.api.Eve
|
||||
/**
|
||||
* If the overlay type is BLOCK, then this is the block which the overlay is getting it's icon from
|
||||
*/
|
||||
public IBlockState getBlockForOverlay() { return blockForOverlay; }
|
||||
public BlockState getBlockForOverlay() { return blockForOverlay; }
|
||||
public BlockPos getBlockPos() { return blockPos; }
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import java.util.ArrayList;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.MainWindow;
|
||||
import net.minecraft.client.gui.BossInfoClient;
|
||||
import net.minecraft.client.gui.ClientBossInfo;
|
||||
|
||||
@Cancelable
|
||||
public class RenderGameOverlayEvent extends Event
|
||||
@@ -99,11 +99,11 @@ public class RenderGameOverlayEvent extends Event
|
||||
|
||||
public static class BossInfo extends Pre
|
||||
{
|
||||
private final BossInfoClient bossInfo;
|
||||
private final ClientBossInfo bossInfo;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private int increment;
|
||||
public BossInfo(RenderGameOverlayEvent parent, ElementType type, BossInfoClient bossInfo, int x, int y, int increment)
|
||||
public BossInfo(RenderGameOverlayEvent parent, ElementType type, ClientBossInfo bossInfo, int x, int y, int increment)
|
||||
{
|
||||
super(parent, type);
|
||||
this.bossInfo = bossInfo;
|
||||
@@ -115,7 +115,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
/**
|
||||
* @return The {@link BossInfoClient} currently being rendered
|
||||
*/
|
||||
public BossInfoClient getBossInfo()
|
||||
public ClientBossInfo getBossInfo()
|
||||
{
|
||||
return bossInfo;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItemFrame;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
|
||||
import net.minecraft.entity.item.ItemFrameEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -36,10 +36,10 @@ import javax.annotation.Nonnull;
|
||||
public class RenderItemInFrameEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final ItemStack item;
|
||||
private final EntityItemFrame entityItemFrame;
|
||||
private final RenderItemFrame renderer;
|
||||
private final ItemFrameEntity entityItemFrame;
|
||||
private final ItemFrameRenderer renderer;
|
||||
|
||||
public RenderItemInFrameEvent(EntityItemFrame itemFrame, RenderItemFrame renderItemFrame)
|
||||
public RenderItemInFrameEvent(ItemFrameEntity itemFrame, ItemFrameRenderer renderItemFrame)
|
||||
{
|
||||
item = itemFrame.getDisplayedItem();
|
||||
entityItemFrame = itemFrame;
|
||||
@@ -52,12 +52,12 @@ public class RenderItemInFrameEvent extends net.minecraftforge.eventbus.api.Even
|
||||
return item;
|
||||
}
|
||||
|
||||
public EntityItemFrame getEntityItemFrame()
|
||||
public ItemFrameEntity getEntityItemFrame()
|
||||
{
|
||||
return entityItemFrame;
|
||||
}
|
||||
|
||||
public RenderItemFrame getRenderer()
|
||||
public ItemFrameRenderer getRenderer()
|
||||
{
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@@ -21,19 +21,20 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.client.renderer.entity.LivingRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
public abstract class RenderLivingEvent<T extends EntityLivingBase> extends net.minecraftforge.eventbus.api.Event
|
||||
public abstract class RenderLivingEvent<T extends LivingEntity, M extends EntityModel<T>> extends Event
|
||||
{
|
||||
private final EntityLivingBase entity;
|
||||
private final RenderLivingBase<T> renderer;
|
||||
private final LivingEntity entity;
|
||||
private final LivingRenderer<T, M> renderer;
|
||||
private final float partialRenderTick;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
public RenderLivingEvent(EntityLivingBase entity, RenderLivingBase<T> renderer, float partialRenderTick, double x, double y, double z)
|
||||
public RenderLivingEvent(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, double x, double y, double z)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.renderer = renderer;
|
||||
@@ -43,35 +44,35 @@ public abstract class RenderLivingEvent<T extends EntityLivingBase> extends net.
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public EntityLivingBase getEntity() { return entity; }
|
||||
public RenderLivingBase<T> getRenderer() { return renderer; }
|
||||
public LivingEntity getEntity() { return entity; }
|
||||
public LivingRenderer<T, M> getRenderer() { return renderer; }
|
||||
public float getPartialRenderTick() { return partialRenderTick; }
|
||||
public double getX() { return x; }
|
||||
public double getY() { return y; }
|
||||
public double getZ() { return z; }
|
||||
|
||||
@net.minecraftforge.eventbus.api.Cancelable
|
||||
public static class Pre<T extends EntityLivingBase> extends RenderLivingEvent<T>
|
||||
@Cancelable
|
||||
public static class Pre<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
public Pre(EntityLivingBase entity, RenderLivingBase<T> renderer, float partialRenderTick, double x, double y, double z){ super(entity, renderer, partialRenderTick, x, y, z); }
|
||||
public Pre(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, double x, double y, double z){ super(entity, renderer, partialRenderTick, x, y, z); }
|
||||
}
|
||||
public static class Post<T extends EntityLivingBase> extends RenderLivingEvent<T>
|
||||
public static class Post<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
public Post(EntityLivingBase entity, RenderLivingBase<T> renderer, float partialRenderTick, double x, double y, double z){ super(entity, renderer, partialRenderTick, x, y, z); }
|
||||
public Post(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, double x, double y, double z){ super(entity, renderer, partialRenderTick, x, y, z); }
|
||||
}
|
||||
|
||||
public abstract static class Specials<T extends EntityLivingBase> extends RenderLivingEvent<T>
|
||||
public abstract static class Specials<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
public Specials(EntityLivingBase entity, RenderLivingBase<T> renderer, double x, double y, double z){ super(entity, renderer, 0, x, y, z); }
|
||||
public Specials(LivingEntity entity, LivingRenderer<T, M> renderer, double x, double y, double z){ super(entity, renderer, 0, x, y, z); }
|
||||
|
||||
@net.minecraftforge.eventbus.api.Cancelable
|
||||
public static class Pre<T extends EntityLivingBase> extends Specials<T>
|
||||
@Cancelable
|
||||
public static class Pre<T extends LivingEntity, M extends EntityModel<T>> extends Specials<T, M>
|
||||
{
|
||||
public Pre(EntityLivingBase entity, RenderLivingBase<T> renderer, double x, double y, double z){ super(entity, renderer, x, y, z); }
|
||||
public Pre(LivingEntity entity, LivingRenderer<T, M> renderer, double x, double y, double z){ super(entity, renderer, x, y, z); }
|
||||
}
|
||||
public static class Post<T extends EntityLivingBase> extends Specials<T>
|
||||
public static class Post<T extends LivingEntity, M extends EntityModel<T>> extends Specials<T, M>
|
||||
{
|
||||
public Post(EntityLivingBase entity, RenderLivingBase<T> renderer, double x, double y, double z){ super(entity, renderer, x, y, z); }
|
||||
public Post(LivingEntity entity, LivingRenderer<T, M> renderer, double x, double y, double z){ super(entity, renderer, x, y, z); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,8 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.client.renderer.entity.PlayerRenderer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
@@ -29,13 +29,13 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
{
|
||||
private final RenderPlayer renderer;
|
||||
private final PlayerRenderer renderer;
|
||||
private final float partialRenderTick;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
public RenderPlayerEvent(EntityPlayer player, RenderPlayer renderer, float partialRenderTick, double x, double y, double z)
|
||||
public RenderPlayerEvent(PlayerEntity player, PlayerRenderer renderer, float partialRenderTick, double x, double y, double z)
|
||||
{
|
||||
super(player);
|
||||
this.renderer = renderer;
|
||||
@@ -45,7 +45,7 @@ public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public RenderPlayer getRenderer() { return renderer; }
|
||||
public PlayerRenderer getRenderer() { return renderer; }
|
||||
public float getPartialRenderTick() { return partialRenderTick; }
|
||||
public double getX() { return x; }
|
||||
public double getY() { return y; }
|
||||
@@ -54,12 +54,12 @@ public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
@net.minecraftforge.eventbus.api.Cancelable
|
||||
public static class Pre extends RenderPlayerEvent
|
||||
{
|
||||
public Pre(EntityPlayer player, RenderPlayer renderer, float tick, double x, double y, double z){ super(player, renderer, tick, x, y, z); }
|
||||
public Pre(PlayerEntity player, PlayerRenderer renderer, float tick, double x, double y, double z){ super(player, renderer, tick, x, y, z); }
|
||||
}
|
||||
|
||||
public static class Post extends RenderPlayerEvent
|
||||
{
|
||||
public Post(EntityPlayer player, RenderPlayer renderer, float tick, double x, double y, double z){ super(player, renderer, tick, x, y, z); }
|
||||
public Post(PlayerEntity player, PlayerRenderer renderer, float tick, double x, double y, double z){ super(player, renderer, tick, x, y, z); }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@@ -35,7 +35,7 @@ import javax.annotation.Nonnull;
|
||||
@Cancelable
|
||||
public class RenderSpecificHandEvent extends Event
|
||||
{
|
||||
private final EnumHand hand;
|
||||
private final Hand hand;
|
||||
private final float partialTicks;
|
||||
private final float interpolatedPitch;
|
||||
private final float swingProgress;
|
||||
@@ -43,7 +43,7 @@ public class RenderSpecificHandEvent extends Event
|
||||
@Nonnull
|
||||
private final ItemStack stack;
|
||||
|
||||
public RenderSpecificHandEvent(EnumHand hand, float partialTicks, float interpolatedPitch, float swingProgress, float equipProgress, @Nonnull ItemStack stack)
|
||||
public RenderSpecificHandEvent(Hand hand, float partialTicks, float interpolatedPitch, float swingProgress, float equipProgress, @Nonnull ItemStack stack)
|
||||
{
|
||||
this.hand = hand;
|
||||
this.partialTicks = partialTicks;
|
||||
@@ -53,7 +53,7 @@ public class RenderSpecificHandEvent extends Event
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public EnumHand getHand()
|
||||
public Hand getHand()
|
||||
{
|
||||
return hand;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.io.File;
|
||||
public class ScreenshotEvent extends Event
|
||||
{
|
||||
|
||||
public static final ITextComponent DEFAULT_CANCEL_REASON = new TextComponentString("Screenshot canceled");
|
||||
public static final ITextComponent DEFAULT_CANCEL_REASON = new StringTextComponent("Screenshot canceled");
|
||||
|
||||
private NativeImage image;
|
||||
private File screenshotFile;
|
||||
|
||||
@@ -20,19 +20,19 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
|
||||
|
||||
public class TextureStitchEvent extends Event
|
||||
{
|
||||
private final TextureMap map;
|
||||
private final AtlasTexture map;
|
||||
|
||||
public TextureStitchEvent(TextureMap map)
|
||||
public TextureStitchEvent(AtlasTexture map)
|
||||
{
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public TextureMap getMap()
|
||||
public AtlasTexture getMap()
|
||||
{
|
||||
return map;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class TextureStitchEvent extends Event
|
||||
*/
|
||||
public static class Pre extends TextureStitchEvent
|
||||
{
|
||||
public Pre(TextureMap map){ super(map); }
|
||||
public Pre(AtlasTexture map){ super(map); }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,6 +54,6 @@ public class TextureStitchEvent extends Event
|
||||
*/
|
||||
public static class Post extends TextureStitchEvent
|
||||
{
|
||||
public Post(TextureMap map){ super(map); }
|
||||
public Post(AtlasTexture map){ super(map); }
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
|
||||
/***
|
||||
* Raised when the SoundManager tries to play a normal sound.
|
||||
@@ -34,7 +34,7 @@ public class PlaySoundEvent extends SoundEvent
|
||||
private final ISound sound;
|
||||
private ISound result;
|
||||
|
||||
public PlaySoundEvent(SoundManager manager, ISound sound)
|
||||
public PlaySoundEvent(SoundEngine manager, ISound sound)
|
||||
{
|
||||
super(manager);
|
||||
this.sound = sound;
|
||||
|
||||
@@ -20,13 +20,14 @@
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.audio.SoundSource;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
|
||||
public class PlaySoundSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
public PlaySoundSourceEvent(SoundManager manager, ISound sound, String uuid)
|
||||
public PlaySoundSourceEvent(SoundEngine manager, ISound sound, SoundSource source)
|
||||
{
|
||||
super(manager, sound, uuid);
|
||||
super(manager, sound, source);
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,14 @@
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.audio.SoundSource;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
|
||||
public class PlayStreamingSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
public PlayStreamingSourceEvent(SoundManager manager, ISound sound, String uuid)
|
||||
public PlayStreamingSourceEvent(SoundEngine manager, ISound sound, SoundSource source)
|
||||
{
|
||||
super(manager, sound, uuid);
|
||||
super(manager, sound, source);
|
||||
}
|
||||
}
|
||||
@@ -21,17 +21,18 @@ package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
import net.minecraft.client.audio.SoundSource;
|
||||
|
||||
public class SoundEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final SoundManager manager;
|
||||
public SoundEvent(SoundManager manager)
|
||||
private final SoundEngine manager;
|
||||
public SoundEvent(SoundEngine manager)
|
||||
{
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
public SoundManager getManager()
|
||||
public SoundEngine getManager()
|
||||
{
|
||||
return manager;
|
||||
}
|
||||
@@ -39,15 +40,15 @@ public class SoundEvent extends net.minecraftforge.eventbus.api.Event
|
||||
public static class SoundSourceEvent extends SoundEvent
|
||||
{
|
||||
private final ISound sound;
|
||||
private final String uuid;
|
||||
private final SoundSource source;
|
||||
private final String name;
|
||||
|
||||
public SoundSourceEvent(SoundManager manager, ISound sound, String uuid)
|
||||
public SoundSourceEvent(SoundEngine manager, ISound sound, SoundSource source)
|
||||
{
|
||||
super(manager);
|
||||
this.name = sound.getSoundLocation().getPath();
|
||||
this.sound = sound;
|
||||
this.uuid = uuid;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public ISound getSound()
|
||||
@@ -55,9 +56,9 @@ public class SoundEvent extends net.minecraftforge.eventbus.api.Event
|
||||
return sound;
|
||||
}
|
||||
|
||||
public String getUuid()
|
||||
public SoundSource getSource()
|
||||
{
|
||||
return uuid;
|
||||
return source;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
|
||||
/**
|
||||
* Raised by the SoundManager.loadSoundSettings, this would be a good place for
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.client.audio.SoundManager;
|
||||
*/
|
||||
public class SoundLoadEvent extends SoundEvent
|
||||
{
|
||||
public SoundLoadEvent(SoundManager manager)
|
||||
public SoundLoadEvent(SoundEngine manager)
|
||||
{
|
||||
super(manager);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundEngine;
|
||||
|
||||
/**
|
||||
* This event is raised by the SoundManager when it does its first setup of the
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.client.audio.SoundManager;
|
||||
*/
|
||||
public class SoundSetupEvent extends SoundEvent
|
||||
{
|
||||
public SoundSetupEvent(SoundManager manager)
|
||||
public SoundSetupEvent(SoundEngine manager)
|
||||
{
|
||||
super(manager);
|
||||
}
|
||||
|
||||
@@ -25,30 +25,30 @@ import java.util.Random;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
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.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.IEnviromentBlockReader;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
public interface IForgeBakedModel
|
||||
{
|
||||
{
|
||||
default IBakedModel getBakedModel()
|
||||
{
|
||||
return (IBakedModel) this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
default List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, @Nonnull Random rand, @Nonnull IModelData extraData)
|
||||
default List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData)
|
||||
{
|
||||
return getBakedModel().getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
default boolean isAmbientOcclusion(IBlockState state) { return getBakedModel().isAmbientOcclusion(); }
|
||||
|
||||
default boolean isAmbientOcclusion(BlockState state) { return getBakedModel().isAmbientOcclusion(); }
|
||||
|
||||
/*
|
||||
* 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).
|
||||
@@ -57,8 +57,8 @@ public interface IForgeBakedModel
|
||||
{
|
||||
return net.minecraftforge.client.ForgeHooksClient.handlePerspective(getBakedModel(), cameraTransformType);
|
||||
}
|
||||
|
||||
default @Nonnull IModelData getModelData(@Nonnull IWorldReader world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull IModelData tileData)
|
||||
|
||||
default @Nonnull IModelData getModelData(@Nonnull IEnviromentBlockReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
{
|
||||
return tileData;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.client.renderer.chunk.RenderChunkCache;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderCache;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -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 RenderChunkCache createRegionRenderCache(World world, BlockPos from, BlockPos to, int subtract)
|
||||
default ChunkRenderCache createRegionRenderCache(World world, BlockPos from, BlockPos to, int subtract)
|
||||
{
|
||||
return RenderChunkCache.func_212397_a(world, from, to, subtract);
|
||||
return ChunkRenderCache.generateCache(world, from, to, subtract);
|
||||
}
|
||||
}
|
||||
@@ -19,12 +19,14 @@
|
||||
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
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.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
@@ -33,22 +35,23 @@ import net.minecraftforge.fml.client.ClientModLoader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class NotificationModUpdateScreen extends GuiScreen
|
||||
public class NotificationModUpdateScreen extends Screen
|
||||
{
|
||||
|
||||
private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png");
|
||||
|
||||
private final GuiButton modButton;
|
||||
private final Button modButton;
|
||||
private VersionChecker.Status showNotification = null;
|
||||
private boolean hasCheckedForUpdates = false;
|
||||
|
||||
public NotificationModUpdateScreen(GuiButton modButton)
|
||||
public NotificationModUpdateScreen(Button modButton)
|
||||
{
|
||||
super(new TranslationTextComponent("forge.menu.updatescreen.title"));
|
||||
this.modButton = modButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
public void init()
|
||||
{
|
||||
if (!hasCheckedForUpdates)
|
||||
{
|
||||
@@ -74,18 +77,18 @@ public class NotificationModUpdateScreen extends GuiScreen
|
||||
|
||||
int x = modButton.x;
|
||||
int y = modButton.y;
|
||||
int w = modButton.width;
|
||||
int h = modButton.height;
|
||||
int w = modButton.getWidth();
|
||||
int h = modButton.getHeight();
|
||||
|
||||
drawModalRectWithCustomSizedTexture(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);
|
||||
blit(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);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public static NotificationModUpdateScreen init(GuiMainMenu guiMainMenu, GuiButton modButton)
|
||||
public static NotificationModUpdateScreen init(MainMenuScreen guiMainMenu, Button modButton)
|
||||
{
|
||||
NotificationModUpdateScreen notificationModUpdateScreen = new NotificationModUpdateScreen(modButton);
|
||||
notificationModUpdateScreen.setWorldAndResolution(guiMainMenu.mc, guiMainMenu.width, guiMainMenu.height);
|
||||
notificationModUpdateScreen.initGui();
|
||||
notificationModUpdateScreen.init(guiMainMenu.getMinecraft(), guiMainMenu.width, guiMainMenu.height);
|
||||
notificationModUpdateScreen.init();
|
||||
return notificationModUpdateScreen;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ package net.minecraftforge.client.model;
|
||||
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumType;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.Type;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.Usage;
|
||||
|
||||
public class Attributes
|
||||
{
|
||||
@@ -34,10 +34,10 @@ public class Attributes
|
||||
static
|
||||
{
|
||||
DEFAULT_BAKED_FORMAT = new VertexFormat();
|
||||
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, EnumType.FLOAT, EnumUsage.POSITION, 3));
|
||||
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, EnumType.UBYTE, EnumUsage.COLOR, 4));
|
||||
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, EnumType.FLOAT, EnumUsage.UV, 2));
|
||||
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, EnumType.BYTE, EnumUsage.PADDING, 4));
|
||||
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, Type.FLOAT, Usage.POSITION, 3));
|
||||
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, Type.UBYTE, Usage.COLOR, 4));
|
||||
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, Type.FLOAT, Usage.UV, 2));
|
||||
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, Type.BYTE, Usage.PADDING, 4));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -52,7 +52,7 @@ public class Attributes
|
||||
int j = 0;
|
||||
for(VertexFormatElement firstAttr : first.getElements())
|
||||
{
|
||||
while(j < second.getElementCount() && second.getElement(j).getUsage() == EnumUsage.PADDING)
|
||||
while(j < second.getElementCount() && second.getElement(j).getUsage() == Usage.PADDING)
|
||||
{
|
||||
padding += second.getElement(j++).getSize();
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ import java.util.Random;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
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.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class BakedItemModel implements IBakedModel
|
||||
@Override public ItemOverrideList getOverrides() { return overrides; }
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand)
|
||||
{
|
||||
if (side == null)
|
||||
{
|
||||
@@ -103,7 +103,7 @@ public class BakedItemModel implements IBakedModel
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
for (BakedQuad quad : originalModel.quads)
|
||||
{
|
||||
if (quad.getFace() == EnumFacing.SOUTH)
|
||||
if (quad.getFace() == Direction.SOUTH)
|
||||
{
|
||||
builder.add(quad);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class BakedItemModel implements IBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads (@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
public List<BakedQuad> getQuads (@Nullable BlockState state, @Nullable Direction side, Random rand)
|
||||
{
|
||||
if(side == null)
|
||||
{
|
||||
|
||||
@@ -24,13 +24,13 @@ import javax.vecmath.Matrix4f;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
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 net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public abstract class BakedModelWrapper<T extends IBakedModel> implements IBakedModel
|
||||
@@ -43,7 +43,7 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand)
|
||||
{
|
||||
return originalModel.getQuads(state, side, rand);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion(IBlockState state)
|
||||
public boolean isAmbientOcclusion(BlockState state)
|
||||
{
|
||||
return originalModel.isAmbientOcclusion(state);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
|
||||
public class BasicState implements ISprite
|
||||
{
|
||||
private final IModelState defaultState;
|
||||
private final boolean uvLock;
|
||||
|
||||
public BasicState(IModelState defaultState, boolean uvLock)
|
||||
{
|
||||
this.defaultState = defaultState;
|
||||
this.uvLock = uvLock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getState()
|
||||
{
|
||||
return defaultState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUvLock()
|
||||
{
|
||||
return uvLock;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.model.BlockModelDefinition;
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.model.Variant;
|
||||
import net.minecraft.client.renderer.model.VariantList;
|
||||
@@ -75,7 +75,7 @@ public class BlockStateLoader
|
||||
*
|
||||
* @return Model definition including variants for all known combinations.
|
||||
*/
|
||||
public static ModelBlockDefinition load(Reader reader, ResourceLocation location, final Gson vanillaGSON)
|
||||
public static BlockModelDefinition load(Reader reader, ResourceLocation location, final Gson vanillaGSON)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -106,10 +106,10 @@ public class BlockStateLoader
|
||||
variants.put(entry.getKey(), new VariantList(mcVars));
|
||||
}
|
||||
|
||||
return new ModelBlockDefinition(variants, null);
|
||||
return new BlockModelDefinition(variants, null);
|
||||
|
||||
default: //Unknown version.. try loading it as normal.
|
||||
return vanillaGSON.fromJson(reader, ModelBlockDefinition.class);
|
||||
return vanillaGSON.fromJson(reader, BlockModelDefinition.class);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
|
||||
@@ -26,16 +26,13 @@ import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
@@ -100,18 +97,19 @@ final class FancyMissingModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
IBakedModel bigMissing = missingModel.bake(modelGetter, bakedTextureGetter, state, uvlock, format);
|
||||
IModelState smallState = new ModelStateComposition(state, smallTransformation);
|
||||
IBakedModel smallMissing = missingModel.bake(modelGetter, bakedTextureGetter, smallState, uvlock, format);
|
||||
return new BakedModel(bigMissing, smallMissing, fontCache.getUnchecked(format), message, bakedTextureGetter.apply(font2));
|
||||
IBakedModel bigMissing = missingModel.bake(modelGetter, spriteGetter, sprite, format);
|
||||
ModelStateComposition smallState = new ModelStateComposition(sprite.getState(), smallTransformation);
|
||||
IBakedModel smallMissing = missingModel.bake(modelGetter, spriteGetter, smallState, format);
|
||||
return new BakedModel(bigMissing, smallMissing, fontCache.getUnchecked(format), message, spriteGetter.apply(font2));
|
||||
}
|
||||
|
||||
static final class BakedModel implements IBakedModel
|
||||
@@ -145,7 +143,7 @@ final class FancyMissingModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand)
|
||||
{
|
||||
if (side == null)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.BlockStateLoader.Marker;
|
||||
import net.minecraftforge.client.model.BlockStateLoader.SubModel;
|
||||
@@ -76,7 +76,7 @@ public class ForgeBlockStateV1 extends Marker
|
||||
{
|
||||
JsonObject json = element.getAsJsonObject();
|
||||
ForgeBlockStateV1 ret = new ForgeBlockStateV1();
|
||||
ret.forge_marker = JsonUtils.getInt(json, "forge_marker");
|
||||
ret.forge_marker = JSONUtils.getInt(json, "forge_marker");
|
||||
|
||||
if (json.has("defaults")) // Load defaults Variant.
|
||||
{
|
||||
@@ -89,7 +89,7 @@ public class ForgeBlockStateV1 extends Marker
|
||||
Map<String, Map<String, ForgeBlockStateV1.Variant>> condensed = Maps.newLinkedHashMap(); // map(property name -> map(property value -> variant))
|
||||
Multimap<String, ForgeBlockStateV1.Variant> specified = LinkedHashMultimap.create(); // Multimap containing all the states specified with "property=value".
|
||||
|
||||
for (Entry<String, JsonElement> e : JsonUtils.getJsonObject(json, "variants").entrySet())
|
||||
for (Entry<String, JsonElement> e : JSONUtils.getJsonObject(json, "variants").entrySet())
|
||||
{
|
||||
if (e.getValue().isJsonArray())
|
||||
{
|
||||
@@ -470,7 +470,7 @@ public class ForgeBlockStateV1 extends Marker
|
||||
if (json.get("model").isJsonNull())
|
||||
ret.model = null; // Allow overriding base model to remove it from a state.
|
||||
else
|
||||
ret.model = getBlockLocation(JsonUtils.getString(json, "model"));
|
||||
ret.model = getBlockLocation(JSONUtils.getString(json, "model"));
|
||||
ret.modelSet = true;
|
||||
}
|
||||
|
||||
@@ -487,8 +487,8 @@ public class ForgeBlockStateV1 extends Marker
|
||||
|
||||
if (json.has("x") || json.has("y"))
|
||||
{ // Load rotation values.
|
||||
int x = JsonUtils.getInt(json, "x", 0);
|
||||
int y = JsonUtils.getInt(json, "y", 0);
|
||||
int x = JSONUtils.getInt(json, "x", 0);
|
||||
int y = JSONUtils.getInt(json, "y", 0);
|
||||
ret.state = Optional.ofNullable(ModelRotation.getModelRotation(x, y));
|
||||
if (!ret.state.isPresent())
|
||||
throw new JsonParseException("Invalid BlockModelRotation x: " + x + " y: " + y);
|
||||
@@ -612,22 +612,22 @@ public class ForgeBlockStateV1 extends Marker
|
||||
|
||||
if (json.has("uvlock"))
|
||||
{ // Load uvlock.
|
||||
ret.uvLock = Optional.of(JsonUtils.getBoolean(json, "uvlock"));
|
||||
ret.uvLock = Optional.of(JSONUtils.getBoolean(json, "uvlock"));
|
||||
}
|
||||
|
||||
if (json.has("smooth_lighting"))
|
||||
{
|
||||
ret.smooth = Optional.of(JsonUtils.getBoolean(json, "smooth_lighting"));
|
||||
ret.smooth = Optional.of(JSONUtils.getBoolean(json, "smooth_lighting"));
|
||||
}
|
||||
|
||||
if (json.has("gui3d"))
|
||||
{
|
||||
ret.gui3d = Optional.of(JsonUtils.getBoolean(json, "gui3d"));
|
||||
ret.gui3d = Optional.of(JSONUtils.getBoolean(json, "gui3d"));
|
||||
}
|
||||
|
||||
if (json.has("weight"))
|
||||
{ // Load weight.
|
||||
ret.weight = Optional.of(JsonUtils.getInt(json, "weight"));
|
||||
ret.weight = Optional.of(JSONUtils.getInt(json, "weight"));
|
||||
}
|
||||
|
||||
if (json.has("submodel"))
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -41,9 +43,9 @@ import net.minecraftforge.common.model.animation.IClip;
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public interface IModel<T extends IModel<T>>
|
||||
{
|
||||
{
|
||||
@Nullable
|
||||
IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, IModelState state, boolean uvlock, VertexFormat format);
|
||||
IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format);
|
||||
|
||||
/*
|
||||
* Default state this model will be baked with.
|
||||
|
||||
@@ -19,20 +19,18 @@
|
||||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
|
||||
import net.minecraftforge.client.model.pipeline.TRSRTransformer;
|
||||
@@ -56,8 +54,8 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
{
|
||||
public static final ItemLayerModel INSTANCE = new ItemLayerModel(ImmutableList.of());
|
||||
|
||||
private static final EnumFacing[] HORIZONTALS = {EnumFacing.UP, EnumFacing.DOWN};
|
||||
private static final EnumFacing[] VERTICALS = {EnumFacing.WEST, EnumFacing.EAST};
|
||||
private static final Direction[] HORIZONTALS = {Direction.UP, Direction.DOWN};
|
||||
private static final Direction[] VERTICALS = {Direction.WEST, Direction.EAST};
|
||||
|
||||
private final ImmutableList<ResourceLocation> textures;
|
||||
private final ItemOverrideList overrides;
|
||||
@@ -73,12 +71,12 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
this.overrides = overrides;
|
||||
}
|
||||
|
||||
public ItemLayerModel(ModelBlock model)
|
||||
public ItemLayerModel(BlockModel model)
|
||||
{
|
||||
this(getTextures(model), model.getOverrides(model, ModelLoader.defaultModelGetter(), ModelLoader.defaultTextureGetter()));
|
||||
}
|
||||
|
||||
private static ImmutableList<ResourceLocation> getTextures(ModelBlock model)
|
||||
private static ImmutableList<ResourceLocation> getTextures(BlockModel model)
|
||||
{
|
||||
ImmutableList.Builder<ResourceLocation> builder = ImmutableList.builder();
|
||||
for(int i = 0; model.isTexturePresent("layer" + i); i++)
|
||||
@@ -95,7 +93,7 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -118,18 +116,20 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
return new ItemLayerModel(builder.build(), overrides);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format) {
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
Optional<TRSRTransformation> transform = state.apply(Optional.empty());
|
||||
Optional<TRSRTransformation> transform = sprite.getState().apply(Optional.empty());
|
||||
boolean identity = !transform.isPresent() || transform.get().isIdentity();
|
||||
for(int i = 0; i < textures.size(); i++)
|
||||
{
|
||||
TextureAtlasSprite sprite = bakedTextureGetter.apply(textures.get(i));
|
||||
builder.addAll(getQuadsForSprite(i, sprite, format, transform));
|
||||
TextureAtlasSprite tas = spriteGetter.apply(textures.get(i));
|
||||
builder.addAll(getQuadsForSprite(i, tas, format, transform));
|
||||
}
|
||||
TextureAtlasSprite particle = bakedTextureGetter.apply(textures.isEmpty() ? new ResourceLocation("missingno") : textures.get(0));
|
||||
ImmutableMap<TransformType, TRSRTransformation> map = PerspectiveMapWrapper.getTransforms(state);
|
||||
TextureAtlasSprite particle = spriteGetter.apply(textures.isEmpty() ? new ResourceLocation("missingno") : textures.get(0));
|
||||
ImmutableMap<TransformType, TRSRTransformation> map = PerspectiveMapWrapper.getTransforms(sprite.getState());
|
||||
return new BakedItemModel(builder.build(), particle, map, overrides, identity);
|
||||
}
|
||||
|
||||
@@ -163,19 +163,19 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
|
||||
if(ptu && !t) // left - transparent, right - opaque
|
||||
{
|
||||
faceData.set(EnumFacing.WEST, u, v);
|
||||
faceData.set(Direction.WEST, u, v);
|
||||
}
|
||||
if(!ptu && t) // left - opaque, right - transparent
|
||||
{
|
||||
faceData.set(EnumFacing.EAST, u-1, v);
|
||||
faceData.set(Direction.EAST, u-1, v);
|
||||
}
|
||||
if(ptv[u] && !t) // up - transparent, down - opaque
|
||||
{
|
||||
faceData.set(EnumFacing.UP, u, v);
|
||||
faceData.set(Direction.UP, u, v);
|
||||
}
|
||||
if(!ptv[u] && t) // up - opaque, down - transparent
|
||||
{
|
||||
faceData.set(EnumFacing.DOWN, u, v-1);
|
||||
faceData.set(Direction.DOWN, u, v-1);
|
||||
}
|
||||
|
||||
ptu = t;
|
||||
@@ -183,7 +183,7 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
}
|
||||
if(!ptu) // last - opaque
|
||||
{
|
||||
faceData.set(EnumFacing.EAST, uMax-1, v);
|
||||
faceData.set(Direction.EAST, uMax-1, v);
|
||||
}
|
||||
}
|
||||
// last line
|
||||
@@ -191,13 +191,13 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
{
|
||||
if(!ptv[u])
|
||||
{
|
||||
faceData.set(EnumFacing.DOWN, u, vMax-1);
|
||||
faceData.set(Direction.DOWN, u, vMax-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// horizontal quads
|
||||
for (EnumFacing facing : HORIZONTALS)
|
||||
for (Direction facing : HORIZONTALS)
|
||||
{
|
||||
for (int v = 0; v < vMax; v++)
|
||||
{
|
||||
@@ -223,7 +223,7 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
if (building && !face) // finish current quad
|
||||
{
|
||||
// make quad [uStart, u]
|
||||
int off = facing == EnumFacing.DOWN ? 1 : 0;
|
||||
int off = facing == Direction.DOWN ? 1 : 0;
|
||||
builder.add(buildSideQuad(format, transform, facing, tint, sprite, uStart, v+off, u-uStart));
|
||||
building = false;
|
||||
}
|
||||
@@ -237,14 +237,14 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
if (building) // build remaining quad
|
||||
{
|
||||
// make quad [uStart, uEnd]
|
||||
int off = facing == EnumFacing.DOWN ? 1 : 0;
|
||||
int off = facing == Direction.DOWN ? 1 : 0;
|
||||
builder.add(buildSideQuad(format, transform, facing, tint, sprite, uStart, v+off, uEnd-uStart));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vertical quads
|
||||
for (EnumFacing facing : VERTICALS)
|
||||
for (Direction facing : VERTICALS)
|
||||
{
|
||||
for (int u = 0; u < uMax; u++)
|
||||
{
|
||||
@@ -270,7 +270,7 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
if (building && !face) // finish current quad
|
||||
{
|
||||
// make quad [vStart, v]
|
||||
int off = facing == EnumFacing.EAST ? 1 : 0;
|
||||
int off = facing == Direction.EAST ? 1 : 0;
|
||||
builder.add(buildSideQuad(format, transform, facing, tint, sprite, u+off, vStart, v-vStart));
|
||||
building = false;
|
||||
}
|
||||
@@ -284,21 +284,21 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
if (building) // build remaining quad
|
||||
{
|
||||
// make quad [vStart, vEnd]
|
||||
int off = facing == EnumFacing.EAST ? 1 : 0;
|
||||
int off = facing == Direction.EAST ? 1 : 0;
|
||||
builder.add(buildSideQuad(format, transform, facing, tint, sprite, u+off, vStart, vEnd-vStart));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// front
|
||||
builder.add(buildQuad(format, transform, EnumFacing.NORTH, sprite, tint,
|
||||
builder.add(buildQuad(format, transform, Direction.NORTH, sprite, tint,
|
||||
0, 0, 7.5f / 16f, sprite.getMinU(), sprite.getMaxV(),
|
||||
0, 1, 7.5f / 16f, sprite.getMinU(), sprite.getMinV(),
|
||||
1, 1, 7.5f / 16f, sprite.getMaxU(), sprite.getMinV(),
|
||||
1, 0, 7.5f / 16f, sprite.getMaxU(), sprite.getMaxV()
|
||||
));
|
||||
// back
|
||||
builder.add(buildQuad(format, transform, EnumFacing.SOUTH, sprite, tint,
|
||||
builder.add(buildQuad(format, transform, Direction.SOUTH, sprite, tint,
|
||||
0, 0, 8.5f / 16f, sprite.getMinU(), sprite.getMaxV(),
|
||||
1, 0, 8.5f / 16f, sprite.getMaxU(), sprite.getMaxV(),
|
||||
1, 1, 8.5f / 16f, sprite.getMaxU(), sprite.getMinV(),
|
||||
@@ -310,7 +310,7 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
|
||||
private static class FaceData
|
||||
{
|
||||
private final EnumMap<EnumFacing, BitSet> data = new EnumMap<>(EnumFacing.class);
|
||||
private final EnumMap<Direction, BitSet> data = new EnumMap<>(Direction.class);
|
||||
|
||||
private final int vMax;
|
||||
|
||||
@@ -318,18 +318,18 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
{
|
||||
this.vMax = vMax;
|
||||
|
||||
data.put(EnumFacing.WEST, new BitSet(uMax * vMax));
|
||||
data.put(EnumFacing.EAST, new BitSet(uMax * vMax));
|
||||
data.put(EnumFacing.UP, new BitSet(uMax * vMax));
|
||||
data.put(EnumFacing.DOWN, new BitSet(uMax * vMax));
|
||||
data.put(Direction.WEST, new BitSet(uMax * vMax));
|
||||
data.put(Direction.EAST, new BitSet(uMax * vMax));
|
||||
data.put(Direction.UP, new BitSet(uMax * vMax));
|
||||
data.put(Direction.DOWN, new BitSet(uMax * vMax));
|
||||
}
|
||||
|
||||
public void set(EnumFacing facing, int u, int v)
|
||||
public void set(Direction facing, int u, int v)
|
||||
{
|
||||
data.get(facing).set(getIndex(u, v));
|
||||
}
|
||||
|
||||
public boolean get(EnumFacing facing, int u, int v)
|
||||
public boolean get(Direction facing, int u, int v)
|
||||
{
|
||||
return data.get(facing).get(getIndex(u, v));
|
||||
}
|
||||
@@ -340,7 +340,7 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
}
|
||||
}
|
||||
|
||||
private static BakedQuad buildSideQuad(VertexFormat format, Optional<TRSRTransformation> transform, EnumFacing side, int tint, TextureAtlasSprite sprite, int u, int v, int size)
|
||||
private static BakedQuad buildSideQuad(VertexFormat format, Optional<TRSRTransformation> transform, Direction side, int tint, TextureAtlasSprite sprite, int u, int v, int size)
|
||||
{
|
||||
final float eps = 1e-2f;
|
||||
|
||||
@@ -387,14 +387,14 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
);
|
||||
}
|
||||
|
||||
private static EnumFacing remap(EnumFacing side)
|
||||
private static Direction remap(Direction side)
|
||||
{
|
||||
// getOpposite is related to the swapping of V direction
|
||||
return side.getAxis() == EnumFacing.Axis.Y ? side.getOpposite() : side;
|
||||
return side.getAxis() == Direction.Axis.Y ? side.getOpposite() : side;
|
||||
}
|
||||
|
||||
private static BakedQuad buildQuad(
|
||||
VertexFormat format, Optional<TRSRTransformation> transform, EnumFacing side, TextureAtlasSprite sprite, int tint,
|
||||
VertexFormat format, Optional<TRSRTransformation> transform, Direction side, TextureAtlasSprite sprite, int tint,
|
||||
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,
|
||||
@@ -417,7 +417,7 @@ public final class ItemLayerModel implements IUnbakedModel
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static void putVertex(IVertexConsumer consumer, VertexFormat format, EnumFacing side, float x, float y, float z, float u, float v)
|
||||
private static void putVertex(IVertexConsumer consumer, VertexFormat format, Direction side, float x, float y, float z, float u, float v)
|
||||
{
|
||||
for(int e = 0; e < format.getElementCount(); e++)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
|
||||
import net.minecraftforge.client.model.pipeline.TRSRTransformer;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
@@ -52,7 +52,7 @@ public final class ItemTextureQuadConverter
|
||||
* @param sprite The texture whose UVs shall be used
|
||||
* @return The generated quads.
|
||||
*/
|
||||
public static List<UnpackedBakedQuad> convertTexture(VertexFormat format, TRSRTransformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, EnumFacing facing, int color, int tint)
|
||||
public static List<UnpackedBakedQuad> convertTexture(VertexFormat format, TRSRTransformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint)
|
||||
{
|
||||
List<UnpackedBakedQuad> horizontal = convertTextureHorizontal(format, transform, template, sprite, z, facing, color, tint);
|
||||
List<UnpackedBakedQuad> vertical = convertTextureVertical(format, transform, template, sprite, z, facing, color, tint);
|
||||
@@ -64,7 +64,7 @@ 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<UnpackedBakedQuad> convertTextureHorizontal(VertexFormat format, TRSRTransformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, EnumFacing facing, int color, int tint)
|
||||
public static List<UnpackedBakedQuad> convertTextureHorizontal(VertexFormat format, TRSRTransformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint)
|
||||
{
|
||||
int w = template.getWidth();
|
||||
int h = template.getHeight();
|
||||
@@ -135,7 +135,7 @@ 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<UnpackedBakedQuad> convertTextureVertical(VertexFormat format, TRSRTransformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, EnumFacing facing, int color, int tint)
|
||||
public static List<UnpackedBakedQuad> convertTextureVertical(VertexFormat format, TRSRTransformation transform, TextureAtlasSprite template, TextureAtlasSprite sprite, float z, Direction facing, int color, int tint)
|
||||
{
|
||||
int w = template.getWidth();
|
||||
int h = template.getHeight();
|
||||
@@ -211,7 +211,7 @@ 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 UnpackedBakedQuad genQuad(VertexFormat format, TRSRTransformation transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, EnumFacing facing, int color, int tint)
|
||||
public static UnpackedBakedQuad genQuad(VertexFormat format, TRSRTransformation transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint)
|
||||
{
|
||||
float u1 = sprite.getInterpolatedU(x1);
|
||||
float v1 = sprite.getInterpolatedV(y1);
|
||||
@@ -230,7 +230,7 @@ public final class ItemTextureQuadConverter
|
||||
return putQuad(format, transform, facing, sprite, color, tint, x1, y1, x2, y2, z, u1, v1, u2, v2);
|
||||
}
|
||||
|
||||
private static UnpackedBakedQuad putQuad(VertexFormat format, TRSRTransformation transform, EnumFacing side, TextureAtlasSprite sprite, int color, int tint,
|
||||
private static UnpackedBakedQuad putQuad(VertexFormat format, TRSRTransformation 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)
|
||||
{
|
||||
@@ -244,7 +244,7 @@ public final class ItemTextureQuadConverter
|
||||
boolean hasTransform = !transform.isIdentity();
|
||||
IVertexConsumer consumer = hasTransform ? new TRSRTransformer(builder, transform) : builder;
|
||||
|
||||
if (side == EnumFacing.SOUTH)
|
||||
if (side == Direction.SOUTH)
|
||||
{
|
||||
putVertex(consumer, format, side, x1, y1, z, u1, v2, color);
|
||||
putVertex(consumer, format, side, x2, y1, z, u2, v2, color);
|
||||
@@ -261,7 +261,7 @@ public final class ItemTextureQuadConverter
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static void putVertex(IVertexConsumer consumer, VertexFormat format, EnumFacing side,
|
||||
private static void putVertex(IVertexConsumer consumer, VertexFormat format, Direction side,
|
||||
float x, float y, float z, float u, float v, int color)
|
||||
{
|
||||
for (int e = 0; e < format.getElementCount(); e++)
|
||||
|
||||
@@ -28,22 +28,19 @@ import javax.annotation.Nullable;
|
||||
import javax.vecmath.Quat4f;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraft.client.renderer.texture.PngSizeInfo;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.data.AnimationMetadataSection;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
@@ -122,21 +119,23 @@ public final class ModelDynBucket implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
|
||||
IModelState state = sprite.getState();
|
||||
ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state);
|
||||
|
||||
// if the fluid is lighter than air, will manipulate the initial state to be rotated 180° to turn it upside down
|
||||
if (flipGas && fluid != null && fluid.isLighterThanAir())
|
||||
{
|
||||
state = new ModelStateComposition(state, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(null, new Quat4f(0, 0, 1, 0), null, null)));
|
||||
sprite = new ModelStateComposition(state, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(null, new Quat4f(0, 0, 1, 0), null, null)));
|
||||
state = sprite.getState();
|
||||
}
|
||||
|
||||
TRSRTransformation transform = state.apply(Optional.empty()).orElse(TRSRTransformation.identity());
|
||||
@@ -145,32 +144,32 @@ public final class ModelDynBucket implements IUnbakedModel
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
|
||||
if(fluid != null) {
|
||||
fluidSprite = bakedTextureGetter.apply(fluid.getStill());
|
||||
fluidSprite = spriteGetter.apply(fluid.getStill());
|
||||
}
|
||||
|
||||
Random random = new Random();
|
||||
if (baseLocation != null)
|
||||
{
|
||||
// build base (insidest)
|
||||
IBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(modelGetter, bakedTextureGetter, state, uvlock, format);
|
||||
IBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(modelGetter, spriteGetter, sprite, format);
|
||||
random.setSeed(42);
|
||||
builder.addAll(model.getQuads(null, null, random));
|
||||
particleSprite = model.getParticleTexture();
|
||||
}
|
||||
if (liquidLocation != null && fluidSprite != null)
|
||||
{
|
||||
TextureAtlasSprite liquid = bakedTextureGetter.apply(liquidLocation);
|
||||
TextureAtlasSprite liquid = spriteGetter.apply(liquidLocation);
|
||||
// build liquid layer (inside)
|
||||
builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, liquid, fluidSprite, NORTH_Z_FLUID, EnumFacing.NORTH, tint ? fluid.getColor() : 0xFFFFFFFF, 1));
|
||||
builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, liquid, fluidSprite, SOUTH_Z_FLUID, EnumFacing.SOUTH, tint ? fluid.getColor() : 0xFFFFFFFF, 1));
|
||||
builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, liquid, fluidSprite, NORTH_Z_FLUID, Direction.NORTH, tint ? fluid.getColor() : 0xFFFFFFFF, 1));
|
||||
builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, liquid, fluidSprite, SOUTH_Z_FLUID, Direction.SOUTH, tint ? fluid.getColor() : 0xFFFFFFFF, 1));
|
||||
particleSprite = fluidSprite;
|
||||
}
|
||||
if (coverLocation != null)
|
||||
{
|
||||
// cover (the actual item around the other two)
|
||||
TextureAtlasSprite cover = bakedTextureGetter.apply(coverLocation);
|
||||
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16, 16, NORTH_Z_COVER, cover, EnumFacing.NORTH, 0xFFFFFFFF, 2));
|
||||
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16, 16, SOUTH_Z_COVER, cover, EnumFacing.SOUTH, 0xFFFFFFFF, 2));
|
||||
TextureAtlasSprite cover = spriteGetter.apply(coverLocation);
|
||||
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16, 16, NORTH_Z_COVER, cover, Direction.NORTH, 0xFFFFFFFF, 2));
|
||||
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16, 16, SOUTH_Z_COVER, cover, Direction.SOUTH, 0xFFFFFFFF, 2));
|
||||
if (particleSprite == null)
|
||||
{
|
||||
particleSprite = cover;
|
||||
@@ -267,7 +266,7 @@ public final class ModelDynBucket implements IUnbakedModel
|
||||
{
|
||||
try
|
||||
{
|
||||
return new PngSizeInfo(resource);
|
||||
return new PngSizeInfo(resource.toString(), resource.getInputStream());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -297,7 +296,7 @@ public final class ModelDynBucket implements IUnbakedModel
|
||||
// no need to clear cache since we create a new model instance
|
||||
}
|
||||
|
||||
public void register(TextureMap map)
|
||||
public void register(AtlasTexture map)
|
||||
{
|
||||
// only create these textures if they are not added by a resource pack
|
||||
|
||||
@@ -431,7 +430,7 @@ public final class ModelDynBucket implements IUnbakedModel
|
||||
private BakedDynBucketOverrideHandler() {}
|
||||
|
||||
@Override
|
||||
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable LivingEntity entity)
|
||||
{
|
||||
return FluidUtil.getFluidContained(stack)
|
||||
.map(fluidStack -> {
|
||||
@@ -446,7 +445,7 @@ public final class ModelDynBucket implements IUnbakedModel
|
||||
Function<ResourceLocation, TextureAtlasSprite> textureGetter;
|
||||
textureGetter = location -> Minecraft.getInstance().getTextureMap().getAtlasSprite(location.toString());
|
||||
|
||||
IBakedModel bakedModel = parent.bake(ModelLoader.defaultModelGetter(), textureGetter, new SimpleModelState(model.transforms), false, model.format);
|
||||
IBakedModel bakedModel = parent.bake(ModelLoader.defaultModelGetter(), textureGetter, new SimpleModelState(model.transforms), model.format);
|
||||
model.cache.put(name, bakedModel);
|
||||
return bakedModel;
|
||||
}
|
||||
|
||||
@@ -31,16 +31,14 @@ import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
@@ -87,21 +85,22 @@ public final class ModelFluid implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations() {
|
||||
public Collection<ResourceLocation> getDependencies() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
return new CachingBakedFluid(
|
||||
state.apply(Optional.empty()),
|
||||
PerspectiveMapWrapper.getTransforms(state),
|
||||
sprite.getState().apply(Optional.empty()),
|
||||
PerspectiveMapWrapper.getTransforms(sprite.getState()),
|
||||
format,
|
||||
fluid.getColor(),
|
||||
bakedTextureGetter.apply(fluid.getStill()),
|
||||
bakedTextureGetter.apply(fluid.getFlowing()),
|
||||
Optional.ofNullable(fluid.getOverlay()).map(bakedTextureGetter),
|
||||
spriteGetter.apply(fluid.getStill()),
|
||||
spriteGetter.apply(fluid.getFlowing()),
|
||||
Optional.ofNullable(fluid.getOverlay()).map(spriteGetter),
|
||||
fluid.isLighterThanAir(),
|
||||
null
|
||||
);
|
||||
@@ -229,7 +228,7 @@ public final class ModelFluid implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand, IModelData modelData)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData)
|
||||
{
|
||||
if (side != null)
|
||||
{
|
||||
@@ -275,7 +274,7 @@ public final class ModelFluid implements IUnbakedModel
|
||||
protected final TextureAtlasSprite still, flowing;
|
||||
protected final Optional<TextureAtlasSprite> overlay;
|
||||
protected final boolean gas;
|
||||
protected final ImmutableMap<EnumFacing, ImmutableList<BakedQuad>> faceQuads;
|
||||
protected final ImmutableMap<Direction, ImmutableList<BakedQuad>> faceQuads;
|
||||
|
||||
public BakedFluid(Optional<TRSRTransformation> transformation, ImmutableMap<TransformType, TRSRTransformation> transforms, VertexFormat format, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, Optional<TextureAtlasSprite> overlay, boolean gas, boolean statePresent, int[] cornerRound, int flowRound, boolean[] sideOverlays)
|
||||
{
|
||||
@@ -290,10 +289,10 @@ public final class ModelFluid implements IUnbakedModel
|
||||
this.faceQuads = buildQuads(statePresent, cornerRound, flowRound, sideOverlays);
|
||||
}
|
||||
|
||||
private ImmutableMap<EnumFacing, ImmutableList<BakedQuad>> buildQuads(boolean statePresent, int[] cornerRound, int flowRound, boolean[] sideOverlays)
|
||||
private ImmutableMap<Direction, ImmutableList<BakedQuad>> buildQuads(boolean statePresent, int[] cornerRound, int flowRound, boolean[] sideOverlays)
|
||||
{
|
||||
EnumMap<EnumFacing, ImmutableList<BakedQuad>> faceQuads = new EnumMap<>(EnumFacing.class);
|
||||
for (EnumFacing side : EnumFacing.values())
|
||||
EnumMap<Direction, ImmutableList<BakedQuad>> faceQuads = new EnumMap<>(Direction.class);
|
||||
for (Direction side : Direction.values())
|
||||
{
|
||||
faceQuads.put(side, ImmutableList.of());
|
||||
}
|
||||
@@ -321,7 +320,7 @@ public final class ModelFluid implements IUnbakedModel
|
||||
float s = MathHelper.sin(flow) * scale;
|
||||
|
||||
// top
|
||||
EnumFacing top = gas ? EnumFacing.DOWN : EnumFacing.UP;
|
||||
Direction top = gas ? Direction.DOWN : Direction.UP;
|
||||
|
||||
// base uv offset for flow direction
|
||||
VertexParameter uv = i -> c * (x[i] * 2 - 1) + s * (z[i] * 2 - 1);
|
||||
@@ -342,7 +341,7 @@ public final class ModelFluid implements IUnbakedModel
|
||||
}
|
||||
|
||||
// bottom
|
||||
EnumFacing bottom = top.getOpposite();
|
||||
Direction bottom = top.getOpposite();
|
||||
faceQuads.put(bottom, ImmutableList.of(
|
||||
buildQuad(bottom, still, gas, false,
|
||||
i -> z[i],
|
||||
@@ -356,7 +355,7 @@ public final class ModelFluid implements IUnbakedModel
|
||||
// sides
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
EnumFacing side = EnumFacing.byHorizontalIndex((5 - i) % 4); // [W, S, E, N]
|
||||
Direction side = Direction.byHorizontalIndex((5 - i) % 4); // [W, S, E, N]
|
||||
boolean useOverlay = overlay.isPresent() && sideOverlays[side.getHorizontalIndex()];
|
||||
int si = i; // local var for lambda capture
|
||||
|
||||
@@ -377,8 +376,8 @@ public final class ModelFluid implements IUnbakedModel
|
||||
else
|
||||
{
|
||||
// inventory
|
||||
faceQuads.put(EnumFacing.SOUTH, ImmutableList.of(
|
||||
buildQuad(EnumFacing.UP, still, false, false,
|
||||
faceQuads.put(Direction.SOUTH, ImmutableList.of(
|
||||
buildQuad(Direction.UP, still, false, false,
|
||||
i -> z[i],
|
||||
i -> x[i],
|
||||
i -> 0,
|
||||
@@ -397,7 +396,7 @@ public final class ModelFluid implements IUnbakedModel
|
||||
float get(int index);
|
||||
}
|
||||
|
||||
private BakedQuad buildQuad(EnumFacing side, TextureAtlasSprite texture, boolean flip, boolean offset, VertexParameter x, VertexParameter y, VertexParameter z, VertexParameter u, VertexParameter v)
|
||||
private BakedQuad buildQuad(Direction side, TextureAtlasSprite texture, boolean flip, boolean offset, VertexParameter x, VertexParameter y, VertexParameter z, VertexParameter u, VertexParameter v)
|
||||
{
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
|
||||
|
||||
@@ -422,7 +421,7 @@ public final class ModelFluid implements IUnbakedModel
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private void putVertex(IVertexConsumer consumer, EnumFacing side, boolean offset, float x, float y, float z, float u, float v)
|
||||
private void putVertex(IVertexConsumer consumer, Direction side, boolean offset, float x, float y, float z, float u, float v)
|
||||
{
|
||||
for(int e = 0; e < format.getElementCount(); e++)
|
||||
{
|
||||
@@ -486,7 +485,7 @@ public final class ModelFluid implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand)
|
||||
{
|
||||
return side == null ? ImmutableList.of() : faceQuads.get(side);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
@@ -52,9 +52,8 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemModelGenerator;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.model.ModelBlockDefinition;
|
||||
import net.minecraft.client.renderer.model.ModelBlockDefinition.ContainerHolder;
|
||||
import net.minecraft.client.renderer.model.BlockModel;
|
||||
import net.minecraft.client.renderer.model.BlockModelDefinition;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.model.MultipartBakedModel;
|
||||
@@ -64,17 +63,18 @@ import net.minecraft.client.renderer.model.VariantList;
|
||||
import net.minecraft.client.renderer.model.WeightedBakedModel;
|
||||
import net.minecraft.client.renderer.model.multipart.Multipart;
|
||||
import net.minecraft.client.renderer.model.multipart.Selector;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.client.model.animation.AnimationItemOverrideList;
|
||||
import net.minecraftforge.client.model.animation.ModelBlockAnimation;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
@@ -123,8 +123,8 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final Map<ModelResourceLocation, IUnbakedModel> stateModels = Maps.newHashMap();
|
||||
private final Map<ModelResourceLocation, ModelBlockDefinition> multipartDefinitions = Maps.newHashMap();
|
||||
private final Map<ModelBlockDefinition, IUnbakedModel> multipartModels = Maps.newHashMap();
|
||||
private final Map<ModelResourceLocation, BlockModelDefinition> multipartDefinitions = Maps.newHashMap();
|
||||
private final Map<BlockModelDefinition, IUnbakedModel> multipartModels = Maps.newHashMap();
|
||||
// TODO: nothing adds to missingVariants, remove it?
|
||||
private final Set<ModelResourceLocation> missingVariants = Sets.newHashSet();
|
||||
private final Map<ResourceLocation, Exception> loadingExceptions = Maps.newHashMap();
|
||||
@@ -136,9 +136,9 @@ public final class ModelLoader extends ModelBakery
|
||||
return isLoading;
|
||||
}
|
||||
|
||||
public ModelLoader(IResourceManager manager, TextureMap map)
|
||||
public ModelLoader(IResourceManager manager, AtlasTexture map, IProfiler profiler)
|
||||
{
|
||||
super(manager, map);
|
||||
super(manager, map, profiler);
|
||||
VanillaLoader.INSTANCE.setLoader(this);
|
||||
VariantLoader.INSTANCE.setLoader(this);
|
||||
ModelLoaderRegistry.clearModelCache(manager);
|
||||
@@ -167,7 +167,7 @@ public final class ModelLoader extends ModelBakery
|
||||
|
||||
textureMap.stitch(resourceManager, textures);
|
||||
|
||||
field_209607_C.forEach((p_209602_2_, p_209602_3_) -> {
|
||||
STATE_CONTAINER_OVERRIDES.forEach((p_209602_2_, p_209602_3_) -> {
|
||||
p_209602_3_.getValidStates().forEach((p_209601_3_) -> {
|
||||
this.getUnbakedModel(map, BlockModelShapes.getModelLocation(p_209602_2_, p_209601_3_));
|
||||
});
|
||||
@@ -354,11 +354,11 @@ public final class ModelLoader extends ModelBakery
|
||||
private final FaceBakery faceBakery = new FaceBakery();
|
||||
|
||||
private final ResourceLocation location;
|
||||
private final ModelBlock model;
|
||||
private final BlockModel model;
|
||||
private final boolean uvlock;
|
||||
private final ModelBlockAnimation animation;
|
||||
|
||||
public VanillaModelWrapper(ResourceLocation location, ModelBlock model, boolean uvlock, ModelBlockAnimation animation)
|
||||
public VanillaModelWrapper(ResourceLocation location, BlockModel model, boolean uvlock, ModelBlockAnimation animation)
|
||||
{
|
||||
this.location = location;
|
||||
this.model = model;
|
||||
@@ -367,10 +367,10 @@ public final class ModelLoader extends ModelBakery
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
Set<ResourceLocation> set = Sets.newHashSet();
|
||||
for(ResourceLocation dep : model.getOverrideLocations())
|
||||
for(ResourceLocation dep : model.getDependencies())
|
||||
{
|
||||
if(!location.equals(dep))
|
||||
{
|
||||
@@ -434,10 +434,11 @@ public final class ModelLoader extends ModelBakery
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
return VanillaLoader.INSTANCE.modelCache.getUnchecked(new BakedModelCacheKey(this, modelGetter, bakedTextureGetter, state, uvlock, format));
|
||||
return VanillaLoader.INSTANCE.modelCache.getUnchecked(new BakedModelCacheKey(this, modelGetter, spriteGetter, sprite.getState(), uvlock, format));
|
||||
}
|
||||
|
||||
public IBakedModel bakeImpl(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
@@ -446,8 +447,8 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
throw new IllegalArgumentException("can't bake vanilla models to the format that doesn't fit into the default one: " + format);
|
||||
}
|
||||
ModelBlock model = this.model;
|
||||
if(model == null) return getMissingModel().bake(modelGetter, bakedTextureGetter, getMissingModel().getDefaultState(), uvlock, format);
|
||||
BlockModel model = this.model;
|
||||
if(model == null) return getMissingModel().bake(modelGetter, bakedTextureGetter, new BasicState(getMissingModel().getDefaultState(), uvlock), format);
|
||||
|
||||
List<TRSRTransformation> newTransforms = Lists.newArrayList();
|
||||
for(int i = 0; i < model.getElements().size(); i++)
|
||||
@@ -464,13 +465,14 @@ public final class ModelLoader extends ModelBakery
|
||||
|
||||
if(model == ModelBakery.MODEL_GENERATED)
|
||||
{
|
||||
return new ItemLayerModel(model).bake(modelGetter, bakedTextureGetter, perState, uvlock, format);
|
||||
return new ItemLayerModel(model).bake(modelGetter, bakedTextureGetter, new BasicState(perState, uvlock), format);
|
||||
}
|
||||
if(model == ModelBakery.MODEL_ENTITY) return new BuiltInModel(transforms, model.getOverrides(model, modelGetter, bakedTextureGetter));
|
||||
TextureAtlasSprite textureatlassprite = bakedTextureGetter.apply(new ResourceLocation(model.resolveTextureName("particle")));
|
||||
if(model == ModelBakery.MODEL_ENTITY) return new BuiltInModel(transforms, model.getOverrides(model, modelGetter, bakedTextureGetter), textureatlassprite);
|
||||
return bakeNormal(model, perState, state, newTransforms, format, modelGetter, bakedTextureGetter, uvlock);
|
||||
}
|
||||
|
||||
private IBakedModel bakeNormal(ModelBlock model, IModelState perState, final IModelState modelState, List<TRSRTransformation> newTransforms, final VertexFormat format, final Function<ResourceLocation, IUnbakedModel> modelGetter, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, boolean uvLocked)
|
||||
private IBakedModel bakeNormal(BlockModel model, IModelState perState, final IModelState modelState, List<TRSRTransformation> newTransforms, final VertexFormat format, final Function<ResourceLocation, IUnbakedModel> modelGetter, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, boolean uvLocked)
|
||||
{
|
||||
final TRSRTransformation baseState = modelState.apply(Optional.empty()).orElse(TRSRTransformation.identity());
|
||||
TextureAtlasSprite particle = bakedTextureGetter.apply(new ResourceLocation(model.resolveTextureName("particle")));
|
||||
@@ -487,20 +489,20 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
transformation = transformation.compose(newTransforms.get(i));
|
||||
BlockPartRotation rot = part.partRotation;
|
||||
if(rot == null) rot = new BlockPartRotation(new Vector3f(), EnumFacing.Axis.Y, 0, false);
|
||||
if(rot == null) rot = new BlockPartRotation(new Vector3f(), Direction.Axis.Y, 0, false);
|
||||
part = new BlockPart(part.positionFrom, part.positionTo, part.mapFaces, rot, part.shade);
|
||||
}
|
||||
for(Map.Entry<EnumFacing, BlockPartFace> e : part.mapFaces.entrySet())
|
||||
for(Map.Entry<Direction, BlockPartFace> e : part.mapFaces.entrySet())
|
||||
{
|
||||
TextureAtlasSprite textureatlassprite1 = bakedTextureGetter.apply(new ResourceLocation(model.resolveTextureName(e.getValue().texture)));
|
||||
|
||||
if (e.getValue().cullFace == null || !TRSRTransformation.isInteger(transformation.getMatrixVec()))
|
||||
{
|
||||
builder.addGeneralQuad(ModelBlock.makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), transformation, uvLocked));
|
||||
builder.addGeneralQuad(BlockModel.makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), new BasicState(transformation, uvLocked)));
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.addFaceQuad(baseState.rotate(e.getValue().cullFace), ModelBlock.makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), transformation, uvLocked));
|
||||
builder.addFaceQuad(baseState.rotate(e.getValue().cullFace), BlockModel.makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), new BasicState(transformation, uvLocked)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -510,12 +512,12 @@ public final class ModelLoader extends ModelBakery
|
||||
private final ItemOverrideList overrides = new AnimationItemOverrideList(VanillaModelWrapper.this, modelState, format, bakedTextureGetter, super.getOverrides());
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand, IModelData modelData)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData)
|
||||
{
|
||||
IModelState newState = modelData.getData(Properties.AnimationProperty);
|
||||
if(newState != null)
|
||||
{
|
||||
return VanillaModelWrapper.this.bake(modelGetter, bakedTextureGetter, new ModelStateComposition(modelState, newState), uvlock, format).getQuads(state, side, rand, modelData);
|
||||
return VanillaModelWrapper.this.bake(modelGetter, bakedTextureGetter, new ModelStateComposition(modelState, newState, uvlock), format).getQuads(state, side, rand, modelData);
|
||||
}
|
||||
return super.getQuads(state, side, rand);
|
||||
}
|
||||
@@ -540,7 +542,7 @@ public final class ModelLoader extends ModelBakery
|
||||
elements.add(new BlockPart(part.positionFrom, part.positionTo, Maps.newHashMap(part.mapFaces), part.partRotation, part.shade));
|
||||
}
|
||||
|
||||
ModelBlock newModel = new ModelBlock(this.model.getParentLocation(), elements,
|
||||
BlockModel newModel = new BlockModel(this.model.getParentLocation(), elements,
|
||||
Maps.newHashMap(this.model.textures), this.model.isAmbientOcclusion(), this.model.isGui3d(), //New Textures man VERY IMPORTANT
|
||||
model.getAllTransforms(), Lists.newArrayList(model.getOverrides()));
|
||||
newModel.name = this.model.name;
|
||||
@@ -600,7 +602,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
return this;
|
||||
}
|
||||
ModelBlock newModel = new ModelBlock(model.getParentLocation(), model.getElements(), model.textures, value, model.isGui3d(), model.getAllTransforms(), Lists.newArrayList(model.getOverrides()));
|
||||
BlockModel newModel = new BlockModel(model.getParentLocation(), model.getElements(), model.textures, value, model.isGui3d(), model.getAllTransforms(), Lists.newArrayList(model.getOverrides()));
|
||||
newModel.parent = model.parent;
|
||||
newModel.name = model.name;
|
||||
return new VanillaModelWrapper(location, newModel, uvlock, animation);
|
||||
@@ -613,7 +615,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
return this;
|
||||
}
|
||||
ModelBlock newModel = new ModelBlock(model.getParentLocation(), model.getElements(), model.textures, model.ambientOcclusion, value, model.getAllTransforms(), Lists.newArrayList(model.getOverrides()));
|
||||
BlockModel newModel = new BlockModel(model.getParentLocation(), model.getElements(), model.textures, model.ambientOcclusion, value, model.getAllTransforms(), Lists.newArrayList(model.getOverrides()));
|
||||
newModel.parent = model.parent;
|
||||
newModel.name = model.name;
|
||||
return new VanillaModelWrapper(location, newModel, uvlock, animation);
|
||||
@@ -657,7 +659,7 @@ public final class ModelLoader extends ModelBakery
|
||||
|
||||
// FIXME: is this the place? messes up dependency and texture resolution
|
||||
model = v.process(model);
|
||||
for(ResourceLocation location : model.getOverrideLocations())
|
||||
for(ResourceLocation location : model.getDependencies())
|
||||
{
|
||||
ModelLoaderRegistry.getModelOrMissing(location);
|
||||
}
|
||||
@@ -668,7 +670,7 @@ public final class ModelLoader extends ModelBakery
|
||||
|
||||
IModelState modelDefaultState = model.getDefaultState();
|
||||
Preconditions.checkNotNull(modelDefaultState, "Model %s returned null as default state", loc);
|
||||
builder.add(Pair.of(model, new ModelStateComposition(v.getState(), modelDefaultState)));
|
||||
builder.add(Pair.of(model, new ModelStateComposition(v.getState(), modelDefaultState, v.isUvLock())));
|
||||
}
|
||||
|
||||
if (models.size() == 0) //If all variants are missing, add one with the missing model and default rotation.
|
||||
@@ -692,7 +694,7 @@ public final class ModelLoader extends ModelBakery
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return ImmutableList.copyOf(locations);
|
||||
}
|
||||
@@ -703,8 +705,9 @@ public final class ModelLoader extends ModelBakery
|
||||
return ImmutableSet.copyOf(textures);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
if(!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT))
|
||||
{
|
||||
@@ -713,13 +716,13 @@ public final class ModelLoader extends ModelBakery
|
||||
if(variants.size() == 1)
|
||||
{
|
||||
IUnbakedModel model = models.get(0);
|
||||
return model.bake(modelGetter, bakedTextureGetter, MultiModelState.getPartState(state, model, 0), uvlock, format);
|
||||
return model.bake(modelGetter, spriteGetter, new BasicState(MultiModelState.getPartState(sprite.getState(), model, 0), sprite.isUvLock()), format);
|
||||
}
|
||||
WeightedBakedModel.Builder builder = new WeightedBakedModel.Builder();
|
||||
for(int i = 0; i < variants.size(); i++)
|
||||
{
|
||||
IUnbakedModel model = models.get(i);
|
||||
builder.add(model.bake(modelGetter, bakedTextureGetter, MultiModelState.getPartState(state, model, i), uvlock, format), variants.get(i).getWeight());
|
||||
builder.add(model.bake(modelGetter, spriteGetter, new BasicState(MultiModelState.getPartState(sprite.getState(), model, i), sprite.isUvLock()), format), variants.get(i).getWeight());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
@@ -859,7 +862,7 @@ public final class ModelLoader extends ModelBakery
|
||||
}
|
||||
ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getNamespace(), "armatures/" + modelPath + ".json");
|
||||
ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation(loader.resourceManager, armatureLocation);
|
||||
ModelBlock model = loader.loadModel(modelLocation);
|
||||
BlockModel model = loader.loadModel(modelLocation);
|
||||
IUnbakedModel iModel = loader.new VanillaModelWrapper(modelLocation, model, false, animation);
|
||||
if(loader.missingModel == null && modelLocation.equals(MODEL_MISSING))
|
||||
{
|
||||
@@ -878,7 +881,7 @@ public final class ModelLoader extends ModelBakery
|
||||
// Temporary to compile things
|
||||
public static final class White {
|
||||
public static final ResourceLocation LOCATION = new ResourceLocation("white");
|
||||
public static final TextureAtlasSprite INSTANCE = MissingTextureSprite.getSprite();
|
||||
public static final TextureAtlasSprite INSTANCE = MissingTextureSprite.func_217790_a();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
public class ModelLoaderRegistry
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
|
||||
private static final Set<ICustomModelLoader> loaders = Sets.newHashSet();
|
||||
private static final Map<ResourceLocation, IUnbakedModel> cache = Maps.newHashMap();
|
||||
private static final Deque<ResourceLocation> loadingModels = Queues.newArrayDeque();
|
||||
@@ -79,7 +79,7 @@ public class ModelLoaderRegistry
|
||||
public static void registerLoader(ICustomModelLoader loader)
|
||||
{
|
||||
loaders.add(loader);
|
||||
((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).addReloadListener(loader);
|
||||
((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).func_219534_a(loader);
|
||||
}
|
||||
|
||||
public static boolean loaded(ResourceLocation location)
|
||||
@@ -185,7 +185,7 @@ public class ModelLoaderRegistry
|
||||
}
|
||||
}
|
||||
cache.put(location, model);
|
||||
for (ResourceLocation dep : model.getOverrideLocations())
|
||||
for (ResourceLocation dep : model.getDependencies())
|
||||
{
|
||||
getModelOrMissing(dep);
|
||||
}
|
||||
|
||||
@@ -20,21 +20,41 @@
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraftforge.common.model.IModelPart;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class ModelStateComposition implements IModelState
|
||||
public class ModelStateComposition implements IModelState, ISprite
|
||||
{
|
||||
private final IModelState first;
|
||||
private final IModelState second;
|
||||
private final boolean uvLock;
|
||||
|
||||
public ModelStateComposition(IModelState first, IModelState second)
|
||||
{
|
||||
this(first, second, false);
|
||||
}
|
||||
|
||||
public ModelStateComposition(IModelState first, IModelState second, boolean uvLock)
|
||||
{
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
this.uvLock = uvLock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getState()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUvLock()
|
||||
{
|
||||
return uvLock;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,18 +26,15 @@ import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
@@ -71,7 +68,7 @@ public final class MultiLayerModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return ImmutableList.copyOf(models.values());
|
||||
}
|
||||
@@ -82,25 +79,26 @@ public final class MultiLayerModel implements IUnbakedModel
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private static ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> buildModels(ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models, IModelState state, boolean uvlock, VertexFormat format, Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
private static ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> buildModels(ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models, ISprite sprite, VertexFormat format, Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter)
|
||||
{
|
||||
ImmutableMap.Builder<Optional<BlockRenderLayer>, IBakedModel> builder = ImmutableMap.builder();
|
||||
for(Optional<BlockRenderLayer> key : models.keySet())
|
||||
{
|
||||
IUnbakedModel model = ModelLoaderRegistry.getModelOrLogError(models.get(key), "Couldn't load MultiLayerModel dependency: " + models.get(key));
|
||||
builder.put(key, model.bake(modelGetter, bakedTextureGetter, new ModelStateComposition(state, model.getDefaultState()), uvlock, format));
|
||||
builder.put(key, model.bake(modelGetter, spriteGetter, new ModelStateComposition(sprite.getState(), model.getDefaultState(), sprite.isUvLock()), format));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
IUnbakedModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
return new MultiLayerBakedModel(
|
||||
buildModels(models, state, uvlock, format, modelGetter, bakedTextureGetter),
|
||||
missing.bake(modelGetter, bakedTextureGetter, missing.getDefaultState(), uvlock, format),
|
||||
PerspectiveMapWrapper.getTransforms(state)
|
||||
buildModels(models, sprite, format, modelGetter, spriteGetter),
|
||||
missing.bake(modelGetter, spriteGetter, new BasicState(missing.getDefaultState(), sprite.isUvLock()), format),
|
||||
PerspectiveMapWrapper.getTransforms(sprite.getState())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -154,7 +152,7 @@ public final class MultiLayerModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand)
|
||||
{
|
||||
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
|
||||
if (layer == null)
|
||||
@@ -177,7 +175,7 @@ public final class MultiLayerModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion(IBlockState state)
|
||||
public boolean isAmbientOcclusion(BlockState state)
|
||||
{
|
||||
return base.isAmbientOcclusion(state);
|
||||
}
|
||||
|
||||
@@ -31,18 +31,15 @@ import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
@@ -76,7 +73,7 @@ public final class MultiModel implements IUnbakedModel
|
||||
private final ItemOverrideList overrides = new ItemOverrideList()
|
||||
{
|
||||
@Override
|
||||
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable LivingEntity entity)
|
||||
{
|
||||
if(originalModel != Baked.this)
|
||||
{
|
||||
@@ -158,7 +155,7 @@ public final class MultiModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion(IBlockState state)
|
||||
public boolean isAmbientOcclusion(BlockState state)
|
||||
{
|
||||
return internalBase.isAmbientOcclusion(state);
|
||||
}
|
||||
@@ -188,7 +185,7 @@ public final class MultiModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand)
|
||||
{
|
||||
ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
|
||||
if (base != null)
|
||||
@@ -235,15 +232,15 @@ public final class MultiModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
Set<ResourceLocation> deps = Sets.newHashSet();
|
||||
|
||||
if (base != null)
|
||||
deps.addAll(base.getOverrideLocations());
|
||||
deps.addAll(base.getDependencies());
|
||||
|
||||
for (Pair<IUnbakedModel, IModelState> pair : parts.values())
|
||||
deps.addAll(pair.getLeft().getOverrideLocations());
|
||||
deps.addAll(pair.getLeft().getDependencies());
|
||||
|
||||
return deps;
|
||||
}
|
||||
@@ -262,27 +259,28 @@ public final class MultiModel implements IUnbakedModel
|
||||
return deps;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
IBakedModel bakedBase = null;
|
||||
|
||||
if (base != null)
|
||||
bakedBase = base.bake(modelGetter, bakedTextureGetter, state, uvlock, format);
|
||||
bakedBase = base.bake(modelGetter, spriteGetter, sprite, format);
|
||||
|
||||
ImmutableMap.Builder<String, IBakedModel> mapBuilder = ImmutableMap.builder();
|
||||
|
||||
for (Entry<String, Pair<IUnbakedModel, IModelState>> entry : parts.entrySet())
|
||||
{
|
||||
Pair<IUnbakedModel, IModelState> pair = entry.getValue();
|
||||
mapBuilder.put(entry.getKey(), pair.getLeft().bake(modelGetter, bakedTextureGetter, new ModelStateComposition(state, pair.getRight()), uvlock, format));
|
||||
mapBuilder.put(entry.getKey(), pair.getLeft().bake(modelGetter, spriteGetter, new ModelStateComposition(sprite.getState(), pair.getRight(), sprite.isUvLock()), format));
|
||||
}
|
||||
|
||||
if(bakedBase == null && parts.isEmpty())
|
||||
{
|
||||
LOGGER.error("MultiModel {} is empty (no base model or parts were provided/resolved)", location);
|
||||
IUnbakedModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
return missing.bake(modelGetter, bakedTextureGetter, missing.getDefaultState(), uvlock, format);
|
||||
return missing.bake(modelGetter, spriteGetter, new BasicState(missing.getDefaultState(), sprite.isUvLock()), format);
|
||||
}
|
||||
return new Baked(location, true, bakedBase, mapBuilder.build());
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
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 net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -104,13 +104,13 @@ public class PerspectiveMapWrapper implements IBakedModel
|
||||
}
|
||||
|
||||
@Override public boolean isAmbientOcclusion() { return parent.isAmbientOcclusion(); }
|
||||
@Override public boolean isAmbientOcclusion(IBlockState state) { return parent.isAmbientOcclusion(state); }
|
||||
@Override public boolean isAmbientOcclusion(BlockState state) { return parent.isAmbientOcclusion(state); }
|
||||
@Override public boolean isGui3d() { return parent.isGui3d(); }
|
||||
@Override public boolean isBuiltInRenderer() { return parent.isBuiltInRenderer(); }
|
||||
@Override public TextureAtlasSprite getParticleTexture() { return parent.getParticleTexture(); }
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); }
|
||||
@Override public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) { return parent.getQuads(state, side, rand); }
|
||||
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { return parent.getQuads(state, side, rand); }
|
||||
@Override public ItemOverrideList getOverrides() { return parent.getOverrides(); }
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,7 @@ import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class SimpleModelFontRenderer extends FontRenderer {
|
||||
@@ -45,7 +45,7 @@ public abstract class SimpleModelFontRenderer extends FontRenderer {
|
||||
private ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
private final VertexFormat format;
|
||||
private final Vector3f normal = new Vector3f(0, 0, 1);
|
||||
private final EnumFacing orientation;
|
||||
private final Direction orientation;
|
||||
private boolean fillBlanks = false;
|
||||
|
||||
private TextureAtlasSprite sprite;
|
||||
@@ -56,7 +56,7 @@ public abstract class SimpleModelFontRenderer extends FontRenderer {
|
||||
this.transform = new TRSRTransformation(matrix);
|
||||
this.format = format;
|
||||
transform.transformNormal(normal);
|
||||
orientation = EnumFacing.getFacingFromVector(normal.x, normal.y, normal.z);
|
||||
orientation = Direction.getFacingFromVector(normal.x, normal.y, normal.z);
|
||||
}
|
||||
|
||||
public void setSprite(TextureAtlasSprite sprite)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraftforge.common.model.IModelPart;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
@@ -29,7 +30,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
/*
|
||||
* Simple implementation of IModelState via a map and a default value.
|
||||
*/
|
||||
public final class SimpleModelState implements IModelState
|
||||
public final class SimpleModelState implements IModelState, ISprite
|
||||
{
|
||||
private final ImmutableMap<? extends IModelPart, TRSRTransformation> map;
|
||||
private final Optional<TRSRTransformation> def;
|
||||
@@ -45,6 +46,12 @@ public final class SimpleModelState implements IModelState
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getState()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part)
|
||||
{
|
||||
|
||||
+4
-4
@@ -28,7 +28,7 @@ import net.minecraft.client.renderer.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
@@ -57,7 +57,7 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
|
||||
public AnimationItemOverrideList(IUnbakedModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, List<ItemOverride> overrides)
|
||||
{
|
||||
super(model, ModelLoader.defaultModelGetter(), bakedTextureGetter, overrides);
|
||||
super(model, ModelLoader.defaultModelGetter(), overrides, bakedTextureGetter);
|
||||
this.model = model;
|
||||
this.state = state;
|
||||
this.format = format;
|
||||
@@ -65,7 +65,7 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
|
||||
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable LivingEntity entity)
|
||||
{
|
||||
return stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)
|
||||
.map(asm ->
|
||||
@@ -83,7 +83,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(ModelLoader.defaultModelGetter(), bakedTextureGetter, new ModelStateComposition(state, this.state), false, format))
|
||||
.map(state -> model.bake(ModelLoader.defaultModelGetter(), bakedTextureGetter, new ModelStateComposition(state, this.state), format))
|
||||
.orElseGet(() -> super.getModelWithOverrides(originalModel, stack, world, entity));
|
||||
}
|
||||
}
|
||||
@@ -23,19 +23,19 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBase;
|
||||
import net.minecraft.client.renderer.model.Model;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.BasicState;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.pipeline.VertexLighterFlat;
|
||||
@@ -46,12 +46,15 @@ import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
/**
|
||||
* ModelBase that works with the Forge model system and animations.
|
||||
* Some quirks are still left, deprecated for the moment.
|
||||
*/
|
||||
/*
|
||||
@Deprecated
|
||||
public class AnimationModelBase<T extends Entity> extends ModelBase implements IEventHandler<T>
|
||||
public class AnimationModelBase<T extends Entity> extends Model implements IEventHandler<T>
|
||||
{
|
||||
private final VertexLighterFlat lighter;
|
||||
private final ResourceLocation modelLocation;
|
||||
@@ -63,7 +66,7 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
//@Override
|
||||
public void render(Entity entity, float limbSwing, float limbSwingSpeed, float timeAlive, float yawHead, float rotationPitch, float scale)
|
||||
{
|
||||
entity.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)
|
||||
@@ -72,7 +75,7 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
||||
handleEvents((T) entity, timeAlive / 20, pair.getRight());
|
||||
IUnbakedModel unbaked = ModelLoaderRegistry.getModelOrMissing(modelLocation);
|
||||
// TODO where should uvlock data come from?
|
||||
return unbaked.bake(ModelLoader.defaultModelGetter(), ModelLoader.defaultTextureGetter(), pair.getLeft(), false, DefaultVertexFormats.ITEM);
|
||||
return unbaked.bake(ModelLoader.defaultModelGetter(), ModelLoader.defaultTextureGetter(), new BasicState(pair.getLeft(), false), DefaultVertexFormats.ITEM);
|
||||
}).ifPresent(model -> drawModel(model, entity));
|
||||
}
|
||||
|
||||
@@ -105,7 +108,7 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
||||
quad.pipe(lighter);
|
||||
}
|
||||
}
|
||||
for(EnumFacing side : EnumFacing.values())
|
||||
for(Direction side : Direction.values())
|
||||
{
|
||||
random.setSeed(42);
|
||||
quads = bakedModel.getQuads(null, side, random);
|
||||
@@ -121,10 +124,10 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
||||
}
|
||||
|
||||
// debug quad
|
||||
/*VertexBuffer.pos(0, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 0).lightmap(240, 0).endVertex();
|
||||
VertexBuffer.pos(0, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 1).lightmap(240, 0).endVertex();
|
||||
VertexBuffer.pos(1, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 1).lightmap(240, 0).endVertex();
|
||||
VertexBuffer.pos(1, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 0).lightmap(240, 0).endVertex();*/
|
||||
//VertexBuffer.pos(0, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 0).lightmap(240, 0).endVertex();
|
||||
//VertexBuffer.pos(0, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 1).lightmap(240, 0).endVertex();
|
||||
//VertexBuffer.pos(1, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 1).lightmap(240, 0).endVertex();
|
||||
//VertexBuffer.pos(1, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 0).lightmap(240, 0).endVertex();
|
||||
|
||||
builder.setTranslation(0, 0, 0);
|
||||
|
||||
@@ -136,3 +139,4 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
|
||||
@Override
|
||||
public void handleEvents(T instance, float time, Iterable<Event> pastEvents) {}
|
||||
}
|
||||
*/
|
||||
+3
-3
@@ -21,7 +21,7 @@ package net.minecraftforge.client.model.animation;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
@@ -56,8 +56,8 @@ public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntit
|
||||
}
|
||||
if(blockRenderer == null) blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
BlockPos pos = te.getPos();
|
||||
IWorldReader world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
net.minecraft.world.IEnviromentBlockReader world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
IBakedModel model = blockRenderer.getBlockModelShapes().getModel(state);
|
||||
IModelData data = model.getModelData(world, pos, state, ModelDataManager.getModelData(te.getWorld(), pos));
|
||||
if (data.hasProperty(Properties.AnimationProperty))
|
||||
|
||||
@@ -21,12 +21,13 @@ package net.minecraftforge.client.model.animation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
@@ -59,7 +60,7 @@ public abstract class TileEntityRendererFast<T extends TileEntity> extends TileE
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
this.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
@@ -37,6 +37,8 @@ import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
@@ -54,17 +56,13 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.client.model.ICustomModelLoader;
|
||||
@@ -460,16 +458,17 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
|
||||
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
|
||||
TextureAtlasSprite missing = spriteGetter.apply(new ResourceLocation("missingno"));
|
||||
for(Map.Entry<String, ResourceLocation> e : textures.entrySet())
|
||||
{
|
||||
if(e.getValue().getPath().startsWith("#"))
|
||||
@@ -479,11 +478,11 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue()));
|
||||
builder.put(e.getKey(), spriteGetter.apply(e.getValue()));
|
||||
}
|
||||
}
|
||||
builder.put("missingno", missing);
|
||||
return new BakedWrapper(model.getRoot(), state, smooth, gui3d, format, meshes, builder.build());
|
||||
return new BakedWrapper(model.getRoot(), sprite.getState(), smooth, gui3d, format, meshes, builder.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -647,7 +646,7 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand, IModelData data)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData data)
|
||||
{
|
||||
if(side != null) return ImmutableList.of();
|
||||
IModelState modelState = this.state;
|
||||
@@ -723,7 +722,7 @@ public enum B3DLoader implements ICustomModelLoader
|
||||
{
|
||||
UnpackedBakedQuad.Builder quadBuilder = new UnpackedBakedQuad.Builder(format);
|
||||
quadBuilder.setContractUVs(true);
|
||||
quadBuilder.setQuadOrientation(EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z));
|
||||
quadBuilder.setQuadOrientation(Direction.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z));
|
||||
List<Texture> textures = null;
|
||||
if(f.getBrush() != null) textures = f.getBrush().getTextures();
|
||||
TextureAtlasSprite sprite;
|
||||
|
||||
@@ -25,10 +25,10 @@ import java.util.Random;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
/**
|
||||
* Convenience interface with default implementation of {@link IBakedModel#getQuads(net.minecraft.block.state.IBlockState, net.minecraft.util.EnumFacing, java.util.Random)}.
|
||||
@@ -36,7 +36,7 @@ import net.minecraft.util.EnumFacing;
|
||||
public interface IDynamicBakedModel extends IBakedModel
|
||||
{
|
||||
@Override
|
||||
default @Nonnull List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, @Nonnull Random rand)
|
||||
default @Nonnull List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand)
|
||||
{
|
||||
return getQuads(state, side, rand, EmptyModelData.INSTANCE);
|
||||
}
|
||||
@@ -44,5 +44,5 @@ public interface IDynamicBakedModel extends IBakedModel
|
||||
// Force this to be overriden otherwise this introduces a default cycle between the two overloads.
|
||||
@Override
|
||||
@Nonnull
|
||||
List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, @Nonnull Random rand, @Nonnull IModelData extraData);
|
||||
List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData);
|
||||
}
|
||||
@@ -41,17 +41,15 @@ import javax.vecmath.Vector2f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.ISprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.*;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
@@ -118,17 +116,18 @@ public class OBJModel implements IUnbakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getOverrideLocations()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModelState state, boolean uvlock, VertexFormat format)
|
||||
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, ISprite sprite, VertexFormat format)
|
||||
{
|
||||
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
|
||||
builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE);
|
||||
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
|
||||
TextureAtlasSprite missing = spriteGetter.apply(new ResourceLocation("missingno"));
|
||||
for (Map.Entry<String, Material> e : matLib.materials.entrySet())
|
||||
{
|
||||
if (e.getValue().getTexture().getTextureLocation().getPath().startsWith("#"))
|
||||
@@ -138,11 +137,11 @@ public class OBJModel implements IUnbakedModel
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue().getTexture().getTextureLocation()));
|
||||
builder.put(e.getKey(), spriteGetter.apply(e.getValue().getTexture().getTextureLocation()));
|
||||
}
|
||||
}
|
||||
builder.put("missingno", missing);
|
||||
return new OBJBakedModel(this, state, format, builder.build());
|
||||
return new OBJBakedModel(this, sprite.getState(), format, builder.build());
|
||||
}
|
||||
|
||||
public MaterialLibrary getMatLib()
|
||||
@@ -1279,7 +1278,7 @@ public class OBJModel implements IUnbakedModel
|
||||
|
||||
// FIXME: merge with getQuads
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, Random rand, IModelData modelData)
|
||||
public List<BakedQuad> getQuads(BlockState blockState, Direction side, Random rand, IModelData modelData)
|
||||
{
|
||||
if (side != null) return ImmutableList.of();
|
||||
if (quads == null)
|
||||
@@ -1373,7 +1372,7 @@ public class OBJModel implements IUnbakedModel
|
||||
else sprite = this.textures.get(f.getMaterialName());
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
|
||||
builder.setContractUVs(true);
|
||||
builder.setQuadOrientation(EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z));
|
||||
builder.setQuadOrientation(Direction.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z));
|
||||
builder.setTexture(sprite);
|
||||
Normal faceNormal = f.getNormal();
|
||||
putVertexData(builder, f.verts[0], faceNormal, TextureCoordinate.getDefaultUVs()[0], sprite);
|
||||
|
||||
@@ -19,20 +19,21 @@
|
||||
|
||||
package net.minecraftforge.client.model.pipeline;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.IEnviromentBlockReader;
|
||||
|
||||
public class BlockInfo
|
||||
{
|
||||
private static final EnumFacing[] SIDES = EnumFacing.values();
|
||||
private static final Direction[] SIDES = Direction.values();
|
||||
|
||||
private final BlockColors colors;
|
||||
private IWorldReader world;
|
||||
private IBlockState state;
|
||||
private IEnviromentBlockReader world;
|
||||
private BlockState state;
|
||||
private BlockPos blockPos;
|
||||
|
||||
private final boolean[][][] t = new boolean[3][3][3];
|
||||
@@ -60,7 +61,7 @@ public class BlockInfo
|
||||
{
|
||||
if(cachedTint == tint) return cachedMultiplier;
|
||||
cachedTint = tint;
|
||||
cachedMultiplier = colors.getColor(state, world, blockPos, tint);
|
||||
cachedMultiplier = colors.func_216860_a(state, world, blockPos, tint);
|
||||
return cachedMultiplier;
|
||||
}
|
||||
|
||||
@@ -72,14 +73,14 @@ public class BlockInfo
|
||||
shz = (float) offset.z;
|
||||
}
|
||||
|
||||
public void setWorld(IWorldReader world)
|
||||
public void setWorld(IEnviromentBlockReader world)
|
||||
{
|
||||
this.world = world;
|
||||
cachedTint = -1;
|
||||
cachedMultiplier = -1;
|
||||
}
|
||||
|
||||
public void setState(IBlockState state)
|
||||
public void setState(BlockState state)
|
||||
{
|
||||
this.state = state;
|
||||
cachedTint = -1;
|
||||
@@ -122,16 +123,16 @@ public class BlockInfo
|
||||
for(int z = 0; z <= 2; z++)
|
||||
{
|
||||
BlockPos pos = blockPos.add(x - 1, y - 1, z - 1);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
t[x][y][z] = state.getOpacity(world, pos) < 15;
|
||||
int brightness = state.getPackedLightmapCoords(world, pos);
|
||||
int brightness = state.func_215684_a(world, pos);
|
||||
s[x][y][z] = (brightness >> 0x14) & 0xF;
|
||||
b[x][y][z] = (brightness >> 0x04) & 0xF;
|
||||
ao[x][y][z] = state.getAmbientOcclusionLightValue();
|
||||
ao[x][y][z] = state.func_215703_d(world, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(EnumFacing side : SIDES)
|
||||
for(Direction side : SIDES)
|
||||
{
|
||||
if(!state.doesSideBlockRendering(world, blockPos, side))
|
||||
{
|
||||
@@ -185,22 +186,22 @@ public class BlockInfo
|
||||
|
||||
public void updateFlatLighting()
|
||||
{
|
||||
full = state.isFullCube();
|
||||
packed[0] = state.getPackedLightmapCoords(world, blockPos);
|
||||
full = Block.isOpaque(state.getCollisionShape(world, blockPos));
|
||||
packed[0] = state.func_215684_a(world, blockPos);
|
||||
|
||||
for (EnumFacing side : SIDES)
|
||||
for (Direction side : SIDES)
|
||||
{
|
||||
int i = side.ordinal() + 1;
|
||||
packed[i] = state.getPackedLightmapCoords(world, blockPos.offset(side));
|
||||
packed[i] = state.func_215684_a(world, blockPos.offset(side));
|
||||
}
|
||||
}
|
||||
|
||||
public IWorldReader getWorld()
|
||||
public IEnviromentBlockReader getWorld()
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
public IBlockState getState()
|
||||
public BlockState getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
+14
-12
@@ -23,16 +23,18 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IEnviromentBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
|
||||
public class ForgeBlockModelRenderer extends BlockModelRenderer
|
||||
@@ -50,7 +52,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderModelFlat(IWorldReader world, IBakedModel model, IBlockState state, BlockPos pos, BufferBuilder buffer, boolean checkSides, Random rand, long seed)
|
||||
public boolean renderModelFlat(IEnviromentBlockReader world, IBakedModel model, BlockState state, BlockPos pos, BufferBuilder buffer, boolean checkSides, Random rand, long seed, IModelData modelData)
|
||||
{
|
||||
if(ForgeMod.forgeLightPipelineEnabled)
|
||||
{
|
||||
@@ -61,16 +63,16 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
||||
VertexLighterFlat lighter = lighterFlat.get();
|
||||
lighter.setParent(consumer);
|
||||
|
||||
return render(lighter, world, model, state, pos, buffer, checkSides, rand, seed);
|
||||
return render(lighter, world, model, state, pos, buffer, checkSides, rand, seed, modelData);
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.renderModelFlat(world, model, state, pos, buffer, checkSides, rand, seed);
|
||||
return super.renderModelFlat(world, model, state, pos, buffer, checkSides, rand, seed, modelData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderModelSmooth(IWorldReader world, IBakedModel model, IBlockState state, BlockPos pos, BufferBuilder buffer, boolean checkSides, Random rand, long seed)
|
||||
public boolean renderModelSmooth(IEnviromentBlockReader world, IBakedModel model, BlockState state, BlockPos pos, BufferBuilder buffer, boolean checkSides, Random rand, long seed, IModelData modelData)
|
||||
{
|
||||
if(ForgeMod.forgeLightPipelineEnabled)
|
||||
{
|
||||
@@ -81,22 +83,22 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
||||
VertexLighterSmoothAo lighter = lighterSmooth.get();
|
||||
lighter.setParent(consumer);
|
||||
|
||||
return render(lighter, world, model, state, pos, buffer, checkSides, rand, seed);
|
||||
return render(lighter, world, model, state, pos, buffer, checkSides, rand, seed, modelData);
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.renderModelSmooth(world, model, state, pos, buffer, checkSides, rand, seed);
|
||||
return super.renderModelSmooth(world, model, state, pos, buffer, checkSides, rand, seed, modelData);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean render(VertexLighterFlat lighter, IWorldReader world, IBakedModel model, IBlockState state, BlockPos pos, BufferBuilder wr, boolean checkSides, Random rand, long seed)
|
||||
public static boolean render(VertexLighterFlat lighter, IEnviromentBlockReader world, IBakedModel model, BlockState state, BlockPos pos, BufferBuilder wr, boolean checkSides, Random rand, long seed, IModelData modelData)
|
||||
{
|
||||
lighter.setWorld(world);
|
||||
lighter.setState(state);
|
||||
lighter.setBlockPos(pos);
|
||||
boolean empty = true;
|
||||
rand.setSeed(seed);
|
||||
List<BakedQuad> quads = model.getQuads(state, null, rand);
|
||||
List<BakedQuad> quads = model.getQuads(state, null, rand, modelData);
|
||||
if(!quads.isEmpty())
|
||||
{
|
||||
lighter.updateBlockInfo();
|
||||
@@ -106,10 +108,10 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
||||
quad.pipe(lighter);
|
||||
}
|
||||
}
|
||||
for(EnumFacing side : EnumFacing.values())
|
||||
for(Direction side : Direction.values())
|
||||
{
|
||||
rand.setSeed(seed);
|
||||
quads = model.getQuads(state, side, rand);
|
||||
quads = model.getQuads(state, side, rand, modelData);
|
||||
if(!quads.isEmpty())
|
||||
{
|
||||
if(!checkSides || Block.shouldSideBeRendered(state, world, pos, side))
|
||||
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.client.model.pipeline;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
/**
|
||||
* Assumes that the data length is not less than e.getElementCount().
|
||||
@@ -36,7 +36,7 @@ public interface IVertexConsumer
|
||||
VertexFormat getVertexFormat();
|
||||
|
||||
void setQuadTint(int tint);
|
||||
void setQuadOrientation(EnumFacing orientation);
|
||||
void setQuadOrientation(Direction orientation);
|
||||
void setApplyDiffuseLighting(boolean diffuse);
|
||||
void setTexture(TextureAtlasSprite texture);
|
||||
void put(int element, float... data);
|
||||
|
||||
@@ -25,8 +25,8 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.Usage;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class LightUtil
|
||||
return Math.min(x * x * 0.6f + y * y * ((3f + y) / 4f) + z * z * 0.8f, 1f);
|
||||
}
|
||||
|
||||
public static float diffuseLight(EnumFacing side)
|
||||
public static float diffuseLight(Direction side)
|
||||
{
|
||||
switch(side)
|
||||
{
|
||||
@@ -56,32 +56,32 @@ public class LightUtil
|
||||
}
|
||||
}
|
||||
|
||||
public static EnumFacing toSide(float x, float y, float z)
|
||||
public static Direction toSide(float x, float y, float z)
|
||||
{
|
||||
if(Math.abs(x) > Math.abs(y))
|
||||
{
|
||||
if(Math.abs(x) > Math.abs(z))
|
||||
{
|
||||
if(x < 0) return EnumFacing.WEST;
|
||||
return EnumFacing.EAST;
|
||||
if(x < 0) return Direction.WEST;
|
||||
return Direction.EAST;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(z < 0) return EnumFacing.NORTH;
|
||||
return EnumFacing.SOUTH;
|
||||
if(z < 0) return Direction.NORTH;
|
||||
return Direction.SOUTH;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Math.abs(y) > Math.abs(z))
|
||||
{
|
||||
if(y < 0) return EnumFacing.DOWN;
|
||||
return EnumFacing.UP;
|
||||
if(y < 0) return Direction.DOWN;
|
||||
return Direction.UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(z < 0) return EnumFacing.NORTH;
|
||||
return EnumFacing.SOUTH;
|
||||
if(z < 0) return Direction.NORTH;
|
||||
return Direction.SOUTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class LightUtil
|
||||
VertexFormatElement element = formatFrom.getElement(e);
|
||||
int vertexStart = v * formatFrom.getSize() + formatFrom.getOffset(e);
|
||||
int count = element.getElementCount();
|
||||
VertexFormatElement.EnumType type = element.getType();
|
||||
VertexFormatElement.Type type = element.getType();
|
||||
int size = type.getSize();
|
||||
int mask = (256 << (8 * (size - 1))) - 1;
|
||||
for(int i = 0; i < length; i++)
|
||||
@@ -177,27 +177,27 @@ public class LightUtil
|
||||
bits |= from[index + 1] << ((4 - offset) * 8);
|
||||
}
|
||||
bits &= mask;
|
||||
if(type == VertexFormatElement.EnumType.FLOAT)
|
||||
if(type == VertexFormatElement.Type.FLOAT)
|
||||
{
|
||||
to[i] = Float.intBitsToFloat(bits);
|
||||
}
|
||||
else if(type == VertexFormatElement.EnumType.UBYTE || type == VertexFormatElement.EnumType.USHORT)
|
||||
else if(type == VertexFormatElement.Type.UBYTE || type == VertexFormatElement.Type.USHORT)
|
||||
{
|
||||
to[i] = (float)bits / mask;
|
||||
}
|
||||
else if(type == VertexFormatElement.EnumType.UINT)
|
||||
else if(type == VertexFormatElement.Type.UINT)
|
||||
{
|
||||
to[i] = (float)((double)(bits & 0xFFFFFFFFL) / 0xFFFFFFFFL);
|
||||
}
|
||||
else if(type == VertexFormatElement.EnumType.BYTE)
|
||||
else if(type == VertexFormatElement.Type.BYTE)
|
||||
{
|
||||
to[i] = ((float)(byte)bits) / (mask >> 1);
|
||||
}
|
||||
else if(type == VertexFormatElement.EnumType.SHORT)
|
||||
else if(type == VertexFormatElement.Type.SHORT)
|
||||
{
|
||||
to[i] = ((float)(short)bits) / (mask >> 1);
|
||||
}
|
||||
else if(type == VertexFormatElement.EnumType.INT)
|
||||
else if(type == VertexFormatElement.Type.INT)
|
||||
{
|
||||
to[i] = (float)((double)(bits & 0xFFFFFFFFL) / (0xFFFFFFFFL >> 1));
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public class LightUtil
|
||||
VertexFormatElement element = formatTo.getElement(e);
|
||||
int vertexStart = v * formatTo.getSize() + formatTo.getOffset(e);
|
||||
int count = element.getElementCount();
|
||||
VertexFormatElement.EnumType type = element.getType();
|
||||
VertexFormatElement.Type type = element.getType();
|
||||
int size = type.getSize();
|
||||
int mask = (256 << (8 * (size - 1))) - 1;
|
||||
for(int i = 0; i < 4; i++)
|
||||
@@ -226,14 +226,14 @@ public class LightUtil
|
||||
int offset = pos & 3;
|
||||
int bits = 0;
|
||||
float f = i < from.length ? from[i] : 0;
|
||||
if(type == VertexFormatElement.EnumType.FLOAT)
|
||||
if(type == VertexFormatElement.Type.FLOAT)
|
||||
{
|
||||
bits = Float.floatToRawIntBits(f);
|
||||
}
|
||||
else if(
|
||||
type == VertexFormatElement.EnumType.UBYTE ||
|
||||
type == VertexFormatElement.EnumType.USHORT ||
|
||||
type == VertexFormatElement.EnumType.UINT
|
||||
type == VertexFormatElement.Type.UBYTE ||
|
||||
type == VertexFormatElement.Type.USHORT ||
|
||||
type == VertexFormatElement.Type.UINT
|
||||
)
|
||||
{
|
||||
bits = Math.round(f * mask);
|
||||
@@ -339,7 +339,7 @@ public class LightUtil
|
||||
@Override
|
||||
public void put(int element, float... data)
|
||||
{
|
||||
if(getVertexFormat().getElement(element).getUsage() == EnumUsage.COLOR)
|
||||
if(getVertexFormat().getElement(element).getUsage() == Usage.COLOR)
|
||||
{
|
||||
System.arraycopy(auxColor, 0, buf, 0, buf.length);
|
||||
int n = Math.min(4, data.length);
|
||||
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.client.renderer.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.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
// advantages: non-fixed-length vertex format, no overhead of packing and unpacking attributes to transform the model
|
||||
// disadvantages: (possibly) larger memory footprint, overhead on packing the attributes at the final rendering stage
|
||||
@@ -33,7 +33,7 @@ public class UnpackedBakedQuad extends BakedQuad
|
||||
protected final VertexFormat format;
|
||||
protected boolean packed = false;
|
||||
|
||||
public UnpackedBakedQuad(float[][][] unpackedData, int tint, EnumFacing orientation, TextureAtlasSprite texture, boolean applyDiffuseLighting, VertexFormat format)
|
||||
public UnpackedBakedQuad(float[][][] unpackedData, int tint, Direction orientation, TextureAtlasSprite texture, boolean applyDiffuseLighting, VertexFormat format)
|
||||
{
|
||||
super(new int[format.getSize() /* / 4 * 4 */], tint, orientation, texture, applyDiffuseLighting, format);
|
||||
this.unpackedData = unpackedData;
|
||||
@@ -90,7 +90,7 @@ public class UnpackedBakedQuad extends BakedQuad
|
||||
private final VertexFormat format;
|
||||
private final float[][][] unpackedData;
|
||||
private int tint = -1;
|
||||
private EnumFacing orientation;
|
||||
private Direction orientation;
|
||||
private TextureAtlasSprite texture;
|
||||
private boolean applyDiffuseLighting = true;
|
||||
|
||||
@@ -122,7 +122,7 @@ public class UnpackedBakedQuad extends BakedQuad
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuadOrientation(EnumFacing orientation)
|
||||
public void setQuadOrientation(Direction orientation)
|
||||
{
|
||||
this.orientation = orientation;
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class UnpackedBakedQuad extends BakedQuad
|
||||
while(uve < format.getElementCount())
|
||||
{
|
||||
VertexFormatElement e = format.getElement(uve);
|
||||
if(e.getUsage() == VertexFormatElement.EnumUsage.UV && e.getIndex() == 0)
|
||||
if(e.getUsage() == VertexFormatElement.Usage.UV && e.getIndex() == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ package net.minecraftforge.client.model.pipeline;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.Usage;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
/**
|
||||
* Assumes VertexFormatElement is present in the BufferBuilder's vertex format.
|
||||
@@ -55,7 +55,7 @@ public class VertexBufferConsumer implements IVertexConsumer
|
||||
public void put(int e, float... data)
|
||||
{
|
||||
VertexFormat format = getVertexFormat();
|
||||
if(renderer.isColorDisabled() && format.getElement(e).getUsage() == EnumUsage.COLOR)
|
||||
if(renderer.isColorDisabled() && format.getElement(e).getUsage() == Usage.COLOR)
|
||||
{
|
||||
data = dummyColor;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class VertexBufferConsumer implements IVertexConsumer
|
||||
@Override
|
||||
public void setQuadTint(int tint) {}
|
||||
@Override
|
||||
public void setQuadOrientation(EnumFacing orientation) {}
|
||||
public void setQuadOrientation(Direction orientation) {}
|
||||
@Override
|
||||
public void setApplyDiffuseLighting(boolean diffuse) {}
|
||||
@Override
|
||||
|
||||
@@ -21,22 +21,23 @@ package net.minecraftforge.client.model.pipeline;
|
||||
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
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.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IEnviromentBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class VertexLighterFlat extends QuadGatheringTransformer
|
||||
{
|
||||
protected static final VertexFormatElement NORMAL_4F = new VertexFormatElement(0, VertexFormatElement.EnumType.FLOAT, VertexFormatElement.EnumUsage.NORMAL, 4);
|
||||
protected static final VertexFormatElement NORMAL_4F = new VertexFormatElement(0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.NORMAL, 4);
|
||||
|
||||
protected final BlockInfo blockInfo;
|
||||
private int tint = -1;
|
||||
@@ -243,14 +244,14 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
||||
final float e2 = 0.95f;
|
||||
|
||||
boolean full = blockInfo.isFullCube();
|
||||
EnumFacing side = null;
|
||||
Direction side = null;
|
||||
|
||||
if((full || y < -e1) && normal[1] < -e2) side = EnumFacing.DOWN;
|
||||
else if((full || y > e1) && normal[1] > e2) side = EnumFacing.UP;
|
||||
else if((full || z < -e1) && normal[2] < -e2) side = EnumFacing.NORTH;
|
||||
else if((full || z > e1) && normal[2] > e2) side = EnumFacing.SOUTH;
|
||||
else if((full || x < -e1) && normal[0] < -e2) side = EnumFacing.WEST;
|
||||
else if((full || x > e1) && normal[0] > e2) side = EnumFacing.EAST;
|
||||
if((full || y < -e1) && normal[1] < -e2) side = Direction.DOWN;
|
||||
else if((full || y > e1) && normal[1] > e2) side = Direction.UP;
|
||||
else if((full || z < -e1) && normal[2] < -e2) side = Direction.NORTH;
|
||||
else if((full || z > e1) && normal[2] > e2) side = Direction.SOUTH;
|
||||
else if((full || x < -e1) && normal[0] < -e2) side = Direction.WEST;
|
||||
else if((full || x > e1) && normal[0] > e2) side = Direction.EAST;
|
||||
|
||||
int i = side == null ? 0 : side.ordinal() + 1;
|
||||
int brightness = blockInfo.getPackedLight()[i];
|
||||
@@ -275,7 +276,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
||||
this.tint = tint;
|
||||
}
|
||||
@Override
|
||||
public void setQuadOrientation(EnumFacing orientation) {}
|
||||
public void setQuadOrientation(Direction orientation) {}
|
||||
public void setQuadCulled() {}
|
||||
@Override
|
||||
public void setTexture(TextureAtlasSprite texture) {}
|
||||
@@ -285,12 +286,12 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
||||
this.diffuse = diffuse;
|
||||
}
|
||||
|
||||
public void setWorld(IWorldReader world)
|
||||
public void setWorld(IEnviromentBlockReader world)
|
||||
{
|
||||
blockInfo.setWorld(world);
|
||||
}
|
||||
|
||||
public void setState(IBlockState state)
|
||||
public void setState(BlockState state)
|
||||
{
|
||||
blockInfo.setState(state);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.client.model.pipeline;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class VertexTransformer implements IVertexConsumer
|
||||
{
|
||||
@@ -51,7 +51,7 @@ public class VertexTransformer implements IVertexConsumer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuadOrientation(EnumFacing orientation)
|
||||
public void setQuadOrientation(Direction orientation)
|
||||
{
|
||||
parent.setQuadOrientation(orientation);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ package net.minecraftforge.client.settings;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.util.IntHashMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package net.minecraftforge.client.settings;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public enum KeyConflictContext implements IKeyConflictContext
|
||||
{
|
||||
|
||||
@@ -19,10 +19,12 @@
|
||||
|
||||
package net.minecraftforge.client.settings;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
|
||||
@@ -47,13 +49,13 @@ public enum KeyModifier {
|
||||
@Override
|
||||
public boolean isActive(@Nullable IKeyConflictContext conflictContext)
|
||||
{
|
||||
return GuiScreen.isCtrlKeyDown();
|
||||
return Screen.hasControlDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedComboName(InputMappings.Input key)
|
||||
public String getLocalizedComboName(InputMappings.Input key, Supplier<String> defaultLogic)
|
||||
{
|
||||
String keyName = key.getName();
|
||||
String keyName = defaultLogic.get();
|
||||
String localizationFormatKey = Minecraft.IS_RUNNING_ON_MAC ? "forge.controlsgui.control.mac" : "forge.controlsgui.control";
|
||||
return I18n.format(localizationFormatKey, keyName);
|
||||
}
|
||||
@@ -68,13 +70,13 @@ public enum KeyModifier {
|
||||
@Override
|
||||
public boolean isActive(@Nullable IKeyConflictContext conflictContext)
|
||||
{
|
||||
return GuiScreen.isShiftKeyDown();
|
||||
return Screen.hasShiftDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedComboName(InputMappings.Input key)
|
||||
public String getLocalizedComboName(InputMappings.Input key, Supplier<String> defaultLogic)
|
||||
{
|
||||
return I18n.format("forge.controlsgui.shift", key.getName());
|
||||
return I18n.format("forge.controlsgui.shift", defaultLogic.get());
|
||||
}
|
||||
},
|
||||
ALT {
|
||||
@@ -87,13 +89,13 @@ public enum KeyModifier {
|
||||
@Override
|
||||
public boolean isActive(@Nullable IKeyConflictContext conflictContext)
|
||||
{
|
||||
return GuiScreen.isAltKeyDown();
|
||||
return Screen.hasAltDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedComboName(InputMappings.Input keyCode)
|
||||
public String getLocalizedComboName(InputMappings.Input keyCode, Supplier<String> defaultLogic)
|
||||
{
|
||||
return I18n.format("forge.controlsgui.alt", keyCode.getName());
|
||||
return I18n.format("forge.controlsgui.alt", defaultLogic.get());
|
||||
}
|
||||
},
|
||||
NONE {
|
||||
@@ -120,9 +122,9 @@ public enum KeyModifier {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedComboName(InputMappings.Input key)
|
||||
public String getLocalizedComboName(InputMappings.Input key, Supplier<String> defaultLogic)
|
||||
{
|
||||
return key.getName();
|
||||
return defaultLogic.get();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -168,5 +170,5 @@ public enum KeyModifier {
|
||||
|
||||
public abstract boolean isActive(@Nullable IKeyConflictContext conflictContext);
|
||||
|
||||
public abstract String getLocalizedComboName(InputMappings.Input key);
|
||||
public abstract String getLocalizedComboName(InputMappings.Input key, Supplier<String> defaultLogic);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import javax.annotation.Nullable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.init.Biomes;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.biome.*;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.*;
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.init.Biomes;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.provider.BiomeProvider;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -40,16 +41,18 @@ import com.google.common.collect.MapMaker;
|
||||
import com.google.common.collect.Multiset;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.MutableRegistry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ServerWorldEventHandler;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.WorldServerMulti;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.chunk.listener.IChunkStatusListener;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
import net.minecraft.world.ServerMultiWorld;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.event.world.RegisterDimensionsEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
@@ -88,10 +91,10 @@ public class DimensionManager
|
||||
* @param type Dimension Type.
|
||||
* @param data Configuration data for this dimension, passed into
|
||||
*/
|
||||
public static DimensionType registerDimension(ResourceLocation name, ModDimension type, PacketBuffer data)
|
||||
public static DimensionType registerDimension(ResourceLocation name, ModDimension type, PacketBuffer data, boolean hasSkyLight)
|
||||
{
|
||||
Validate.notNull(name, "Can not register a dimension with null name");
|
||||
Validate.isTrue(!REGISTRY.func_212607_c(name), "Dimension: " + name + " Already registered");
|
||||
Validate.isTrue(!REGISTRY.containsKey(name), "Dimension: " + name + " Already registered");
|
||||
Validate.notNull(type, "Can not register a null dimension type");
|
||||
|
||||
int id = REGISTRY.getNextId();
|
||||
@@ -103,8 +106,9 @@ public class DimensionManager
|
||||
LOGGER.info(DIMMGR, "Changing ModDimension for '{}' from '{}' to '{}'", name.toString(), old.getType() == null ? null : old.getType().toString(), type.getRegistryName().toString());
|
||||
savedEntries.remove(name);
|
||||
}
|
||||
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), type, data);
|
||||
REGISTRY.register(id, name, instance);
|
||||
@SuppressWarnings("deprecation")
|
||||
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), hasSkyLight, type, data);
|
||||
REGISTRY.func_218382_a(id, name, instance);
|
||||
LOGGER.info(DIMMGR, "Registered dimension {} of type {} and id {}", name.toString(), type.getRegistryName().toString(), id);
|
||||
return instance;
|
||||
}
|
||||
@@ -147,7 +151,7 @@ public class DimensionManager
|
||||
* @return The world, null if unloaded and not loadable.
|
||||
*/
|
||||
@Nullable
|
||||
public static WorldServer getWorld(MinecraftServer server, DimensionType dim, boolean resetUnloadDelay, boolean forceLoad)
|
||||
public static ServerWorld getWorld(MinecraftServer server, DimensionType dim, boolean resetUnloadDelay, boolean forceLoad)
|
||||
{
|
||||
Validate.notNull(server, "Must provide server when creating world");
|
||||
Validate.notNull(dim, "Dimension type must not be null");
|
||||
@@ -161,7 +165,7 @@ public class DimensionManager
|
||||
getData(dim).ticksWaited = 0;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
WorldServer ret = server.forgeGetWorldMap().get(dim);
|
||||
ServerWorld ret = server.forgeGetWorldMap().get(dim);
|
||||
if (ret == null && forceLoad)
|
||||
ret = initWorld(server, dim);
|
||||
return ret;
|
||||
@@ -177,47 +181,45 @@ public class DimensionManager
|
||||
dimensions.remove(id);
|
||||
}
|
||||
|
||||
public static DimensionType registerDimensionInternal(int id, ResourceLocation name, ModDimension type, PacketBuffer data)
|
||||
public static DimensionType registerDimensionInternal(int id, ResourceLocation name, ModDimension type, PacketBuffer data, boolean hasSkyLight)
|
||||
{
|
||||
Validate.notNull(name, "Can not register a dimension with null name");
|
||||
Validate.notNull(type, "Can not register a null dimension type");
|
||||
Validate.isTrue(!REGISTRY.func_212607_c(name), "Dimension: " + name + " Already registered");
|
||||
Validate.isTrue(REGISTRY.get(id) == null, "Dimension with id " + id + " already registered as name " + REGISTRY.getKey(REGISTRY.get(id)));
|
||||
Validate.isTrue(!REGISTRY.containsKey(name), "Dimension: " + name + " Already registered");
|
||||
Validate.isTrue(REGISTRY.getByValue(id) == null, "Dimension with id " + id + " already registered as name " + REGISTRY.getKey(REGISTRY.getByValue(id)));
|
||||
|
||||
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), type, data);
|
||||
REGISTRY.register(id, name, instance);
|
||||
@SuppressWarnings("deprecation")
|
||||
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), hasSkyLight, type, data);
|
||||
REGISTRY.func_218382_a(id, name, instance);
|
||||
LOGGER.info(DIMMGR, "Registered dimension {} of type {} and id {}", name.toString(), type.getRegistryName().toString(), id);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static WorldServer initWorld(MinecraftServer server, DimensionType dim)
|
||||
public static ServerWorld initWorld(MinecraftServer server, DimensionType dim)
|
||||
{
|
||||
Validate.isTrue(dim != DimensionType.OVERWORLD, "Can not hotload overworld. This must be loaded at all times by main Server.");
|
||||
Validate.notNull(server, "Must provide server when creating world");
|
||||
Validate.notNull(dim, "Must provide dimension when creating world");
|
||||
|
||||
WorldServer overworld = getWorld(server, DimensionType.OVERWORLD, false, false);
|
||||
ServerWorld overworld = getWorld(server, DimensionType.OVERWORLD, false, false);
|
||||
Validate.notNull(overworld, "Cannot Hotload Dim: Overworld is not Loaded!");
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
WorldServer world = new WorldServerMulti(server, overworld.getSaveHandler(), dim, overworld, server.profiler).func_212251_i__();
|
||||
world.addEventListener(new ServerWorldEventHandler(server, world));
|
||||
ServerWorld world = new ServerMultiWorld(overworld, server, server.func_213207_aT(), overworld.func_217485_w(), dim, server.func_213185_aS(), new NoopChunkStatusListener());
|
||||
if (!server.isSinglePlayer())
|
||||
world.getWorldInfo().setGameType(server.getGameType());
|
||||
server.forgeGetWorldMap().put(dim, world);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
|
||||
|
||||
server.setDifficultyForAllWorlds(server.getDifficulty());
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
private static boolean canUnloadWorld(WorldServer world)
|
||||
private static boolean canUnloadWorld(ServerWorld world)
|
||||
{
|
||||
return world.func_212412_ag().isEmpty()
|
||||
&& world.playerEntities.isEmpty()
|
||||
return world.func_217469_z().isEmpty()
|
||||
&& world.func_217369_A().isEmpty()
|
||||
//&& !world.dimension.getType().shouldLoadSpawn()
|
||||
&& !getData(world.getDimension().getType()).keepLoaded;
|
||||
}
|
||||
@@ -226,7 +228,7 @@ public class DimensionManager
|
||||
* Queues a dimension to unload, if it can be unloaded.
|
||||
* @param id The id of the dimension
|
||||
*/
|
||||
public static void unloadWorld(WorldServer world)
|
||||
public static void unloadWorld(ServerWorld world)
|
||||
{
|
||||
if (world == null || !canUnloadWorld(world))
|
||||
return;
|
||||
@@ -261,7 +263,7 @@ public class DimensionManager
|
||||
|
||||
queueIterator.remove();
|
||||
|
||||
WorldServer w = server.forgeGetWorldMap().get(dim);
|
||||
ServerWorld w = server.forgeGetWorldMap().get(dim);
|
||||
|
||||
dimension.ticksWaited = 0;
|
||||
// Don't unload the world if the status changed
|
||||
@@ -272,7 +274,7 @@ public class DimensionManager
|
||||
}
|
||||
try
|
||||
{
|
||||
w.saveAllChunks(true, null);
|
||||
w.func_217445_a(null, true, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -281,7 +283,11 @@ public class DimensionManager
|
||||
finally
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(w));
|
||||
w.close();
|
||||
try {
|
||||
w.close();
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Exception closing the level", e);
|
||||
}
|
||||
server.forgeGetWorldMap().remove(dim);
|
||||
}
|
||||
}
|
||||
@@ -304,22 +310,22 @@ public class DimensionManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeRegistry(NBTTagCompound data)
|
||||
public static void writeRegistry(CompoundNBT data)
|
||||
{
|
||||
data.setInt("version", 1);
|
||||
data.putInt("version", 1);
|
||||
List<SavedEntry> list = new ArrayList<>();
|
||||
for (DimensionType type : REGISTRY)
|
||||
list.add(new SavedEntry(type));
|
||||
savedEntries.values().forEach(list::add);
|
||||
|
||||
Collections.sort(list, (a, b) -> a.id - b.id);
|
||||
NBTTagList lst = new NBTTagList();
|
||||
ListNBT lst = new ListNBT();
|
||||
list.forEach(e -> lst.add(e.write()));
|
||||
|
||||
data.setTag("entries", lst);
|
||||
data.func_218657_a("entries", lst);
|
||||
}
|
||||
|
||||
public static void readRegistry(NBTTagCompound data)
|
||||
public static void readRegistry(CompoundNBT data)
|
||||
{
|
||||
int version = data.getInt("version");
|
||||
if (version != 1)
|
||||
@@ -330,19 +336,19 @@ public class DimensionManager
|
||||
REGISTRY.clear();
|
||||
vanilla.forEach((key, value) -> {
|
||||
LOGGER.debug(DIMMGR, "Registering vanilla entry ID: {} Name: {} Value: {}", value.getId() + 1, key.toString(), value.toString());
|
||||
REGISTRY.register(value.getId() + 1, key, value);
|
||||
REGISTRY.func_218382_a(value.getId() + 1, key, value);
|
||||
});
|
||||
|
||||
savedEntries.clear();
|
||||
|
||||
boolean error = false;
|
||||
NBTTagList list = data.getList("entries", 10);
|
||||
ListNBT list = data.getList("entries", 10);
|
||||
for (int x = 0; x < list.size(); x++)
|
||||
{
|
||||
SavedEntry entry = new SavedEntry(list.getCompound(x));
|
||||
if (entry.type == null)
|
||||
{
|
||||
DimensionType type = REGISTRY.func_212608_b(entry.name);
|
||||
DimensionType type = REGISTRY.getOrDefault(entry.name);
|
||||
if (type == null)
|
||||
{
|
||||
LOGGER.error(DIMMGR, "Vanilla entry '{}' id {} in save file not found in registry.", entry.name.toString(), entry.id);
|
||||
@@ -366,7 +372,7 @@ public class DimensionManager
|
||||
savedEntries.put(entry.name, entry);
|
||||
continue;
|
||||
}
|
||||
registerDimensionInternal(entry.id, entry.name, mod, entry.data == null ? null : new PacketBuffer(Unpooled.wrappedBuffer(entry.data)));
|
||||
registerDimensionInternal(entry.id, entry.name, mod, entry.data == null ? null : new PacketBuffer(Unpooled.wrappedBuffer(entry.data)), entry.skyLight());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +388,7 @@ public class DimensionManager
|
||||
}
|
||||
|
||||
@Deprecated //Forge: Internal use only.
|
||||
public static IRegistry<DimensionType> getRegistry()
|
||||
public static MutableRegistry<DimensionType> getRegistry()
|
||||
{
|
||||
return REGISTRY;
|
||||
}
|
||||
@@ -404,6 +410,7 @@ public class DimensionManager
|
||||
ResourceLocation name;
|
||||
ResourceLocation type;
|
||||
byte[] data;
|
||||
boolean skyLight;
|
||||
|
||||
public int getId()
|
||||
{
|
||||
@@ -427,12 +434,18 @@ public class DimensionManager
|
||||
return data;
|
||||
}
|
||||
|
||||
private SavedEntry(NBTTagCompound data)
|
||||
public boolean skyLight()
|
||||
{
|
||||
return this.skyLight;
|
||||
}
|
||||
|
||||
private SavedEntry(CompoundNBT data)
|
||||
{
|
||||
this.id = data.getInt("id");
|
||||
this.name = new ResourceLocation(data.getString("name"));
|
||||
this.type = data.contains("type", 8) ? new ResourceLocation(data.getString("type")) : null;
|
||||
this.data = data.contains("data", 7) ? data.getByteArray("data") : null;
|
||||
this.skyLight = data.contains("sky_light", 99) ? data.getByte("sky_light") == 0 : true;
|
||||
}
|
||||
|
||||
private SavedEntry(DimensionType data)
|
||||
@@ -443,18 +456,27 @@ public class DimensionManager
|
||||
this.type = data.getModType().getRegistryName();
|
||||
if (data.getData() != null)
|
||||
this.data = data.getData().array();
|
||||
this.skyLight = data.func_218272_d();
|
||||
}
|
||||
|
||||
private NBTTagCompound write()
|
||||
private CompoundNBT write()
|
||||
{
|
||||
NBTTagCompound ret = new NBTTagCompound();
|
||||
ret.setInt("id", id);
|
||||
ret.setString("name", name.toString());
|
||||
CompoundNBT ret = new CompoundNBT();
|
||||
ret.putInt("id", id);
|
||||
ret.putString("name", name.toString());
|
||||
if (type != null)
|
||||
ret.setString("type", type.toString());
|
||||
ret.putString("type", type.toString());
|
||||
if (data != null)
|
||||
ret.setByteArray("data", data);
|
||||
ret.putByteArray("data", data);
|
||||
ret.putByte("sky_light", (byte)(skyLight ? 1 : 0));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
private static class NoopChunkStatusListener implements IChunkStatusListener
|
||||
{
|
||||
@Override public void func_219509_a(ChunkPos p_219509_1_) { }
|
||||
@Override public void func_219508_a(ChunkPos p_219508_1_, ChunkStatus p_219508_2_) { }
|
||||
@Override public void func_219510_b() { }
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
@@ -50,11 +51,15 @@ public class DungeonHooks
|
||||
throw new IllegalArgumentException("Rarity must be greater then zero");
|
||||
}
|
||||
|
||||
for (DungeonMob mob : dungeonMobs)
|
||||
Iterator<DungeonMob> itr = dungeonMobs.iterator();
|
||||
while (itr.hasNext())
|
||||
{
|
||||
DungeonMob mob = itr.next();
|
||||
if (type == mob.type)
|
||||
{
|
||||
return mob.itemWeight += rarity;
|
||||
itr.remove();
|
||||
rarity = mob.itemWeight + rarity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IWorldReaderBase;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraftforge.common.ticket.AABBTicket;
|
||||
@@ -107,7 +106,7 @@ public class FarmlandWaterManager
|
||||
* Tests if a block is in a region that is watered by blocks. This does not check vanilla water, see {@link net.minecraft.block.BlockFarmland#hasWater(World, BlockPos)}
|
||||
* @return true if there is a ticket with an AABB that includes your block
|
||||
*/
|
||||
public static boolean hasBlockWaterTicket(IWorldReaderBase world, BlockPos pos)
|
||||
public static boolean hasBlockWaterTicket(IWorldReader world, BlockPos pos)
|
||||
{
|
||||
ChunkTicketManager<Vec3d> ticketManager = getTicketManager(new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4), world);
|
||||
if (ticketManager != null)
|
||||
@@ -133,7 +132,7 @@ public class FarmlandWaterManager
|
||||
}
|
||||
}
|
||||
|
||||
private static ChunkTicketManager<Vec3d> getTicketManager(ChunkPos pos, IWorldReaderBase world) {
|
||||
private static ChunkTicketManager<Vec3d> getTicketManager(ChunkPos pos, IWorldReader world) {
|
||||
Preconditions.checkArgument(!world.isRemote(), "Water region is only determined server-side");
|
||||
Map<ChunkPos, ChunkTicketManager<Vec3d>> ticketMap = customWaterHandler.get(world.getDimension().getType().getId());
|
||||
if (ticketMap == null)
|
||||
|
||||
@@ -22,17 +22,15 @@ package net.minecraftforge.common;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.google.common.base.Throwables;
|
||||
@@ -43,78 +41,78 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.BlockWorldState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.CachedBlockInfo;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityMinecartContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.item.minecart.ContainerMinecartEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Fluids;
|
||||
import net.minecraft.inventory.ContainerRepair;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.inventory.container.RepairContainer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
import net.minecraft.item.ItemEnchantedBook;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemPotion;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemSpawnEgg;
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.BucketItem;
|
||||
import net.minecraft.item.EnchantedBookItem;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.item.PotionItem;
|
||||
import net.minecraft.item.ShovelItem;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTippedArrow;
|
||||
import net.minecraft.item.TippedArrowItem;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.datasync.DataSerializer;
|
||||
import net.minecraft.network.play.server.SPacketBlockChange;
|
||||
import net.minecraft.potion.PotionType;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.network.play.ServerPlayNetHandler;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.datasync.IDataSerializer;
|
||||
import net.minecraft.network.play.server.SChangeBlockPacket;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||
import net.minecraft.world.spawner.AbstractSpawner;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.IntIdentityHashBiMap;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.storage.loot.LootEntry;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.storage.loot.LootTable;
|
||||
import net.minecraft.world.storage.loot.LootTableManager;
|
||||
import net.minecraft.world.storage.loot.conditions.LootCondition;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||
import net.minecraftforge.event.DifficultyChangeEvent;
|
||||
@@ -133,23 +131,19 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingKnockBackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
||||
import net.minecraftforge.event.entity.living.LootingLevelEvent;
|
||||
import net.minecraftforge.event.entity.player.AdvancementEvent;
|
||||
import net.minecraftforge.event.entity.player.AnvilRepairEvent;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.CriticalHitEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.AdvancementEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.event.world.NoteBlockEvent;
|
||||
import net.minecraftforge.eventbus.api.Event.Result;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DataSerializerEntry;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
@@ -160,57 +154,6 @@ public class ForgeHooks
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker FORGEHOOKS = MarkerManager.getMarker("FORGEHOOKS");
|
||||
//TODO: Remove in 1.14 as vanilla uses loot tables
|
||||
public static class SeedEntry extends WeightedRandom.Item
|
||||
{
|
||||
@Nonnull
|
||||
public final ItemStack seed;
|
||||
public SeedEntry(@Nonnull ItemStack seed, int weight)
|
||||
{
|
||||
super(weight);
|
||||
this.seed = seed;
|
||||
}
|
||||
@Nonnull
|
||||
public ItemStack getStack(Random rand, int fortune)
|
||||
{
|
||||
return seed.copy();
|
||||
}
|
||||
}
|
||||
public static class FortuneSeedEntry extends SeedEntry
|
||||
{
|
||||
private int min, factor;
|
||||
public FortuneSeedEntry(@Nonnull ItemStack seed, int weight, int min, int factor)
|
||||
{
|
||||
super(seed, weight);
|
||||
this.min = min;
|
||||
this.factor = factor;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getStack(Random rand, int fortune)
|
||||
{
|
||||
ItemStack ret = seed.copy();
|
||||
ret.setCount(min + rand.nextInt(fortune * factor + 1));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
static final List<SeedEntry> seedList = new ArrayList<SeedEntry>();
|
||||
|
||||
@Nonnull
|
||||
public static ItemStack getGrassSeed(Random rand, int fortune)
|
||||
{
|
||||
if (seedList.size() == 0)
|
||||
{
|
||||
return ItemStack.EMPTY; //Some bad mods hack in and empty our list, so lets not hard crash -.-
|
||||
}
|
||||
SeedEntry entry = WeightedRandom.getRandomItem(rand, seedList);
|
||||
if (entry == null || entry.seed.isEmpty())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return entry.getStack(rand, fortune);
|
||||
}
|
||||
|
||||
public static boolean canContinueUsing(@Nonnull ItemStack from, @Nonnull ItemStack to)
|
||||
{
|
||||
@@ -221,7 +164,7 @@ public class ForgeHooks
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canHarvestBlock(@Nonnull IBlockState state, @Nonnull EntityPlayer player, @Nonnull IBlockReader world, @Nonnull BlockPos pos)
|
||||
public static boolean canHarvestBlock(@Nonnull BlockState state, @Nonnull PlayerEntity player, @Nonnull IBlockReader world, @Nonnull BlockPos pos)
|
||||
{
|
||||
//state = state.getActualState(world, pos);
|
||||
if (state.getMaterial().isToolNotRequired())
|
||||
@@ -247,7 +190,7 @@ public class ForgeHooks
|
||||
|
||||
public static boolean canToolHarvestBlock(IWorldReader world, BlockPos pos, @Nonnull ItemStack stack)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
//state = state.getActualState(world, pos);
|
||||
ToolType tool = state.getHarvestTool();
|
||||
if (stack.isEmpty() || tool == null) return false;
|
||||
@@ -256,7 +199,7 @@ public class ForgeHooks
|
||||
|
||||
public static boolean isToolEffective(IWorldReader world, BlockPos pos, @Nonnull ItemStack stack)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
//state = state.getActualState(world, pos);
|
||||
for (ToolType type : stack.getToolTypes())
|
||||
{
|
||||
@@ -273,11 +216,11 @@ public class ForgeHooks
|
||||
return;
|
||||
toolInit = true;
|
||||
|
||||
Set<Block> blocks = getPrivateValue(ItemPickaxe.class, null, 0);
|
||||
Set<Block> blocks = getPrivateValue(PickaxeItem.class, null, 0);
|
||||
blocks.forEach(block -> blockToolSetter.accept(block, ToolType.PICKAXE, 0));
|
||||
blocks = getPrivateValue(ItemSpade.class, null, 0);
|
||||
blocks = getPrivateValue(ShovelItem.class, null, 0);
|
||||
blocks.forEach(block -> blockToolSetter.accept(block, ToolType.SHOVEL, 0));
|
||||
blocks = getPrivateValue(ItemAxe.class, null, 0);
|
||||
blocks = getPrivateValue(AxeItem.class, null, 0);
|
||||
blocks.forEach(block -> blockToolSetter.accept(block, ToolType.AXE, 0));
|
||||
|
||||
//This is taken from ItemAxe, if that changes update here.
|
||||
@@ -291,54 +234,53 @@ public class ForgeHooks
|
||||
/**
|
||||
* Called when a player uses 'pick block', calls new Entity and Block hooks.
|
||||
*/
|
||||
public static boolean onPickBlock(RayTraceResult target, EntityPlayer player, World world)
|
||||
public static boolean onPickBlock(RayTraceResult target, PlayerEntity player, World world)
|
||||
{
|
||||
ItemStack result;
|
||||
ItemStack result = ItemStack.EMPTY;
|
||||
boolean isCreative = player.abilities.isCreativeMode;
|
||||
TileEntity te = null;
|
||||
|
||||
if (target.type == RayTraceResult.Type.BLOCK)
|
||||
if (target.func_216346_c() == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
IBlockState state = world.getBlockState(target.getBlockPos());
|
||||
BlockPos pos = ((BlockRayTraceResult)target).func_216350_a();
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
if (state.isAir(world, target.getBlockPos()))
|
||||
if (state.isAir(world, pos))
|
||||
return false;
|
||||
|
||||
if (isCreative && GuiScreen.isCtrlKeyDown() && state.hasTileEntity())
|
||||
te = world.getTileEntity(target.getBlockPos());
|
||||
if (isCreative && Screen.hasControlDown() && state.hasTileEntity())
|
||||
te = world.getTileEntity(pos);
|
||||
|
||||
result = state.getBlock().getPickBlock(state, target, world, target.getBlockPos(), player);
|
||||
result = state.getBlock().getPickBlock(state, target, world, pos, player);
|
||||
|
||||
if (result.isEmpty())
|
||||
LOGGER.warn("Picking on: [{}] {} gave null item", target.func_216346_c(), state.getBlock().getRegistryName());
|
||||
}
|
||||
else
|
||||
else if (target.func_216346_c() == RayTraceResult.Type.ENTITY)
|
||||
{
|
||||
if (target.type != RayTraceResult.Type.ENTITY || target.entity == null || !isCreative)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Entity entity = ((EntityRayTraceResult)target).func_216348_a();
|
||||
result = entity.getPickedResult(target);
|
||||
|
||||
result = target.entity.getPickedResult(target);
|
||||
if (result.isEmpty())
|
||||
LOGGER.warn("Picking on: [{}] {} gave null item", target.func_216346_c(), entity.getType().getRegistryName());
|
||||
}
|
||||
|
||||
if (result.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (te != null)
|
||||
{
|
||||
Minecraft.getInstance().storeTEInStack(result, te);
|
||||
}
|
||||
|
||||
if (isCreative)
|
||||
{
|
||||
player.inventory.setPickedItemStack(result);
|
||||
Minecraft.getInstance().playerController.sendSlotPacket(player.getHeldItem(EnumHand.MAIN_HAND), 36 + player.inventory.currentItem);
|
||||
Minecraft.getInstance().playerController.sendSlotPacket(player.getHeldItem(Hand.MAIN_HAND), 36 + player.inventory.currentItem);
|
||||
return true;
|
||||
}
|
||||
int slot = player.inventory.getSlotFor(result);
|
||||
if (slot != -1)
|
||||
{
|
||||
if (InventoryPlayer.isHotbar(slot))
|
||||
if (PlayerInventory.isHotbar(slot))
|
||||
player.inventory.currentItem = slot;
|
||||
else
|
||||
Minecraft.getInstance().playerController.pickItem(slot);
|
||||
@@ -347,7 +289,7 @@ public class ForgeHooks
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onDifficultyChange(EnumDifficulty difficulty, EnumDifficulty oldDifficulty)
|
||||
public static void onDifficultyChange(Difficulty difficulty, Difficulty oldDifficulty)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new DifficultyChangeEvent(difficulty, oldDifficulty));
|
||||
}
|
||||
@@ -355,57 +297,57 @@ public class ForgeHooks
|
||||
//Optifine Helper Functions u.u, these are here specifically for Optifine
|
||||
//Note: When using Optifine, these methods are invoked using reflection, which
|
||||
//incurs a major performance penalty.
|
||||
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
|
||||
public static void onLivingSetAttackTarget(LivingEntity entity, LivingEntity target)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
|
||||
}
|
||||
|
||||
public static boolean onLivingUpdate(EntityLivingBase entity)
|
||||
public static boolean onLivingUpdate(LivingEntity entity)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new LivingUpdateEvent(entity));
|
||||
}
|
||||
|
||||
public static boolean onLivingAttack(EntityLivingBase entity, DamageSource src, float amount)
|
||||
public static boolean onLivingAttack(LivingEntity entity, DamageSource src, float amount)
|
||||
{
|
||||
return entity instanceof EntityPlayer || !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
|
||||
return entity instanceof PlayerEntity || !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
|
||||
}
|
||||
|
||||
public static boolean onPlayerAttack(EntityLivingBase entity, DamageSource src, float amount)
|
||||
public static boolean onPlayerAttack(LivingEntity entity, DamageSource src, float amount)
|
||||
{
|
||||
return !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
|
||||
}
|
||||
|
||||
public static LivingKnockBackEvent onLivingKnockBack(EntityLivingBase target, Entity attacker, float strength, double ratioX, double ratioZ)
|
||||
public static LivingKnockBackEvent onLivingKnockBack(LivingEntity target, Entity attacker, float strength, double ratioX, double ratioZ)
|
||||
{
|
||||
LivingKnockBackEvent event = new LivingKnockBackEvent(target, attacker, strength, ratioX, ratioZ);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static float onLivingHurt(EntityLivingBase entity, DamageSource src, float amount)
|
||||
public static float onLivingHurt(LivingEntity entity, DamageSource src, float amount)
|
||||
{
|
||||
LivingHurtEvent event = new LivingHurtEvent(entity, src, amount);
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
|
||||
}
|
||||
|
||||
public static float onLivingDamage(EntityLivingBase entity, DamageSource src, float amount)
|
||||
public static float onLivingDamage(LivingEntity entity, DamageSource src, float amount)
|
||||
{
|
||||
LivingDamageEvent event = new LivingDamageEvent(entity, src, amount);
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
|
||||
}
|
||||
|
||||
public static boolean onLivingDeath(EntityLivingBase entity, DamageSource src)
|
||||
public static boolean onLivingDeath(LivingEntity entity, DamageSource src)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new LivingDeathEvent(entity, src));
|
||||
}
|
||||
|
||||
public static boolean onLivingDrops(EntityLivingBase entity, DamageSource source, Collection<EntityItem> drops, int lootingLevel, boolean recentlyHit)
|
||||
public static boolean onLivingDrops(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static float[] onLivingFall(EntityLivingBase entity, float distance, float damageMultiplier)
|
||||
public static float[] onLivingFall(LivingEntity entity, float distance, float damageMultiplier)
|
||||
{
|
||||
LivingFallEvent event = new LivingFallEvent(entity, distance, damageMultiplier);
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.getDistance(), event.getDamageMultiplier()});
|
||||
@@ -414,21 +356,21 @@ public class ForgeHooks
|
||||
public static int getLootingLevel(Entity target, @Nullable Entity killer, DamageSource cause)
|
||||
{
|
||||
int looting = 0;
|
||||
if (killer instanceof EntityLivingBase)
|
||||
looting = EnchantmentHelper.getLootingModifier((EntityLivingBase)killer);
|
||||
if (target instanceof EntityLivingBase)
|
||||
looting = getLootingLevel((EntityLivingBase)target, cause, looting);
|
||||
if (killer instanceof LivingEntity)
|
||||
looting = EnchantmentHelper.getLootingModifier((LivingEntity)killer);
|
||||
if (target instanceof LivingEntity)
|
||||
looting = getLootingLevel((LivingEntity)target, cause, looting);
|
||||
return looting;
|
||||
}
|
||||
|
||||
public static int getLootingLevel(EntityLivingBase target, DamageSource cause, int level)
|
||||
public static int getLootingLevel(LivingEntity target, DamageSource cause, int level)
|
||||
{
|
||||
LootingLevelEvent event = new LootingLevelEvent(target, cause, level);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getLootingLevel();
|
||||
}
|
||||
|
||||
public static double getPlayerVisibilityDistance(EntityPlayer player, double xzDistance, double maxXZDistance)
|
||||
public static double getPlayerVisibilityDistance(PlayerEntity player, double xzDistance, double maxXZDistance)
|
||||
{
|
||||
PlayerEvent.Visibility event = new PlayerEvent.Visibility(player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
@@ -436,9 +378,9 @@ public class ForgeHooks
|
||||
return value >= maxXZDistance ? maxXZDistance : value;
|
||||
}
|
||||
|
||||
public static boolean isLivingOnLadder(@Nonnull IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EntityLivingBase entity)
|
||||
public static boolean isLivingOnLadder(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull LivingEntity entity)
|
||||
{
|
||||
boolean isSpectator = (entity instanceof EntityPlayer && ((EntityPlayer)entity).isSpectator());
|
||||
boolean isSpectator = (entity instanceof PlayerEntity && ((PlayerEntity)entity).isSpectator());
|
||||
if (isSpectator) return false;
|
||||
if (!ForgeConfig.SERVER.fullBoundingBoxLadders.get())
|
||||
{
|
||||
@@ -469,16 +411,16 @@ public class ForgeHooks
|
||||
}
|
||||
}
|
||||
|
||||
public static void onLivingJump(EntityLivingBase entity)
|
||||
public static void onLivingJump(LivingEntity entity)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new LivingJumpEvent(entity));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static EntityItem onPlayerTossEvent(@Nonnull EntityPlayer player, @Nonnull ItemStack item, boolean includeName)
|
||||
public static ItemEntity onPlayerTossEvent(@Nonnull PlayerEntity player, @Nonnull ItemStack item, boolean includeName)
|
||||
{
|
||||
player.captureDrops(Lists.newArrayList());
|
||||
EntityItem ret = player.dropItem(item, false, includeName);
|
||||
ItemEntity ret = player.dropItem(item, false, includeName);
|
||||
player.captureDrops(null);
|
||||
|
||||
if (ret == null)
|
||||
@@ -489,12 +431,12 @@ public class ForgeHooks
|
||||
return null;
|
||||
|
||||
if (!player.world.isRemote)
|
||||
player.getEntityWorld().spawnEntity(event.getEntityItem());
|
||||
player.getEntityWorld().func_217376_c(event.getEntityItem());
|
||||
return event.getEntityItem();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ITextComponent onServerChatEvent(NetHandlerPlayServer net, String raw, ITextComponent comp)
|
||||
public static ITextComponent onServerChatEvent(ServerPlayNetHandler net, String raw, ITextComponent comp)
|
||||
{
|
||||
ServerChatEvent event = new ServerChatEvent(net.player, raw, comp);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
@@ -532,13 +474,13 @@ public class ForgeHooks
|
||||
if (part.length() > 0)
|
||||
{
|
||||
if (ichat == null)
|
||||
ichat = new TextComponentString(part);
|
||||
ichat = new StringTextComponent(part);
|
||||
else
|
||||
ichat.appendText(part);
|
||||
}
|
||||
lastEnd = end;
|
||||
String url = string.substring(start, end);
|
||||
ITextComponent link = new TextComponentString(url);
|
||||
ITextComponent link = new StringTextComponent(url);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -548,7 +490,7 @@ public class ForgeHooks
|
||||
if (!allowMissingHeader)
|
||||
{
|
||||
if (ichat == null)
|
||||
ichat = new TextComponentString(url);
|
||||
ichat = new StringTextComponent(url);
|
||||
else
|
||||
ichat.appendText(url);
|
||||
continue;
|
||||
@@ -559,7 +501,7 @@ public class ForgeHooks
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
// Bad syntax bail out!
|
||||
if (ichat == null) ichat = new TextComponentString(url);
|
||||
if (ichat == null) ichat = new StringTextComponent(url);
|
||||
else ichat.appendText(url);
|
||||
continue;
|
||||
}
|
||||
@@ -578,13 +520,13 @@ public class ForgeHooks
|
||||
// Append the rest of the message.
|
||||
String end = string.substring(lastEnd);
|
||||
if (ichat == null)
|
||||
ichat = new TextComponentString(end);
|
||||
ichat = new StringTextComponent(end);
|
||||
else if (end.length() > 0)
|
||||
ichat.appendText(string.substring(lastEnd));
|
||||
return ichat;
|
||||
}
|
||||
|
||||
public static int onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, BlockPos pos)
|
||||
public static int onBlockBreakEvent(World world, GameType gameType, ServerPlayerEntity entityPlayer, BlockPos pos)
|
||||
{
|
||||
// Logic from tryHarvestBlock for pre-canceling the event
|
||||
boolean preCancelEvent = false;
|
||||
@@ -600,7 +542,7 @@ public class ForgeHooks
|
||||
|
||||
if (!entityPlayer.isAllowEdit())
|
||||
{
|
||||
if (itemstack.isEmpty() || !itemstack.canDestroy(world.getTags(), new BlockWorldState(world, pos, false)))
|
||||
if (itemstack.isEmpty() || !itemstack.canDestroy(world.getTags(), new CachedBlockInfo(world, pos, false)))
|
||||
preCancelEvent = true;
|
||||
}
|
||||
}
|
||||
@@ -608,11 +550,11 @@ public class ForgeHooks
|
||||
// Tell client the block is gone immediately then process events
|
||||
if (world.getTileEntity(pos) == null)
|
||||
{
|
||||
entityPlayer.connection.sendPacket(new SPacketBlockChange(DUMMY_WORLD, pos));
|
||||
entityPlayer.connection.sendPacket(new SChangeBlockPacket(DUMMY_WORLD, pos));
|
||||
}
|
||||
|
||||
// Post the block break event
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, entityPlayer);
|
||||
event.setCanceled(preCancelEvent);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
@@ -621,13 +563,13 @@ public class ForgeHooks
|
||||
if (event.isCanceled())
|
||||
{
|
||||
// Let the client know the block still exists
|
||||
entityPlayer.connection.sendPacket(new SPacketBlockChange(world, pos));
|
||||
entityPlayer.connection.sendPacket(new SChangeBlockPacket(world, pos));
|
||||
|
||||
// Update any tile entity data for this block
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
if (tileentity != null)
|
||||
{
|
||||
Packet<?> pkt = tileentity.getUpdatePacket();
|
||||
IPacket<?> pkt = tileentity.getUpdatePacket();
|
||||
if (pkt != null)
|
||||
{
|
||||
entityPlayer.connection.sendPacket(pkt);
|
||||
@@ -637,32 +579,32 @@ public class ForgeHooks
|
||||
return event.isCanceled() ? -1 : event.getExpToDrop();
|
||||
}
|
||||
|
||||
public static EnumActionResult onPlaceItemIntoWorld(@Nonnull ItemUseContext context)
|
||||
public static ActionResultType onPlaceItemIntoWorld(@Nonnull ItemUseContext context)
|
||||
{
|
||||
ItemStack itemstack = context.getItem();
|
||||
World world = context.getWorld();
|
||||
|
||||
// handle all placement events here
|
||||
int size = itemstack.getCount();
|
||||
NBTTagCompound nbt = null;
|
||||
CompoundNBT nbt = null;
|
||||
if (itemstack.hasTag())
|
||||
{
|
||||
nbt = itemstack.getTag().copy();
|
||||
}
|
||||
|
||||
if (!(itemstack.getItem() instanceof ItemBucket)) // if not bucket
|
||||
if (!(itemstack.getItem() instanceof BucketItem)) // if not bucket
|
||||
{
|
||||
world.captureBlockSnapshots = true;
|
||||
}
|
||||
|
||||
EnumActionResult ret = itemstack.getItem().onItemUse(context);
|
||||
ActionResultType ret = itemstack.getItem().onItemUse(context);
|
||||
world.captureBlockSnapshots = false;
|
||||
|
||||
if (ret == EnumActionResult.SUCCESS)
|
||||
if (ret == ActionResultType.SUCCESS)
|
||||
{
|
||||
// save new item data
|
||||
int newSize = itemstack.getCount();
|
||||
NBTTagCompound newNBT = null;
|
||||
CompoundNBT newNBT = null;
|
||||
if (itemstack.hasTag())
|
||||
{
|
||||
newNBT = itemstack.getTag().copy();
|
||||
@@ -678,8 +620,8 @@ public class ForgeHooks
|
||||
itemstack.setTag(nbt);
|
||||
}
|
||||
|
||||
EntityPlayer player = context.getPlayer();
|
||||
EnumFacing side = context.getFace();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
Direction side = context.getFace();
|
||||
|
||||
boolean eventResult = false;
|
||||
if (blockSnapshots.size() > 1)
|
||||
@@ -693,7 +635,7 @@ public class ForgeHooks
|
||||
|
||||
if (eventResult)
|
||||
{
|
||||
ret = EnumActionResult.FAIL; // cancel placement
|
||||
ret = ActionResultType.FAIL; // cancel placement
|
||||
// revert back all captured blocks
|
||||
for (BlockSnapshot blocksnapshot : Lists.reverse(blockSnapshots))
|
||||
{
|
||||
@@ -714,16 +656,16 @@ public class ForgeHooks
|
||||
for (BlockSnapshot snap : blockSnapshots)
|
||||
{
|
||||
int updateFlag = snap.getFlag();
|
||||
IBlockState oldBlock = snap.getReplacedBlock();
|
||||
IBlockState newBlock = world.getBlockState(snap.getPos());
|
||||
BlockState oldBlock = snap.getReplacedBlock();
|
||||
BlockState newBlock = world.getBlockState(snap.getPos());
|
||||
if (!newBlock.getBlock().hasTileEntity(newBlock)) // Containers get placed automatically
|
||||
{
|
||||
newBlock.onBlockAdded(world, snap.getPos(), oldBlock);
|
||||
newBlock.func_215705_a(world, snap.getPos(), oldBlock, false);
|
||||
}
|
||||
|
||||
world.markAndNotifyBlock(snap.getPos(), null, oldBlock, newBlock, updateFlag);
|
||||
}
|
||||
player.addStat(StatList.ITEM_USED.get(itemstack.getItem()));
|
||||
player.addStat(Stats.ITEM_USED.get(itemstack.getItem()));
|
||||
}
|
||||
}
|
||||
world.capturedBlockSnapshots.clear();
|
||||
@@ -731,31 +673,31 @@ public class ForgeHooks
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean onAnvilChange(ContainerRepair container, @Nonnull ItemStack left, @Nonnull ItemStack right, IInventory outputSlot, String name, int baseCost)
|
||||
public static boolean onAnvilChange(RepairContainer container, @Nonnull ItemStack left, @Nonnull ItemStack right, IInventory outputSlot, String name, int baseCost)
|
||||
{
|
||||
AnvilUpdateEvent e = new AnvilUpdateEvent(left, right, name, baseCost);
|
||||
if (MinecraftForge.EVENT_BUS.post(e)) return false;
|
||||
if (e.getOutput().isEmpty()) return true;
|
||||
|
||||
outputSlot.setInventorySlotContents(0, e.getOutput());
|
||||
container.maximumCost = e.getCost();
|
||||
container.setMaximumCost(e.getCost());
|
||||
container.materialCost = e.getMaterialCost();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static float onAnvilRepair(EntityPlayer player, @Nonnull ItemStack output, @Nonnull ItemStack left, @Nonnull ItemStack right)
|
||||
public static float onAnvilRepair(PlayerEntity player, @Nonnull ItemStack output, @Nonnull ItemStack left, @Nonnull ItemStack right)
|
||||
{
|
||||
AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
|
||||
MinecraftForge.EVENT_BUS.post(e);
|
||||
return e.getBreakChance();
|
||||
}
|
||||
|
||||
private static ThreadLocal<EntityPlayer> craftingPlayer = new ThreadLocal<EntityPlayer>();
|
||||
public static void setCraftingPlayer(EntityPlayer player)
|
||||
private static ThreadLocal<PlayerEntity> craftingPlayer = new ThreadLocal<PlayerEntity>();
|
||||
public static void setCraftingPlayer(PlayerEntity player)
|
||||
{
|
||||
craftingPlayer.set(player);
|
||||
}
|
||||
public static EntityPlayer getCraftingPlayer()
|
||||
public static PlayerEntity getCraftingPlayer()
|
||||
{
|
||||
return craftingPlayer.get();
|
||||
}
|
||||
@@ -775,7 +717,7 @@ public class ForgeHooks
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static boolean onPlayerAttackTarget(EntityPlayer player, Entity target)
|
||||
public static boolean onPlayerAttackTarget(PlayerEntity player, Entity target)
|
||||
{
|
||||
if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false;
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
@@ -789,76 +731,61 @@ public class ForgeHooks
|
||||
if (event.isCanceled())
|
||||
{
|
||||
// Revert variable back to true as it would have been set to false
|
||||
if (entity instanceof EntityMinecartContainer)
|
||||
if (entity instanceof ContainerMinecartEntity)
|
||||
{
|
||||
((EntityMinecartContainer) entity).dropContentsWhenDead = true;
|
||||
((ContainerMinecartEntity) entity).dropContentsWhenDead(true);
|
||||
}
|
||||
}
|
||||
return !event.isCanceled();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static RayTraceResult rayTraceEyes(EntityLivingBase entity, double length)
|
||||
public static ActionResultType onInteractEntityAt(PlayerEntity player, Entity entity, RayTraceResult ray, Hand hand)
|
||||
{
|
||||
Vec3d startPos = new Vec3d(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ);
|
||||
Vec3d endPos = startPos.add(new Vec3d(entity.getLookVec().x * length, entity.getLookVec().y * length, entity.getLookVec().z * length));
|
||||
return entity.world.rayTraceBlocks(startPos, endPos);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Vec3d rayTraceEyeHitVec(EntityLivingBase entity, double length)
|
||||
{
|
||||
RayTraceResult git = rayTraceEyes(entity, length);
|
||||
return git == null ? null : git.hitVec;
|
||||
}
|
||||
|
||||
public static EnumActionResult onInteractEntityAt(EntityPlayer player, Entity entity, RayTraceResult ray, EnumHand hand)
|
||||
{
|
||||
Vec3d vec3d = new Vec3d(ray.hitVec.x - entity.posX, ray.hitVec.y - entity.posY, ray.hitVec.z - entity.posZ);
|
||||
Vec3d vec3d = new Vec3d(ray.func_216347_e().x - entity.posX, ray.func_216347_e().y - entity.posY, ray.func_216347_e().z - entity.posZ);
|
||||
return onInteractEntityAt(player, entity, vec3d, hand);
|
||||
}
|
||||
|
||||
public static EnumActionResult onInteractEntityAt(EntityPlayer player, Entity entity, Vec3d vec3d, EnumHand hand)
|
||||
public static ActionResultType onInteractEntityAt(PlayerEntity player, Entity entity, Vec3d vec3d, Hand hand)
|
||||
{
|
||||
PlayerInteractEvent.EntityInteractSpecific evt = new PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, vec3d);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt.isCanceled() ? evt.getCancellationResult() : null;
|
||||
}
|
||||
|
||||
public static EnumActionResult onInteractEntity(EntityPlayer player, Entity entity, EnumHand hand)
|
||||
public static ActionResultType onInteractEntity(PlayerEntity player, Entity entity, Hand hand)
|
||||
{
|
||||
PlayerInteractEvent.EntityInteract evt = new PlayerInteractEvent.EntityInteract(player, hand, entity);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt.isCanceled() ? evt.getCancellationResult() : null;
|
||||
}
|
||||
|
||||
public static EnumActionResult onItemRightClick(EntityPlayer player, EnumHand hand)
|
||||
public static ActionResultType onItemRightClick(PlayerEntity player, Hand hand)
|
||||
{
|
||||
PlayerInteractEvent.RightClickItem evt = new PlayerInteractEvent.RightClickItem(player, hand);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt.isCanceled() ? evt.getCancellationResult() : null;
|
||||
}
|
||||
|
||||
public static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(EntityPlayer player, BlockPos pos, EnumFacing face, Vec3d hitVec)
|
||||
public static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(PlayerEntity player, BlockPos pos, Direction face)
|
||||
{
|
||||
PlayerInteractEvent.LeftClickBlock evt = new PlayerInteractEvent.LeftClickBlock(player, pos, face, hitVec);
|
||||
PlayerInteractEvent.LeftClickBlock evt = new PlayerInteractEvent.LeftClickBlock(player, pos, face);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt;
|
||||
}
|
||||
|
||||
public static PlayerInteractEvent.RightClickBlock onRightClickBlock(EntityPlayer player, EnumHand hand, BlockPos pos, EnumFacing face, Vec3d hitVec)
|
||||
public static PlayerInteractEvent.RightClickBlock onRightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, Direction face)
|
||||
{
|
||||
PlayerInteractEvent.RightClickBlock evt = new PlayerInteractEvent.RightClickBlock(player, hand, pos, face, hitVec);
|
||||
PlayerInteractEvent.RightClickBlock evt = new PlayerInteractEvent.RightClickBlock(player, hand, pos, face);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt;
|
||||
}
|
||||
|
||||
public static void onEmptyClick(EntityPlayer player, EnumHand hand)
|
||||
public static void onEmptyClick(PlayerEntity player, Hand hand)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.RightClickEmpty(player, hand));
|
||||
}
|
||||
|
||||
public static void onEmptyLeftClick(EntityPlayer player)
|
||||
public static void onEmptyLeftClick(PlayerEntity player)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.LeftClickEmpty(player));
|
||||
}
|
||||
@@ -956,7 +883,7 @@ public class ForgeHooks
|
||||
ctx.resetPoolCtx();
|
||||
|
||||
if (json.has("name"))
|
||||
return JsonUtils.getString(json, "name");
|
||||
return JSONUtils.getString(json, "name");
|
||||
|
||||
if (ctx.custom)
|
||||
return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!
|
||||
@@ -975,40 +902,36 @@ public class ForgeHooks
|
||||
ctx.entryCount++;
|
||||
|
||||
if (json.has("entryName"))
|
||||
return ctx.validateEntryName(JsonUtils.getString(json, "entryName"));
|
||||
return ctx.validateEntryName(JSONUtils.getString(json, "entryName"));
|
||||
|
||||
if (ctx.custom)
|
||||
return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!
|
||||
|
||||
String name = null;
|
||||
if ("item".equals(type))
|
||||
name = JsonUtils.getString(json, "name");
|
||||
name = JSONUtils.getString(json, "name");
|
||||
else if ("loot_table".equals(type))
|
||||
name = JsonUtils.getString(json, "name");
|
||||
name = JSONUtils.getString(json, "name");
|
||||
else if ("empty".equals(type))
|
||||
name = "empty";
|
||||
|
||||
return ctx.validateEntryName(name);
|
||||
}
|
||||
|
||||
//TODO: Some registry to support custom LootEntry types?
|
||||
public static LootEntry deserializeJsonLootEntry(String type, JsonObject json, int weight, int quality, LootCondition[] conditions){ return null; }
|
||||
public static String getLootEntryType(LootEntry entry){ return null; } //Companion to above function
|
||||
|
||||
public static boolean onCropsGrowPre(World worldIn, BlockPos pos, IBlockState state, boolean def)
|
||||
public static boolean onCropsGrowPre(World worldIn, BlockPos pos, BlockState state, boolean def)
|
||||
{
|
||||
BlockEvent ev = new BlockEvent.CropGrowEvent.Pre(worldIn,pos,state);
|
||||
MinecraftForge.EVENT_BUS.post(ev);
|
||||
return (ev.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (ev.getResult() == net.minecraftforge.eventbus.api.Event.Result.DEFAULT && def));
|
||||
}
|
||||
|
||||
public static void onCropsGrowPost(World worldIn, BlockPos pos, IBlockState state)
|
||||
public static void onCropsGrowPost(World worldIn, BlockPos pos, BlockState state)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new BlockEvent.CropGrowEvent.Post(worldIn, pos, state, worldIn.getBlockState(pos)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CriticalHitEvent getCriticalHit(EntityPlayer player, Entity target, boolean vanillaCritical, float damageModifier)
|
||||
public static CriticalHitEvent getCriticalHit(PlayerEntity player, Entity target, boolean vanillaCritical, float damageModifier)
|
||||
{
|
||||
CriticalHitEvent hitResult = new CriticalHitEvent(player, target, damageModifier, vanillaCritical);
|
||||
MinecraftForge.EVENT_BUS.post(hitResult);
|
||||
@@ -1019,7 +942,7 @@ public class ForgeHooks
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void onAdvancement(EntityPlayerMP player, Advancement advancement)
|
||||
public static void onAdvancement(ServerPlayerEntity player, Advancement advancement)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new AdvancementEvent(player, advancement));
|
||||
}
|
||||
@@ -1035,31 +958,31 @@ public class ForgeHooks
|
||||
String modId = registryName == null ? null : registryName.getNamespace();
|
||||
if ("minecraft".equals(modId))
|
||||
{
|
||||
if (item instanceof ItemEnchantedBook)
|
||||
if (item instanceof EnchantedBookItem)
|
||||
{
|
||||
NBTTagList enchantmentsNbt = ItemEnchantedBook.getEnchantments(itemStack);
|
||||
ListNBT enchantmentsNbt = EnchantedBookItem.getEnchantments(itemStack);
|
||||
if (enchantmentsNbt.size() == 1)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = enchantmentsNbt.getCompound(0);
|
||||
ResourceLocation resourceLocation = ResourceLocation.makeResourceLocation(nbttagcompound.getString("id"));
|
||||
CompoundNBT nbttagcompound = enchantmentsNbt.getCompound(0);
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryCreate(nbttagcompound.getString("id"));
|
||||
if (resourceLocation != null && ForgeRegistries.ENCHANTMENTS.containsKey(resourceLocation))
|
||||
{
|
||||
return resourceLocation.getNamespace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item instanceof ItemPotion || item instanceof ItemTippedArrow)
|
||||
else if (item instanceof PotionItem || item instanceof TippedArrowItem)
|
||||
{
|
||||
PotionType potionType = PotionUtils.getPotionFromItem(itemStack);
|
||||
Potion potionType = PotionUtils.getPotionFromItem(itemStack);
|
||||
ResourceLocation resourceLocation = ForgeRegistries.POTION_TYPES.getKey(potionType);
|
||||
if (resourceLocation != null)
|
||||
{
|
||||
return resourceLocation.getNamespace();
|
||||
}
|
||||
}
|
||||
else if (item instanceof ItemSpawnEgg)
|
||||
else if (item instanceof SpawnEggItem)
|
||||
{
|
||||
ResourceLocation resourceLocation = ((ItemSpawnEgg)item).getType(null).getRegistryName();
|
||||
ResourceLocation resourceLocation = ((SpawnEggItem)item).getType(null).getRegistryName();
|
||||
if (resourceLocation != null)
|
||||
{
|
||||
return resourceLocation.getNamespace();
|
||||
@@ -1069,7 +992,7 @@ public class ForgeHooks
|
||||
return modId;
|
||||
}
|
||||
|
||||
public static boolean onFarmlandTrample(World world, BlockPos pos, IBlockState state, float fallDistance, Entity entity)
|
||||
public static boolean onFarmlandTrample(World world, BlockPos pos, BlockState state, float fallDistance, Entity entity)
|
||||
{
|
||||
if (entity.canTrample(state, pos, fallDistance))
|
||||
{
|
||||
@@ -1111,7 +1034,7 @@ public class ForgeHooks
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getBlockState(BlockPos pos) {
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
|
||||
@@ -1122,50 +1045,46 @@ public class ForgeHooks
|
||||
|
||||
}
|
||||
|
||||
public static int onNoteChange(World world, BlockPos pos, IBlockState state, int old, int _new) {
|
||||
public static int onNoteChange(World world, BlockPos pos, BlockState state, int old, int _new) {
|
||||
NoteBlockEvent.Change event = new NoteBlockEvent.Change(world, pos, state, old, _new);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return -1;
|
||||
return event.getVanillaNoteId();
|
||||
}
|
||||
|
||||
public static int canEntitySpawn(EntityLiving entity, IWorld world, double x, double y, double z, MobSpawnerBaseLogic spawner) {
|
||||
public static int canEntitySpawn(MobEntity entity, IWorld world, double x, double y, double z, AbstractSpawner spawner) {
|
||||
Result res = ForgeEventFactory.canEntitySpawn(entity, world, x, y, z, null);
|
||||
return res == Result.DEFAULT ? 0 : res == Result.DENY ? -1 : 1;
|
||||
}
|
||||
|
||||
public static <T> void deserializeTagAdditions(Tag.Builder<T> builder, Predicate<ResourceLocation> isValueKnown, Function<ResourceLocation, T> valueGetter, JsonObject json)
|
||||
public static <T> void deserializeTagAdditions(Tag.Builder<T> builder, Function<ResourceLocation, Optional<T>> valueGetter, JsonObject json)
|
||||
{
|
||||
if (json.has("optional"))
|
||||
{
|
||||
for (JsonElement entry : JsonUtils.getJsonArray(json, "optional"))
|
||||
for (JsonElement entry : JSONUtils.getJsonArray(json, "optional"))
|
||||
{
|
||||
String s = JsonUtils.getString(entry, "value");
|
||||
String s = JSONUtils.getString(entry, "value");
|
||||
if (!s.startsWith("#"))
|
||||
{
|
||||
ResourceLocation rl = new ResourceLocation(s);
|
||||
if (isValueKnown.test(rl) && valueGetter.apply(rl) != null)
|
||||
{
|
||||
builder.add(valueGetter.apply(rl));
|
||||
}
|
||||
T value = valueGetter.apply(new ResourceLocation(s)).orElse(null);
|
||||
if (value != null)
|
||||
builder.add(value);
|
||||
} else
|
||||
{
|
||||
builder.add(new OptionalTagEntry<>(new ResourceLocation(s.substring(1))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (json.has("remove"))
|
||||
{
|
||||
for (JsonElement entry : JsonUtils.getJsonArray(json, "remove"))
|
||||
for (JsonElement entry : JSONUtils.getJsonArray(json, "remove"))
|
||||
{
|
||||
String s = JsonUtils.getString(entry, "value");
|
||||
String s = JSONUtils.getString(entry, "value");
|
||||
if (!s.startsWith("#"))
|
||||
{
|
||||
ResourceLocation rl = new ResourceLocation(s);
|
||||
if (isValueKnown.test(rl) && valueGetter.apply(rl) != null)
|
||||
T value = valueGetter.apply(new ResourceLocation(s)).orElse(null);
|
||||
if (value != null)
|
||||
{
|
||||
Tag.ITagEntry<T> dummyEntry = new Tag.ListEntry<>(Collections.singletonList(valueGetter.apply(rl)));
|
||||
Tag.ITagEntry<T> dummyEntry = new Tag.ListEntry<>(Collections.singletonList(value));
|
||||
builder.remove(dummyEntry);
|
||||
}
|
||||
} else
|
||||
@@ -1206,14 +1125,14 @@ public class ForgeHooks
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<DataSerializer<?>, DataSerializerEntry> serializerEntries = GameData.getSerializerMap();
|
||||
private static final Map<IDataSerializer<?>, DataSerializerEntry> serializerEntries = GameData.getSerializerMap();
|
||||
//private static final ForgeRegistry<DataSerializerEntry> serializerRegistry = (ForgeRegistry<DataSerializerEntry>) ForgeRegistries.DATA_SERIALIZERS;
|
||||
// Do not reimplement this ^ it introduces a chicken-egg scenario by classloading registries during bootstrap
|
||||
|
||||
@Nullable
|
||||
public static DataSerializer<?> getSerializer(int id, IntIdentityHashBiMap<DataSerializer<?>> vanilla)
|
||||
public static IDataSerializer<?> getSerializer(int id, IntIdentityHashBiMap<IDataSerializer<?>> vanilla)
|
||||
{
|
||||
DataSerializer<?> serializer = vanilla.get(id);
|
||||
IDataSerializer<?> serializer = vanilla.getByValue(id);
|
||||
if (serializer == null)
|
||||
{
|
||||
DataSerializerEntry entry = ((ForgeRegistry<DataSerializerEntry>)ForgeRegistries.DATA_SERIALIZERS).getValue(id);
|
||||
@@ -1222,7 +1141,7 @@ public class ForgeHooks
|
||||
return serializer;
|
||||
}
|
||||
|
||||
public static int getSerializerId(DataSerializer<?> serializer, IntIdentityHashBiMap<DataSerializer<?>> vanilla)
|
||||
public static int getSerializerId(IDataSerializer<?> serializer, IntIdentityHashBiMap<IDataSerializer<?>> vanilla)
|
||||
{
|
||||
int id = vanilla.getId(serializer);
|
||||
if (id < 0)
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
import net.minecraftforge.client.CloudRenderer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
@@ -42,9 +42,9 @@ public class ForgeInternalHandler
|
||||
public void onEntityJoinWorld(EntityJoinWorldEvent event)
|
||||
{
|
||||
Entity entity = event.getEntity();
|
||||
if (entity.getClass().equals(EntityItem.class))
|
||||
if (entity.getClass().equals(ItemEntity.class))
|
||||
{
|
||||
ItemStack stack = ((EntityItem)entity).getItem();
|
||||
ItemStack stack = ((ItemEntity)entity).getItem();
|
||||
Item item = stack.getItem();
|
||||
/*
|
||||
if (item.hasCustomEntity(stack))
|
||||
@@ -65,8 +65,8 @@ public class ForgeInternalHandler
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void onDimensionUnload(WorldEvent.Unload event)
|
||||
{
|
||||
if (event.getWorld() instanceof WorldServer)
|
||||
FakePlayerFactory.unloadWorld((WorldServer) event.getWorld());
|
||||
if (event.getWorld() instanceof ServerWorld)
|
||||
FakePlayerFactory.unloadWorld((ServerWorld) event.getWorld());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
@@ -138,9 +138,9 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
{
|
||||
VersionChecker.startVersionCheck();
|
||||
}
|
||||
|
||||
|
||||
// Brandings need to recompute when language changes
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> ((SimpleReloadableResourceManager)Minecraft.getInstance().getResourceManager()).addReloadListener((ISelectiveResourceReloadListener) BrandingControl::clearCaches));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> ((SimpleReloadableResourceManager)Minecraft.getInstance().getResourceManager()).func_219534_a((ISelectiveResourceReloadListener) BrandingControl::clearCaches));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -195,19 +195,19 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info)
|
||||
public CompoundNBT getDataForWriting(SaveHandler handler, WorldInfo info)
|
||||
{
|
||||
NBTTagCompound forgeData = new NBTTagCompound();
|
||||
NBTTagCompound dims = new NBTTagCompound();
|
||||
CompoundNBT forgeData = new CompoundNBT();
|
||||
CompoundNBT dims = new CompoundNBT();
|
||||
DimensionManager.writeRegistry(dims);
|
||||
if (!dims.isEmpty())
|
||||
forgeData.setTag("dims", dims);
|
||||
forgeData.func_218657_a("dims", dims);
|
||||
// TODO fluids FluidRegistry.writeDefaultFluidList(forgeData);
|
||||
return forgeData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(SaveHandler handler, WorldInfo info, NBTTagCompound tag)
|
||||
public void readData(SaveHandler handler, WorldInfo info, CompoundNBT tag)
|
||||
{
|
||||
if (tag.contains("dims", 10))
|
||||
DimensionManager.readRegistry(tag.getCompound("dims"));
|
||||
|
||||
@@ -41,4 +41,4 @@ package net.minecraftforge.common;
|
||||
*/
|
||||
public interface IExtensibleEnum
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
|
||||
/**
|
||||
* This class defines a replacement for the default minecart collision code.
|
||||
@@ -38,7 +38,7 @@ public interface IMinecartCollisionHandler
|
||||
* @param cart The cart that called the collision.
|
||||
* @param other The object it collided with.
|
||||
*/
|
||||
void onEntityCollision(EntityMinecart cart, Entity other);
|
||||
void onEntityCollision(AbstractMinecartEntity cart, Entity other);
|
||||
|
||||
/**
|
||||
* This function replaced the function of the same name in EntityMinecart.
|
||||
@@ -48,7 +48,7 @@ public interface IMinecartCollisionHandler
|
||||
* @param other The entity requesting the collision box.
|
||||
* @return The collision box or null.
|
||||
*/
|
||||
AxisAlignedBB getCollisionBox(EntityMinecart cart, Entity other);
|
||||
AxisAlignedBB getCollisionBox(AbstractMinecartEntity cart, Entity other);
|
||||
|
||||
/**
|
||||
* This function is used to define the box used for detecting minecart collisions.
|
||||
@@ -56,7 +56,7 @@ public interface IMinecartCollisionHandler
|
||||
* @param cart The cart for which the collision box was requested.
|
||||
* @return The collision box, cannot be null.
|
||||
*/
|
||||
AxisAlignedBB getMinecartCollisionBox(EntityMinecart cart);
|
||||
AxisAlignedBB getMinecartCollisionBox(AbstractMinecartEntity cart);
|
||||
|
||||
/**
|
||||
* This function replaces the function of the same name in EntityMinecart.
|
||||
@@ -64,6 +64,6 @@ public interface IMinecartCollisionHandler
|
||||
* @param cart The cart for which the bounding box was requested.
|
||||
* @return The bounding box or null.
|
||||
*/
|
||||
AxisAlignedBB getBoundingBox(EntityMinecart cart);
|
||||
AxisAlignedBB getBoundingBox(AbstractMinecartEntity cart);
|
||||
}
|
||||
|
||||
@@ -19,28 +19,28 @@
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.CropsBlock;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.SaplingBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
||||
public interface IPlantable
|
||||
{
|
||||
default EnumPlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
if (this instanceof BlockCrops) return EnumPlantType.Crop;
|
||||
if (this instanceof BlockSapling) return EnumPlantType.Plains;
|
||||
if (this instanceof BlockFlower) return EnumPlantType.Plains;
|
||||
if (this == Blocks.DEAD_BUSH) return EnumPlantType.Desert;
|
||||
if (this == Blocks.LILY_PAD) return EnumPlantType.Water;
|
||||
if (this == Blocks.RED_MUSHROOM) return EnumPlantType.Cave;
|
||||
if (this == Blocks.BROWN_MUSHROOM) return EnumPlantType.Cave;
|
||||
if (this == Blocks.NETHER_WART) return EnumPlantType.Nether;
|
||||
if (this == Blocks.TALL_GRASS) return EnumPlantType.Plains;
|
||||
return net.minecraftforge.common.EnumPlantType.Plains;
|
||||
default PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
if (this instanceof CropsBlock) return PlantType.Crop;
|
||||
if (this instanceof SaplingBlock) return PlantType.Plains;
|
||||
if (this instanceof FlowerBlock) return PlantType.Plains;
|
||||
if (this == Blocks.DEAD_BUSH) return PlantType.Desert;
|
||||
if (this == Blocks.LILY_PAD) return PlantType.Water;
|
||||
if (this == Blocks.RED_MUSHROOM) return PlantType.Cave;
|
||||
if (this == Blocks.BROWN_MUSHROOM) return PlantType.Cave;
|
||||
if (this == Blocks.NETHER_WART) return PlantType.Nether;
|
||||
if (this == Blocks.TALL_GRASS) return PlantType.Plains;
|
||||
return net.minecraftforge.common.PlantType.Plains;
|
||||
}
|
||||
|
||||
IBlockState getPlant(IBlockReader world, BlockPos pos);
|
||||
BlockState getPlant(IBlockReader world, BlockPos pos);
|
||||
}
|
||||
@@ -22,6 +22,7 @@ package net.minecraftforge.common;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
@@ -38,6 +39,8 @@ import javax.annotation.Nonnull;
|
||||
*/
|
||||
//TODO Change to World, not IWorldReader and make Implementor responsible for removing itself from the world.
|
||||
//Better mimics vanilla behavior and allows more control for the user.
|
||||
|
||||
@Deprecated //TODO: Reevaluate the entire thing, loot from blocks is now a loot table. So this is just a marker now.
|
||||
public interface IShearable
|
||||
{
|
||||
/**
|
||||
@@ -72,5 +75,7 @@ public interface IShearable
|
||||
* @return A List containing all items from this shearing. May be empty.
|
||||
*/
|
||||
@Nonnull
|
||||
List<ItemStack> onSheared(@Nonnull ItemStack item, IWorld world, BlockPos pos, int fortune);
|
||||
default List<ItemStack> onSheared(@Nonnull ItemStack item, IWorld world, BlockPos pos, int fortune) {
|
||||
return NonNullList.create();
|
||||
}
|
||||
}
|
||||
@@ -21,20 +21,13 @@ package net.minecraftforge.common;
|
||||
|
||||
import net.minecraftforge.eventbus.api.BusBuilder;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeHooks.SeedEntry;
|
||||
import net.minecraftforge.common.ForgeHooks.FortuneSeedEntry;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class MinecraftForge
|
||||
{
|
||||
/**
|
||||
@@ -51,24 +44,6 @@ public class MinecraftForge
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker FORGE = MarkerManager.getMarker("FORGE");
|
||||
|
||||
/**
|
||||
* Register a new seed to be dropped when breaking tall grass.
|
||||
*
|
||||
* @param seed The item to drop as a seed.
|
||||
* @param weight The relative probability of the seeds,
|
||||
* where wheat seeds are 10.
|
||||
*
|
||||
* Note: These functions may be going away soon, we're looking into loot tables....
|
||||
*/
|
||||
public static void addGrassSeed(@Nonnull ItemStack seed, int weight)
|
||||
{
|
||||
addGrassSeed(new SeedEntry(seed, weight));
|
||||
}
|
||||
public static void addGrassSeed(SeedEntry seed)
|
||||
{
|
||||
ForgeHooks.seedList.add(seed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method invoked by FML before any other mods are loaded.
|
||||
*/
|
||||
@@ -83,8 +58,6 @@ public class MinecraftForge
|
||||
|
||||
//For all the normal CrashReport classes to be defined. We're in MC's classloader so this should all be fine
|
||||
new CrashReport("ThisIsFake", new Exception("Not real"));
|
||||
|
||||
addGrassSeed(new FortuneSeedEntry(new ItemStack(Items.WHEAT_SEEDS), 100, 1, 2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
@@ -34,7 +35,7 @@ import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
*/
|
||||
public abstract class ModDimension extends ForgeRegistryEntry<ModDimension>
|
||||
{
|
||||
public abstract Function<DimensionType, ? extends Dimension> getFactory();
|
||||
public abstract BiFunction<World, DimensionType, ? extends Dimension> getFactory();
|
||||
|
||||
/**
|
||||
* Serialize any necessary data, this is called both when saving the world on the server.
|
||||
|
||||
+5
-7
@@ -19,12 +19,10 @@
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
public enum EnumPlantType
|
||||
public enum PlantType
|
||||
{
|
||||
Plains,
|
||||
Desert,
|
||||
@@ -35,17 +33,17 @@ public enum EnumPlantType
|
||||
Crop;
|
||||
|
||||
/**
|
||||
* Getting a custom {@link EnumPlantType}, or an existing one if it has the same name as that one. Your plant should implement {@link IPlantable}
|
||||
* Getting a custom {@link PlantType}, or an existing one if it has the same name as that one. Your plant should implement {@link IPlantable}
|
||||
* and return this custom type in {@link IPlantable#getPlantType(IBlockAccess, BlockPos)}.
|
||||
*
|
||||
* <p>If your new plant grows on blocks like any one of them above, never create a new {@link EnumPlantType}.
|
||||
* <p>If your new plant grows on blocks like any one of them above, never create a new {@link PlantType}.
|
||||
* This enumeration is only functioning in
|
||||
* {@link net.minecraft.block.Block#canSustainPlant(IBlockState, IWorldReader, BlockPos, EnumFacing, IPlantable)},
|
||||
* which you are supposed to override this function in your new block and create a new plant type to grow on that block.
|
||||
*
|
||||
* <p>You can create an instance of your plant type in your API and let your/others mods access it. It will be faster than calling this method.
|
||||
* @param name the name of the type of plant, you had better follow the style above
|
||||
* @return the acquired {@link EnumPlantType}, a new one if not found.
|
||||
* @return the acquired {@link PlantType}, a new one if not found.
|
||||
*/
|
||||
public static EnumPlantType create(String name){ return null; }
|
||||
public static PlantType create(String name){ return null; }
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package net.minecraftforge.common.brewing;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionBrewing;
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.concurrent.Callable;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -60,7 +60,7 @@ public class Capability<T>
|
||||
* @return a NBT holding the data. Null if no data needs to be stored.
|
||||
*/
|
||||
@Nullable
|
||||
INBTBase writeNBT(Capability<T> capability, T instance, EnumFacing side);
|
||||
INBT writeNBT(Capability<T> capability, T instance, Direction side);
|
||||
|
||||
/**
|
||||
* Read the capability instance from a NBT tag.
|
||||
@@ -81,7 +81,7 @@ public class Capability<T>
|
||||
* @param side The side of the object the instance is associated with.
|
||||
* @param nbt A NBT holding the data. Must not be null, as doesn't make sense to call this function with nothing to read...
|
||||
*/
|
||||
void readNBT(Capability<T> capability, T instance, EnumFacing side, INBTBase nbt);
|
||||
void readNBT(Capability<T> capability, T instance, Direction side, INBT nbt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ public class Capability<T>
|
||||
* Quick access to the IStorage's readNBT.
|
||||
* See {@link IStorage#readNBT(Capability, Object, EnumFacing, NBTBase)} for documentation.
|
||||
*/
|
||||
public void readNBT(T instance, EnumFacing side, INBTBase nbt)
|
||||
public void readNBT(T instance, Direction side, INBT nbt)
|
||||
{
|
||||
storage.readNBT(this, instance, side, nbt);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class Capability<T>
|
||||
* See {@link IStorage#writeNBT(Capability, Object, EnumFacing)} for documentation.
|
||||
*/
|
||||
@Nullable
|
||||
public INBTBase writeNBT(T instance, EnumFacing side)
|
||||
public INBT writeNBT(T instance, Direction side)
|
||||
{
|
||||
return storage.writeNBT(this, instance, side);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ import java.util.Map;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
@@ -47,10 +47,10 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
public final class CapabilityDispatcher implements INBTSerializable<NBTTagCompound>, ICapabilityProvider
|
||||
public final class CapabilityDispatcher implements INBTSerializable<CompoundNBT>, ICapabilityProvider
|
||||
{
|
||||
private ICapabilityProvider[] caps;
|
||||
private INBTSerializable<INBTBase>[] writers;
|
||||
private INBTSerializable<INBT>[] writers;
|
||||
private String[] names;
|
||||
private final List<Runnable> listeners;
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class CapabilityDispatcher implements INBTSerializable<NBTTagCompou
|
||||
public CapabilityDispatcher(Map<ResourceLocation, ICapabilityProvider> list, List<Runnable> listeners, @Nullable ICapabilityProvider parent)
|
||||
{
|
||||
List<ICapabilityProvider> lstCaps = Lists.newArrayList();
|
||||
List<INBTSerializable<INBTBase>> lstWriters = Lists.newArrayList();
|
||||
List<INBTSerializable<INBT>> lstWriters = Lists.newArrayList();
|
||||
List<String> lstNames = Lists.newArrayList();
|
||||
this.listeners = listeners;
|
||||
|
||||
@@ -72,7 +72,7 @@ public final class CapabilityDispatcher implements INBTSerializable<NBTTagCompou
|
||||
lstCaps.add(parent);
|
||||
if (parent instanceof INBTSerializable)
|
||||
{
|
||||
lstWriters.add((INBTSerializable<INBTBase>)parent);
|
||||
lstWriters.add((INBTSerializable<INBT>)parent);
|
||||
lstNames.add("Parent");
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public final class CapabilityDispatcher implements INBTSerializable<NBTTagCompou
|
||||
lstCaps.add(prov);
|
||||
if (prov instanceof INBTSerializable)
|
||||
{
|
||||
lstWriters.add((INBTSerializable<INBTBase>)prov);
|
||||
lstWriters.add((INBTSerializable<INBT>)prov);
|
||||
lstNames.add(entry.getKey().toString());
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public final class CapabilityDispatcher implements INBTSerializable<NBTTagCompou
|
||||
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, @Nullable EnumFacing side)
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, @Nullable Direction side)
|
||||
{
|
||||
for (ICapabilityProvider c : caps)
|
||||
{
|
||||
@@ -108,24 +108,24 @@ public final class CapabilityDispatcher implements INBTSerializable<NBTTagCompou
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serializeNBT()
|
||||
public CompoundNBT serializeNBT()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
CompoundNBT nbt = new CompoundNBT();
|
||||
for (int x = 0; x < writers.length; x++)
|
||||
{
|
||||
nbt.setTag(names[x], writers[x].serializeNBT());
|
||||
nbt.func_218657_a(names[x], writers[x].serializeNBT());
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(NBTTagCompound nbt)
|
||||
public void deserializeNBT(CompoundNBT nbt)
|
||||
{
|
||||
for (int x = 0; x < writers.length; x++)
|
||||
{
|
||||
if (nbt.hasKey(names[x]))
|
||||
if (nbt.contains(names[x]))
|
||||
{
|
||||
writers[x].deserializeNBT(nbt.getTag(names[x]));
|
||||
writers[x].deserializeNBT(nbt.get(names[x]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,9 @@ package net.minecraftforge.common.capabilities;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
@@ -79,7 +78,7 @@ public abstract class CapabilityProvider<B extends CapabilityProvider<B>> implem
|
||||
}
|
||||
}
|
||||
|
||||
protected final @Nullable NBTTagCompound serializeCaps()
|
||||
protected final @Nullable CompoundNBT serializeCaps()
|
||||
{
|
||||
final CapabilityDispatcher disp = getCapabilities();
|
||||
if (disp != null)
|
||||
@@ -89,7 +88,7 @@ public abstract class CapabilityProvider<B extends CapabilityProvider<B>> implem
|
||||
return null;
|
||||
}
|
||||
|
||||
protected final void deserializeCaps(NBTTagCompound tag)
|
||||
protected final void deserializeCaps(CompoundNBT tag)
|
||||
{
|
||||
final CapabilityDispatcher disp = getCapabilities();
|
||||
if (disp != null)
|
||||
@@ -113,7 +112,7 @@ public abstract class CapabilityProvider<B extends CapabilityProvider<B>> implem
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable EnumFacing side)
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side)
|
||||
{
|
||||
final CapabilityDispatcher disp = getCapabilities();
|
||||
return !valid || disp == null ? LazyOptional.empty() : disp.getCapability(cap, side);
|
||||
|
||||
@@ -22,7 +22,7 @@ package net.minecraftforge.common.capabilities;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
public interface ICapabilityProvider
|
||||
@@ -38,7 +38,7 @@ public interface ICapabilityProvider
|
||||
* <strong>CAN BE NULL</strong>. Null is defined to represent 'internal' or 'self'
|
||||
* @return The requested an optional holding the requested capability.
|
||||
*/
|
||||
@Nonnull <T> LazyOptional<T> getCapability(@Nonnull final Capability<T> cap, final @Nullable EnumFacing side);
|
||||
@Nonnull <T> LazyOptional<T> getCapability(@Nonnull final Capability<T> cap, final @Nullable Direction side);
|
||||
|
||||
/*
|
||||
* Purely added as a bouncer to sided version, to make modders stop complaining about calling with a null value.
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package net.minecraftforge.common.capabilities;
|
||||
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
|
||||
//Just a mix of the two, useful in patches to lower the size.
|
||||
public interface ICapabilitySerializable<T extends INBTBase> extends ICapabilityProvider, INBTSerializable<T>{}
|
||||
public interface ICapabilitySerializable<T extends INBT> extends ICapabilityProvider, INBTSerializable<T>{}
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* 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.common.chunkio;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
|
||||
public class ChunkIOExecutor
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final int BASE_THREADS = 1;
|
||||
private static final int PLAYERS_PER_THREAD = 50;
|
||||
|
||||
private static final Map<QueuedChunk, ChunkIOProvider> tasks = Maps.newConcurrentMap();
|
||||
private static final ThreadPoolExecutor pool = new ChunkIOThreadPoolExecutor(BASE_THREADS, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(),
|
||||
new ThreadFactory()
|
||||
{
|
||||
private AtomicInteger count = new AtomicInteger(1);
|
||||
@Override
|
||||
public Thread newThread(Runnable r)
|
||||
{
|
||||
Thread thread = new Thread(r, "Chunk I/O Executor Thread-" + count.getAndIncrement());
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//Load the chunk completely in this thread. Dequeue as needed...
|
||||
public static Chunk syncChunkLoad(World world, AnvilChunkLoader loader, ChunkProviderServer provider, int x, int z)
|
||||
{
|
||||
QueuedChunk key = new QueuedChunk(x, z, world);
|
||||
ChunkIOProvider task = tasks.remove(key); // Remove task because we will call the sync callbacks directly
|
||||
if (task != null)
|
||||
{
|
||||
if (!pool.remove(task)) // If it wasn't in the pool, and run hasn't finished, then wait for the async thread.
|
||||
{
|
||||
synchronized(task)
|
||||
{
|
||||
while (!task.runFinished())
|
||||
{
|
||||
try
|
||||
{
|
||||
task.wait();
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace(); // Something happened? Log it?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the task was not run yet we still need to load the chunk
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
task = new ChunkIOProvider(key, loader, provider);
|
||||
task.run();
|
||||
}
|
||||
task.syncCallback();
|
||||
return task.getChunk();
|
||||
}
|
||||
|
||||
//Queue the chunk to be loaded, and call the runnable when finished
|
||||
public static void queueChunkLoad(World world, AnvilChunkLoader loader, ChunkProviderServer provider, int x, int z, Runnable runnable)
|
||||
{
|
||||
QueuedChunk key = new QueuedChunk(x, z, world);
|
||||
ChunkIOProvider task = tasks.get(key);
|
||||
if (task == null)
|
||||
{
|
||||
task = new ChunkIOProvider(key, loader, provider);
|
||||
task.addCallback(runnable); // Add before calling execute for thread safety
|
||||
tasks.put(key, task);
|
||||
pool.execute(task);
|
||||
}
|
||||
else
|
||||
{
|
||||
task.addCallback(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the chunk from the queue if it's in the list.
|
||||
public static void dropQueuedChunkLoad(World world, int x, int z, Runnable runnable)
|
||||
{
|
||||
QueuedChunk key = new QueuedChunk(x, z, world);
|
||||
ChunkIOProvider task = tasks.get(key);
|
||||
if (task == null)
|
||||
{
|
||||
LOGGER.warn("Attempted to dequeue chunk that wasn't queued? {} @ ({}, {})", DimensionType.func_212678_a(world.dimension.getType()).toString(), x, z);
|
||||
return;
|
||||
}
|
||||
|
||||
task.removeCallback(runnable);
|
||||
|
||||
if (!task.hasCallback())
|
||||
{
|
||||
tasks.remove(key);
|
||||
pool.remove(task);
|
||||
}
|
||||
}
|
||||
|
||||
public static void adjustPoolSize(int players)
|
||||
{
|
||||
pool.setCorePoolSize(Math.max(BASE_THREADS, players / PLAYERS_PER_THREAD));
|
||||
}
|
||||
|
||||
public static void tick()
|
||||
{
|
||||
Iterator<ChunkIOProvider> itr = tasks.values().iterator();
|
||||
while (itr.hasNext())
|
||||
{
|
||||
ChunkIOProvider task = itr.next();
|
||||
if (task.runFinished())
|
||||
{
|
||||
if (task.hasCallback())
|
||||
task.syncCallback();
|
||||
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* 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.common.chunkio;
|
||||
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.ChunkDataEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
class ChunkIOProvider implements Runnable
|
||||
{
|
||||
private final QueuedChunk chunkInfo;
|
||||
private final AnvilChunkLoader loader;
|
||||
private final ChunkProviderServer provider;
|
||||
|
||||
private Chunk chunk;
|
||||
private NBTTagCompound nbt;
|
||||
private final ConcurrentLinkedQueue<Runnable> callbacks = new ConcurrentLinkedQueue<Runnable>();
|
||||
private boolean ran = false;
|
||||
|
||||
ChunkIOProvider(QueuedChunk chunk, AnvilChunkLoader loader, ChunkProviderServer provider)
|
||||
{
|
||||
this.chunkInfo = chunk;
|
||||
this.loader = loader;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public void addCallback(Runnable callback)
|
||||
{
|
||||
this.callbacks.add(callback);
|
||||
}
|
||||
public void removeCallback(Runnable callback)
|
||||
{
|
||||
this.callbacks.remove(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() // async stuff
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
try
|
||||
{
|
||||
Object[] data = null;
|
||||
/*try
|
||||
{ TODO Chunk loading
|
||||
data = this.loader.loadChunk__Async(chunkInfo.world, chunkInfo.x, chunkInfo.z);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e); // Allow exception to bubble up to afterExecute
|
||||
}*/
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
this.nbt = (NBTTagCompound)data[1];
|
||||
this.chunk = (Chunk)data[0];
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.ran = true;
|
||||
this.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sync stuff
|
||||
public void syncCallback()
|
||||
{
|
||||
if (chunk == null)
|
||||
{
|
||||
this.runCallbacks();
|
||||
return;
|
||||
}
|
||||
|
||||
/*/ Load Entities TODO Chunk loading
|
||||
this.loader.loadEntities(this.chunkInfo.world, this.nbt.getCompoundTag("Level"), this.chunk);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(this.chunk, this.nbt)); // Don't call ChunkDataEvent.Load async
|
||||
|
||||
this.chunk.setLastSaveTime(provider.world.getTotalWorldTime());
|
||||
this.provider.chunkGenerator.recreateStructures(this.chunk, this.chunkInfo.x, this.chunkInfo.z);
|
||||
|
||||
provider.id2ChunkMap.put(ChunkPos.asLong(this.chunkInfo.x, this.chunkInfo.z), this.chunk);
|
||||
this.chunk.onLoad();
|
||||
this.chunk.populate(provider, provider.chunkGenerator);
|
||||
*/
|
||||
this.runCallbacks();
|
||||
}
|
||||
|
||||
public Chunk getChunk()
|
||||
{
|
||||
return this.chunk;
|
||||
}
|
||||
|
||||
public boolean runFinished()
|
||||
{
|
||||
return this.ran;
|
||||
}
|
||||
|
||||
public boolean hasCallback()
|
||||
{
|
||||
return this.callbacks.size() > 0;
|
||||
}
|
||||
|
||||
public void runCallbacks()
|
||||
{
|
||||
for (Runnable r : this.callbacks)
|
||||
{
|
||||
r.run();
|
||||
}
|
||||
|
||||
this.callbacks.clear();
|
||||
}
|
||||
|
||||
public QueuedChunk getChunkInfo()
|
||||
{
|
||||
return chunkInfo;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* 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.common.chunkio;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
|
||||
class ChunkIOThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public ChunkIOThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
|
||||
{
|
||||
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterExecute(Runnable r, Throwable t)
|
||||
{
|
||||
if (t != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
LOGGER.error("Unhandled exception loading chunk:", t);
|
||||
QueuedChunk queuedChunk = ((ChunkIOProvider) r).getChunkInfo();
|
||||
LOGGER.error(queuedChunk);
|
||||
LOGGER.error(CrashReportCategory.getCoordinateInfo(queuedChunk.x << 4, 64, queuedChunk.z << 4));
|
||||
}
|
||||
catch (Throwable t2)
|
||||
{
|
||||
LOGGER.error(t2);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Make absolutely sure that we do not leave any deadlock case
|
||||
r.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* 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.common.chunkio;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
class QueuedChunk {
|
||||
final int x;
|
||||
final int z;
|
||||
final World world;
|
||||
|
||||
public QueuedChunk(int x, int z, World world) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (x * 31 + z * 29) ^ world.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof QueuedChunk) {
|
||||
QueuedChunk other = (QueuedChunk) object;
|
||||
return x == other.x && z == other.z && world == other.world;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
String NEW_LINE = System.getProperty("line.separator");
|
||||
|
||||
result.append(this.getClass().getName() + " {" + NEW_LINE);
|
||||
result.append(" x: " + x + NEW_LINE);
|
||||
result.append(" z: " + z + NEW_LINE);
|
||||
result.append(" world: " + world.getWorldInfo().getWorldName() + NEW_LINE);
|
||||
result.append(" dimension: " + DimensionType.func_212678_a(world.dimension.getType()).toString() + NEW_LINE);
|
||||
result.append(" provider: " + world.dimension.getClass().getName() + NEW_LINE);
|
||||
result.append("}");
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class CompoundIngredient extends Ingredient
|
||||
@Override
|
||||
public CompoundIngredient parse(PacketBuffer buffer)
|
||||
{
|
||||
return new CompoundIngredient(Stream.generate(() -> Ingredient.fromBuffer(buffer)).limit(buffer.readVarInt()).collect(Collectors.toList()));
|
||||
return new CompoundIngredient(Stream.generate(() -> Ingredient.read(buffer)).limit(buffer.readVarInt()).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,7 +131,7 @@ public class CompoundIngredient extends Ingredient
|
||||
public void write(PacketBuffer buffer, CompoundIngredient ingredient)
|
||||
{
|
||||
buffer.writeVarInt(ingredient.children.size());
|
||||
ingredient.children.forEach(c -> c.writeToBuffer(buffer));
|
||||
ingredient.children.forEach(c -> c.write(buffer));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,11 +49,11 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.crafting.Ingredient.IItemList;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@@ -73,19 +73,19 @@ public class CraftingHelper
|
||||
private static Map<ResourceLocation, IItemList> constants = new HashMap<>();
|
||||
|
||||
public static final IConditionSerializer CONDITION_MOD_LOADED = condition("mod_loaded", json -> {
|
||||
String modid = JsonUtils.getString(json, "modid");
|
||||
String modid = JSONUtils.getString(json, "modid");
|
||||
return () -> ModList.get().isLoaded(modid);
|
||||
});
|
||||
public static final IConditionSerializer CONDITION_ITEM_EXISTS = condition("item_exists", json -> {
|
||||
String itemName = JsonUtils.getString(json, "item");
|
||||
String itemName = JSONUtils.getString(json, "item");
|
||||
return () -> ForgeRegistries.ITEMS.containsKey(new ResourceLocation(itemName));
|
||||
});
|
||||
public static final IConditionSerializer CONDITION_NOT = condition("not", json -> {
|
||||
BooleanSupplier child = CraftingHelper.getCondition(JsonUtils.getJsonObject(json, "value"));
|
||||
BooleanSupplier child = CraftingHelper.getCondition(JSONUtils.getJsonObject(json, "value"));
|
||||
return () -> !child.getAsBoolean();
|
||||
});
|
||||
public static final IConditionSerializer CONDITION_OR = condition("or", json -> {
|
||||
JsonArray values = JsonUtils.getJsonArray(json, "values");
|
||||
JsonArray values = JSONUtils.getJsonArray(json, "values");
|
||||
List<BooleanSupplier> children = Lists.newArrayList();
|
||||
for (JsonElement j : values)
|
||||
{
|
||||
@@ -96,7 +96,7 @@ public class CraftingHelper
|
||||
return () -> children.stream().anyMatch(BooleanSupplier::getAsBoolean);
|
||||
});
|
||||
public static final IConditionSerializer CONDITION_AND = condition("and", json -> {
|
||||
JsonArray values = JsonUtils.getJsonArray(json, "values");
|
||||
JsonArray values = JSONUtils.getJsonArray(json, "values");
|
||||
List<BooleanSupplier> children = Lists.newArrayList();
|
||||
for (JsonElement j : values)
|
||||
{
|
||||
@@ -208,7 +208,7 @@ public class CraftingHelper
|
||||
|
||||
JsonObject obj = (JsonObject)json;
|
||||
|
||||
String type = JsonUtils.getString(obj, "type", "minecraft:item");
|
||||
String type = JSONUtils.getString(obj, "type", "minecraft:item");
|
||||
if (type.isEmpty())
|
||||
throw new JsonSyntaxException("Ingredient type can not be an empty string");
|
||||
|
||||
@@ -221,7 +221,7 @@ public class CraftingHelper
|
||||
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT)
|
||||
{
|
||||
String itemName = JsonUtils.getString(json, "item");
|
||||
String itemName = JSONUtils.getString(json, "item");
|
||||
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName));
|
||||
|
||||
@@ -234,22 +234,22 @@ public class CraftingHelper
|
||||
try
|
||||
{
|
||||
JsonElement element = json.get("nbt");
|
||||
NBTTagCompound nbt;
|
||||
CompoundNBT nbt;
|
||||
if(element.isJsonObject())
|
||||
nbt = JsonToNBT.getTagFromJson(GSON.toJson(element));
|
||||
else
|
||||
nbt = JsonToNBT.getTagFromJson(JsonUtils.getString(element, "nbt"));
|
||||
nbt = JsonToNBT.getTagFromJson(JSONUtils.getString(element, "nbt"));
|
||||
|
||||
NBTTagCompound tmp = new NBTTagCompound();
|
||||
if (nbt.hasKey("ForgeCaps"))
|
||||
CompoundNBT tmp = new CompoundNBT();
|
||||
if (nbt.contains("ForgeCaps"))
|
||||
{
|
||||
tmp.setTag("ForgeCaps", nbt.getTag("ForgeCaps"));
|
||||
nbt.removeTag("ForgeCaps");
|
||||
tmp.func_218657_a("ForgeCaps", nbt.get("ForgeCaps"));
|
||||
nbt.remove("ForgeCaps");
|
||||
}
|
||||
|
||||
tmp.setTag("tag", nbt);
|
||||
tmp.setString("id", itemName);
|
||||
tmp.setInt("Count", JsonUtils.getInt(json, "count", 1));
|
||||
tmp.func_218657_a("tag", nbt);
|
||||
tmp.putString("id", itemName);
|
||||
tmp.putInt("Count", JSONUtils.getInt(json, "count", 1));
|
||||
|
||||
return ItemStack.read(tmp);
|
||||
}
|
||||
@@ -259,12 +259,12 @@ public class CraftingHelper
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemStack(item, JsonUtils.getInt(json, "count", 1));
|
||||
return new ItemStack(item, JSONUtils.getInt(json, "count", 1));
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonObject json, String memberName)
|
||||
{
|
||||
return !json.has(memberName) || processConditions(JsonUtils.getJsonArray(json, memberName));
|
||||
return !json.has(memberName) || processConditions(JSONUtils.getJsonArray(json, memberName));
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonArray conditions)
|
||||
@@ -284,7 +284,7 @@ public class CraftingHelper
|
||||
|
||||
public static BooleanSupplier getCondition(JsonObject json)
|
||||
{
|
||||
ResourceLocation type = new ResourceLocation(JsonUtils.getString(json, "type"));
|
||||
ResourceLocation type = new ResourceLocation(JSONUtils.getString(json, "type"));
|
||||
IConditionSerializer serrializer = conditions.get(type);
|
||||
if (serrializer == null)
|
||||
throw new JsonSyntaxException("Unknown condition type: " + type.toString());
|
||||
@@ -303,23 +303,23 @@ public class CraftingHelper
|
||||
String path = key.getPath();
|
||||
if (!path.equals("recipes/_constants.json")) //Top level only
|
||||
continue;
|
||||
|
||||
|
||||
tmp.putAll(loadConstants(manager, key));
|
||||
}
|
||||
constants = tmp;
|
||||
}
|
||||
|
||||
|
||||
public static Map<ResourceLocation, IItemList> loadConstants(IResourceManager manager, ResourceLocation key) {
|
||||
Map<ResourceLocation, IItemList> tmp = new HashMap<>();
|
||||
try (IResource iresource = manager.getResource(key))
|
||||
{
|
||||
JsonObject[] elements = JsonUtils.fromJson(GSON, IOUtils.toString(iresource.getInputStream(), StandardCharsets.UTF_8), JsonObject[].class);
|
||||
JsonObject[] elements = JSONUtils.fromJson(GSON, IOUtils.toString(iresource.getInputStream(), StandardCharsets.UTF_8), JsonObject[].class);
|
||||
for (int x = 0; x < elements.length; x++)
|
||||
{
|
||||
JsonObject json = elements[x];
|
||||
//Force namespace to the directory that this constants file is in, to prevent modders from overriding other's sneakily
|
||||
//TODO: Move back to a resource pack/mod specific constant list?
|
||||
ResourceLocation name = json.has("name") ? new ResourceLocation(JsonUtils.getString(json, "name")) : null;
|
||||
ResourceLocation name = json.has("name") ? new ResourceLocation(JSONUtils.getString(json, "name")) : null;
|
||||
if (name != null)
|
||||
name = new ResourceLocation(key.getNamespace(), name.getPath());
|
||||
|
||||
@@ -332,7 +332,7 @@ public class CraftingHelper
|
||||
else if (json.has("items"))
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for (JsonElement item : JsonUtils.getJsonArray(json, "items"))
|
||||
for (JsonElement item : JSONUtils.getJsonArray(json, "items"))
|
||||
{
|
||||
if (item.isJsonObject())
|
||||
items.add(getItemStack(item.getAsJsonObject(), true));
|
||||
@@ -349,7 +349,7 @@ public class CraftingHelper
|
||||
else if (json.has("tag"))
|
||||
tmp.put(name, Ingredient.deserializeItemList(json));
|
||||
else if (json.has("item"))
|
||||
tmp.put(name, new StackList(Lists.newArrayList(getItemStack(JsonUtils.getJsonObject(json, "item"), true))));
|
||||
tmp.put(name, new StackList(Lists.newArrayList(getItemStack(JSONUtils.getJsonObject(json, "item"), true))));
|
||||
else
|
||||
LOGGER.error(CRAFTHELPER, "Couldn't load constant #{} from {} as it's missing `item` or `items` element", x, key);
|
||||
}
|
||||
|
||||
@@ -19,10 +19,8 @@
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import net.minecraft.inventory.ContainerPlayer;
|
||||
import net.minecraft.inventory.ContainerWorkbench;
|
||||
import net.minecraft.inventory.InventoryCraftResult;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.CraftResultInventory;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
|
||||
/**
|
||||
* This interface is to be implemented on Container objects.
|
||||
@@ -36,12 +34,12 @@ public interface IRecipeContainer
|
||||
* The equivalent for {@link ContainerWorkbench} is {@link ContainerWorkbench#craftResult}.
|
||||
* The equivalent for {@link ContainerPlayer} is {@link ContainerPlayer#craftResult}.
|
||||
*/
|
||||
InventoryCraftResult getCraftResult();
|
||||
CraftResultInventory getCraftResult();
|
||||
|
||||
/**
|
||||
* The crafting matrix of your container, where ingredients go for crafting.
|
||||
* The equivalent for {@link ContainerWorkbench} is {@link ContainerWorkbench#craftMatrix}.
|
||||
* The equivalent for {@link ContainerPlayer} is {@link ContainerPlayer#craftMatrix}.
|
||||
*/
|
||||
InventoryCrafting getCraftMatrix();
|
||||
CraftingInventory getCraftMatrix();
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package net.minecraftforge.common.crafting;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
* book and auto crafting picks the correct shape.
|
||||
* Note: These methods can't be named 'getHeight' or 'getWidth' due to obfusication issues.
|
||||
*/
|
||||
public interface IShapedRecipe extends IRecipe
|
||||
public interface IShapedRecipe<T extends IInventory> extends IRecipe<T>
|
||||
{
|
||||
int getRecipeWidth();
|
||||
int getRecipeHeight();
|
||||
|
||||
@@ -43,7 +43,7 @@ public class StackList implements IItemList
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject toJson()
|
||||
public JsonObject serialize()
|
||||
{
|
||||
if (items.size() == 1)
|
||||
return toJson(items.iterator().next());
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* 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.common.extensions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.RecipeType;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class ForgeRecipeManager implements IResourceManagerReloadListener
|
||||
{
|
||||
/**
|
||||
* Master list of sorted recipes.
|
||||
*/
|
||||
protected final Map<RecipeType<? extends IRecipe>, List<? extends IRecipe>> sortedRecipes = Maps.newHashMap();
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager)
|
||||
{
|
||||
this.sortedRecipes.clear();
|
||||
CraftingHelper.reloadConstants(resourceManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the recipes that match this type.
|
||||
* @param type A recipe type.
|
||||
* @return All recipes that are of the passed type. This list may be empty.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends IRecipe> List<T> getRecipes(RecipeType<T> type)
|
||||
{
|
||||
return (List<T>) this.sortedRecipes.computeIfAbsent(type, t -> new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically returns a result from the first recipe that matches this inv and type.
|
||||
* Modders should probably not use this, and instead use {@link #getRecipe(IInventory, World, RecipeType)} since you get the recipe object itself.
|
||||
* @param input An inventory.
|
||||
* @param world The world.
|
||||
* @param type The type of recipe to match against.
|
||||
* @return The output of the first matching recipe, or {@link ItemStack#EMPTY} if no recipes match.
|
||||
*/
|
||||
public ItemStack getResult(IInventory input, World world, RecipeType<?> type)
|
||||
{
|
||||
for(IRecipe irecipe : getRecipes(type))
|
||||
if (irecipe.matches(input, world)) return irecipe.getCraftingResult(input);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to find a matching recipe for the given inv, world, and type.
|
||||
* Since this requires an IInventory, modders can use {@link RecipeWrapper} to avoid direct implementation.
|
||||
* For crafting recipes, it is advised to still use {@link InventoryCrafting}. The dynamic vanilla recipes require they be crafted in one.
|
||||
* @param input An inventory.
|
||||
* @param world The world.
|
||||
* @param type The type of recipe to match against.
|
||||
* @return The first matching recipe.
|
||||
*/
|
||||
@Nullable
|
||||
public <T extends IRecipe> T getRecipe(IInventory input, World world, RecipeType<T> type)
|
||||
{
|
||||
for(T irecipe : getRecipes(type))
|
||||
if (irecipe.matches(input, world)) return irecipe;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modders should not use this if possible. In the context that this is used, you should already have the recipe. Do not run extra lookups using this method.
|
||||
* Use {@link IRecipe#getRemainingItems(IInventory)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public NonNullList<ItemStack> getRemainingItems(IInventory input, World world, RecipeType<?> type)
|
||||
{
|
||||
for(IRecipe irecipe : getRecipes(type))
|
||||
if (irecipe.matches(input, world)) return irecipe.getRemainingItems(input);
|
||||
|
||||
NonNullList<ItemStack> nonnulllist = NonNullList.withSize(input.getSizeInventory(), ItemStack.EMPTY);
|
||||
|
||||
for(int i = 0; i < nonnulllist.size(); ++i)
|
||||
nonnulllist.set(i, input.getStackInSlot(i));
|
||||
|
||||
return nonnulllist;
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 1010 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user