Attempt to fix 1.16.3 branch's issues on the repository
Added the original 'wayoftime' folder back, so see if that fixed the multiple folder issue.
This commit is contained in:
parent
6b4145a67c
commit
9fa68e86ae
224 changed files with 24047 additions and 0 deletions
100
src/main/java/wayoftime/bloodmagic/client/ClientEvents.java
Normal file
100
src/main/java/wayoftime/bloodmagic/client/ClientEvents.java
Normal file
|
@ -0,0 +1,100 @@
|
|||
package wayoftime.bloodmagic.client;
|
||||
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.IItemPropertyGetter;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.client.render.block.RenderAlchemyArray;
|
||||
import wayoftime.bloodmagic.client.render.block.RenderAltar;
|
||||
import wayoftime.bloodmagic.client.screens.ScreenAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.client.screens.ScreenSoulForge;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilToggleable;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemSentientSword;
|
||||
import wayoftime.bloodmagic.iface.IMultiWillTool;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
import wayoftime.bloodmagic.tile.TileAltar;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = BloodMagic.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ClientEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
ClientRegistry.bindTileEntityRenderer(TileAltar.TYPE, RenderAltar::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileAlchemyArray.TYPE, RenderAlchemyArray::new);
|
||||
// ClientRegistry.bindTileEntityRenderer(TileSoulForge.TYPE, RenderAlchemyArray::new);
|
||||
}
|
||||
|
||||
public static void registerContainerScreens()
|
||||
{
|
||||
ScreenManager.registerFactory(BloodMagicBlocks.SOUL_FORGE_CONTAINER.get(), ScreenSoulForge::new);
|
||||
ScreenManager.registerFactory(BloodMagicBlocks.ARC_CONTAINER.get(), ScreenAlchemicalReactionChamber::new);
|
||||
}
|
||||
|
||||
public static void registerItemModelProperties(FMLClientSetupEvent event)
|
||||
{
|
||||
registerToggleableProperties(BloodMagicItems.GREEN_GROVE_SIGIL.get());
|
||||
registerToggleableProperties(BloodMagicItems.FAST_MINER_SIGIL.get());
|
||||
registerToggleableProperties(BloodMagicItems.MAGNETISM_SIGIL.get());
|
||||
registerToggleableProperties(BloodMagicItems.ICE_SIGIL.get());
|
||||
registerMultiWillTool(BloodMagicItems.SENTIENT_SWORD.get());
|
||||
registerMultiWillTool(BloodMagicItems.PETTY_GEM.get());
|
||||
registerMultiWillTool(BloodMagicItems.LESSER_GEM.get());
|
||||
registerMultiWillTool(BloodMagicItems.COMMON_GEM.get());
|
||||
|
||||
ItemModelsProperties.registerProperty(BloodMagicItems.SENTIENT_SWORD.get(), BloodMagic.rl("active"), new IItemPropertyGetter()
|
||||
{
|
||||
@Override
|
||||
public float call(ItemStack stack, ClientWorld world, LivingEntity entity)
|
||||
{
|
||||
return ((ItemSentientSword) stack.getItem()).getActivated(stack) ? 1 : 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerToggleableProperties(Item item)
|
||||
{
|
||||
ItemModelsProperties.registerProperty(item, BloodMagic.rl("active"), new IItemPropertyGetter()
|
||||
{
|
||||
@Override
|
||||
public float call(ItemStack stack, ClientWorld world, LivingEntity entity)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ItemSigilToggleable)
|
||||
{
|
||||
return ((ItemSigilToggleable) item).getActivated(stack) ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerMultiWillTool(Item item)
|
||||
{
|
||||
ItemModelsProperties.registerProperty(item, BloodMagic.rl("type"), new IItemPropertyGetter()
|
||||
{
|
||||
@Override
|
||||
public float call(ItemStack stack, ClientWorld world, LivingEntity entity)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof IMultiWillTool)
|
||||
{
|
||||
return ((IMultiWillTool) item).getCurrentType(stack).ordinal();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package wayoftime.bloodmagic.client.render;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class BloodMagicRenderer
|
||||
{
|
||||
public static float getRed(int color)
|
||||
{
|
||||
return (color >> 16 & 0xFF) / 255.0F;
|
||||
}
|
||||
|
||||
public static float getGreen(int color)
|
||||
{
|
||||
return (color >> 8 & 0xFF) / 255.0F;
|
||||
}
|
||||
|
||||
public static float getBlue(int color)
|
||||
{
|
||||
return (color & 0xFF) / 255.0F;
|
||||
}
|
||||
|
||||
public static float getAlpha(int color)
|
||||
{
|
||||
return (color >> 24 & 0xFF) / 255.0F;
|
||||
}
|
||||
|
||||
public static class Model3D
|
||||
{
|
||||
public double minX, minY, minZ;
|
||||
public double maxX, maxY, maxZ;
|
||||
|
||||
public final TextureAtlasSprite[] textures = new TextureAtlasSprite[6];
|
||||
|
||||
public final boolean[] renderSides = new boolean[]
|
||||
{ true, true, true, true, true, true, false };
|
||||
|
||||
public double sizeX()
|
||||
{
|
||||
return maxX - minX;
|
||||
}
|
||||
|
||||
public double sizeY()
|
||||
{
|
||||
return maxY - minY;
|
||||
}
|
||||
|
||||
public double sizeZ()
|
||||
{
|
||||
return maxZ - minZ;
|
||||
}
|
||||
|
||||
public void setSideRender(Direction side, boolean value)
|
||||
{
|
||||
renderSides[side.ordinal()] = value;
|
||||
}
|
||||
|
||||
public boolean shouldSideRender(Direction side)
|
||||
{
|
||||
return renderSides[side.ordinal()];
|
||||
}
|
||||
|
||||
public void setTexture(TextureAtlasSprite tex)
|
||||
{
|
||||
Arrays.fill(textures, tex);
|
||||
}
|
||||
|
||||
public void setTextures(TextureAtlasSprite down, TextureAtlasSprite up, TextureAtlasSprite north, TextureAtlasSprite south, TextureAtlasSprite west, TextureAtlasSprite east)
|
||||
{
|
||||
textures[0] = down;
|
||||
textures[1] = up;
|
||||
textures[2] = north;
|
||||
textures[3] = south;
|
||||
textures[4] = west;
|
||||
textures[5] = east;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Model2D
|
||||
{
|
||||
public double minX, minY;
|
||||
public double maxX, maxY;
|
||||
|
||||
public ResourceLocation resource;
|
||||
|
||||
public double sizeX()
|
||||
{
|
||||
return maxX - minX;
|
||||
}
|
||||
|
||||
public double sizeY()
|
||||
{
|
||||
return maxY - minY;
|
||||
}
|
||||
|
||||
public void setTexture(ResourceLocation resource)
|
||||
{
|
||||
this.resource = resource;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
package wayoftime.bloodmagic.client.render;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Direction.AxisDirection;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model3D;
|
||||
|
||||
/**
|
||||
* Adapted from BuildCraft
|
||||
*/
|
||||
public class RenderResizableCuboid
|
||||
{
|
||||
public static final RenderResizableCuboid INSTANCE = new RenderResizableCuboid();
|
||||
private static final Vector3f VEC_ZERO = new Vector3f(0, 0, 0);
|
||||
private static final int U_MIN = 0;
|
||||
private static final int U_MAX = 1;
|
||||
private static final int V_MIN = 2;
|
||||
private static final int V_MAX = 3;
|
||||
|
||||
protected EntityRendererManager manager = Minecraft.getInstance().getRenderManager();
|
||||
|
||||
private static Vector3f withValue(Vector3f vector, Axis axis, float value)
|
||||
{
|
||||
if (axis == Axis.X)
|
||||
{
|
||||
return new Vector3f(value, vector.getY(), vector.getZ());
|
||||
} else if (axis == Axis.Y)
|
||||
{
|
||||
return new Vector3f(vector.getX(), value, vector.getZ());
|
||||
} else if (axis == Axis.Z)
|
||||
{
|
||||
return new Vector3f(vector.getX(), vector.getY(), value);
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
}
|
||||
|
||||
public static double getValue(Vector3d vector, Axis axis)
|
||||
{
|
||||
if (axis == Axis.X)
|
||||
{
|
||||
return vector.x;
|
||||
} else if (axis == Axis.Y)
|
||||
{
|
||||
return vector.y;
|
||||
} else if (axis == Axis.Z)
|
||||
{
|
||||
return vector.z;
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
}
|
||||
|
||||
public void renderCube(Model3D cube, MatrixStack matrix, IVertexBuilder buffer, int argb, int light, int overlay)
|
||||
{
|
||||
float red = BloodMagicRenderer.getRed(argb);
|
||||
float green = BloodMagicRenderer.getGreen(argb);
|
||||
float blue = BloodMagicRenderer.getBlue(argb);
|
||||
float alpha = BloodMagicRenderer.getAlpha(argb);
|
||||
Vector3d size = new Vector3d(cube.sizeX(), cube.sizeY(), cube.sizeZ());
|
||||
matrix.push();
|
||||
matrix.translate(cube.minX, cube.minY, cube.minZ);
|
||||
MatrixStack.Entry lastMatrix = matrix.getLast();
|
||||
Matrix4f matrix4f = lastMatrix.getMatrix();
|
||||
Matrix3f normal = lastMatrix.getNormal();
|
||||
for (Direction face : Direction.values())
|
||||
{
|
||||
if (cube.shouldSideRender(face))
|
||||
{
|
||||
int ordinal = face.ordinal();
|
||||
TextureAtlasSprite sprite = cube.textures[ordinal];
|
||||
if (sprite != null)
|
||||
{
|
||||
Axis u = face.getAxis() == Axis.X ? Axis.Z : Axis.X;
|
||||
Axis v = face.getAxis() == Axis.Y ? Axis.Z : Axis.Y;
|
||||
float other = face.getAxisDirection() == AxisDirection.POSITIVE
|
||||
? (float) getValue(size, face.getAxis())
|
||||
: 0;
|
||||
|
||||
// Swap the face if this is positive: the renderer returns indexes that ALWAYS
|
||||
// are for the negative face, so light it properly this way
|
||||
face = face.getAxisDirection() == AxisDirection.NEGATIVE ? face : face.getOpposite();
|
||||
Direction opposite = face.getOpposite();
|
||||
|
||||
float minU = sprite.getMinU();
|
||||
float maxU = sprite.getMaxU();
|
||||
// Flip the v
|
||||
float minV = sprite.getMaxV();
|
||||
float maxV = sprite.getMinV();
|
||||
double sizeU = getValue(size, u);
|
||||
double sizeV = getValue(size, v);
|
||||
// TODO: Look into this more, as it makes tiling of multiple objects not render
|
||||
// properly if they don't fit the full texture.
|
||||
// Example: Mechanical pipes rendering water or lava, makes it relatively easy
|
||||
// to see the texture artifacts
|
||||
for (int uIndex = 0; uIndex < sizeU; uIndex++)
|
||||
{
|
||||
float[] baseUV = new float[]
|
||||
{ minU, maxU, minV, maxV };
|
||||
double addU = 1;
|
||||
// If the size of the texture is greater than the cuboid goes on for then make
|
||||
// sure the texture positions are lowered
|
||||
if (uIndex + addU > sizeU)
|
||||
{
|
||||
addU = sizeU - uIndex;
|
||||
baseUV[U_MAX] = baseUV[U_MIN] + (baseUV[U_MAX] - baseUV[U_MIN]) * (float) addU;
|
||||
}
|
||||
for (int vIndex = 0; vIndex < sizeV; vIndex++)
|
||||
{
|
||||
float[] uv = Arrays.copyOf(baseUV, 4);
|
||||
double addV = 1;
|
||||
if (vIndex + addV > sizeV)
|
||||
{
|
||||
addV = sizeV - vIndex;
|
||||
uv[V_MAX] = uv[V_MIN] + (uv[V_MAX] - uv[V_MIN]) * (float) addV;
|
||||
}
|
||||
float[] xyz = new float[]
|
||||
{ uIndex, (float) (uIndex + addU), vIndex, (float) (vIndex + addV) };
|
||||
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, false, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, false, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, false, false, red, green, blue, alpha, light, overlay);
|
||||
|
||||
renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, false, false, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, false, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, true, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, true, false, red, green, blue, alpha, light, overlay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
matrix.pop();
|
||||
}
|
||||
|
||||
private void renderPoint(Matrix4f matrix4f, Matrix3f normal, IVertexBuilder buffer, Direction face, Axis u, Axis v,
|
||||
float other, float[] uv, float[] xyz, boolean minU, boolean minV, float red, float green, float blue,
|
||||
float alpha, int light, int overlay)
|
||||
{
|
||||
int U_ARRAY = minU ? U_MIN : U_MAX;
|
||||
int V_ARRAY = minV ? V_MIN : V_MAX;
|
||||
Vector3f vertex = withValue(VEC_ZERO, u, xyz[U_ARRAY]);
|
||||
vertex = withValue(vertex, v, xyz[V_ARRAY]);
|
||||
vertex = withValue(vertex, face.getAxis(), other);
|
||||
Vector3i normalForFace = face.getDirectionVec();
|
||||
// TODO: Figure out how and why this works, it gives about the same brightness
|
||||
// as we used to have but I don't understand why/how
|
||||
float adjustment = 2.5F;
|
||||
Vector3f norm = new Vector3f(normalForFace.getX() + adjustment, normalForFace.getY()
|
||||
+ adjustment, normalForFace.getZ() + adjustment);
|
||||
norm.normalize();
|
||||
buffer.pos(matrix4f, vertex.getX(), vertex.getY(), vertex.getZ()).color(red, green, blue, alpha).tex(uv[U_ARRAY], uv[V_ARRAY]).overlay(overlay).lightmap(light).normal(normal, norm.getX(), norm.getY(), norm.getZ()).endVertex();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
package wayoftime.bloodmagic.client.render;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Direction.AxisDirection;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model2D;
|
||||
|
||||
public class RenderResizableQuadrilateral
|
||||
{
|
||||
public static final RenderResizableQuadrilateral INSTANCE = new RenderResizableQuadrilateral();
|
||||
private static final Vector3f VEC_ZERO = new Vector3f(0, 0, 0);
|
||||
private static final int U_MIN = 0;
|
||||
private static final int U_MAX = 1;
|
||||
private static final int V_MIN = 2;
|
||||
private static final int V_MAX = 3;
|
||||
|
||||
protected EntityRendererManager manager = Minecraft.getInstance().getRenderManager();
|
||||
|
||||
private static Vector3f withValue(Vector3f vector, Axis axis, float value)
|
||||
{
|
||||
if (axis == Axis.X)
|
||||
{
|
||||
return new Vector3f(value, vector.getY(), vector.getZ());
|
||||
} else if (axis == Axis.Y)
|
||||
{
|
||||
return new Vector3f(vector.getX(), value, vector.getZ());
|
||||
} else if (axis == Axis.Z)
|
||||
{
|
||||
return new Vector3f(vector.getX(), vector.getY(), value);
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
}
|
||||
|
||||
public static double getValue(Vector3d vector, Axis axis)
|
||||
{
|
||||
if (axis == Axis.X)
|
||||
{
|
||||
return vector.x;
|
||||
} else if (axis == Axis.Y)
|
||||
{
|
||||
return vector.y;
|
||||
} else if (axis == Axis.Z)
|
||||
{
|
||||
return vector.z;
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
}
|
||||
|
||||
public void renderSquare(Model2D square, MatrixStack matrix, IVertexBuilder buffer, int argb, int light, int overlay)
|
||||
{
|
||||
float red = BloodMagicRenderer.getRed(argb);
|
||||
float green = BloodMagicRenderer.getGreen(argb);
|
||||
float blue = BloodMagicRenderer.getBlue(argb);
|
||||
float alpha = BloodMagicRenderer.getAlpha(argb);
|
||||
Vector3d size = new Vector3d(square.sizeX(), 0, square.sizeY());
|
||||
matrix.push();
|
||||
matrix.translate(square.minX, 0, square.minY);
|
||||
MatrixStack.Entry lastMatrix = matrix.getLast();
|
||||
Matrix4f matrix4f = lastMatrix.getMatrix();
|
||||
Matrix3f normal = lastMatrix.getNormal();
|
||||
Direction face = Direction.UP;
|
||||
// for (Direction face : Direction.values())
|
||||
|
||||
int ordinal = face.ordinal();
|
||||
// TextureAtlasSprite sprite = cube.textures[ordinal];
|
||||
ResourceLocation rl = square.resource;
|
||||
if (rl != null)
|
||||
{
|
||||
// Minecraft.getInstance().textureManager.bindTexture(rl);
|
||||
Axis u = face.getAxis() == Axis.X ? Axis.Z : Axis.X;
|
||||
Axis v = face.getAxis() == Axis.Y ? Axis.Z : Axis.Y;
|
||||
float other = face.getAxisDirection() == AxisDirection.POSITIVE ? (float) getValue(size, face.getAxis())
|
||||
: 0;
|
||||
|
||||
// Swap the face if this is positive: the renderer returns indexes that ALWAYS
|
||||
// are for the negative face, so light it properly this way
|
||||
face = face.getAxisDirection() == AxisDirection.NEGATIVE ? face : face.getOpposite();
|
||||
// Direction opposite = face.getOpposite();
|
||||
|
||||
float minU = 0;
|
||||
float maxU = 1;
|
||||
// Flip the v
|
||||
float minV = 1;
|
||||
float maxV = 0;
|
||||
// float minU = sprite.getMinU();
|
||||
// float maxU = sprite.getMaxU();
|
||||
// // Flip the v
|
||||
// float minV = sprite.getMaxV();
|
||||
// float maxV = sprite.getMinV();
|
||||
double sizeU = getValue(size, u);
|
||||
double sizeV = getValue(size, v);
|
||||
// TODO: Look into this more, as it makes tiling of multiple objects not render
|
||||
// properly if they don't fit the full texture.
|
||||
// Example: Mechanical pipes rendering water or lava, makes it relatively easy
|
||||
// to see the texture artifacts
|
||||
for (int uIndex = 0; uIndex < sizeU; uIndex++)
|
||||
{
|
||||
float[] baseUV = new float[]
|
||||
{ minU, maxU, minV, maxV };
|
||||
double addU = 1;
|
||||
// If the size of the texture is greater than the cuboid goes on for then make
|
||||
// sure the texture positions are lowered
|
||||
if (uIndex + addU > sizeU)
|
||||
{
|
||||
// addU = sizeU - uIndex;
|
||||
baseUV[U_MAX] = baseUV[U_MIN] + (baseUV[U_MAX] - baseUV[U_MIN]) * (float) addU;
|
||||
}
|
||||
for (int vIndex = 0; vIndex < sizeV; vIndex++)
|
||||
{
|
||||
float[] uv = Arrays.copyOf(baseUV, 4);
|
||||
double addV = 1;
|
||||
if (vIndex + addV > sizeV)
|
||||
{
|
||||
// addV = sizeV - vIndex;
|
||||
uv[V_MAX] = uv[V_MIN] + (uv[V_MAX] - uv[V_MIN]) * (float) addV;
|
||||
}
|
||||
float[] xyz = new float[]
|
||||
{ uIndex, (float) (uIndex + addU), vIndex, (float) (vIndex + addV) };
|
||||
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, false, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, false, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, false, false, red, green, blue, alpha, light, overlay);
|
||||
|
||||
// renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, false, false, red, green, blue, alpha, light, overlay);
|
||||
// renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, false, true, red, green, blue, alpha, light, overlay);
|
||||
// renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, true, true, red, green, blue, alpha, light, overlay);
|
||||
// renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, true, false, red, green, blue, alpha, light, overlay);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
matrix.pop();
|
||||
}
|
||||
|
||||
private void renderPoint(Matrix4f matrix4f, Matrix3f normal, IVertexBuilder buffer, Direction face, Axis u, Axis v, float other, float[] uv, float[] xyz, boolean minU, boolean minV, float red, float green, float blue, float alpha, int light, int overlay)
|
||||
{
|
||||
int U_ARRAY = minU ? U_MIN : U_MAX;
|
||||
int V_ARRAY = minV ? V_MIN : V_MAX;
|
||||
Vector3f vertex = withValue(VEC_ZERO, u, xyz[U_ARRAY]);
|
||||
vertex = withValue(vertex, v, xyz[V_ARRAY]);
|
||||
vertex = withValue(vertex, face.getAxis(), other);
|
||||
Vector3i normalForFace = face.getDirectionVec();
|
||||
// TODO: Figure out how and why this works, it gives about the same brightness
|
||||
// as we used to have but I don't understand why/how
|
||||
float adjustment = 2.5F;
|
||||
Vector3f norm = new Vector3f(normalForFace.getX() + adjustment, normalForFace.getY()
|
||||
+ adjustment, normalForFace.getZ() + adjustment);
|
||||
norm.normalize();
|
||||
buffer.pos(matrix4f, vertex.getX(), vertex.getY(), vertex.getZ()).color(red, green, blue, alpha).tex(uv[U_ARRAY], uv[V_ARRAY]).overlay(overlay).lightmap(light).normal(normal, norm.getX(), norm.getY(), norm.getZ()).endVertex();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package wayoftime.bloodmagic.client.render.alchemyarray;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model2D;
|
||||
import wayoftime.bloodmagic.client.render.RenderResizableQuadrilateral;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class AlchemyArrayRenderer
|
||||
{
|
||||
public final ResourceLocation arrayResource;
|
||||
|
||||
public AlchemyArrayRenderer()
|
||||
{
|
||||
this(new ResourceLocation("bloodmagic", "textures/models/alchemyarrays/sightsigil.png"));
|
||||
}
|
||||
|
||||
public AlchemyArrayRenderer(ResourceLocation arrayResource)
|
||||
{
|
||||
this.arrayResource = arrayResource;
|
||||
}
|
||||
|
||||
public float getRotation(float craftTime)
|
||||
{
|
||||
float offset = 2;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSecondaryRotation(float craftTime)
|
||||
{
|
||||
float offset = 50;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSizeModifier(float craftTime)
|
||||
{
|
||||
if (craftTime >= 150 && craftTime <= 250)
|
||||
{
|
||||
return (200 - craftTime) / 50f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public float getVerticalOffset(float craftTime)
|
||||
{
|
||||
if (craftTime >= 5)
|
||||
{
|
||||
if (craftTime <= 40)
|
||||
{
|
||||
return (float) (-0.4 + (0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -0.4f;
|
||||
}
|
||||
|
||||
public void renderAt(TileAlchemyArray tileArray, double x, double y, double z, float craftTime, MatrixStack matrixStack, IRenderTypeBuffer renderer, int combinedLightIn, int combinedOverlayIn)
|
||||
{
|
||||
matrixStack.push();
|
||||
|
||||
matrixStack.translate(0.5, 0.5, 0.5);
|
||||
|
||||
float rot = getRotation(craftTime);
|
||||
float secondaryRot = getSecondaryRotation(craftTime);
|
||||
|
||||
float size = 1.0F * getSizeModifier(craftTime);
|
||||
Direction rotation = tileArray.getRotation();
|
||||
|
||||
matrixStack.push();
|
||||
matrixStack.translate(0, getVerticalOffset(craftTime), 0);
|
||||
matrixStack.rotate(new Quaternion(Direction.UP.toVector3f(), -rotation.getHorizontalAngle(), true));
|
||||
|
||||
matrixStack.push();
|
||||
|
||||
matrixStack.rotate(new Quaternion(Direction.UP.toVector3f(), rot, true));
|
||||
matrixStack.rotate(new Quaternion(Direction.NORTH.toVector3f(), secondaryRot, true));
|
||||
matrixStack.rotate(new Quaternion(Direction.EAST.toVector3f(), secondaryRot * 0.45812f, true));
|
||||
|
||||
IVertexBuilder twoDBuffer = renderer.getBuffer(RenderType.getEntityTranslucent(arrayResource));
|
||||
Model2D arrayModel = new BloodMagicRenderer.Model2D();
|
||||
arrayModel.minX = -0.5;
|
||||
arrayModel.maxX = +0.5;
|
||||
arrayModel.minY = -0.5;
|
||||
arrayModel.maxY = +0.5;
|
||||
arrayModel.resource = arrayResource;
|
||||
|
||||
matrixStack.scale(size, size, size);
|
||||
|
||||
RenderResizableQuadrilateral.INSTANCE.renderSquare(arrayModel, matrixStack, twoDBuffer, 0xFFFFFFFF, combinedLightIn, combinedOverlayIn);
|
||||
|
||||
matrixStack.pop();
|
||||
matrixStack.pop();
|
||||
matrixStack.pop();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package wayoftime.bloodmagic.client.render.block;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import wayoftime.bloodmagic.client.render.alchemyarray.AlchemyArrayRenderer;
|
||||
import wayoftime.bloodmagic.core.registry.AlchemyArrayRendererRegistry;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class RenderAlchemyArray extends TileEntityRenderer<TileAlchemyArray>
|
||||
{
|
||||
public static final AlchemyArrayRenderer arrayRenderer = new AlchemyArrayRenderer();
|
||||
|
||||
public RenderAlchemyArray(TileEntityRendererDispatcher rendererDispatcherIn)
|
||||
{
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileAlchemyArray tileArray, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn)
|
||||
{
|
||||
ItemStack inputStack = tileArray.getStackInSlot(0);
|
||||
ItemStack catalystStack = tileArray.getStackInSlot(1);
|
||||
// arrayRenderer.renderAt(tileArray, 0, 0, 0, tileArray.activeCounter
|
||||
// + partialTicks, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
||||
|
||||
AlchemyArrayRenderer renderer = AlchemyArrayRendererRegistry.getRenderer(tileArray.getWorld(), inputStack, catalystStack);
|
||||
if (renderer == null)
|
||||
{
|
||||
renderer = AlchemyArrayRendererRegistry.DEFAULT_RENDERER;
|
||||
}
|
||||
|
||||
renderer.renderAt(tileArray, 0, 0, 0, tileArray.activeCounter
|
||||
+ partialTicks, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
||||
// arrayRenderer.renderAt(tileArray, 0, 0, 0, 0, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
||||
|
||||
// if (tileAltar.getCurrentTierDisplayed() != AltarTier.ONE)
|
||||
// renderHologram(tileAltar, tileAltar.getCurrentTierDisplayed(), partialTicks);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,279 @@
|
|||
package wayoftime.bloodmagic.client.render.block;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model3D;
|
||||
import wayoftime.bloodmagic.client.render.RenderResizableCuboid;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.tile.TileAltar;
|
||||
|
||||
public class RenderAltar extends TileEntityRenderer<TileAltar>
|
||||
{
|
||||
public RenderAltar(TileEntityRendererDispatcher rendererDispatcherIn)
|
||||
{
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
private static final float MIN_HEIGHT = 0.499f;
|
||||
private static final float MAX_HEIGHT = 0.745f;
|
||||
|
||||
@Override
|
||||
public void render(TileAltar tileAltar, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn)
|
||||
{
|
||||
ItemStack inputStack = tileAltar.getStackInSlot(0);
|
||||
|
||||
float level = ((float) tileAltar.getCurrentBlood()) / (float) tileAltar.getCapacity();
|
||||
|
||||
this.renderItem(inputStack, tileAltar, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
||||
|
||||
renderFluid(level, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
||||
|
||||
// if (tileAltar.getCurrentTierDisplayed() != AltarTier.ONE)
|
||||
// renderHologram(tileAltar, tileAltar.getCurrentTierDisplayed(), partialTicks);
|
||||
}
|
||||
|
||||
private void renderFluid(float fluidLevel, MatrixStack matrixStack, IRenderTypeBuffer renderer, int combinedLightIn, int combinedOverlayIn)
|
||||
{
|
||||
Fluid fluid = BloodMagicBlocks.LIFE_ESSENCE_FLUID.get();
|
||||
FluidStack fluidStack = new FluidStack(fluid, 1000);
|
||||
|
||||
FluidRenderData data = new FluidRenderData(fluidStack);
|
||||
matrixStack.push();
|
||||
|
||||
Model3D model = getFluidModel(fluidLevel, data);
|
||||
IVertexBuilder buffer = renderer.getBuffer(Atlases.getTranslucentCullBlockType());
|
||||
|
||||
// matrixStack.translate(data.loca, y, z);
|
||||
// int glow = data.calculateGlowLight(0);
|
||||
RenderResizableCuboid.INSTANCE.renderCube(model, matrixStack, buffer, data.getColorARGB(1), combinedLightIn, combinedOverlayIn);
|
||||
|
||||
matrixStack.pop();
|
||||
}
|
||||
|
||||
public float getRotation(float craftTime)
|
||||
{
|
||||
float offset = 2;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSecondaryRotation(float craftTime)
|
||||
{
|
||||
float offset = 50;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSizeModifier(float craftTime)
|
||||
{
|
||||
if (craftTime >= 150 && craftTime <= 250)
|
||||
{
|
||||
return (200 - craftTime) / 50f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public float getVerticalOffset(float craftTime)
|
||||
{
|
||||
if (craftTime >= 5)
|
||||
{
|
||||
if (craftTime <= 40)
|
||||
{
|
||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else
|
||||
{
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void renderItem(ItemStack stack, TileAltar tileAltar, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn)
|
||||
{
|
||||
matrixStack.push();
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ItemRenderer itemRenderer = mc.getItemRenderer();
|
||||
if (!stack.isEmpty())
|
||||
{
|
||||
matrixStack.translate(0.5, 1, 0.5);
|
||||
matrixStack.push();
|
||||
|
||||
float rotation = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
|
||||
|
||||
matrixStack.rotate(Vector3f.YP.rotationDegrees(rotation));
|
||||
matrixStack.scale(0.5F, 0.5F, 0.5F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(stack, tileAltar.getWorld(), (LivingEntity) null);
|
||||
itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, true, matrixStack, buffer, combinedLightIn, combinedOverlayIn, ibakedmodel); // renderItem
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
matrixStack.pop();
|
||||
}
|
||||
|
||||
matrixStack.pop();
|
||||
}
|
||||
|
||||
private Model3D getFluidModel(float fluidLevel, FluidRenderData data)
|
||||
{
|
||||
Model3D model = new BloodMagicRenderer.Model3D();
|
||||
model.setTexture(data.getTexture());
|
||||
model.minX = 0.1;
|
||||
model.minY = MIN_HEIGHT;
|
||||
model.minZ = 0.1;
|
||||
model.maxX = 0.9;
|
||||
model.maxY = (MAX_HEIGHT - MIN_HEIGHT) * fluidLevel + MIN_HEIGHT;
|
||||
model.maxZ = 0.9;
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public class FluidRenderData
|
||||
{
|
||||
public BlockPos location;
|
||||
|
||||
public int height;
|
||||
public int length;
|
||||
public int width;
|
||||
|
||||
public final FluidStack fluidType;
|
||||
|
||||
public FluidRenderData(FluidStack fluidType)
|
||||
{
|
||||
this.fluidType = fluidType;
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getTexture()
|
||||
{
|
||||
return Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidType.getFluid().getAttributes().getStillTexture());
|
||||
}
|
||||
|
||||
public boolean isGaseous()
|
||||
{
|
||||
return fluidType.getFluid().getAttributes().isGaseous(fluidType);
|
||||
}
|
||||
|
||||
public int getColorARGB(float scale)
|
||||
{
|
||||
return fluidType.getFluid().getAttributes().getColor(fluidType);
|
||||
}
|
||||
|
||||
public int calculateGlowLight(int light)
|
||||
{
|
||||
return light;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int code = super.hashCode();
|
||||
code = 31 * code + fluidType.getFluid().getRegistryName().hashCode();
|
||||
if (fluidType.hasTag())
|
||||
{
|
||||
code = 31 * code + fluidType.getTag().hashCode();
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object data)
|
||||
{
|
||||
return super.equals(data) && data instanceof FluidRenderData
|
||||
&& fluidType.isFluidEqual(((FluidRenderData) data).fluidType);
|
||||
}
|
||||
}
|
||||
//
|
||||
// private void renderHologram(TileAltar altar, AltarTier tier, float partialTicks)
|
||||
// {
|
||||
// EntityPlayerSP player = Minecraft.getMinecraft().player;
|
||||
// World world = player.world;
|
||||
//
|
||||
// if (tier == AltarTier.ONE)
|
||||
// return;
|
||||
//
|
||||
// GlStateManager.pushMatrix();
|
||||
// GlStateManager.enableBlend();
|
||||
// GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
// GlStateManager.color(1F, 1F, 1F, 0.6125F);
|
||||
//
|
||||
// BlockPos vec3, vX;
|
||||
// vec3 = altar.getPos();
|
||||
// double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||
// double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
// double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
//
|
||||
// for (AltarComponent altarComponent : tier.getAltarComponents())
|
||||
// {
|
||||
// vX = vec3.add(altarComponent.getOffset());
|
||||
// double minX = vX.getX() - posX;
|
||||
// double minY = vX.getY() - posY;
|
||||
// double minZ = vX.getZ() - posZ;
|
||||
//
|
||||
// if (!world.getBlockState(vX).isOpaqueCube())
|
||||
// {
|
||||
// TextureAtlasSprite texture = null;
|
||||
//
|
||||
// switch (altarComponent.getComponent())
|
||||
// {
|
||||
// case BLOODRUNE:
|
||||
// texture = ClientHandler.blankBloodRune;
|
||||
// break;
|
||||
// case NOTAIR:
|
||||
// texture = ClientHandler.stoneBrick;
|
||||
// break;
|
||||
// case GLOWSTONE:
|
||||
// texture = ClientHandler.glowstone;
|
||||
// break;
|
||||
// case BLOODSTONE:
|
||||
// texture = ClientHandler.bloodStoneBrick;
|
||||
// break;
|
||||
// case BEACON:
|
||||
// texture = ClientHandler.beacon;
|
||||
// break;
|
||||
// case CRYSTAL:
|
||||
// texture = ClientHandler.crystalCluster;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// GlStateManager.popMatrix();
|
||||
// }
|
||||
|
||||
// private static void setGLColorFromInt(int color)
|
||||
// {
|
||||
// float red = (color >> 16 & 0xFF) / 255.0F;
|
||||
// float green = (color >> 8 & 0xFF) / 255.0F;
|
||||
// float blue = (color & 0xFF) / 255.0F;
|
||||
//
|
||||
// GlStateManager.color(red, green, blue, 1.0F);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package wayoftime.bloodmagic.client.render.block;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
||||
public class RenderFakeBlocks
|
||||
{
|
||||
public static void drawFakeBlock(TextureAtlasSprite texture, double minX, double minY, double minZ)
|
||||
{
|
||||
if (texture == null)
|
||||
return;
|
||||
|
||||
double maxX = minX + 1;
|
||||
double maxY = minY + 1;
|
||||
double maxZ = minZ + 1;
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder wr = tessellator.getBuffer();
|
||||
|
||||
Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(texture.getName());
|
||||
|
||||
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
|
||||
float texMinU = texture.getMinU();
|
||||
float texMinV = texture.getMinV();
|
||||
float texMaxU = texture.getMaxU();
|
||||
float texMaxV = texture.getMaxV();
|
||||
|
||||
wr.pos(minX, minY, minZ).tex(texMinU, texMinV).endVertex();
|
||||
wr.pos(maxX, minY, minZ).tex(texMaxU, texMinV).endVertex();
|
||||
wr.pos(maxX, minY, maxZ).tex(texMaxU, texMaxV).endVertex();
|
||||
wr.pos(minX, minY, maxZ).tex(texMinU, texMaxV).endVertex();
|
||||
|
||||
wr.pos(minX, maxY, maxZ).tex(texMinU, texMaxV).endVertex();
|
||||
wr.pos(maxX, maxY, maxZ).tex(texMaxU, texMaxV).endVertex();
|
||||
wr.pos(maxX, maxY, minZ).tex(texMaxU, texMinV).endVertex();
|
||||
wr.pos(minX, maxY, minZ).tex(texMinU, texMinV).endVertex();
|
||||
|
||||
wr.pos(maxX, minY, minZ).tex(texMinU, texMaxV).endVertex();
|
||||
wr.pos(minX, minY, minZ).tex(texMaxU, texMaxV).endVertex();
|
||||
wr.pos(minX, maxY, minZ).tex(texMaxU, texMinV).endVertex();
|
||||
wr.pos(maxX, maxY, minZ).tex(texMinU, texMinV).endVertex();
|
||||
|
||||
wr.pos(minX, minY, maxZ).tex(texMinU, texMaxV).endVertex();
|
||||
wr.pos(maxX, minY, maxZ).tex(texMaxU, texMaxV).endVertex();
|
||||
wr.pos(maxX, maxY, maxZ).tex(texMaxU, texMinV).endVertex();
|
||||
wr.pos(minX, maxY, maxZ).tex(texMinU, texMinV).endVertex();
|
||||
|
||||
wr.pos(minX, minY, minZ).tex(texMinU, texMaxV).endVertex();
|
||||
wr.pos(minX, minY, maxZ).tex(texMaxU, texMaxV).endVertex();
|
||||
wr.pos(minX, maxY, maxZ).tex(texMaxU, texMinV).endVertex();
|
||||
wr.pos(minX, maxY, minZ).tex(texMinU, texMinV).endVertex();
|
||||
|
||||
wr.pos(maxX, minY, maxZ).tex(texMinU, texMaxV).endVertex();
|
||||
wr.pos(maxX, minY, minZ).tex(texMaxU, texMaxV).endVertex();
|
||||
wr.pos(maxX, maxY, minZ).tex(texMaxU, texMinV).endVertex();
|
||||
wr.pos(maxX, maxY, maxZ).tex(texMinU, texMinV).endVertex();
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package wayoftime.bloodmagic.client.render.entity;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.entity.SpriteRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IRendersAsItem;
|
||||
|
||||
public class BloodLightRenderer<T extends Entity & IRendersAsItem> extends SpriteRenderer<T>
|
||||
{
|
||||
public BloodLightRenderer(EntityRendererManager renderManagerIn)
|
||||
{
|
||||
super(renderManagerIn, Minecraft.getInstance().getItemRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn)
|
||||
{
|
||||
super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package wayoftime.bloodmagic.client.render.entity;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.entity.SpriteRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IRendersAsItem;
|
||||
|
||||
public class SoulSnareRenderer<T extends Entity & IRendersAsItem> extends SpriteRenderer<T>
|
||||
{
|
||||
public SoulSnareRenderer(EntityRendererManager renderManagerIn)
|
||||
{
|
||||
super(renderManagerIn, Minecraft.getInstance().getItemRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn)
|
||||
{
|
||||
super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package wayoftime.bloodmagic.client.screens;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.util.handler.event.ClientHandler;
|
||||
|
||||
public class ScreenAlchemicalReactionChamber extends ScreenBase<ContainerAlchemicalReactionChamber>
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation(BloodMagic.MODID, "textures/gui/arc_gui.png");
|
||||
public TileAlchemicalReactionChamber tileARC;
|
||||
|
||||
public ScreenAlchemicalReactionChamber(ContainerAlchemicalReactionChamber container, PlayerInventory playerInventory, ITextComponent title)
|
||||
{
|
||||
super(container, playerInventory, title);
|
||||
tileARC = container.tileARC;
|
||||
this.xSize = 176;
|
||||
this.ySize = 205;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
// public
|
||||
|
||||
// public ScreenSoulForge(InventoryPlayer playerInventory, IInventory tileSoulForge)
|
||||
// {
|
||||
// super(new ContainerSoulForge(playerInventory, tileSoulForge));
|
||||
// this.tileSoulForge = tileSoulForge;
|
||||
// this.xSize = 176;
|
||||
// this.ySize = 205;
|
||||
// }
|
||||
//
|
||||
@Override
|
||||
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
List<ITextComponent> tooltip = new ArrayList<>();
|
||||
// FluidTank inputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 2);
|
||||
// inputTank.fill(new FluidStack(Fluids.WATER, 1000), FluidAction.EXECUTE);
|
||||
|
||||
ClientHandler.handleGuiTank(stack, tileARC.inputTank, this.guiLeft + 8, this.guiTop
|
||||
+ 40, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), tooltip);
|
||||
ClientHandler.handleGuiTank(stack, tileARC.outputTank, this.guiLeft + 152, this.guiTop
|
||||
+ 15, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), tooltip);
|
||||
|
||||
if (!tooltip.isEmpty())
|
||||
GuiUtils.drawHoveringText(stack, tooltip, mouseX, mouseY, width, height, -1, font);
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack stack, int mouseX, int mouseY)
|
||||
{
|
||||
this.font.func_243248_b(stack, new TranslationTextComponent("tile.bloodmagic.arc.name"), 8, 5, 4210752);
|
||||
this.font.func_243248_b(stack, new TranslationTextComponent("container.inventory"), 8, 111, 4210752);
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
getMinecraft().getTextureManager().bindTexture(background);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.blit(stack, i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
// FluidTank inputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 2);
|
||||
// inputTank.fill(new FluidStack(Fluids.WATER, 1000), FluidAction.EXECUTE);
|
||||
|
||||
ClientHandler.handleGuiTank(stack, tileARC.inputTank, this.guiLeft + 8, this.guiTop
|
||||
+ 40, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), null);
|
||||
ClientHandler.handleGuiTank(stack, tileARC.outputTank, this.guiLeft + 152, this.guiTop
|
||||
+ 15, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), null);
|
||||
|
||||
// int l = this.getCookProgressScaled(90);
|
||||
// this.blit(stack, i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l);
|
||||
}
|
||||
|
||||
////
|
||||
// public int getCookProgressScaled(int scale)
|
||||
// {
|
||||
// double progress = ((TileSoulForge) tileSoulForge).getProgressForGui();
|
||||
//// if (tileSoulForge != null)
|
||||
//// {
|
||||
//// System.out.println("Tile is NOT null");
|
||||
//// }
|
||||
//// double progress = ((float) this.container.data.get(0)) / ((float) this.container.data.get(1));
|
||||
//// System.out.println(this.container.data.get(0));
|
||||
// return (int) (progress * scale);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package wayoftime.bloodmagic.client.screens;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
|
||||
public abstract class ScreenBase<T extends Container> extends ContainerScreen<T>
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation(BloodMagic.MODID, "textures/gui/soulforge.png");
|
||||
|
||||
protected final T container;
|
||||
|
||||
public ScreenBase(T container, PlayerInventory playerInventory, ITextComponent title)
|
||||
{
|
||||
super(container, playerInventory, title);
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public ResourceLocation getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
|
||||
this.renderHoveredTooltip(stack, mouseX, mouseY); // @mcp: func_230459_a_ = renderHoveredToolTip
|
||||
// if (mouseX > (guiLeft + 7) && mouseX < (guiLeft + 7) + 18 && mouseY > (guiTop + 7)
|
||||
// && mouseY < (guiTop + 7) + 73)
|
||||
// this.renderTooltip(stack, LanguageMap.getInstance().func_244260_a(Arrays.asList(new TranslationTextComponent("screen.diregoo.energy", MagicHelpers.withSuffix(this.container.getEnergy()), MagicHelpers.withSuffix(this.container.getMaxPower())))), mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
// RenderSystem.color4f(1, 1, 1, 1);
|
||||
// getMinecraft().getTextureManager().bindTexture(getBackground());
|
||||
// this.blit(stack, guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
// int maxEnergy = this.container.getMaxPower(), height = 70;
|
||||
// if (maxEnergy > 0)
|
||||
// {
|
||||
// int remaining = (this.container.getEnergy() * height) / maxEnergy;
|
||||
// this.blit(stack, guiLeft + 8, guiTop + 78 - remaining, 176, 84 - remaining, 16, remaining + 1);
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
protected static TranslationTextComponent getTrans(String key, Object... args)
|
||||
{
|
||||
return new TranslationTextComponent(BloodMagic.MODID + "." + key, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package wayoftime.bloodmagic.client.screens;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.tile.TileSoulForge;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerSoulForge;
|
||||
|
||||
public class ScreenSoulForge extends ScreenBase<ContainerSoulForge>
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation(BloodMagic.MODID, "textures/gui/soulforge.png");
|
||||
public IInventory tileSoulForge;
|
||||
|
||||
public ScreenSoulForge(ContainerSoulForge container, PlayerInventory playerInventory, ITextComponent title)
|
||||
{
|
||||
super(container, playerInventory, title);
|
||||
tileSoulForge = container.tileForge;
|
||||
this.xSize = 176;
|
||||
this.ySize = 205;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
// public
|
||||
|
||||
// public ScreenSoulForge(InventoryPlayer playerInventory, IInventory tileSoulForge)
|
||||
// {
|
||||
// super(new ContainerSoulForge(playerInventory, tileSoulForge));
|
||||
// this.tileSoulForge = tileSoulForge;
|
||||
// this.xSize = 176;
|
||||
// this.ySize = 205;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
// {
|
||||
// this.drawDefaultBackground();
|
||||
// super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
// this.renderHoveredToolTip(mouseX, mouseY);
|
||||
// }
|
||||
//
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack stack, int mouseX, int mouseY)
|
||||
{
|
||||
this.font.func_243248_b(stack, new TranslationTextComponent("tile.bloodmagic.soulforge.name"), 8, 5, 4210752);
|
||||
this.font.func_243248_b(stack, new TranslationTextComponent("container.inventory"), 8, 111, 4210752);
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
getMinecraft().getTextureManager().bindTexture(background);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.blit(stack, i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int l = this.getCookProgressScaled(90);
|
||||
this.blit(stack, i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l);
|
||||
}
|
||||
|
||||
//
|
||||
public int getCookProgressScaled(int scale)
|
||||
{
|
||||
double progress = ((TileSoulForge) tileSoulForge).getProgressForGui();
|
||||
// if (tileSoulForge != null)
|
||||
// {
|
||||
// System.out.println("Tile is NOT null");
|
||||
// }
|
||||
// double progress = ((float) this.container.data.get(0)) / ((float) this.container.data.get(1));
|
||||
// System.out.println(this.container.data.get(0));
|
||||
return (int) (progress * scale);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package wayoftime.bloodmagic.client.utils;
|
||||
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderState;
|
||||
import net.minecraft.client.renderer.RenderState.AlphaState;
|
||||
import net.minecraft.client.renderer.RenderState.CullState;
|
||||
import net.minecraft.client.renderer.RenderState.FogState;
|
||||
import net.minecraft.client.renderer.RenderState.LightmapState;
|
||||
import net.minecraft.client.renderer.RenderState.LineState;
|
||||
import net.minecraft.client.renderer.RenderState.ShadeModelState;
|
||||
import net.minecraft.client.renderer.RenderState.TextureState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
|
||||
public class BMRenderTypes
|
||||
{
|
||||
public static final RenderType SOLID_FULLBRIGHT;
|
||||
public static final RenderType TRANSLUCENT_LINES;
|
||||
public static final RenderType LINES;
|
||||
public static final RenderType TRANSLUCENT_TRIANGLES;
|
||||
public static final RenderType TRANSLUCENT_POSITION_COLOR;
|
||||
public static final RenderType TRANSLUCENT_NO_DEPTH;
|
||||
public static final RenderType CHUNK_MARKER;
|
||||
public static final RenderType VEIN_MARKER;
|
||||
public static final RenderType POSITION_COLOR_TEX_LIGHTMAP;
|
||||
public static final RenderType POSITION_COLOR_LIGHTMAP;
|
||||
public static final RenderType ITEM_DAMAGE_BAR;
|
||||
protected static final RenderState.ShadeModelState SHADE_ENABLED = new RenderState.ShadeModelState(true);
|
||||
protected static final RenderState.TextureState BLOCK_SHEET_MIPPED = new RenderState.TextureState(AtlasTexture.LOCATION_BLOCKS_TEXTURE, false, true);
|
||||
protected static final RenderState.LightmapState LIGHTMAP_DISABLED = new RenderState.LightmapState(false);
|
||||
protected static final RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = new RenderState.TransparencyState("translucent_transparency", () -> {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
}, RenderSystem::disableBlend);
|
||||
protected static final RenderState.TransparencyState NO_TRANSPARENCY = new RenderState.TransparencyState("no_transparency", RenderSystem::disableBlend, () -> {
|
||||
});
|
||||
protected static final RenderState.DepthTestState DEPTH_ALWAYS = new RenderState.DepthTestState("", GL11.GL_ALWAYS);
|
||||
|
||||
static
|
||||
{
|
||||
RenderType.State fullbrightSolidState = RenderType.State.getBuilder().shadeModel(SHADE_ENABLED).lightmap(LIGHTMAP_DISABLED).texture(BLOCK_SHEET_MIPPED).build(true);
|
||||
SOLID_FULLBRIGHT = RenderType.makeType(BloodMagic.MODID + ":block_fullbright", DefaultVertexFormats.BLOCK, GL11.GL_QUADS, 256, fullbrightSolidState);
|
||||
RenderType.State translucentNoDepthState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).line(new LineState(OptionalDouble.of(2))).texture(new TextureState()).depthTest(DEPTH_ALWAYS).build(false);
|
||||
RenderType.State translucentNoTextureState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).texture(new TextureState()).build(false);
|
||||
TRANSLUCENT_LINES = RenderType.makeType(BloodMagic.MODID + ":translucent_lines", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 256, translucentNoDepthState);
|
||||
LINES = RenderType.makeType(BloodMagic.MODID + ":lines", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 256, RenderType.State.getBuilder().build(false));
|
||||
TRANSLUCENT_TRIANGLES = RenderType.makeType(BloodMagic.MODID + ":translucent_triangle_fan", DefaultVertexFormats.POSITION_COLOR, GL11.GL_TRIANGLES, 256, translucentNoDepthState);
|
||||
TRANSLUCENT_POSITION_COLOR = RenderType.makeType(BloodMagic.MODID + ":translucent_pos_color", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256, translucentNoTextureState);
|
||||
TRANSLUCENT_NO_DEPTH = RenderType.makeType(BloodMagic.MODID + ":translucent_no_depth", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256, translucentNoDepthState);
|
||||
RenderType.State chunkMarkerState = RenderType.State.getBuilder().texture(new TextureState()).transparency(TRANSLUCENT_TRANSPARENCY).cull(new CullState(false)).shadeModel(new ShadeModelState(true)).line(new LineState(OptionalDouble.of(5))).build(false);
|
||||
CHUNK_MARKER = RenderType.makeType(BloodMagic.MODID + ":chunk_marker", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 256, chunkMarkerState);
|
||||
VEIN_MARKER = RenderType.makeType(BloodMagic.MODID + ":vein_marker", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINE_LOOP, 256, chunkMarkerState);
|
||||
POSITION_COLOR_TEX_LIGHTMAP = RenderType.makeType(BloodMagic.MODID + ":pos_color_tex_lightmap", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, GL11.GL_QUADS, 256, RenderType.State.getBuilder().texture(new TextureState(PlayerContainer.LOCATION_BLOCKS_TEXTURE, false, false)).lightmap(new LightmapState(true)).build(false));
|
||||
POSITION_COLOR_LIGHTMAP = RenderType.makeType(BloodMagic.MODID + ":pos_color_lightmap", DefaultVertexFormats.POSITION_COLOR_LIGHTMAP, GL11.GL_QUADS, 256, RenderType.State.getBuilder().texture(new TextureState()).lightmap(new LightmapState(true)).build(false));
|
||||
ITEM_DAMAGE_BAR = RenderType.makeType(BloodMagic.MODID + ":item_damage_bar", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256, RenderType.State.getBuilder().depthTest(DEPTH_ALWAYS).texture(new TextureState()).alpha(new AlphaState(0)).transparency(NO_TRANSPARENCY).build(false));
|
||||
}
|
||||
|
||||
public static RenderType getGui(ResourceLocation texture)
|
||||
{
|
||||
return RenderType.makeType("gui_" + texture, DefaultVertexFormats.POSITION_COLOR_TEX, GL11.GL_QUADS, 256, RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).alpha(new AlphaState(0.5F)).build(false));
|
||||
}
|
||||
|
||||
public static RenderType getLines(float lineWidth)
|
||||
{
|
||||
return RenderType.makeType("lines_color_pos_" + lineWidth, DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 256, RenderType.State.getBuilder().line(new LineState(OptionalDouble.of(lineWidth))).texture(new TextureState()).build(false));
|
||||
}
|
||||
|
||||
public static RenderType getPoints(float pointSize)
|
||||
{
|
||||
// Not really a fog state, but using it like this makes using RenderType.State
|
||||
// with custom states possible
|
||||
FogState setPointSize = new FogState(BloodMagic.MODID + ":pointsize_" + pointSize, () -> GL11.glPointSize(pointSize), () -> {
|
||||
GL11.glPointSize(1);
|
||||
});
|
||||
return RenderType.makeType("point_pos_color_" + pointSize, DefaultVertexFormats.POSITION_COLOR, GL11.GL_POINTS, 256, RenderType.State.getBuilder().fog(setPointSize).texture(new TextureState()).build(false));
|
||||
}
|
||||
|
||||
public static RenderType getPositionTex(ResourceLocation texture)
|
||||
{
|
||||
return RenderType.makeType(BloodMagic.MODID + ":pos_tex_" + texture, DefaultVertexFormats.POSITION_TEX, GL11.GL_QUADS, 256, RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).build(false));
|
||||
}
|
||||
|
||||
public static RenderType getFullbrightTranslucent(ResourceLocation resourceLocation)
|
||||
{
|
||||
RenderType.State glState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).texture(new TextureState(resourceLocation, false, false)).lightmap(new LightmapState(false)).build(false);
|
||||
return RenderType.makeType("BloodMagic:fullbright_translucent_" + resourceLocation, DefaultVertexFormats.BLOCK, GL11.GL_QUADS, 256, glState);
|
||||
}
|
||||
|
||||
public static IRenderTypeBuffer wrapWithStencil(IRenderTypeBuffer in, Consumer<IVertexBuilder> setupStencilArea, String name, int ref)
|
||||
{
|
||||
return wrapWithAdditional(in, "stencil_" + name + "_" + ref, () -> {
|
||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
||||
RenderSystem.colorMask(false, false, false, false);
|
||||
RenderSystem.depthMask(false);
|
||||
GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
|
||||
GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
|
||||
|
||||
GL11.glStencilMask(0xFF);
|
||||
RenderSystem.clear(GL11.GL_STENCIL_BUFFER_BIT, true);
|
||||
RenderSystem.disableTexture();
|
||||
Tessellator tes = Tessellator.getInstance();
|
||||
BufferBuilder bb = tes.getBuffer();
|
||||
bb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
|
||||
setupStencilArea.accept(bb);
|
||||
tes.draw();
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.depthMask(true);
|
||||
GL11.glStencilMask(0x00);
|
||||
GL11.glStencilFunc(GL11.GL_EQUAL, ref, 0xFF);
|
||||
}, () -> GL11.glDisable(GL11.GL_STENCIL_TEST));
|
||||
}
|
||||
|
||||
public static IRenderTypeBuffer disableLighting(IRenderTypeBuffer in)
|
||||
{
|
||||
return wrapWithAdditional(in, "no_lighting", RenderSystem::disableLighting, () -> {
|
||||
});
|
||||
}
|
||||
|
||||
public static IRenderTypeBuffer disableCull(IRenderTypeBuffer in)
|
||||
{
|
||||
return wrapWithAdditional(in, "no_cull", RenderSystem::disableCull, RenderSystem::enableCull);
|
||||
}
|
||||
|
||||
private static IRenderTypeBuffer wrapWithAdditional(IRenderTypeBuffer in, String name, Runnable setup, Runnable teardown)
|
||||
{
|
||||
return type -> {
|
||||
return in.getBuffer(new RenderType(BloodMagic.MODID + ":" + type + "_" + name, type.getVertexFormat(), type.getDrawMode(), type.getBufferSize(), type.isUseDelegate(), false, () -> {
|
||||
type.setupRenderState();
|
||||
setup.run();
|
||||
}, () -> {
|
||||
teardown.run();
|
||||
type.clearRenderState();
|
||||
})
|
||||
{
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue