mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 06:24:12 +01:00
Port new code to 1.15
This commit is contained in:
parent
a1605af46a
commit
ed19a65b9f
@ -2,6 +2,7 @@ package com.simibubi.create.foundation.block.connected;
|
|||||||
|
|
||||||
import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour.CTContext;
|
import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour.CTContext;
|
||||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||||
|
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
||||||
|
|
||||||
public abstract class CTSpriteShiftEntry extends SpriteShiftEntry {
|
public abstract class CTSpriteShiftEntry extends SpriteShiftEntry {
|
||||||
|
|
||||||
@ -14,13 +15,13 @@ public abstract class CTSpriteShiftEntry extends SpriteShiftEntry {
|
|||||||
public float getTargetU(float localU, int index) {
|
public float getTargetU(float localU, int index) {
|
||||||
float uOffset = (index % textureSheetSize);
|
float uOffset = (index % textureSheetSize);
|
||||||
return getTarget().getInterpolatedU(
|
return getTarget().getInterpolatedU(
|
||||||
(getOriginal().getUnInterpolatedU(localU) + (uOffset * 16)) / ((float) textureSheetSize));
|
(SuperByteBuffer.getUnInterpolatedU(getOriginal(), localU) + (uOffset * 16)) / ((float) textureSheetSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getTargetV(float localV, int index) {
|
public float getTargetV(float localV, int index) {
|
||||||
float vOffset = (index / textureSheetSize);
|
float vOffset = (index / textureSheetSize);
|
||||||
return getTarget().getInterpolatedV(
|
return getTarget().getInterpolatedV(
|
||||||
(getOriginal().getUnInterpolatedV(localV) + (vOffset * 16)) / ((float) textureSheetSize));
|
(SuperByteBuffer.getUnInterpolatedV(getOriginal(), localV) + (vOffset * 16)) / ((float) textureSheetSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int getTextureIndex(CTContext context);
|
public abstract int getTextureIndex(CTContext context);
|
||||||
|
@ -10,6 +10,7 @@ import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
|||||||
|
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.BufferBuilder.DrawState;
|
import net.minecraft.client.renderer.BufferBuilder.DrawState;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.client.renderer.GLAllocation;
|
import net.minecraft.client.renderer.GLAllocation;
|
||||||
import net.minecraft.client.renderer.Matrix4f;
|
import net.minecraft.client.renderer.Matrix4f;
|
||||||
import net.minecraft.client.renderer.Vector4f;
|
import net.minecraft.client.renderer.Vector4f;
|
||||||
@ -88,9 +89,9 @@ public class SuperByteBuffer {
|
|||||||
float u = getU(original, vertex);
|
float u = getU(original, vertex);
|
||||||
float v = getV(original, vertex);
|
float v = getV(original, vertex);
|
||||||
float targetU = spriteShift.getTarget()
|
float targetU = spriteShift.getTarget()
|
||||||
.getInterpolatedU((spriteShift.getOriginal().getUnInterpolatedU(u) / sheetSize) + uTarget * 16);
|
.getInterpolatedU((getUnInterpolatedU(spriteShift.getOriginal(), u) / sheetSize) + uTarget * 16);
|
||||||
float targetV = spriteShift.getTarget()
|
float targetV = spriteShift.getTarget()
|
||||||
.getInterpolatedV((spriteShift.getOriginal().getUnInterpolatedV(v) / sheetSize) + vTarget * 16);
|
.getInterpolatedV((getUnInterpolatedV(spriteShift.getOriginal(), v) / sheetSize) + vTarget * 16);
|
||||||
putUV(mutable, vertex, targetU, targetV);
|
putUV(mutable, vertex, targetU, targetV);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +115,16 @@ public class SuperByteBuffer {
|
|||||||
return mutable;
|
return mutable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float getUnInterpolatedU(TextureAtlasSprite sprite, float u) {
|
||||||
|
float f = sprite.getMaxU() - sprite.getMinU();
|
||||||
|
return (u - sprite.getMinU()) / f * 16.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getUnInterpolatedV(TextureAtlasSprite sprite, float v) {
|
||||||
|
float f = sprite.getMaxV() - sprite.getMinV();
|
||||||
|
return (v - sprite.getMinV()) / f * 16.0F;
|
||||||
|
}
|
||||||
|
|
||||||
public void renderInto(MatrixStack input, IVertexBuilder buffer) {
|
public void renderInto(MatrixStack input, IVertexBuilder buffer) {
|
||||||
if (original.limit() == 0)
|
if (original.limit() == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.simibubi.create.modules.contraptions;
|
package com.simibubi.create.modules.contraptions;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.utility.DirectionHelper;
|
||||||
import com.simibubi.create.foundation.utility.VoxelShaper;
|
import com.simibubi.create.foundation.utility.VoxelShaper;
|
||||||
import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock;
|
import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock;
|
||||||
import com.simibubi.create.modules.contraptions.base.DirectionalKineticBlock;
|
import com.simibubi.create.modules.contraptions.base.DirectionalKineticBlock;
|
||||||
@ -43,13 +44,13 @@ public interface IWrenchable {
|
|||||||
|
|
||||||
if (targetedFace.getAxis() == Direction.Axis.Y) {
|
if (targetedFace.getAxis() == Direction.Axis.Y) {
|
||||||
if (originalState.has(HorizontalAxisKineticBlock.HORIZONTAL_AXIS))
|
if (originalState.has(HorizontalAxisKineticBlock.HORIZONTAL_AXIS))
|
||||||
return originalState.with(HorizontalAxisKineticBlock.HORIZONTAL_AXIS, VoxelShaper.axisAsFace(originalState.get(HorizontalAxisKineticBlock.HORIZONTAL_AXIS)).rotateAround(targetedFace.getAxis()).getAxis());
|
return originalState.with(HorizontalAxisKineticBlock.HORIZONTAL_AXIS, DirectionHelper.rotateAround(VoxelShaper.axisAsFace(originalState.get(HorizontalAxisKineticBlock.HORIZONTAL_AXIS)), targetedFace.getAxis()).getAxis());
|
||||||
if (originalState.has(HorizontalKineticBlock.HORIZONTAL_FACING))
|
if (originalState.has(HorizontalKineticBlock.HORIZONTAL_FACING))
|
||||||
return originalState.with(HorizontalKineticBlock.HORIZONTAL_FACING, originalState.get(HorizontalKineticBlock.HORIZONTAL_FACING).rotateAround(targetedFace.getAxis()));
|
return originalState.with(HorizontalKineticBlock.HORIZONTAL_FACING, DirectionHelper.rotateAround(originalState.get(HorizontalKineticBlock.HORIZONTAL_FACING), targetedFace.getAxis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (originalState.has(RotatedPillarKineticBlock.AXIS))
|
if (originalState.has(RotatedPillarKineticBlock.AXIS))
|
||||||
return originalState.with(RotatedPillarKineticBlock.AXIS, VoxelShaper.axisAsFace(originalState.get(RotatedPillarKineticBlock.AXIS)).rotateAround(targetedFace.getAxis()).getAxis());
|
return originalState.with(RotatedPillarKineticBlock.AXIS, DirectionHelper.rotateAround(VoxelShaper.axisAsFace(originalState.get(RotatedPillarKineticBlock.AXIS)), targetedFace.getAxis()).getAxis());
|
||||||
|
|
||||||
if (!originalState.has(DirectionalKineticBlock.FACING)) return originalState;
|
if (!originalState.has(DirectionalKineticBlock.FACING)) return originalState;
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ public interface IWrenchable {
|
|||||||
else return originalState;
|
else return originalState;
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
newState = newState.with(DirectionalKineticBlock.FACING, newState.get(DirectionalKineticBlock.FACING).rotateAround(targetedFace.getAxis()));
|
newState = newState.with(DirectionalKineticBlock.FACING, DirectionHelper.rotateAround(newState.get(DirectionalKineticBlock.FACING), targetedFace.getAxis()));
|
||||||
if (targetedFace.getAxis() == Direction.Axis.Y && newState.has(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE)) newState = newState.cycle(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE);
|
if (targetedFace.getAxis() == Direction.Axis.Y && newState.has(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE)) newState = newState.cycle(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE);
|
||||||
} while (newState.get(DirectionalKineticBlock.FACING).getAxis().equals(targetedFace.getAxis()));
|
} while (newState.get(DirectionalKineticBlock.FACING).getAxis().equals(targetedFace.getAxis()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user