-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Ore and additional changes (#199)
Co-authored-by: MagicMaan <[email protected]>
- Loading branch information
1 parent
57460f4
commit 0923728
Showing
58 changed files
with
1,428 additions
and
71 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
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
55 changes: 55 additions & 0 deletions
55
common/src/main/java/whocraft/tardis_refined/client/renderer/RenderHelper.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,55 @@ | ||
package whocraft.tardis_refined.client.renderer; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import com.mojang.blaze3d.vertex.*; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.phys.AABB; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.joml.Matrix4f; | ||
|
||
public class RenderHelper { | ||
|
||
public static void renderFilledBox(PoseStack stack, VertexConsumer vertexConsumer, AABB box, float red, float green, float blue, float alpha, int combinedLightIn) { | ||
Matrix4f matrix = stack.last().pose(); | ||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
|
||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
|
||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
|
||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
|
||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.maxY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.maxX, (float) box.minY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
|
||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.minY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.maxZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
vertexConsumer.vertex(matrix, (float) box.minX, (float) box.maxY, (float) box.minZ).color(red, green, blue, alpha).uv2(combinedLightIn).endVertex(); | ||
} | ||
|
||
|
||
|
||
public static void drawGlowingBox(PoseStack poseStack, VertexConsumer consumer, float length, float height, float width, float red, float green, float blue, float alpha, int combinedLightIn) { | ||
AABB box = new AABB(-length / 2F, -height / 2f, -width / 2F, length / 2F, height / 2f, width / 2F); | ||
renderFilledBox(poseStack, consumer, box, 1F, 1F, 1F, alpha, combinedLightIn); | ||
|
||
for (int i = 0; i < 3; i++) { | ||
renderFilledBox(poseStack, consumer, box.inflate(i * 0.5F * 0.0625F), red, green, blue, (1F / i / 2) * alpha, combinedLightIn); | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
...whocraft/tardis_refined/client/renderer/blockentity/device/AstralManipulatorRenderer.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,96 @@ | ||
package whocraft.tardis_refined.client.renderer.blockentity.device; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import com.mojang.math.Axis; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||
import net.minecraft.client.renderer.texture.OverlayTexture; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.joml.Vector3f; | ||
import whocraft.tardis_refined.client.model.blockentity.console.ConsoleModelCollection; | ||
import whocraft.tardis_refined.client.model.blockentity.console.ConsoleUnit; | ||
import whocraft.tardis_refined.client.renderer.RenderHelper; | ||
import whocraft.tardis_refined.common.block.device.ConsoleConfigurationBlock; | ||
import whocraft.tardis_refined.common.block.door.GlobalDoorBlock; | ||
import whocraft.tardis_refined.common.block.shell.ShellBaseBlock; | ||
import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity; | ||
import whocraft.tardis_refined.common.blockentity.device.AstralManipulatorBlockEntity; | ||
import whocraft.tardis_refined.common.blockentity.device.ConsoleConfigurationBlockEntity; | ||
|
||
public class AstralManipulatorRenderer implements BlockEntityRenderer<AstralManipulatorBlockEntity>, BlockEntityRendererProvider<AstralManipulatorBlockEntity> { | ||
|
||
public AstralManipulatorRenderer(Context context) { | ||
} | ||
|
||
@Override | ||
public BlockEntityRenderer<AstralManipulatorBlockEntity> create(Context context) { | ||
return new AstralManipulatorRenderer(context); | ||
} | ||
|
||
@Override | ||
public void render(AstralManipulatorBlockEntity blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, int packedOverlay) { | ||
|
||
var pointA = blockEntity.getPointABlockPos(); | ||
if (pointA != null && blockEntity.shouldDisplay()) { | ||
|
||
var pointB = blockEntity.getPointBBlockPos(); | ||
|
||
float width = 1; | ||
float height = 1; | ||
float length = 1; | ||
|
||
var centerOfBoth = new Vector3f(0,0,0); | ||
if (pointB != null) { | ||
|
||
float xDiff = Math.abs(pointA.getX() - pointB.getX()); | ||
float yDiff = Math.abs(pointA.getY() - pointB.getY()); | ||
float zDiff = Math.abs(pointA.getZ() - pointB.getZ()); | ||
|
||
var smallestPointX = pointA.getX() > pointB.getX() ? pointB.getX() : pointA.getX(); | ||
var smallestPointY = pointA.getY() > pointB.getY() ? pointB.getY() : pointA.getY(); | ||
var smallestPointZ = pointA.getZ() > pointB.getZ() ? pointB.getZ() : pointA.getZ(); | ||
|
||
var xCenter = smallestPointX + (xDiff * 0.5f); | ||
var yCenter = smallestPointY + (yDiff * 0.5f); | ||
var zCenter = smallestPointZ + (zDiff * 0.5f); | ||
|
||
centerOfBoth = new Vector3f(xCenter, yCenter, zCenter); | ||
length = xDiff; | ||
height = yDiff; | ||
width = zDiff; | ||
|
||
} | ||
|
||
|
||
|
||
var centerPos = pointB != null ? centerOfBoth : new Vector3f(pointA.getX(), pointA.getY(), pointA.getZ()); | ||
|
||
var posAOffsetX = blockEntity.getBlockPos().getX() - centerPos.x - .5f; | ||
|
||
var posAOffsetY = blockEntity.getBlockPos().getY() - centerPos.y- .5f; | ||
var posAOffsetZ = blockEntity.getBlockPos().getZ() - centerPos.z- .5f; | ||
|
||
float sine = (float)(Math.sin(blockEntity.getLevel().getGameTime()*10f*Math.PI/8f)*(0.25f/2f) + (0.25f/2f)) * 0.25f; | ||
if (sine < 0.001) { | ||
sine = 0.001f; | ||
} | ||
|
||
poseStack.pushPose(); | ||
poseStack.translate(-posAOffsetX, -posAOffsetY, -posAOffsetZ); | ||
VertexConsumer vertexBuilder = bufferSource.getBuffer(RenderType.lightning()); | ||
RenderHelper.drawGlowingBox(poseStack, vertexBuilder, length + 1.25f, height + 1.25f , width + 1.25f, 0.635f, 0.392f, 0.878f, 0 + sine , 0 ); | ||
|
||
poseStack.popPose(); | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
} |
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
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
56 changes: 56 additions & 0 deletions
56
common/src/main/java/whocraft/tardis_refined/common/block/device/AstralManipulatorBlock.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,56 @@ | ||
package whocraft.tardis_refined.common.block.device; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.EntityBlock; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
import whocraft.tardis_refined.common.blockentity.device.AstralManipulatorBlockEntity; | ||
import whocraft.tardis_refined.common.items.ScrewdriverItem; | ||
|
||
|
||
public class AstralManipulatorBlock extends Block implements EntityBlock { | ||
public AstralManipulatorBlock(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) { | ||
|
||
if (level instanceof ServerLevel && interactionHand == InteractionHand.MAIN_HAND) { | ||
|
||
if (level.getBlockEntity(blockPos) instanceof AstralManipulatorBlockEntity astralManipulatorBlockEntity) { | ||
ItemStack itemStack = player.getItemInHand(interactionHand); | ||
|
||
if (itemStack == ItemStack.EMPTY) { | ||
astralManipulatorBlockEntity.clearDisplay(); | ||
return InteractionResult.CONSUME; | ||
} else { | ||
|
||
if (itemStack.getItem() instanceof ScrewdriverItem) { | ||
|
||
astralManipulatorBlockEntity.OnRightClick(itemStack); | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
return super.use(blockState, level, blockPos, player, interactionHand, blockHitResult); | ||
} | ||
|
||
@Override | ||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { | ||
return new AstralManipulatorBlockEntity(blockPos, blockState); | ||
} | ||
} |
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
Oops, something went wrong.