pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,20 +18,20 @@
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -39,36 +39,37 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.tile.grindstone.TileCrank;
|
||||
|
||||
|
||||
/**
|
||||
* This FastTESR only handles the animated model of the turning crank. When the crank is at rest, it is rendered using a
|
||||
* normal model.
|
||||
* This FastTESR only handles the animated model of the turning crank. When the
|
||||
* crank is at rest, it is rendered using a normal model.
|
||||
*/
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class CrankTESR extends TileEntityRenderer<TileCrank>
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class CrankTESR extends TileEntityRenderer<TileCrank> {
|
||||
|
||||
public CrankTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
public CrankTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileCrank te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) {
|
||||
@Override
|
||||
public void render(TileCrank te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn,
|
||||
int combinedOverlayIn) {
|
||||
|
||||
// Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation
|
||||
ms.push();
|
||||
ms.translate( 0.5, 0.5, 0.5 );
|
||||
FacingToRotation.get( te.getForward(), te.getUp() ).push(ms);
|
||||
ms.rotate( new Quaternion(0, te.getVisibleRotation(), 0, true) );
|
||||
ms.translate( -0.5, -0.5, -0.5 );
|
||||
// Apply GL transformations relative to the center of the block: 1) TE rotation
|
||||
// and 2) crank rotation
|
||||
ms.push();
|
||||
ms.translate(0.5, 0.5, 0.5);
|
||||
FacingToRotation.get(te.getForward(), te.getUp()).push(ms);
|
||||
ms.rotate(new Quaternion(0, te.getVisibleRotation(), 0, true));
|
||||
ms.translate(-0.5, -0.5, -0.5);
|
||||
|
||||
BlockState blockState = te.getWorld().getBlockState( te.getPos() ); // FIXME: i think world might be null here
|
||||
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
IBakedModel model = dispatcher.getModelForState( blockState );
|
||||
IVertexBuilder buffer = buffers.getBuffer(Atlases.getTranslucentBlockType());
|
||||
dispatcher.getBlockModelRenderer().renderModelBrightnessColor(ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn, combinedOverlayIn);
|
||||
ms.pop();
|
||||
BlockState blockState = te.getWorld().getBlockState(te.getPos()); // FIXME: i think world might be null here
|
||||
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
IBakedModel model = dispatcher.getModelForState(blockState);
|
||||
IVertexBuilder buffer = buffers.getBuffer(Atlases.getTranslucentBlockType());
|
||||
dispatcher.getBlockModelRenderer().renderModelBrightnessColor(ms.getLast(), buffer, null, model, 1, 1, 1,
|
||||
combinedLightIn, combinedOverlayIn);
|
||||
ms.pop();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import java.util.EnumMap;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
@@ -13,7 +13,9 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
|
||||
/**
|
||||
* Renders the drive cell status indicators.
|
||||
@@ -34,52 +36,37 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer<TileDrive> {
|
||||
STATE_COLORS.put(DriveSlotState.FULL, new Vector3f(1, 0, 0));
|
||||
}
|
||||
|
||||
private static final float L = 14/16.f; // left (x-axis)
|
||||
private static final float R = 13/16.f; // right (x-axis)
|
||||
private static final float T = 14/16.f; // top (x-axis)
|
||||
private static final float B = 12.999f/16.f; // bottom (x-axis)
|
||||
private static final float FR = 0.4f/16.f; // front (z-axis)
|
||||
private static final float BA = 1/16.f; // back (z-axis)
|
||||
private static final float L = 14 / 16.f; // left (x-axis)
|
||||
private static final float R = 13 / 16.f; // right (x-axis)
|
||||
private static final float T = 14 / 16.f; // top (x-axis)
|
||||
private static final float B = 12.999f / 16.f; // bottom (x-axis)
|
||||
private static final float FR = 0.4f / 16.f; // front (z-axis)
|
||||
private static final float BA = 1 / 16.f; // back (z-axis)
|
||||
|
||||
// Vertex data for the LED cuboid (has no back)
|
||||
// Directions are when looking from the front onto the LED
|
||||
private static final float[] LED_QUADS = {
|
||||
// Front Face
|
||||
R, T, FR,
|
||||
L, T, FR,
|
||||
L, B, FR,
|
||||
R, B, FR,
|
||||
R, T, FR, L, T, FR, L, B, FR, R, B, FR,
|
||||
// Left Face
|
||||
L, T, FR,
|
||||
L, T, BA,
|
||||
L, B, BA,
|
||||
L, B, FR,
|
||||
L, T, FR, L, T, BA, L, B, BA, L, B, FR,
|
||||
// Right Face
|
||||
R, T, BA,
|
||||
R, T, FR,
|
||||
R, B, FR,
|
||||
R, B, BA,
|
||||
R, T, BA, R, T, FR, R, B, FR, R, B, BA,
|
||||
// Top Face
|
||||
R, T, BA,
|
||||
L, T, BA,
|
||||
L, T, FR,
|
||||
R, T, FR,
|
||||
R, T, BA, L, T, BA, L, T, FR, R, T, FR,
|
||||
// Bottom Face
|
||||
R, B, FR,
|
||||
L, B, FR,
|
||||
L, B, BA,
|
||||
R, B, BA,
|
||||
};
|
||||
R, B, FR, L, B, FR, L, B, BA, R, B, BA, };
|
||||
|
||||
private static final RenderType STATE = RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true, RenderType.State.getBuilder()
|
||||
.build(false));
|
||||
private static final RenderType STATE = RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7,
|
||||
32565, false, true, RenderType.State.getBuilder().build(false));
|
||||
|
||||
public DriveLedTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileDrive drive, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) {
|
||||
public void render(TileDrive drive, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers,
|
||||
int combinedLightIn, int combinedOverlayIn) {
|
||||
|
||||
if (drive.getCellCount() != 10) {
|
||||
throw new IllegalStateException("Expected drive to have 10 slots");
|
||||
@@ -90,10 +77,10 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer<TileDrive> {
|
||||
FacingToRotation.get(drive.getForward(), drive.getUp()).push(ms);
|
||||
ms.translate(-0.5, -0.5, -0.5);
|
||||
|
||||
RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228515_g_");
|
||||
RenderType rt =RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true, RenderType.State.getBuilder()
|
||||
.transparency(TRANSLUCENT_TRANSPARENCY)
|
||||
.build(false));
|
||||
RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper
|
||||
.getPrivateValue(RenderState.class, null, "field_228515_g_");
|
||||
RenderType rt = RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true,
|
||||
RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).build(false));
|
||||
IVertexBuilder buffer = buffers.getBuffer(STATE);
|
||||
|
||||
for (int row = 0; row < 5; row++) {
|
||||
@@ -106,7 +93,8 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer<TileDrive> {
|
||||
|
||||
ms.push();
|
||||
|
||||
// Position this drive model copy at the correct slot. The transform is based on the
|
||||
// Position this drive model copy at the correct slot. The transform is based on
|
||||
// the
|
||||
// cell-model being in slot 0,0 at the top left of the drive.
|
||||
float xOffset = -col * 7 / 16.0f;
|
||||
float yOffset = -row * 3 / 16.0f;
|
||||
@@ -114,9 +102,10 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer<TileDrive> {
|
||||
|
||||
for (int i = 0; i < LED_QUADS.length; i += 3) {
|
||||
float x = LED_QUADS[i];
|
||||
float y = LED_QUADS[i+1];
|
||||
float z = LED_QUADS[i+2];
|
||||
buffer.pos(ms.getLast().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f).endVertex();
|
||||
float y = LED_QUADS[i + 1];
|
||||
float z = LED_QUADS[i + 2];
|
||||
buffer.pos(ms.getLast().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
|
||||
.endVertex();
|
||||
}
|
||||
|
||||
ms.pop();
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
@@ -21,203 +18,209 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
|
||||
|
||||
/**
|
||||
* Renders the dynamic parts of an inscriber (the presses, the animation and the item being smashed)
|
||||
* Renders the dynamic parts of an inscriber (the presses, the animation and the
|
||||
* item being smashed)
|
||||
*/
|
||||
public final class InscriberTESR extends TileEntityRenderer<TileInscriber>
|
||||
{
|
||||
public final class InscriberTESR extends TileEntityRenderer<TileInscriber> {
|
||||
|
||||
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
|
||||
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
|
||||
|
||||
private static final Material TEXTURE_INSIDE = new Material(PlayerContainer.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/inscriber_inside" ));
|
||||
private static final Material TEXTURE_INSIDE = new Material(PlayerContainer.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/inscriber_inside"));
|
||||
|
||||
public InscriberTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
public InscriberTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileInscriber tile, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) {
|
||||
@Override
|
||||
public void render(TileInscriber tile, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers,
|
||||
int combinedLight, int combinedOverlay) {
|
||||
|
||||
// render inscriber
|
||||
// render inscriber
|
||||
|
||||
ms.push();
|
||||
ms.translate( 0.5F, 0.5F, 0.5F );
|
||||
FacingToRotation.get( tile.getForward(), tile.getUp() ).push(ms);
|
||||
ms.translate( -0.5F, -0.5F, -0.5F );
|
||||
ms.push();
|
||||
ms.translate(0.5F, 0.5F, 0.5F);
|
||||
FacingToRotation.get(tile.getForward(), tile.getUp()).push(ms);
|
||||
ms.translate(-0.5F, -0.5F, -0.5F);
|
||||
|
||||
// render sides of stamps
|
||||
// render sides of stamps
|
||||
|
||||
long absoluteProgress = 0;
|
||||
long absoluteProgress = 0;
|
||||
|
||||
if( tile.isSmash() )
|
||||
{
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
absoluteProgress = currentTime - tile.getClientStart();
|
||||
if( absoluteProgress > 800 )
|
||||
{
|
||||
tile.setSmash( false );
|
||||
}
|
||||
}
|
||||
if (tile.isSmash()) {
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
absoluteProgress = currentTime - tile.getClientStart();
|
||||
if (absoluteProgress > 800) {
|
||||
tile.setSmash(false);
|
||||
}
|
||||
}
|
||||
|
||||
final float relativeProgress = absoluteProgress % 800 / 400.0f;
|
||||
float progress = relativeProgress;
|
||||
final float relativeProgress = absoluteProgress % 800 / 400.0f;
|
||||
float progress = relativeProgress;
|
||||
|
||||
if( progress > 1.0f )
|
||||
{
|
||||
progress = 1.0f - ( easeDecompressMotion(progress - 1.0f) );
|
||||
} else {
|
||||
progress = easeCompressMotion(progress);
|
||||
}
|
||||
if (progress > 1.0f) {
|
||||
progress = 1.0f - (easeDecompressMotion(progress - 1.0f));
|
||||
} else {
|
||||
progress = easeCompressMotion(progress);
|
||||
}
|
||||
|
||||
float press = 0.2f;
|
||||
press -= progress / 5.0f;
|
||||
float press = 0.2f;
|
||||
press -= progress / 5.0f;
|
||||
|
||||
float middle = 0.5f;
|
||||
middle += 0.02f;
|
||||
final float TwoPx = 2.0f / 16.0f;
|
||||
final float base = 0.4f;
|
||||
float middle = 0.5f;
|
||||
middle += 0.02f;
|
||||
final float TwoPx = 2.0f / 16.0f;
|
||||
final float base = 0.4f;
|
||||
|
||||
final TextureAtlasSprite tas = TEXTURE_INSIDE.getSprite();
|
||||
final TextureAtlasSprite tas = TEXTURE_INSIDE.getSprite();
|
||||
|
||||
IVertexBuilder buffer = buffers.getBuffer(RenderType.getSolid());
|
||||
IVertexBuilder buffer = buffers.getBuffer(RenderType.getSolid());
|
||||
|
||||
// Bottom of Top Stamp
|
||||
addVertex( buffer, ms, tas, TwoPx, middle + press, TwoPx, 2, 13 , combinedOverlay, combinedLight, Direction.DOWN);
|
||||
addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + press, TwoPx, 14, 13 , combinedOverlay, combinedLight, Direction.DOWN);
|
||||
addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + press, 1.0f - TwoPx, 14, 2 , combinedOverlay, combinedLight, Direction.DOWN);
|
||||
addVertex( buffer, ms, tas, TwoPx, middle + press, 1.0f - TwoPx, 2, 2 , combinedOverlay, combinedLight, Direction.DOWN);
|
||||
// Bottom of Top Stamp
|
||||
addVertex(buffer, ms, tas, TwoPx, middle + press, TwoPx, 2, 13, combinedOverlay, combinedLight, Direction.DOWN);
|
||||
addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + press, TwoPx, 14, 13, combinedOverlay, combinedLight,
|
||||
Direction.DOWN);
|
||||
addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + press, 1.0f - TwoPx, 14, 2, combinedOverlay, combinedLight,
|
||||
Direction.DOWN);
|
||||
addVertex(buffer, ms, tas, TwoPx, middle + press, 1.0f - TwoPx, 2, 2, combinedOverlay, combinedLight,
|
||||
Direction.DOWN);
|
||||
|
||||
// Front of Top Stamp
|
||||
addVertex( buffer, ms, tas, TwoPx, middle + base, TwoPx, 2, 3 - 16 * ( press - base ) , combinedOverlay, combinedLight, Direction.NORTH);
|
||||
addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + base, TwoPx, 14, 3 - 16 * ( press - base ) , combinedOverlay, combinedLight, Direction.NORTH);
|
||||
addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + press, TwoPx, 14, 3 , combinedOverlay, combinedLight, Direction.NORTH);
|
||||
addVertex( buffer, ms, tas, TwoPx, middle + press, TwoPx, 2, 3 , combinedOverlay, combinedLight, Direction.NORTH);
|
||||
// Front of Top Stamp
|
||||
addVertex(buffer, ms, tas, TwoPx, middle + base, TwoPx, 2, 3 - 16 * (press - base), combinedOverlay,
|
||||
combinedLight, Direction.NORTH);
|
||||
addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + base, TwoPx, 14, 3 - 16 * (press - base), combinedOverlay,
|
||||
combinedLight, Direction.NORTH);
|
||||
addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + press, TwoPx, 14, 3, combinedOverlay, combinedLight,
|
||||
Direction.NORTH);
|
||||
addVertex(buffer, ms, tas, TwoPx, middle + press, TwoPx, 2, 3, combinedOverlay, combinedLight, Direction.NORTH);
|
||||
|
||||
// Top of Bottom Stamp
|
||||
middle -= 2.0f * 0.02f;
|
||||
addVertex( buffer, ms, tas, 1.0f - TwoPx, middle - press, TwoPx, 2, 13 , combinedOverlay, combinedLight, Direction.UP);
|
||||
addVertex( buffer, ms, tas, TwoPx, middle - press, TwoPx, 14, 13 , combinedOverlay, combinedLight, Direction.UP);
|
||||
addVertex( buffer, ms, tas, TwoPx, middle - press, 1.0f - TwoPx, 14, 2 , combinedOverlay, combinedLight, Direction.UP);
|
||||
addVertex( buffer, ms, tas, 1.0f - TwoPx, middle - press, 1.0f - TwoPx, 2, 2 , combinedOverlay, combinedLight, Direction.UP);
|
||||
// Top of Bottom Stamp
|
||||
middle -= 2.0f * 0.02f;
|
||||
addVertex(buffer, ms, tas, 1.0f - TwoPx, middle - press, TwoPx, 2, 13, combinedOverlay, combinedLight,
|
||||
Direction.UP);
|
||||
addVertex(buffer, ms, tas, TwoPx, middle - press, TwoPx, 14, 13, combinedOverlay, combinedLight, Direction.UP);
|
||||
addVertex(buffer, ms, tas, TwoPx, middle - press, 1.0f - TwoPx, 14, 2, combinedOverlay, combinedLight,
|
||||
Direction.UP);
|
||||
addVertex(buffer, ms, tas, 1.0f - TwoPx, middle - press, 1.0f - TwoPx, 2, 2, combinedOverlay, combinedLight,
|
||||
Direction.UP);
|
||||
|
||||
// Front of Bottom Stamp
|
||||
addVertex( buffer, ms, tas, 1.0f - TwoPx, middle + -base, TwoPx, 2, 3 - 16 * ( press - base ) , combinedOverlay, combinedLight, Direction.NORTH);
|
||||
addVertex( buffer, ms, tas, TwoPx, middle - base, TwoPx, 14, 3 - 16 * ( press - base ) , combinedOverlay, combinedLight, Direction.NORTH);
|
||||
addVertex( buffer, ms, tas, TwoPx, middle - press, TwoPx, 14, 3 , combinedOverlay, combinedLight, Direction.NORTH);
|
||||
addVertex( buffer, ms, tas, 1.0f - TwoPx, middle - press, TwoPx, 2, 3 , combinedOverlay, combinedLight, Direction.NORTH);
|
||||
// Front of Bottom Stamp
|
||||
addVertex(buffer, ms, tas, 1.0f - TwoPx, middle + -base, TwoPx, 2, 3 - 16 * (press - base), combinedOverlay,
|
||||
combinedLight, Direction.NORTH);
|
||||
addVertex(buffer, ms, tas, TwoPx, middle - base, TwoPx, 14, 3 - 16 * (press - base), combinedOverlay,
|
||||
combinedLight, Direction.NORTH);
|
||||
addVertex(buffer, ms, tas, TwoPx, middle - press, TwoPx, 14, 3, combinedOverlay, combinedLight,
|
||||
Direction.NORTH);
|
||||
addVertex(buffer, ms, tas, 1.0f - TwoPx, middle - press, TwoPx, 2, 3, combinedOverlay, combinedLight,
|
||||
Direction.NORTH);
|
||||
|
||||
// render items.
|
||||
// render items.
|
||||
|
||||
IItemHandler tileInv = tile.getInternalInventory();
|
||||
IItemHandler tileInv = tile.getInternalInventory();
|
||||
|
||||
int items = 0;
|
||||
if( !tileInv.getStackInSlot( 0 ).isEmpty() )
|
||||
{
|
||||
items++;
|
||||
}
|
||||
if( !tileInv.getStackInSlot( 1 ).isEmpty() )
|
||||
{
|
||||
items++;
|
||||
}
|
||||
if( !tileInv.getStackInSlot( 2 ).isEmpty() )
|
||||
{
|
||||
items++;
|
||||
}
|
||||
int items = 0;
|
||||
if (!tileInv.getStackInSlot(0).isEmpty()) {
|
||||
items++;
|
||||
}
|
||||
if (!tileInv.getStackInSlot(1).isEmpty()) {
|
||||
items++;
|
||||
}
|
||||
if (!tileInv.getStackInSlot(2).isEmpty()) {
|
||||
items++;
|
||||
}
|
||||
|
||||
boolean renderPresses;
|
||||
if( relativeProgress > 1.0f || items == 0 )
|
||||
{
|
||||
// When crafting completes, dont render the presses (they mave have been consumed, see below)
|
||||
renderPresses = false;
|
||||
boolean renderPresses;
|
||||
if (relativeProgress > 1.0f || items == 0) {
|
||||
// When crafting completes, dont render the presses (they mave have been
|
||||
// consumed, see below)
|
||||
renderPresses = false;
|
||||
|
||||
ItemStack is = tileInv.getStackInSlot( 3 );
|
||||
ItemStack is = tileInv.getStackInSlot(3);
|
||||
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
final InscriberRecipe ir = tile.getTask();
|
||||
if( ir != null )
|
||||
{
|
||||
// The "PRESS" type will consume the presses so they should not render after completing
|
||||
// the press animation
|
||||
renderPresses = ir.getProcessType() == InscriberProcessType.INSCRIBE;
|
||||
is = ir.getOutput().copy();
|
||||
}
|
||||
}
|
||||
this.renderItem( ms, is, 0.0f, buffers, combinedLight, combinedOverlay );
|
||||
}
|
||||
else
|
||||
{
|
||||
renderPresses = true;
|
||||
this.renderItem( ms, tileInv.getStackInSlot( 2 ), 0.0f, buffers, combinedLight, combinedOverlay );
|
||||
}
|
||||
if (is.isEmpty()) {
|
||||
final InscriberRecipe ir = tile.getTask();
|
||||
if (ir != null) {
|
||||
// The "PRESS" type will consume the presses so they should not render after
|
||||
// completing
|
||||
// the press animation
|
||||
renderPresses = ir.getProcessType() == InscriberProcessType.INSCRIBE;
|
||||
is = ir.getOutput().copy();
|
||||
}
|
||||
}
|
||||
this.renderItem(ms, is, 0.0f, buffers, combinedLight, combinedOverlay);
|
||||
} else {
|
||||
renderPresses = true;
|
||||
this.renderItem(ms, tileInv.getStackInSlot(2), 0.0f, buffers, combinedLight, combinedOverlay);
|
||||
}
|
||||
|
||||
if (renderPresses) {
|
||||
this.renderItem( ms, tileInv.getStackInSlot( 0 ), press, buffers, combinedLight, combinedOverlay );
|
||||
this.renderItem( ms, tileInv.getStackInSlot( 1 ), -press, buffers, combinedLight, combinedOverlay );
|
||||
}
|
||||
if (renderPresses) {
|
||||
this.renderItem(ms, tileInv.getStackInSlot(0), press, buffers, combinedLight, combinedOverlay);
|
||||
this.renderItem(ms, tileInv.getStackInSlot(1), -press, buffers, combinedLight, combinedOverlay);
|
||||
}
|
||||
|
||||
ms.pop();
|
||||
}
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
private static void addVertex(IVertexBuilder vb, MatrixStack ms, TextureAtlasSprite sprite, float x, float y, float z, double texU, double texV, int overlayUV, int lightmapUV, Direction front) {
|
||||
vb.pos(ms.getLast().getMatrix(), x, y, z);
|
||||
vb.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
vb.tex(sprite.getInterpolatedU(texU), sprite.getInterpolatedV(texV));
|
||||
vb.overlay(overlayUV);
|
||||
vb.lightmap(lightmapUV);
|
||||
vb.normal(ms.getLast().getNormal(), front.getXOffset(), front.getYOffset(), front.getZOffset());
|
||||
vb.endVertex();
|
||||
}
|
||||
private static void addVertex(IVertexBuilder vb, MatrixStack ms, TextureAtlasSprite sprite, float x, float y,
|
||||
float z, double texU, double texV, int overlayUV, int lightmapUV, Direction front) {
|
||||
vb.pos(ms.getLast().getMatrix(), x, y, z);
|
||||
vb.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
vb.tex(sprite.getInterpolatedU(texU), sprite.getInterpolatedV(texV));
|
||||
vb.overlay(overlayUV);
|
||||
vb.lightmap(lightmapUV);
|
||||
vb.normal(ms.getLast().getNormal(), front.getXOffset(), front.getYOffset(), front.getZOffset());
|
||||
vb.endVertex();
|
||||
}
|
||||
|
||||
private static final ResourceLocation TAG_STORAGE_BLOCKS = new ResourceLocation("forge:storage_blocks");
|
||||
private static final ResourceLocation TAG_STORAGE_BLOCKS = new ResourceLocation("forge:storage_blocks");
|
||||
|
||||
private void renderItem( MatrixStack ms, final ItemStack stack, final float o, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay )
|
||||
{
|
||||
if( !stack.isEmpty() )
|
||||
{
|
||||
ms.push();
|
||||
// move to center
|
||||
ms.translate( 0.5f, 0.5f + o, 0.5f );
|
||||
ms.rotate( new Quaternion(90, 0, 0, true) );
|
||||
// set scale
|
||||
ms.scale( ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE );
|
||||
private void renderItem(MatrixStack ms, final ItemStack stack, final float o, IRenderTypeBuffer buffers,
|
||||
int combinedLight, int combinedOverlay) {
|
||||
if (!stack.isEmpty()) {
|
||||
ms.push();
|
||||
// move to center
|
||||
ms.translate(0.5f, 0.5f + o, 0.5f);
|
||||
ms.rotate(new Quaternion(90, 0, 0, true));
|
||||
// set scale
|
||||
ms.scale(ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE);
|
||||
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||
|
||||
// heuristic to scale items down much further than blocks
|
||||
if( !stack.getItem().getTags().contains(TAG_STORAGE_BLOCKS) )
|
||||
{
|
||||
ms.scale( 0.5f, 0.5f, 0.5f );
|
||||
}
|
||||
// heuristic to scale items down much further than blocks
|
||||
if (!stack.getItem().getTags().contains(TAG_STORAGE_BLOCKS)) {
|
||||
ms.scale(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, ms, buffers);
|
||||
ms.pop();
|
||||
}
|
||||
}
|
||||
itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, ms,
|
||||
buffers);
|
||||
ms.pop();
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerTexture( TextureStitchEvent.Pre evt )
|
||||
{
|
||||
if (evt.getMap().getTextureLocation().equals(TEXTURE_INSIDE.getAtlasLocation())) {
|
||||
evt.addSprite(TEXTURE_INSIDE.getTextureLocation());
|
||||
}
|
||||
}
|
||||
public static void registerTexture(TextureStitchEvent.Pre evt) {
|
||||
if (evt.getMap().getTextureLocation().equals(TEXTURE_INSIDE.getAtlasLocation())) {
|
||||
evt.addSprite(TEXTURE_INSIDE.getTextureLocation());
|
||||
}
|
||||
}
|
||||
|
||||
// See https://easings.net/#easeOutBack
|
||||
private static float easeCompressMotion(float x) {
|
||||
float c1 = 1.70158f;
|
||||
float c3 = c1 + 1;
|
||||
// See https://easings.net/#easeOutBack
|
||||
private static float easeCompressMotion(float x) {
|
||||
float c1 = 1.70158f;
|
||||
float c3 = c1 + 1;
|
||||
|
||||
return (float) (1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2));
|
||||
}
|
||||
return (float) (1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2));
|
||||
}
|
||||
|
||||
// See https://easings.net/#easeInQuint
|
||||
private static float easeDecompressMotion(float x) {
|
||||
return x * x * x * x * x;
|
||||
}
|
||||
// See https://easings.net/#easeInQuint
|
||||
private static float easeDecompressMotion(float x) {
|
||||
return x * x * x * x * x;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
@@ -32,34 +33,28 @@ import appeng.client.render.FacingToRotation;
|
||||
import appeng.client.render.renderable.Renderable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
import java.util.List;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ModularTESR<T extends AEBaseTile> extends TileEntityRenderer<T> {
|
||||
|
||||
private final List<Renderable<? super T>> renderables;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class ModularTESR<T extends AEBaseTile> extends TileEntityRenderer<T>
|
||||
{
|
||||
@SafeVarargs
|
||||
public ModularTESR(TileEntityRendererDispatcher rendererDispatcherIn, Renderable<? super T>... renderables) {
|
||||
super(rendererDispatcherIn);
|
||||
this.renderables = ImmutableList.copyOf(renderables);
|
||||
}
|
||||
|
||||
private final List<Renderable<? super T>> renderables;
|
||||
|
||||
@SafeVarargs
|
||||
public ModularTESR( TileEntityRendererDispatcher rendererDispatcherIn, Renderable<? super T>... renderables )
|
||||
{
|
||||
super( rendererDispatcherIn );
|
||||
this.renderables = ImmutableList.copyOf(renderables);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render( T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay )
|
||||
{
|
||||
ms.push();
|
||||
ms.translate( 0.5, 0.5, 0.5 );
|
||||
FacingToRotation.get( te.getForward(), te.getUp() ).push(ms);
|
||||
ms.translate( -0.5, -0.5, -0.5 );
|
||||
for( Renderable<? super T> renderable : this.renderables )
|
||||
{
|
||||
renderable.renderTileEntityAt( te, partialTicks, ms, buffers, combinedLight, combinedOverlay);
|
||||
}
|
||||
ms.pop();
|
||||
}
|
||||
@Override
|
||||
public void render(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight,
|
||||
int combinedOverlay) {
|
||||
ms.push();
|
||||
ms.translate(0.5, 0.5, 0.5);
|
||||
FacingToRotation.get(te.getForward(), te.getUp()).push(ms);
|
||||
ms.translate(-0.5, -0.5, -0.5);
|
||||
for (Renderable<? super T> renderable : this.renderables) {
|
||||
renderable.renderTileEntityAt(te, partialTicks, ms, buffers, combinedLight, combinedOverlay);
|
||||
}
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,13 +18,9 @@
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
|
||||
import appeng.block.storage.BlockSkyChest;
|
||||
import appeng.block.storage.BlockSkyChest.SkyChestType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
@@ -39,12 +35,19 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
|
||||
import appeng.block.storage.BlockSkyChest;
|
||||
import appeng.block.storage.BlockSkyChest.SkyChestType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
// This is mostly a copy&paste job of the vanilla chest TESR
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class SkyChestTESR extends TileEntityRenderer<TileSkyChest> {
|
||||
|
||||
public static final Material TEXTURE_STONE = new Material(Atlases.CHEST_ATLAS, new ResourceLocation(AppEng.MOD_ID, "models/skychest"));
|
||||
public static final Material TEXTURE_BLOCK = new Material(Atlases.CHEST_ATLAS, new ResourceLocation(AppEng.MOD_ID, "models/skyblockchest"));
|
||||
public static final Material TEXTURE_STONE = new Material(Atlases.CHEST_ATLAS,
|
||||
new ResourceLocation(AppEng.MOD_ID, "models/skychest"));
|
||||
public static final Material TEXTURE_BLOCK = new Material(Atlases.CHEST_ATLAS,
|
||||
new ResourceLocation(AppEng.MOD_ID, "models/skyblockchest"));
|
||||
|
||||
private final ModelRenderer singleLid;
|
||||
private final ModelRenderer singleBottom;
|
||||
@@ -64,7 +67,8 @@ public class SkyChestTESR extends TileEntityRenderer<TileSkyChest> {
|
||||
this.singleLatch.rotationPointY = 8.0F;
|
||||
}
|
||||
|
||||
public void render(TileSkyChest tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
public void render(TileSkyChest tileEntityIn, float partialTicks, MatrixStack matrixStackIn,
|
||||
IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
matrixStackIn.push();
|
||||
float f = tileEntityIn.getForward().getHorizontalAngle();
|
||||
matrixStackIn.translate(0.5D, 0.5D, 0.5D);
|
||||
@@ -76,12 +80,15 @@ public class SkyChestTESR extends TileEntityRenderer<TileSkyChest> {
|
||||
f1 = 1.0F - f1 * f1 * f1;
|
||||
Material material = this.getMaterial(tileEntityIn);
|
||||
IVertexBuilder ivertexbuilder = material.getBuffer(bufferIn, RenderType::getEntityCutout);
|
||||
this.renderModels(matrixStackIn, ivertexbuilder, this.singleLid, this.singleLatch, this.singleBottom, f1, combinedLightIn, combinedOverlayIn);
|
||||
this.renderModels(matrixStackIn, ivertexbuilder, this.singleLid, this.singleLatch, this.singleBottom, f1,
|
||||
combinedLightIn, combinedOverlayIn);
|
||||
|
||||
matrixStackIn.pop();
|
||||
}
|
||||
|
||||
private void renderModels(MatrixStack matrixStackIn, IVertexBuilder bufferIn, ModelRenderer chestLid, ModelRenderer chestLatch, ModelRenderer chestBottom, float lidAngle, int combinedLightIn, int combinedOverlayIn) {
|
||||
private void renderModels(MatrixStack matrixStackIn, IVertexBuilder bufferIn, ModelRenderer chestLid,
|
||||
ModelRenderer chestLatch, ModelRenderer chestBottom, float lidAngle, int combinedLightIn,
|
||||
int combinedOverlayIn) {
|
||||
chestLid.rotateAngleX = -(lidAngle * 1.5707964F);
|
||||
chestLatch.rotateAngleX = chestLid.rotateAngleX;
|
||||
chestLid.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
|
||||
|
||||
@@ -18,11 +18,9 @@
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.client.render.model.SkyCompassModel;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
@@ -35,91 +33,86 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.block.misc.BlockSkyCompass;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.client.render.model.SkyCompassBakedModel;
|
||||
import appeng.client.render.model.SkyCompassModel;
|
||||
import appeng.tile.misc.TileSkyCompass;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class SkyCompassTESR extends TileEntityRenderer<TileSkyCompass> {
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class SkyCompassTESR extends TileEntityRenderer<TileSkyCompass>
|
||||
{
|
||||
private static BlockRendererDispatcher blockRenderer;
|
||||
|
||||
private static BlockRendererDispatcher blockRenderer;
|
||||
public SkyCompassTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
public SkyCompassTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
@Override
|
||||
public void render(TileSkyCompass te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers,
|
||||
int combinedLightIn, int combinedOverlayIn) {
|
||||
|
||||
@Override
|
||||
public void render(TileSkyCompass te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn) {
|
||||
if (blockRenderer == null) {
|
||||
blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
}
|
||||
|
||||
if( blockRenderer == null )
|
||||
{
|
||||
blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
}
|
||||
IVertexBuilder buffer = buffers.getBuffer(Atlases.getTranslucentBlockType());
|
||||
|
||||
IVertexBuilder buffer = buffers.getBuffer(Atlases.getTranslucentBlockType());
|
||||
BlockState blockState = te.getBlockState();
|
||||
IBakedModel model = blockRenderer.getBlockModelShapes().getModel(blockState);
|
||||
|
||||
BlockState blockState = te.getBlockState();
|
||||
IBakedModel model = blockRenderer.getBlockModelShapes().getModel( blockState );
|
||||
// FIXME: Rotation was previously handled by an auto rotating model I think, but
|
||||
// FIXME: Should be handled using matrices instead
|
||||
Direction forward = te.getForward();
|
||||
Direction up = te.getUp();
|
||||
// This ensures the needle isn't flipped by the model rotator. Since the model
|
||||
// is symmetrical, this should
|
||||
// not affect the appearance
|
||||
if (forward == Direction.UP || forward == Direction.DOWN) {
|
||||
up = Direction.NORTH;
|
||||
}
|
||||
// Flip forward/up for rendering, the base model is facing up without any
|
||||
// rotation
|
||||
ms.push();
|
||||
ms.translate(0.5D, 0.5D, 0.5D);
|
||||
FacingToRotation.get(up, forward).push(ms);
|
||||
ms.translate(-0.5D, -0.5D, -0.5D);
|
||||
|
||||
// FIXME: Rotation was previously handled by an auto rotating model I think, but
|
||||
// FIXME: Should be handled using matrices instead
|
||||
Direction forward = te.getForward();
|
||||
Direction up = te.getUp();
|
||||
// This ensures the needle isn't flipped by the model rotator. Since the model is symmetrical, this should
|
||||
// not affect the appearance
|
||||
if( forward == Direction.UP || forward == Direction.DOWN )
|
||||
{
|
||||
up = Direction.NORTH;
|
||||
}
|
||||
// Flip forward/up for rendering, the base model is facing up without any rotation
|
||||
ms.push();
|
||||
ms.translate(0.5D, 0.5D, 0.5D);
|
||||
FacingToRotation.get(up, forward).push(ms);
|
||||
ms.translate(-0.5D, -0.5D, -0.5D);
|
||||
ModelDataMap modelData = new ModelDataMap.Builder().withInitial(SkyCompassBakedModel.ROTATION, getRotation(te))
|
||||
.build();
|
||||
|
||||
ModelDataMap modelData = new ModelDataMap.Builder()
|
||||
.withInitial(SkyCompassBakedModel.ROTATION, getRotation(te))
|
||||
.build();
|
||||
blockRenderer.getBlockModelRenderer().renderModel(ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn,
|
||||
combinedOverlayIn, modelData);
|
||||
ms.pop();
|
||||
|
||||
blockRenderer.getBlockModelRenderer().renderModel( ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn, combinedOverlayIn, modelData );
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
}
|
||||
private static float getRotation(TileSkyCompass skyCompass) {
|
||||
float rotation;
|
||||
|
||||
private static float getRotation( TileSkyCompass skyCompass )
|
||||
{
|
||||
float rotation;
|
||||
if (skyCompass.getForward() == Direction.UP || skyCompass.getForward() == Direction.DOWN) {
|
||||
rotation = SkyCompassBakedModel.getAnimatedRotation(skyCompass.getPos(), false);
|
||||
} else {
|
||||
rotation = SkyCompassBakedModel.getAnimatedRotation(null, false);
|
||||
}
|
||||
|
||||
if( skyCompass.getForward() == Direction.UP || skyCompass.getForward() == Direction.DOWN )
|
||||
{
|
||||
rotation = SkyCompassBakedModel.getAnimatedRotation( skyCompass.getPos(), false );
|
||||
}
|
||||
else
|
||||
{
|
||||
rotation = SkyCompassBakedModel.getAnimatedRotation( null, false );
|
||||
}
|
||||
if (skyCompass.getForward() == Direction.DOWN) {
|
||||
rotation = flipidiy(rotation);
|
||||
}
|
||||
|
||||
if( skyCompass.getForward() == Direction.DOWN )
|
||||
{
|
||||
rotation = flipidiy( rotation );
|
||||
}
|
||||
return rotation;
|
||||
}
|
||||
|
||||
return rotation;
|
||||
}
|
||||
|
||||
private static float flipidiy( float rad )
|
||||
{
|
||||
float x = (float) Math.cos( rad );
|
||||
float y = (float) Math.sin( rad );
|
||||
return (float) Math.atan2( -y, x );
|
||||
}
|
||||
private static float flipidiy(float rad) {
|
||||
float x = (float) Math.cos(rad);
|
||||
float y = (float) Math.sin(rad);
|
||||
return (float) Math.atan2(-y, x);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user