Skip to content

Commit

Permalink
New Ore and additional changes (#199)
Browse files Browse the repository at this point in the history
Co-authored-by: MagicMaan <[email protected]>
  • Loading branch information
CommandrMoose and Magicmaan authored Mar 4, 2024
1 parent 57460f4 commit 0923728
Show file tree
Hide file tree
Showing 58 changed files with 1,428 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.slf4j.Logger;
import whocraft.tardis_refined.client.TRParticles;
import whocraft.tardis_refined.common.capability.upgrades.Upgrades;
import whocraft.tardis_refined.common.crafting.ManipulatorCrafting;
import whocraft.tardis_refined.common.hum.TardisHums;
import whocraft.tardis_refined.common.network.TardisNetwork;
import whocraft.tardis_refined.common.network.messages.sync.SyncConsolePatternsMessage;
Expand Down Expand Up @@ -68,5 +69,7 @@ public static void init() {
ConsolePatterns.registerDefaultPatterns();
ShellPatterns.registerDefaultPatterns();
TardisHums.registerDefaultHums();

ManipulatorCrafting.registerRecipes();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class ModelRegistry {
public static ModelLayerLocation ARS_EGG;
public static ModelLayerLocation BULK_HEAD_DOOR;

public static ModelLayerLocation SCREWDRIVER_CRAFT_GLOW;

public static void init() {
ROOT_PLANT_STATE_ONE = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "root_plant_one"), "root_plant_one"), RootPlantStateOneModel::createBodyLayer);
ROOT_PLANT_STATE_TWO = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "root_plant_two"), "root_plant_two"), RootPlantStateTwoModel::createBodyLayer);
Expand Down Expand Up @@ -134,7 +136,6 @@ public static void init() {
CASTLE_DOOR = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "castle_door"), "castle_door"), CastleShellDoorModel::createBodyLayer);



ARS_EGG = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "ars_egg"), "ars_egg"), ArsEggModel::createBodyLayer);
BULK_HEAD_DOOR = register(new ModelLayerLocation(new ResourceLocation(TardisRefined.MODID, "bulk_head_door"), "bulk_head_door"), BulkHeadDoorModel::createBodyLayer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@

public class RootShellDoorModel extends HierarchicalModel {

private final ModelPart root;
private final ModelPart stage7;

public RootShellDoorModel(ModelPart root) {

this.root = root;
this.stage7 = root.getChild("stage7");
}

Expand All @@ -35,7 +38,7 @@ public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, i

@Override
public ModelPart root() {
return stage7;
return this.root;
}

@Override
Expand Down
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);
}
}
}
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();

}


}


}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void render(ConsoleConfigurationBlockEntity blockEntity, float partialTic
ResourceLocation theme = blockEntity.theme();

ConsoleUnit consoleModel = ConsoleModelCollection.getInstance().getConsoleModel(theme);
consoleModel.renderConsole(null, blockEntity.getLevel(), poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(consoleModel.getDefaultTexture())), packedLight, OverlayTexture.NO_OVERLAY, 1f, 0.64f, 0f, 0.5f);
consoleModel.renderConsole(null, blockEntity.getLevel(), poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(consoleModel.getDefaultTexture())), packedLight, OverlayTexture.NO_OVERLAY, 0.635f, 0.392f, 0.878f, 0.5f);
}

poseStack.popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public RootShellDoorRenderer(BlockEntityRendererProvider.Context context) {
@Override
public void render(RootShellDoorBlockEntity blockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j) {
poseStack.pushPose();

poseStack.translate(0.5F, 1.475F, 0.5F);
poseStack.mulPose(Axis.ZP.rotationDegrees(180F));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package whocraft.tardis_refined.client.renderer.blockentity.shell;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.minecraft.client.renderer.MultiBufferSource;
Expand All @@ -8,6 +9,7 @@
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import whocraft.tardis_refined.client.model.blockentity.shell.ShellModelCollection;
Expand Down
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,6 @@ public InteractionResult use(BlockState blockState, Level level, BlockPos blockP
return InteractionResult.SUCCESS;
}

if (player.getMainHandItem().getItem() == Items.IRON_BLOCK) {
if (!(consoleBlock.getBlock() instanceof GlobalConsoleBlock)) { // If there is no existing console block
//Spawn the console block use set its console theme using the one stored in the configurator
if (this.placeNewGlobalConsoleBlock(level, blockPos, consolePos)) {
//Use up the iron block
if (!player.isCreative()) {
player.getMainHandItem().shrink(1);
}
return InteractionResult.SUCCESS;
}

} else {
//If we're holding an iron block but there is an existing console
this.changeConsoleTheme(level, blockPos, consolePos);
return InteractionResult.SUCCESS;
}
}

if (player.isShiftKeyDown()) { //If we are destroying the console block
this.removeGlobalConsoleBlock(consolePos, level);
return InteractionResult.SUCCESS; //Don't try to continue interaction which will rerun the change console function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.jetbrains.annotations.Nullable;
import whocraft.tardis_refined.common.blockentity.door.InternalDoorBlockEntity;
import whocraft.tardis_refined.common.blockentity.door.TardisInternalDoor;
import whocraft.tardis_refined.common.capability.TardisLevelOperator;
import whocraft.tardis_refined.common.util.TRTeleporter;

import java.util.List;
Expand Down Expand Up @@ -96,10 +97,15 @@ public void entityInside(BlockState blockState, Level level, BlockPos blockPos,
if (!level.isClientSide()) {
ServerLevel serverLevel = (ServerLevel)level;
if (serverLevel.getBlockEntity(blockPos) instanceof TardisInternalDoor door) {
AABB teleportAABB = this.getCollisionShape(blockState, level, blockPos, CollisionContext.of(entity)).bounds().move(blockPos);
if (TRTeleporter.teleportIfCollided(serverLevel, blockPos, entity, teleportAABB)){
door.onAttemptEnter(blockState, serverLevel, blockPos, entity);

if (TardisLevelOperator.get(serverLevel).isPresent()) {
AABB teleportAABB = this.getCollisionShape(blockState, level, blockPos, CollisionContext.of(entity)).bounds().move(blockPos);
if (TRTeleporter.teleportIfCollided(serverLevel, blockPos, entity, teleportAABB)){
door.onAttemptEnter(blockState, serverLevel, blockPos, entity);
}
}


}
}
}
Expand Down
Loading

0 comments on commit 0923728

Please sign in to comment.