forked from DaFuqs/Spectrum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.20.1-main' into compat
- Loading branch information
Showing
152 changed files
with
1,859 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
[InternetShortcut] | ||
URL=https://freesound.org/people/DaveJf/sounds/556315/ | ||
URL=https://freesound.org/people/DaveJf/sounds/556315/ | ||
|
||
music.discovery_theme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/de/dafuqs/spectrum/blocks/decoration/ProjectorBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package de.dafuqs.spectrum.blocks.decoration; | ||
|
||
import de.dafuqs.spectrum.*; | ||
import net.minecraft.block.*; | ||
import net.minecraft.block.entity.*; | ||
import net.minecraft.util.*; | ||
import net.minecraft.util.math.*; | ||
import net.minecraft.util.shape.*; | ||
import net.minecraft.world.*; | ||
import org.jetbrains.annotations.*; | ||
|
||
public class ProjectorBlock extends Block implements BlockEntityProvider { | ||
|
||
private final VoxelShape shape; | ||
final float heightOffset, bobMultiplier, scaling; | ||
final Identifier texture; | ||
|
||
public ProjectorBlock(Settings settings, String path, double width, double height, float heightOffset, float bobMultiplier, float scaling) { | ||
super(settings); | ||
this.heightOffset = heightOffset; | ||
this.bobMultiplier = bobMultiplier; | ||
this.scaling = scaling; | ||
var min = (16 - width) / 2; | ||
var max = width + min; | ||
shape = Block.createCuboidShape(min, 0, min, max, height, max); | ||
this.texture = SpectrumCommon.locate("textures/block/" + path + ".png"); | ||
} | ||
|
||
@Override | ||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { | ||
return shape; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { | ||
return new ProjectorBlockEntity(pos, state); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/de/dafuqs/spectrum/blocks/decoration/ProjectorBlockEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package de.dafuqs.spectrum.blocks.decoration; | ||
|
||
import de.dafuqs.spectrum.registries.*; | ||
import net.minecraft.block.*; | ||
import net.minecraft.block.entity.*; | ||
import net.minecraft.util.*; | ||
import net.minecraft.util.math.*; | ||
|
||
public class ProjectorBlockEntity extends BlockEntity { | ||
|
||
final Identifier texture; | ||
final float heightOffset, bobMultiplier, scaling; | ||
|
||
public ProjectorBlockEntity(BlockPos pos, BlockState state) { | ||
super(SpectrumBlockEntities.PROJECTOR, pos, state); | ||
var projectorBlock = (ProjectorBlock) state.getBlock(); | ||
heightOffset = projectorBlock.heightOffset; | ||
bobMultiplier = projectorBlock.bobMultiplier; | ||
texture = projectorBlock.texture; | ||
scaling = projectorBlock.scaling; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/de/dafuqs/spectrum/blocks/decoration/ProjectorBlockEntityRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package de.dafuqs.spectrum.blocks.decoration; | ||
|
||
import net.minecraft.client.*; | ||
import net.minecraft.client.render.*; | ||
import net.minecraft.client.render.block.entity.*; | ||
import net.minecraft.client.render.entity.*; | ||
import net.minecraft.client.util.math.*; | ||
import net.minecraft.util.math.*; | ||
import org.joml.*; | ||
|
||
import java.lang.*; | ||
import java.lang.Math; | ||
|
||
public class ProjectorBlockEntityRenderer implements BlockEntityRenderer<ProjectorBlockEntity> { | ||
|
||
protected static EntityRenderDispatcher dispatcher; | ||
|
||
public ProjectorBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) { | ||
dispatcher = MinecraftClient.getInstance().getEntityRenderDispatcher(); | ||
} | ||
|
||
@Override | ||
public void render(ProjectorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { | ||
float time = entity.getWorld().getTime() % 24000 + tickDelta; | ||
double bob = Math.sin((time / 19)) * 0.075 * entity.bobMultiplier; | ||
|
||
matrices.push(); | ||
matrices.translate(0.5D, entity.heightOffset + bob, 0.5D); | ||
var center = Vec3d.of(entity.getPos()).add(0.5, 0, 0.5); | ||
var xOffset = center.getX() - dispatcher.camera.getPos().x; | ||
var zOffset = center.getZ() - dispatcher.camera.getPos().z; | ||
matrices.multiply(RotationAxis.POSITIVE_Y.rotation((float) MathHelper.atan2(xOffset, zOffset))); | ||
var buffer = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucent(entity.texture)); | ||
renderRing(matrices, buffer, entity.scaling, 0.75F, overlay, Direction.UP); | ||
matrices.pop(); | ||
} | ||
|
||
//Yes I did in fact just steal this from pastel nodes :3 | ||
private void renderRing(MatrixStack matrices, VertexConsumer vertices, float scale, float alpha, int overlay, Direction facing) { | ||
var size = scale / 16F; | ||
matrices.translate(-size / 2F, -size / 2F, 0); | ||
|
||
var peek = matrices.peek(); | ||
var model = peek.getPositionMatrix(); | ||
var normals = peek.getNormalMatrix(); | ||
var transform = normals.transform(new Vector3f(facing.getUnitVector())); | ||
renderSide(model, normals, vertices, alpha, scale, scale, 0, size, 0, size, transform.x, transform.y, transform.z, overlay); | ||
} | ||
|
||
private void renderSide(Matrix4f model, Matrix3f normals, VertexConsumer vertices, float alpha, float u, float v, float x1, float x2, float z1, float z2, float n1, float n2, float n3, int overlay) { | ||
float u1 = 0, v1 = 0; | ||
float u2 = u1 + u / 16F, v2 = v1 + v / 16F; | ||
|
||
vertices.vertex(model, x1, z2, 0).color(1F, 1F, 1F, alpha).texture(u1, v1).overlay(overlay).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(0, 1, 0).next(); | ||
vertices.vertex(model, x2, z2, 0).color(1F, 1F, 1F, alpha).texture(u2, v1).overlay(overlay).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(0, 1, 0).next(); | ||
vertices.vertex(model, x2, z1, 0).color(1F, 1F, 1F, alpha).texture(u2, v2).overlay(overlay).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(0, 1, 0).next(); | ||
vertices.vertex(model, x1, z1, 0).color(1F, 1F, 1F, alpha).texture(u1, v2).overlay(overlay).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(0, 1, 0).next(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.