diff --git a/common/src/main/java/whocraft/tardis_refined/TardisRefined.java b/common/src/main/java/whocraft/tardis_refined/TardisRefined.java index 553d04e34..350cb34d5 100644 --- a/common/src/main/java/whocraft/tardis_refined/TardisRefined.java +++ b/common/src/main/java/whocraft/tardis_refined/TardisRefined.java @@ -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; @@ -68,5 +69,7 @@ public static void init() { ConsolePatterns.registerDefaultPatterns(); ShellPatterns.registerDefaultPatterns(); TardisHums.registerDefaultHums(); + + ManipulatorCrafting.registerRecipes(); } } \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/client/ModelRegistry.java b/common/src/main/java/whocraft/tardis_refined/client/ModelRegistry.java index 2a6601682..91f973a6b 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/ModelRegistry.java +++ b/common/src/main/java/whocraft/tardis_refined/client/ModelRegistry.java @@ -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); @@ -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); } diff --git a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/internal/door/RootShellDoorModel.java b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/internal/door/RootShellDoorModel.java index e9caafb8e..85b0b08d4 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/internal/door/RootShellDoorModel.java +++ b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/internal/door/RootShellDoorModel.java @@ -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"); } @@ -35,7 +38,7 @@ public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, i @Override public ModelPart root() { - return stage7; + return this.root; } @Override diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/RenderHelper.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/RenderHelper.java new file mode 100644 index 000000000..5a8086b1a --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/RenderHelper.java @@ -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); + } + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/AstralManipulatorRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/AstralManipulatorRenderer.java new file mode 100644 index 000000000..7ae23b19f --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/AstralManipulatorRenderer.java @@ -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, BlockEntityRendererProvider { + + public AstralManipulatorRenderer(Context context) { + } + + @Override + public BlockEntityRenderer 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(); + + } + + + } + + +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/ConsoleConfigurationRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/ConsoleConfigurationRenderer.java index 0d4684522..a52ede165 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/ConsoleConfigurationRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/ConsoleConfigurationRenderer.java @@ -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(); diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/door/RootShellDoorRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/door/RootShellDoorRenderer.java index 6dbcf0bb8..8bc8bf8d7 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/door/RootShellDoorRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/door/RootShellDoorRenderer.java @@ -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)); diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/shell/GlobalShellRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/shell/GlobalShellRenderer.java index 274ea828e..c6a145ed7 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/shell/GlobalShellRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/shell/GlobalShellRenderer.java @@ -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; @@ -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; diff --git a/common/src/main/java/whocraft/tardis_refined/common/block/device/AstralManipulatorBlock.java b/common/src/main/java/whocraft/tardis_refined/common/block/device/AstralManipulatorBlock.java new file mode 100644 index 000000000..8871ad5da --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/block/device/AstralManipulatorBlock.java @@ -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); + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/block/device/ConsoleConfigurationBlock.java b/common/src/main/java/whocraft/tardis_refined/common/block/device/ConsoleConfigurationBlock.java index 1fac4025e..e07c46ffa 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/block/device/ConsoleConfigurationBlock.java +++ b/common/src/main/java/whocraft/tardis_refined/common/block/device/ConsoleConfigurationBlock.java @@ -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 diff --git a/common/src/main/java/whocraft/tardis_refined/common/block/door/InternalDoorBlock.java b/common/src/main/java/whocraft/tardis_refined/common/block/door/InternalDoorBlock.java index cda5e4b95..0aeb21d10 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/block/door/InternalDoorBlock.java +++ b/common/src/main/java/whocraft/tardis_refined/common/block/door/InternalDoorBlock.java @@ -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; @@ -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); + } } + + } } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/block/door/RootShellDoorBlock.java b/common/src/main/java/whocraft/tardis_refined/common/block/door/RootShellDoorBlock.java index f35ef1580..a933a00f5 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/block/door/RootShellDoorBlock.java +++ b/common/src/main/java/whocraft/tardis_refined/common/block/door/RootShellDoorBlock.java @@ -2,17 +2,23 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.Nullable; import whocraft.tardis_refined.common.blockentity.door.GlobalDoorBlockEntity; import whocraft.tardis_refined.common.blockentity.door.RootShellDoorBlockEntity; +import whocraft.tardis_refined.common.capability.TardisLevelOperator; public class RootShellDoorBlock extends GlobalDoorBlock { @@ -27,8 +33,7 @@ public RootShellDoorBlock(Properties properties) { @Nullable @Override public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { - this.setBlockEntity(new RootShellDoorBlockEntity(blockPos, blockState)); - return super.newBlockEntity(blockPos, blockState); + return new RootShellDoorBlockEntity(blockPos, blockState); } @Override @@ -48,22 +53,28 @@ public VoxelShape getCollisionShape(BlockState blockState, BlockGetter blockGett @Override public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) { switch(blockState.getValue(FACING)) { - case EAST: - default: - return EAST_AABB; + case SOUTH: return SOUTH_AABB ; case WEST: return WEST_AABB; case NORTH: return NORTH_AABB; + case EAST: + default: + return EAST_AABB; } } + @Override + public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) { + return InteractionResult.SUCCESS; + } + static { NORTH_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 3.0D); SOUTH_AABB = Block.box(0.0D, 0.0D, 13.0D, 16.0D, 16.0D, 16.0D); - WEST_AABB = Block.box(13.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D); - EAST_AABB = Block.box(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D); + EAST_AABB = Block.box(13.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D); + WEST_AABB = Block.box(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D); } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/blockentity/device/AstralManipulatorBlockEntity.java b/common/src/main/java/whocraft/tardis_refined/common/blockentity/device/AstralManipulatorBlockEntity.java new file mode 100644 index 000000000..148a050bc --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/blockentity/device/AstralManipulatorBlockEntity.java @@ -0,0 +1,252 @@ +package whocraft.tardis_refined.common.blockentity.device; + +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; +import org.jetbrains.annotations.Nullable; +import whocraft.tardis_refined.common.crafting.ManipulatorCrafting; +import whocraft.tardis_refined.common.items.ScrewdriverItem; +import whocraft.tardis_refined.common.items.ScrewdriverMode; +import whocraft.tardis_refined.registry.BlockEntityRegistry; +import whocraft.tardis_refined.registry.SoundRegistry; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class AstralManipulatorBlockEntity extends BlockEntity { + + // Constants + public static final String MAN_POINT_A = "man_point_a"; + public static final String MAN_POINT_B = "man_point_b"; + public static final String SHOULD_DISPLAY = "should_display"; + + + private boolean shouldDisplay = false; + private BlockPos pointABlockPos; + private BlockPos pointBBlockPos; + + public AstralManipulatorBlockEntity(BlockPos blockPos, BlockState blockState) { + super(BlockEntityRegistry.ASTRAL_MANIPULATOR.get(), blockPos, blockState); + } + + @Override + protected void saveAdditional(CompoundTag compoundTag) { + super.saveAdditional(compoundTag); + + compoundTag.putBoolean(SHOULD_DISPLAY, this.shouldDisplay); + + if (this.pointABlockPos != null) { + compoundTag.put(MAN_POINT_A, NbtUtils.writeBlockPos(this.pointABlockPos)); + } + + if (this.pointBBlockPos != null) { + compoundTag.put(MAN_POINT_B, NbtUtils.writeBlockPos(this.pointBBlockPos)); + + } + } + + public BlockPos getPointABlockPos() { + return this.pointABlockPos; + } + + public BlockPos getPointBBlockPos() { + return this.pointBBlockPos; + } + + public void setShouldDisplay(boolean display) { + this.shouldDisplay = display; + this.pointABlockPos = this.getBlockPos(); + this.pointBBlockPos = this.getBlockPos(); + sendUpdates(); + } + + public boolean shouldDisplay() { + + return shouldDisplay; + } + + public void clearDisplay() { + this.shouldDisplay = false; + this.pointABlockPos = this.getBlockPos(); + this.pointBBlockPos = this.getBlockPos(); + sendUpdates(); + } + + @Override + public void load(CompoundTag tag) { + + if (tag.contains(MAN_POINT_A)) { + this.pointABlockPos = NbtUtils.readBlockPos(tag.getCompound(MAN_POINT_A)); + } + if (tag.contains(MAN_POINT_B)) { + this.pointBBlockPos = NbtUtils.readBlockPos(tag.getCompound(MAN_POINT_B)); + } + + if (tag.contains(SHOULD_DISPLAY)) { + this.shouldDisplay = tag.getBoolean(SHOULD_DISPLAY); + } + + super.load(tag); + } + + + public void OnRightClick(ItemStack itemStack) { + if (itemStack.getItem() instanceof ScrewdriverItem screwdriverItem) { + if (!screwdriverItem.isScrewdriverMode(itemStack, ScrewdriverMode.DRAWING)) { + screwdriverItem.setScrewdriverMode(itemStack, ScrewdriverMode.DRAWING, getBlockPos(), null); + setShouldDisplay(true); + screwdriverItem.playScrewdriverSound((ServerLevel) getLevel(), getBlockPos(), SoundRegistry.SCREWDRIVER_CONNECT.get()); + + } else { + + List points = screwdriverItem.getScrewdriverPoint(itemStack); + screwdriverItem.setScrewdriverMode(itemStack, ScrewdriverMode.DISABLED, getBlockPos(), null); + + if (points.size() == 2) { + BlockPos pointA = points.get(0); + BlockPos pointB = points.get(1); + + attemptToBuild(pointA, pointB); + screwdriverItem.clearBlockPosFromScrewdriver(itemStack); + this.clearDisplay(); + } + + this.clearDisplay(); + } + } + } + + public boolean setProjectionBlockPos(BlockPos pos, boolean isPointA) { + + if (!this.shouldDisplay) { + return false; + } + + if (isPointA) { + pointABlockPos = pos; + } else { + pointBBlockPos = pos; + } + + if (checkIfDistanceIsTooGreat(pos)) { + this.clearDisplay(); + sendUpdates(); + return false; + + } + + sendUpdates(); + return true; + } + + private boolean checkIfDistanceIsTooGreat(BlockPos pos) { + var distance = pos.distManhattan(getBlockPos()); + return distance > 25; + } + + @Nullable + @Override + public Packet getUpdatePacket() { + return ClientboundBlockEntityDataPacket.create(this); + } + + public void sendUpdates() { + level.sendBlockUpdated(this.getBlockPos(), level.getBlockState(this.getBlockPos()), level.getBlockState(this.getBlockPos()), Block.UPDATE_CLIENTS); + setChanged(); + } + + public CompoundTag getUpdateTag() { + CompoundTag tag = new CompoundTag(); + saveAdditional(tag); + return tag; + } + + + private void attemptToBuild(BlockPos pointA, BlockPos pointB) { + + var submittedBlocks = new ArrayList(); + + // Grab the absolutes for these items. + float xDiff = Math.abs(pointA.getX() - pointB.getX()); + float yDiff = Math.abs(pointA.getY() - pointB.getY()); + float zDiff = Math.abs(pointA.getZ() - pointB.getZ()); + + int smallestPointX = pointA.getX() > pointB.getX() ? pointB.getX() : pointA.getX(); + int smallestPointY = pointA.getY() > pointB.getY() ? pointB.getY() : pointA.getY(); + int smallestPointZ = pointA.getZ() > pointB.getZ() ? pointB.getZ() : pointA.getZ(); + + BlockPos minPoint = new BlockPos(smallestPointX, smallestPointY, smallestPointZ); + + for (int y = 0; y < yDiff + 1; y++) { + + for (int x = 0; x < xDiff + 1; x++) { + + for (int z = 0; z < zDiff + 1; z++) { + + var blockPosInWorld = new BlockPos(minPoint.getX() + x, minPoint.getY() + y, minPoint.getZ() + z); + + submittedBlocks.add(new ManipulatorCraftingRecipeItem(new BlockPos(x, y, z), level.getBlockState(blockPosInWorld).getBlock())); + } + } + } + + // Filter recipes by the first block, will make it a LOT easier later down the line. (when I make it) + Optional firstBlock = submittedBlocks.stream().filter(x -> x.relativeBlockPos.getX() == 0 && x.relativeBlockPos.getY() == 0 && x.relativeBlockPos.getZ() == 0).findFirst(); + if (!firstBlock.isPresent()) { + return; + } + + List possibleRecipes = new ArrayList(); + + for (ManipulatorCraftingRecipe recipe : ManipulatorCrafting.MANIPULATOR_CRAFTING_RECIPES) { + + var zeroPos = recipe.itemList.stream().filter(x -> x.relativeBlockPos.getX() == 0 && x.relativeBlockPos.getY() == 0 && x.relativeBlockPos.getZ() == 0).findFirst(); + if (zeroPos.isPresent()) { + if (zeroPos.get().block == firstBlock.get().block) { + possibleRecipes.add(recipe); + } + } + + } + + // No recipes, so no result! + if (possibleRecipes.size() == 0) { + return; + } + + for (ManipulatorCraftingRecipe recipe : possibleRecipes) { + + if (recipe.hasSameItems(submittedBlocks)) { + + // Remove the recipe blocks. + for (BlockPos blockPos : BlockPos.betweenClosed(pointA, pointB)) { + level.setBlock(blockPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); + } + + List droppedItems = getLevel().getEntitiesOfClass(ItemEntity.class, new AABB(pointABlockPos, pointBBlockPos).inflate(1)); + droppedItems.forEach(Entity::discard); + + // TODO: Make this system also accept placing a structure. + ItemStack itemStack = new ItemStack(recipe.recipeOutput.asItem()); + ItemEntity item = new ItemEntity(level, getBlockPos().getX() + 0.5f, getBlockPos().getY() + 1, getBlockPos().getZ() + 0.5f, itemStack); + level.addFreshEntity(item); + + return; + } + + } + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/blockentity/device/ManipulatorCraftingRecipe.java b/common/src/main/java/whocraft/tardis_refined/common/blockentity/device/ManipulatorCraftingRecipe.java new file mode 100644 index 000000000..5d8068404 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/blockentity/device/ManipulatorCraftingRecipe.java @@ -0,0 +1,47 @@ +package whocraft.tardis_refined.common.blockentity.device; + +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; + +import java.util.Comparator; +import java.util.List; + + +/** + * Entry item for the Astral Manipulator. + * **/ +public class ManipulatorCraftingRecipe { + // List of ingredient blocks for the recipe to work. + public List itemList; + // Output to be summoned when the recipe is confirmed. + public Item recipeOutput; + + public ManipulatorCraftingRecipe(List itemList, Item recipeOutput) { + this.itemList = itemList; + this.recipeOutput = recipeOutput; + } + + + /** + * Compares a ManipulatorCraftingRecipe to another by sorting by size, then registered block entries + * @param comparedItemList The items of the recipe to compare to. + * **/ + public boolean hasSameItems(List comparedItemList) { + + if (itemList.size() != comparedItemList.size()) { + return false; + } + + // Sort the items so the list comparison is better. + this.itemList.sort(Comparator.comparing(a -> a.relativeBlockPos)); + comparedItemList.sort(Comparator.comparing(a -> a.relativeBlockPos)); + + for (int i = 0; i < this.itemList.size(); i++) { + if (!this.itemList.get(i).IsSameAs(comparedItemList.get(i))) { + return false; + } + } + + return true; + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/blockentity/device/ManipulatorCraftingRecipeItem.java b/common/src/main/java/whocraft/tardis_refined/common/blockentity/device/ManipulatorCraftingRecipeItem.java new file mode 100644 index 000000000..50100c88c --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/blockentity/device/ManipulatorCraftingRecipeItem.java @@ -0,0 +1,34 @@ +package whocraft.tardis_refined.common.blockentity.device; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.Block; + +/** + * Ingredient block for a ManipulatorCraftingRecipe. + * **/ +public class ManipulatorCraftingRecipeItem { + + // Block position relative to the closest corner to 0,0,0 in world space. + public BlockPos relativeBlockPos; + + // The block that must exist at that position. + public Block block; + + public ManipulatorCraftingRecipeItem(BlockPos pos, Block block) { + this.relativeBlockPos = pos; + this.block = block; + } + + /** + * Compares a ManipulatorCraftingRecipeItem to another. + * @param compared The recipe item to compare to. + * @return If the items are equivalent. + * **/ + public boolean IsSameAs(ManipulatorCraftingRecipeItem compared) { + if (compared.block != block) { + return false; + } + return this.relativeBlockPos.getX() == compared.relativeBlockPos.getX() && this.relativeBlockPos.getY() == compared.relativeBlockPos.getY() && this.relativeBlockPos.getZ() == compared.relativeBlockPos.getZ(); + } +} + diff --git a/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/RootShellDoorBlockEntity.java b/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/RootShellDoorBlockEntity.java index 3d554f53a..5ec81bccc 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/RootShellDoorBlockEntity.java +++ b/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/RootShellDoorBlockEntity.java @@ -1,6 +1,10 @@ package whocraft.tardis_refined.common.blockentity.door; import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.TickingBlockEntity; import net.minecraft.world.level.block.state.BlockState; import whocraft.tardis_refined.registry.BlockEntityRegistry; @@ -12,8 +16,15 @@ public RootShellDoorBlockEntity(BlockPos blockPos, BlockState blockState) { super(BlockEntityRegistry.ROOT_SHELL_DOOR.get(), blockPos, blockState); } + @Override + public void onBlockPlaced() { + // Left blank to remove parent functionality. + } + + @Override public boolean isOpen() { return true; } + } diff --git a/common/src/main/java/whocraft/tardis_refined/common/crafting/ManipulatorCrafting.java b/common/src/main/java/whocraft/tardis_refined/common/crafting/ManipulatorCrafting.java new file mode 100644 index 000000000..44f573847 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/crafting/ManipulatorCrafting.java @@ -0,0 +1,133 @@ +package whocraft.tardis_refined.common.crafting; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.Blocks; +import whocraft.tardis_refined.common.blockentity.device.ManipulatorCraftingRecipe; +import whocraft.tardis_refined.common.blockentity.device.ManipulatorCraftingRecipeItem; +import whocraft.tardis_refined.registry.BlockRegistry; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +// Before 50 says anything. Yes, this should be made into a codec. Will I do it? No. +public class ManipulatorCrafting { + + public static List MANIPULATOR_CRAFTING_RECIPES = new ArrayList(); + + public static void registerRecipes() { + + register(new ManipulatorCraftingRecipe( Arrays.asList( + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 0), Blocks.SMOOTH_STONE_SLAB), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 1), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 2), Blocks.SMOOTH_STONE_SLAB), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 0), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 1), Blocks.REDSTONE_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 2), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 0), Blocks.SMOOTH_STONE_SLAB), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 1), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 2), Blocks.SMOOTH_STONE_SLAB), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 1, 0), Blocks.IRON_TRAPDOOR), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 1, 1), Blocks.STONE_BUTTON), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 1, 2), Blocks.IRON_TRAPDOOR), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 1, 0), Blocks.STONE_BUTTON), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 1, 1), Blocks.GLASS), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 1, 2), Blocks.STONE_BUTTON), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 1, 0), Blocks.IRON_TRAPDOOR), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 1, 1), Blocks.STONE_BUTTON), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 1, 2), Blocks.IRON_TRAPDOOR) + + ), BlockRegistry.GLOBAL_CONSOLE_BLOCK.get().asItem())); + + register(new ManipulatorCraftingRecipe( Arrays.asList( + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 0), Blocks.STONE), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 1), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 2), Blocks.STONE), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 0), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 1), BlockRegistry.ZEITON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 2), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 0), Blocks.STONE), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 1), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 2), Blocks.STONE), + + new ManipulatorCraftingRecipeItem(new BlockPos(0, 1, 0), Blocks.STONE), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 1, 1), Blocks.GLASS_PANE), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 1, 2), Blocks.STONE), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 1, 0), Blocks.GLASS_PANE), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 1, 1), Blocks.EMERALD_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 1, 2), Blocks.GLASS_PANE), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 1, 0), Blocks.STONE), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 1, 1), Blocks.GLASS_PANE), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 1, 2), Blocks.STONE), + + new ManipulatorCraftingRecipeItem(new BlockPos(0, 2, 0), Blocks.STONE), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 2, 1), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 2, 2), Blocks.STONE), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 2, 0), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 2, 1), Blocks.DAYLIGHT_DETECTOR), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 2, 2), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 2, 0), Blocks.STONE), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 2, 1), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 2, 2), Blocks.STONE) + + ), BlockRegistry.TERRAFORMER_BLOCK.get().asItem())); + + register(new ManipulatorCraftingRecipe( Arrays.asList( + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 0), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 1), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 2), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 0), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 1), Blocks.OBSERVER), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 2), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 0), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 1), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 2), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()) + + ), BlockRegistry.CONSOLE_CONFIGURATION_BLOCK.get().asItem())); + + register(new ManipulatorCraftingRecipe( Arrays.asList( + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 0), BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 1), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 2), BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 0), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 1), Blocks.DAYLIGHT_DETECTOR), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 2), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 0), BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 1), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 2), BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.get()) + + ), BlockRegistry.FLIGHT_DETECTOR.get().asItem())); + + register(new ManipulatorCraftingRecipe( Arrays.asList( + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 0), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 1), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 2), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 0), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 1), Blocks.TARGET), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 0, 2), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 0), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 1), Blocks.AMETHYST_BLOCK), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 0, 2), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()), + + new ManipulatorCraftingRecipeItem(new BlockPos(0, 1, 0), Blocks.CUT_COPPER_SLAB), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 1, 1), Blocks.IRON_TRAPDOOR), + new ManipulatorCraftingRecipeItem(new BlockPos(0, 1, 2), Blocks.CUT_COPPER_SLAB), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 1, 0), Blocks.IRON_TRAPDOOR), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 1, 1), Blocks.AIR), + new ManipulatorCraftingRecipeItem(new BlockPos(1, 1, 2), Blocks.IRON_TRAPDOOR), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 1, 0), Blocks.CUT_COPPER_SLAB), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 1, 1), Blocks.IRON_TRAPDOOR), + new ManipulatorCraftingRecipeItem(new BlockPos(2, 1, 2), Blocks.CUT_COPPER_SLAB) + + ), BlockRegistry.LANDING_PAD.get().asItem())); + } + + public static ManipulatorCraftingRecipe register(ManipulatorCraftingRecipe manipulatorCraftingRecipe) { + MANIPULATOR_CRAFTING_RECIPES.add(manipulatorCraftingRecipe); + ; + return manipulatorCraftingRecipe; + } + + + +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/items/ScrewdriverItem.java b/common/src/main/java/whocraft/tardis_refined/common/items/ScrewdriverItem.java new file mode 100644 index 000000000..e2bf8f552 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/items/ScrewdriverItem.java @@ -0,0 +1,196 @@ +package whocraft.tardis_refined.common.items; + +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.Nullable; +import whocraft.tardis_refined.common.blockentity.device.AstralManipulatorBlockEntity; +import whocraft.tardis_refined.constants.ModMessages; +import whocraft.tardis_refined.registry.BlockRegistry; +import whocraft.tardis_refined.registry.SoundRegistry; + +import java.util.ArrayList; +import java.util.List; + +public class ScrewdriverItem extends Item { + + // Constants + public static final String SCREWDRIVER_MODE = "screwdriver_mode"; + public static final String LINKED_MANIPULATOR_POS = "linked_manipulator_pos"; + public static final String SCREWDRIVER_POINT_A = "screwdriver_point_a"; + public static final String SCREWDRIVER_POINT_B = "screwdriver_point_b"; + public static final String SCREWDRIVER_B_WAS_LAST_UPDATED = "screwdriver_b_was_last_updated_pos"; + + public ScrewdriverItem(Properties properties) { + super(properties); + } + + @Override + public InteractionResult useOn(UseOnContext context) { + + if (context.getLevel() instanceof ServerLevel serverLevel) { + + if (context.getPlayer().isCrouching()) { + setScrewdriverMode(context.getItemInHand(), ScrewdriverMode.DISABLED, context.getClickedPos(), serverLevel); + } else { + + if (isScrewdriverMode(context.getItemInHand(), ScrewdriverMode.DRAWING) && context.getLevel().getBlockState(context.getClickedPos()).getBlock() != BlockRegistry.ASTRAL_MANIPULATOR_BLOCK.get()) { + addBlockPosToScrewdriver(serverLevel, context.getPlayer(), context.getItemInHand(), context.getClickedPos()); + } + } + } + + + return super.useOn(context); + } + + public void setScrewdriverMode(ItemStack stack, ScrewdriverMode mode, BlockPos sourceChange, @Nullable ServerLevel serverLevel) { + CompoundTag itemtag = stack.getOrCreateTag(); + + if (itemtag.contains(SCREWDRIVER_MODE)) { + ScrewdriverMode currentMode = ScrewdriverMode.valueOf(itemtag.getString(SCREWDRIVER_MODE)); + + + if (currentMode != ScrewdriverMode.DISABLED && mode == ScrewdriverMode.DISABLED) { + if (serverLevel != null) { + playScrewdriverSound(serverLevel, sourceChange, SoundRegistry.SCREWDRIVER_DISCARD.get()); + } + } + + if (currentMode == ScrewdriverMode.DRAWING && mode == ScrewdriverMode.DISABLED) { + + if (serverLevel != null) { + clearLinkedManipulator(serverLevel, stack); + } + + + } + } + + itemtag.putString(SCREWDRIVER_MODE, mode.toString()); + if (mode == ScrewdriverMode.DRAWING) { + itemtag.put(LINKED_MANIPULATOR_POS, NbtUtils.writeBlockPos(sourceChange)); + } + + stack.setTag(itemtag); + } + + public boolean isScrewdriverMode(ItemStack stack, ScrewdriverMode mode) { + CompoundTag itemtag = stack.getOrCreateTag(); + + if (itemtag.contains(SCREWDRIVER_MODE)) { + ScrewdriverMode currentMode = ScrewdriverMode.valueOf(itemtag.getString(SCREWDRIVER_MODE)); + return mode == currentMode; + } + + return false; + } + + private void addBlockPosToScrewdriver(ServerLevel serverLevel, Player player, ItemStack stack, BlockPos pos) { + CompoundTag itemtag = stack.getOrCreateTag(); + + + boolean isUpdatingA = true; + String target = SCREWDRIVER_POINT_A; + + if (itemtag.contains(SCREWDRIVER_B_WAS_LAST_UPDATED)) { + isUpdatingA = itemtag.getBoolean(SCREWDRIVER_B_WAS_LAST_UPDATED); + + if (!isUpdatingA) { + target = SCREWDRIVER_POINT_B; + } + + } + + itemtag.put(target, NbtUtils.writeBlockPos(pos)); + updatedLinkedManipulator((ServerLevel) player.level(), stack, pos, isUpdatingA); + + itemtag.putBoolean(SCREWDRIVER_B_WAS_LAST_UPDATED, !isUpdatingA); + stack.setTag(itemtag); + + playScrewdriverSound(serverLevel, player.getOnPos(), SoundRegistry.SCREWDRIVER_SHORT.get()); + } + + public void playScrewdriverSound(ServerLevel level, BlockPos pos, SoundEvent soundEvent) { + + level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), soundEvent, SoundSource.PLAYERS, 1, 0.875f + level.getRandom().nextFloat() / 4); + } + + private void updatedLinkedManipulator(ServerLevel level, ItemStack stack, BlockPos pos, boolean isPointA) { + CompoundTag itemtag = stack.getOrCreateTag(); + if (itemtag.contains(LINKED_MANIPULATOR_POS)) { + BlockPos manipulator = NbtUtils.readBlockPos(itemtag.getCompound(LINKED_MANIPULATOR_POS)); + if ( level.getBlockEntity(manipulator) instanceof AstralManipulatorBlockEntity astralManipulatorBlockEntity) { + + if (!astralManipulatorBlockEntity.setProjectionBlockPos(pos, isPointA)) { + setScrewdriverMode(stack, ScrewdriverMode.DISABLED, pos, level); + } + + } + + } + } + + private void clearLinkedManipulator(ServerLevel level, ItemStack stack) { + CompoundTag itemtag = stack.getOrCreateTag(); + if (itemtag.contains(LINKED_MANIPULATOR_POS)) { + BlockPos manipulator = NbtUtils.readBlockPos(itemtag.getCompound(LINKED_MANIPULATOR_POS)); + if ( level.getBlockEntity(manipulator) instanceof AstralManipulatorBlockEntity astralManipulatorBlockEntity) { + astralManipulatorBlockEntity.clearDisplay(); + } + + itemtag.remove(LINKED_MANIPULATOR_POS); + } + } + + public void clearBlockPosFromScrewdriver(ItemStack stack) { + CompoundTag itemtag = stack.getOrCreateTag(); + if (itemtag.contains(SCREWDRIVER_POINT_A)) { + itemtag.remove(SCREWDRIVER_POINT_A); + } + + if (itemtag.contains(SCREWDRIVER_POINT_B)) { + itemtag.remove(SCREWDRIVER_POINT_B); + } + + if (itemtag.contains(LINKED_MANIPULATOR_POS)) { + itemtag.remove(LINKED_MANIPULATOR_POS); + } + + stack.setTag(itemtag); + } + + public List getScrewdriverPoint(ItemStack stack) { + CompoundTag itemtag = stack.getOrCreateTag(); + List listOfBlockPos = new ArrayList(); + + if (itemtag.contains(SCREWDRIVER_POINT_A)) { + listOfBlockPos.add(NbtUtils.readBlockPos(itemtag.getCompound(SCREWDRIVER_POINT_A))); + } + + if (itemtag.contains(SCREWDRIVER_POINT_B)) { + listOfBlockPos.add(NbtUtils.readBlockPos(itemtag.getCompound(SCREWDRIVER_POINT_B))); + } + + return listOfBlockPos; + } + + @Override + public void appendHoverText(ItemStack itemStack, @Nullable Level level, List list, TooltipFlag tooltipFlag) { + super.appendHoverText(itemStack, level, list, tooltipFlag); + + list.add(Component.translatable(ModMessages.TOOLTIP_SCREWDRIVER_DESCRIPTION)); + } +} + diff --git a/common/src/main/java/whocraft/tardis_refined/common/items/ScrewdriverMode.java b/common/src/main/java/whocraft/tardis_refined/common/items/ScrewdriverMode.java new file mode 100644 index 000000000..f866b4d80 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/items/ScrewdriverMode.java @@ -0,0 +1,18 @@ +package whocraft.tardis_refined.common.items; + +public enum ScrewdriverMode { + + // * + // Repurposed screwdriver mode - for future use. + // * // + GENERIC, + // * + // No functionality on right click + // * // + DISABLED, + // * + // Drawing for projection + // * // + DRAWING + +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/items/ZeitonIngotItem.java b/common/src/main/java/whocraft/tardis_refined/common/items/ZeitonIngotItem.java new file mode 100644 index 000000000..a827691b2 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/items/ZeitonIngotItem.java @@ -0,0 +1,40 @@ +package whocraft.tardis_refined.common.items; + +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import whocraft.tardis_refined.registry.BlockRegistry; + +public class ZeitonIngotItem extends Item { + public ZeitonIngotItem(Properties properties) { + super(properties); + } + + @Override + public InteractionResult useOn(UseOnContext useOnContext) { + + Level level = useOnContext.getLevel(); + ItemStack itemInHand = useOnContext.getItemInHand(); + + if (level.getBlockState(useOnContext.getClickedPos()).getBlock() == Blocks.IRON_BLOCK) { + level.setBlockAndUpdate(useOnContext.getClickedPos(), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get().defaultBlockState()); + itemInHand.shrink(1); + level.playSound(null, useOnContext.getClickedPos(), SoundEvents.STONE_BREAK, SoundSource.BLOCKS, 1, 1 ); + } + + if (level.getBlockState(useOnContext.getClickedPos()).getBlock() == Blocks.COPPER_BLOCK) { + level.setBlockAndUpdate(useOnContext.getClickedPos(), BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.get().defaultBlockState()); + itemInHand.shrink(1); + level.playSound(null, useOnContext.getClickedPos(), SoundEvents.COPPER_BREAK, SoundSource.BLOCKS, 1, 1); + + } + + return super.useOn(useOnContext); + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java b/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java index 966d50298..310cf3672 100644 --- a/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java +++ b/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java @@ -20,6 +20,7 @@ public class ModMessages { public static String HARDWARE_OFFLINE = message("hardware_offline"); public static String TOOLTIP_TARDIS_LIST_TITLE = tooltip("tardis_list"); + public static String TOOLTIP_SCREWDRIVER_DESCRIPTION = tooltip("screwdriver_description"); /*UI Messages*/ public static final String UI_DESKTOP_CANCEL_DESKTOP = ui("monitor.cancel_desktop"); diff --git a/common/src/main/java/whocraft/tardis_refined/registry/BlockEntityRegistry.java b/common/src/main/java/whocraft/tardis_refined/registry/BlockEntityRegistry.java index 9e2b4e924..12d5c3be1 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/BlockEntityRegistry.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/BlockEntityRegistry.java @@ -4,6 +4,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity; +import whocraft.tardis_refined.common.blockentity.device.AstralManipulatorBlockEntity; import whocraft.tardis_refined.common.blockentity.door.InternalDoorBlockEntity; import whocraft.tardis_refined.common.blockentity.door.RootShellDoorBlockEntity; import whocraft.tardis_refined.common.blockentity.device.ConsoleConfigurationBlockEntity; @@ -33,5 +34,6 @@ public class BlockEntityRegistry { public static final RegistrySupplier> BULK_HEAD_DOOR = BLOCK_ENTITY_TYPES.register("bulk_head_door", () -> BlockEntityType.Builder.of(BulkHeadDoorBlockEntity::new, BlockRegistry.BULK_HEAD_DOOR.get()).build(null)); public static final RegistrySupplier> CONSOLE_CONFIGURATION = BLOCK_ENTITY_TYPES.register("console_configuration", () -> BlockEntityType.Builder.of(ConsoleConfigurationBlockEntity::new, BlockRegistry.CONSOLE_CONFIGURATION_BLOCK.get()).build(null)); public static final RegistrySupplier> FLIGHT_DETECTOR = BLOCK_ENTITY_TYPES.register("flight_detector", () -> BlockEntityType.Builder.of(FlightDetectorBlockEntity::new, BlockRegistry.FLIGHT_DETECTOR.get()).build(null)); + public static final RegistrySupplier> ASTRAL_MANIPULATOR = BLOCK_ENTITY_TYPES.register("astral_manipulator", () -> BlockEntityType.Builder.of(AstralManipulatorBlockEntity::new, BlockRegistry.ASTRAL_MANIPULATOR_BLOCK.get()).build(null)); } diff --git a/common/src/main/java/whocraft/tardis_refined/registry/BlockRegistry.java b/common/src/main/java/whocraft/tardis_refined/registry/BlockRegistry.java index e6606e278..8adef2405 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/BlockRegistry.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/BlockRegistry.java @@ -40,6 +40,7 @@ private static RegistrySupplier register(String id, Supplie } + // Shell Blocks public static final RegistrySupplier ROOT_SHELL_BLOCK = register("root_shell", () -> new RootedShellBlock(BlockBehaviour.Properties.of().noOcclusion().strength(1000, 1000).sound(SoundType.CORAL_BLOCK)), true, true); public static final RegistrySupplier GLOBAL_SHELL_BLOCK = register("tardis_shell", () -> new GlobalShellBlock(BlockBehaviour.Properties.of().noOcclusion().strength(1000, 1000).sound(SoundType.STONE)), false, false); @@ -71,20 +72,26 @@ private static RegistrySupplier register(String id, Supplie public static final RegistrySupplier TERRAFORMER_BLOCK = register("terraformer", () -> new TerraformerBlock(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion()), true, true); public static final RegistrySupplier AIR_LOCK_GENERATION_BLOCK = register("air_lock_generator", () -> new AirLockGenerationBlock(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion()), false, true); public static final RegistrySupplier CONSOLE_CONFIGURATION_BLOCK = register("console_configuration", () -> new ConsoleConfigurationBlock(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion()), true, true); + public static final RegistrySupplier ASTRAL_MANIPULATOR_BLOCK = register("astral_manipulator", () -> new AstralManipulatorBlock(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion()), true, true); + public static final RegistrySupplier LANDING_PAD = register("landing_pad", () -> new LandingPad(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion().lightLevel((x) -> { return 12; })), true, true); - - public static final RegistrySupplier FLIGHT_DETECTOR = register("flight_detector", () -> new FlightDetectorBlock(BlockBehaviour.Properties.of().strength(3, 3).sound(SoundType.ANVIL).noOcclusion()), true, true); - // Console public static final RegistrySupplier GLOBAL_CONSOLE_BLOCK = register("tardis_console", () -> new GlobalConsoleBlock(BlockBehaviour.Properties.of().strength(1000, 1000).sound(SoundType.ANVIL).noOcclusion().lightLevel((x) -> { return 15; })), true, true); + // Blocks + public static final RegistrySupplier ZEITON_BLOCK = register("zeiton_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).sound(SoundType.METAL)), true, true); + public static final RegistrySupplier ZEITON_FUSED_IRON_BLOCK = register("zeiton_fused_iron_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).sound(SoundType.METAL)), true, true); + public static final RegistrySupplier ZEITON_FUSED_COPPER_BLOCK = register("zeiton_fused_copper_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.COPPER_BLOCK).sound(SoundType.COPPER)), true, true); + + public static final RegistrySupplier ZEITON_ORE = register("zeiton_ore", () -> new Block(BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(3.0F, 3.0F)), true, true); + public static final RegistrySupplier ZEITON_ORE_DEEPSLATE = register("deepslate_zeiton_ore", () -> new Block(BlockBehaviour.Properties.copy(Blocks.DEEPSLATE_GOLD_ORE).requiresCorrectToolForDrops()), true, true); } diff --git a/common/src/main/java/whocraft/tardis_refined/registry/ItemRegistry.java b/common/src/main/java/whocraft/tardis_refined/registry/ItemRegistry.java index 346b6b130..4572bfa39 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/ItemRegistry.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/ItemRegistry.java @@ -7,6 +7,8 @@ import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.common.items.DrillItem; import whocraft.tardis_refined.common.items.KeyItem; +import whocraft.tardis_refined.common.items.ScrewdriverItem; +import whocraft.tardis_refined.common.items.ZeitonIngotItem; import java.util.ArrayList; import java.util.List; @@ -22,9 +24,13 @@ public class ItemRegistry { public static final DeferredRegistry ITEMS = DeferredRegistry.create(TardisRefined.MODID, Registries.ITEM); public static final RegistrySupplier KEY = register("tardis_key", () -> new KeyItem(new Item.Properties().stacksTo(1)), true); + public static final RegistrySupplier SCREWDRIVER = register("amethyst_screwdriver", () -> new ScrewdriverItem(new Item.Properties().stacksTo(1)), true); public static final RegistrySupplier PATTERN_MANIPULATOR = register("pattern_manipulator", () -> new Item(new Item.Properties().stacksTo(1)), true); public static final RegistrySupplier DRILL = register("drill", () -> new DrillItem(new Item.Properties().stacksTo(1)), true); + public static final RegistrySupplier RAW_ZEITON = register("raw_zeiton", () -> new Item(new Item.Properties()), true); + public static final RegistrySupplier ZEITON_INGOT = register("zeiton_ingot", () -> new ZeitonIngotItem(new Item.Properties()), true); + private static RegistrySupplier register(String id, Supplier itemSupplier, boolean addToTab) { diff --git a/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java b/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java index a4dd5c7e0..8e6f1cf91 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java @@ -22,6 +22,12 @@ public class SoundRegistry { public static final RegistrySupplier HUM_CORAL = setUpSound("hum_coral"); public static final RegistrySupplier INTERIOR_CREAKS = setUpSound("interior_creaks"); + + // Screwdriver + public static final RegistrySupplier SCREWDRIVER_SHORT = setUpSound("screwdriver_short"); + public static final RegistrySupplier SCREWDRIVER_CONNECT = setUpSound("screwdriver_connect"); + public static final RegistrySupplier SCREWDRIVER_DISCARD = setUpSound("screwdriver_discard"); + private static RegistrySupplier setUpSound(String soundName) { SoundEvent sound = SoundEvent.createVariableRangeEvent(new ResourceLocation(TardisRefined.MODID, soundName)); return SOUNDS.register(soundName, () -> sound); diff --git a/common/src/main/resources/assets/tardis_refined/models/item/amethyst_screwdriver.json b/common/src/main/resources/assets/tardis_refined/models/item/amethyst_screwdriver.json new file mode 100644 index 000000000..61d92eb96 --- /dev/null +++ b/common/src/main/resources/assets/tardis_refined/models/item/amethyst_screwdriver.json @@ -0,0 +1,147 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [64, 64], + "textures": { + "0": "tardis_refined:item/amethyst_screwdriver", + "particle": "tardis_refined:item/amethyst_screwdriver" + }, + "elements": [ + { + "from": [6.8, 6.8, 6.8], + "to": [9.2, 9.2, 9.2], + "rotation": {"angle": 0, "axis": "y", "origin": [0, -1, 0]}, + "faces": { + "north": {"uv": [1.5, 3.25, 2, 3.75], "texture": "#0"}, + "east": {"uv": [3.5, 3, 4, 3.5], "texture": "#0"}, + "south": {"uv": [3.5, 3.5, 4, 4], "texture": "#0"}, + "west": {"uv": [1.5, 3.75, 2, 4.25], "texture": "#0"}, + "up": {"uv": [4.5, 0.5, 4, 0], "texture": "#0"}, + "down": {"uv": [4.5, 0.5, 4, 1], "texture": "#0"} + } + }, + { + "from": [6.7, 9.1, 6.7], + "to": [9.3, 10.7, 9.3], + "rotation": {"angle": 0, "axis": "y", "origin": [0, -1, 0]}, + "faces": { + "north": {"uv": [4, 3.5, 4.5, 3.75], "texture": "#0"}, + "east": {"uv": [4, 3.75, 4.5, 4], "texture": "#0"}, + "south": {"uv": [4, 4, 4.5, 4.25], "texture": "#0"}, + "west": {"uv": [1.5, 4.25, 2, 4.5], "texture": "#0"}, + "up": {"uv": [4.5, 1.5, 4, 1], "texture": "#0"}, + "down": {"uv": [4.5, 1.5, 4, 2], "texture": "#0"} + } + }, + { + "from": [7.2, 14, 7.2], + "to": [8.8, 20.6, 8.8], + "rotation": {"angle": 0, "axis": "y", "origin": [0, -1, 0]}, + "faces": { + "north": {"uv": [3, 3, 3.5, 4.75], "texture": "#0"}, + "east": {"uv": [0, 3.25, 0.5, 5], "texture": "#0"}, + "south": {"uv": [0.5, 3.25, 1, 5], "texture": "#0"}, + "west": {"uv": [1, 3.25, 1.5, 5], "texture": "#0"}, + "up": {"uv": [4.5, 2.5, 4, 2], "texture": "#0"}, + "down": {"uv": [4.5, 2.5, 4, 3], "texture": "#0"} + } + }, + { + "from": [7, 1, 7], + "to": [9, 14, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, -1, 0]}, + "faces": { + "north": {"uv": [0, 0, 0.5, 3.25], "texture": "#0"}, + "east": {"uv": [0.5, 0, 1, 3.25], "texture": "#0"}, + "south": {"uv": [1, 0, 1.5, 3.25], "texture": "#0"}, + "west": {"uv": [1.5, 0, 2, 3.25], "texture": "#0"}, + "up": {"uv": [4.5, 3.5, 4, 3], "texture": "#0"}, + "down": {"uv": [4, 4, 3.5, 4.5], "texture": "#0"} + } + }, + { + "from": [7.5, 0, 7.5], + "to": [8.5, 21.6, 8.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, -1, 0]}, + "faces": { + "north": {"uv": [2, 3, 2.25, 8.5], "texture": "#0"}, + "east": {"uv": [2.25, 3, 2.5, 8.5], "texture": "#0"}, + "south": {"uv": [2.5, 3, 2.75, 8.5], "texture": "#0"}, + "west": {"uv": [2.75, 3, 3, 8.5], "texture": "#0"}, + "up": {"uv": [4.25, 4.5, 4, 4.25], "texture": "#0"}, + "down": {"uv": [4.5, 4.25, 4.25, 4.5], "texture": "#0"} + } + }, + { + "from": [8, 12.8, 6], + "to": [8, 17.8, 10], + "rotation": {"angle": -45, "axis": "y", "origin": [8, 13.3, 8]}, + "faces": { + "north": {"uv": [0, 0, 0, 1.25], "texture": "#0"}, + "east": {"uv": [2, 0, 3, 1.25], "texture": "#0"}, + "south": {"uv": [0, 0, 0, 1.25], "texture": "#0"}, + "west": {"uv": [2, 1.5, 3, 2.75], "texture": "#0"}, + "up": {"uv": [0, 1, 0, 0], "texture": "#0"}, + "down": {"uv": [0, 0, 0, 1], "texture": "#0"} + } + }, + { + "from": [8, 12.8, 6], + "to": [8, 17.8, 10], + "rotation": {"angle": 45, "axis": "y", "origin": [8, 13.3, 8]}, + "faces": { + "north": {"uv": [0, 0, 0, 1.25], "texture": "#0"}, + "east": {"uv": [3, 0, 4, 1.25], "texture": "#0"}, + "south": {"uv": [0, 0, 0, 1.25], "texture": "#0"}, + "west": {"uv": [3, 1.5, 4, 2.75], "texture": "#0"}, + "up": {"uv": [0, 1, 0, 0], "texture": "#0"}, + "down": {"uv": [0, 0, 0, 1], "texture": "#0"} + } + }, + { + "from": [7.5, 7.5, 6.75], + "to": [8.5, 8.5, 7.75], + "faces": { + "north": {"uv": [2, 0.5, 2.25, 0.75], "texture": "#0"}, + "east": {"uv": [2, 5.75, 2.25, 6], "texture": "#0"}, + "south": {"uv": [2, 5.75, 2.25, 6], "texture": "#0"}, + "west": {"uv": [2, 5.75, 2.25, 6], "texture": "#0"}, + "up": {"uv": [2, 5.75, 2.25, 6], "texture": "#0"}, + "down": {"uv": [2, 5.75, 2.25, 6], "texture": "#0"} + } + } + ], + "gui_light": "front", + "display": { + "thirdperson_righthand": { + "translation": [0, 0, 1], + "scale": [0.4, 0.4, 0.4] + }, + "thirdperson_lefthand": { + "translation": [0, 0, 1], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_righthand": { + "rotation": [-12, -13, -16], + "translation": [1.75, 0.25, 0], + "scale": [0.6, 0.6, 0.6] + }, + "firstperson_lefthand": { + "rotation": [-14, -25, -16], + "translation": [1.25, 0.25, 0], + "scale": [0.6, 0.6, 0.6] + }, + "ground": { + "rotation": [18, 82, 59], + "translation": [0, 0, -3] + }, + "gui": { + "rotation": [41, 13, -42], + "translation": [-2.25, -2.25, 0], + "scale": [0.9, 0.9, 0.9] + }, + "fixed": { + "rotation": [-3, 0, 0], + "translation": [0, -4, -1.25] + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tools/screwdriver/screwdriver_connect.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tools/screwdriver/screwdriver_connect.ogg new file mode 100644 index 000000000..4b299cea2 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tools/screwdriver/screwdriver_connect.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tools/screwdriver/screwdriver_discard.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tools/screwdriver/screwdriver_discard.ogg new file mode 100644 index 000000000..86bae4f46 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tools/screwdriver/screwdriver_discard.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tools/screwdriver/screwdriver_short.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tools/screwdriver/screwdriver_short.ogg new file mode 100644 index 000000000..b7fdddd79 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tools/screwdriver/screwdriver_short.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/astral_manipulator.png b/common/src/main/resources/assets/tardis_refined/textures/block/astral_manipulator.png new file mode 100644 index 000000000..d83a0cffb Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/block/astral_manipulator.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/console_configuration.png b/common/src/main/resources/assets/tardis_refined/textures/block/console_configuration.png index 208e8fc18..3b25f7261 100644 Binary files a/common/src/main/resources/assets/tardis_refined/textures/block/console_configuration.png and b/common/src/main/resources/assets/tardis_refined/textures/block/console_configuration.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/deepslate_zeiton_ore.png b/common/src/main/resources/assets/tardis_refined/textures/block/deepslate_zeiton_ore.png new file mode 100644 index 000000000..536032336 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/block/deepslate_zeiton_ore.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/flight_detector.png b/common/src/main/resources/assets/tardis_refined/textures/block/flight_detector.png index a1c893bbe..8c2d6a351 100644 Binary files a/common/src/main/resources/assets/tardis_refined/textures/block/flight_detector.png and b/common/src/main/resources/assets/tardis_refined/textures/block/flight_detector.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/landing_pad.png b/common/src/main/resources/assets/tardis_refined/textures/block/landing_pad.png index f314b468a..ee47e5f5d 100644 Binary files a/common/src/main/resources/assets/tardis_refined/textures/block/landing_pad.png and b/common/src/main/resources/assets/tardis_refined/textures/block/landing_pad.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/transformer_on.png b/common/src/main/resources/assets/tardis_refined/textures/block/transformer_on.png index af9144825..c40a04e32 100644 Binary files a/common/src/main/resources/assets/tardis_refined/textures/block/transformer_on.png and b/common/src/main/resources/assets/tardis_refined/textures/block/transformer_on.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_block.png b/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_block.png new file mode 100644 index 000000000..75b16f5f5 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_block.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_fused_copper_block.png b/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_fused_copper_block.png new file mode 100644 index 000000000..feadb26e7 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_fused_copper_block.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_fused_iron_block.png b/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_fused_iron_block.png new file mode 100644 index 000000000..d7e61cd44 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_fused_iron_block.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_ore.png b/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_ore.png new file mode 100644 index 000000000..6600a38ec Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/block/zeiton_ore.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/item/amethyst_screwdriver.png b/common/src/main/resources/assets/tardis_refined/textures/item/amethyst_screwdriver.png new file mode 100644 index 000000000..c4f56ce6d Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/item/amethyst_screwdriver.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/item/raw_zeiton.png b/common/src/main/resources/assets/tardis_refined/textures/item/raw_zeiton.png new file mode 100644 index 000000000..5ecca4e9c Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/item/raw_zeiton.png differ diff --git a/common/src/main/resources/assets/tardis_refined/textures/item/zeiton_ingot.png b/common/src/main/resources/assets/tardis_refined/textures/item/zeiton_ingot.png new file mode 100644 index 000000000..d35858291 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/textures/item/zeiton_ingot.png differ diff --git a/common/src/main/resources/data/tardis_refined/structures/cave/cave_generation_one.nbt b/common/src/main/resources/data/tardis_refined/structures/cave/cave_generation_one.nbt index 48dae2ccf..a1587243b 100644 Binary files a/common/src/main/resources/data/tardis_refined/structures/cave/cave_generation_one.nbt and b/common/src/main/resources/data/tardis_refined/structures/cave/cave_generation_one.nbt differ diff --git a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java index 2a4a6a88d..2c85211c8 100644 --- a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java +++ b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java @@ -2,15 +2,20 @@ import fuzs.forgeconfigapiport.api.config.v3.ForgeConfigRegistry; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.biome.v1.BiomeModifications; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.minecraft.commands.synchronization.SingletonArgumentInfo; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.resources.PreparableReloadListener; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.level.levelgen.GenerationStep; import net.neoforged.fml.config.ModConfig; import whocraft.tardis_refined.TRConfig; import whocraft.tardis_refined.TardisRefined; @@ -86,5 +91,8 @@ public void onInitialize() { TardisRefined.LOGGER.info("ImmersivePortals was not detected."); } + BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), GenerationStep.Decoration.UNDERGROUND_ORES, ResourceKey.create(Registries.PLACED_FEATURE, new ResourceLocation(TardisRefined.MODID, "ore_zeiton"))); + BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), GenerationStep.Decoration.UNDERGROUND_ORES, ResourceKey.create(Registries.PLACED_FEATURE, new ResourceLocation(TardisRefined.MODID, "ore_zeiton_small"))); + } } \ No newline at end of file diff --git a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabricClient.java b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabricClient.java index 0e700ba5f..fb265d577 100644 --- a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabricClient.java +++ b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabricClient.java @@ -13,6 +13,7 @@ import whocraft.tardis_refined.client.TRParticles; import whocraft.tardis_refined.client.renderer.blockentity.RootPlantRenderer; import whocraft.tardis_refined.client.renderer.blockentity.console.GlobalConsoleRenderer; +import whocraft.tardis_refined.client.renderer.blockentity.device.AstralManipulatorRenderer; import whocraft.tardis_refined.client.renderer.blockentity.device.ConsoleConfigurationRenderer; import whocraft.tardis_refined.client.renderer.blockentity.door.BulkHeadDoorRenderer; import whocraft.tardis_refined.client.renderer.blockentity.door.GlobalDoorRenderer; @@ -54,6 +55,7 @@ private void establishBlockEntityRenderers() { BlockEntityRendererRegistry.register(BlockEntityRegistry.BULK_HEAD_DOOR.get(), BulkHeadDoorRenderer::new); BlockEntityRendererRegistry.register(BlockEntityRegistry.CONSOLE_CONFIGURATION.get(), ConsoleConfigurationRenderer::new); + BlockEntityRendererRegistry.register(BlockEntityRegistry.ASTRAL_MANIPULATOR.get(), AstralManipulatorRenderer::new); /*Required to Render Transparency*/ for (Block block : BlockRegistry.BLOCKS.getRegistry()) { diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/BiomeModifierProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/BiomeModifierProvider.java index fe809cc19..c80dbae3c 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/BiomeModifierProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/BiomeModifierProvider.java @@ -1,19 +1,29 @@ package whocraft.tardis_refined.common.data; +import com.google.common.collect.ImmutableList; +import net.minecraft.core.HolderGetter; import net.minecraft.core.HolderSet; import net.minecraft.core.RegistrySetBuilder; import net.minecraft.core.registries.Registries; import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; +import net.minecraft.data.worldgen.BootstapContext; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BiomeTags; +import net.minecraft.tags.BlockTags; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.VerticalAnchor; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; import net.minecraft.world.level.levelgen.placement.HeightRangePlacement; import net.minecraft.world.level.levelgen.placement.InSquarePlacement; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.placement.RarityFilter; +import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest; +import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest; import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider; import net.neoforged.neoforge.common.world.BiomeModifier; import net.neoforged.neoforge.common.world.BiomeModifiers; @@ -23,43 +33,44 @@ import whocraft.tardis_refined.common.world.Features; import whocraft.tardis_refined.common.world.feature.NbtTemplateFeature; import whocraft.tardis_refined.common.world.feature.config.NbtTemplateFeatureConfig; +import whocraft.tardis_refined.registry.BlockRegistry; import whocraft.tardis_refined.registry.FeatureKeys; import whocraft.tardis_refined.registry.TagKeys; import java.util.List; import java.util.Set; +import static net.minecraft.data.worldgen.features.FeatureUtils.createKey; +import static whocraft.tardis_refined.common.data.ProviderConfiguredFeatures.TARDIS_ROOT_CLUSTER_CONF_FEATURE; +import static whocraft.tardis_refined.common.data.ProviderPlacedFeatures.TARDIS_ROOT_CLUSTER_PLACED_FEATUE; + public class BiomeModifierProvider { - public static final ResourceKey TARDIS_ROOT_CLUSTER_PLACED_FEATUE = ResourceKey.create(Registries.PLACED_FEATURE, FeatureKeys.TARDIS_ROOT_CLUSTER_RL); - public static final ResourceKey> TARDIS_ROOT_CLUSTER_CONF_FEATURE = ResourceKey.create(Registries.CONFIGURED_FEATURE, FeatureKeys.TARDIS_ROOT_CLUSTER_RL); + + private static final ResourceKey ADD_TARDIS_ROOT_CLUSTER = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, FeatureKeys.TARDIS_ROOT_CLUSTER_RL); - public static void genBiomeModifiers(GatherDataEvent e) { - final DataGenerator generator = e.getGenerator(); - final RegistrySetBuilder builder = new RegistrySetBuilder(); + private static final ResourceKey ZEITON = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(TardisRefined.MODID, "zeiton")); + private static final ResourceKey ZEITON_SMALL = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(TardisRefined.MODID, "zeiton_small")); - ResourceLocation templateLocation = new ResourceLocation(TardisRefined.MODID, "cave/tardis_root_cluster_deepslate"); - ConfiguredFeature tardisRootCluster = new ConfiguredFeature<>(Features.NBT_FEATURE.get(), new NbtTemplateFeatureConfig(templateLocation, 0)); - builder.add(Registries.CONFIGURED_FEATURE, context -> context.register(TARDIS_ROOT_CLUSTER_CONF_FEATURE, tardisRootCluster)); - builder.add(Registries.PLACED_FEATURE, context -> context.register(TARDIS_ROOT_CLUSTER_PLACED_FEATUE, new PlacedFeature - (context.lookup(Registries.CONFIGURED_FEATURE).getOrThrow(TARDIS_ROOT_CLUSTER_CONF_FEATURE), - List.of( - RarityFilter.onAverageOnceEvery(25), - InSquarePlacement.spread(), - HeightRangePlacement.uniform(VerticalAnchor.absolute(-50), VerticalAnchor.absolute(20)))) - )); - builder.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, context -> { - var tardisRoot = context.lookup(Registries.BIOME).getOrThrow(TagKeys.TARDIS_ROOT_CLUSTER); + public static void bootstrap(BootstapContext context) { + + var overworldTags = context.lookup(Registries.BIOME).getOrThrow(BiomeTags.IS_OVERWORLD); - context.register(ADD_TARDIS_ROOT_CLUSTER, new BiomeModifiers.AddFeaturesBiomeModifier( - tardisRoot, - HolderSet.direct(context.lookup(Registries.PLACED_FEATURE).getOrThrow(TARDIS_ROOT_CLUSTER_PLACED_FEATUE)), - GenerationStep.Decoration.LOCAL_MODIFICATIONS - )); - }); + HolderGetter placed = context.lookup(Registries.PLACED_FEATURE); - final DataProvider biomeModifierProvider = new DatapackBuiltinEntriesProvider(generator.getPackOutput(), e.getLookupProvider(), builder, Set.of(TardisRefined.MODID)); - generator.addProvider(e.includeServer(), biomeModifierProvider); + BiomeModifiers.AddFeaturesBiomeModifier oreModifer = new BiomeModifiers.AddFeaturesBiomeModifier(overworldTags, HolderSet.direct(placed.getOrThrow(ProviderPlacedFeatures.ORE_ZEITON)), GenerationStep.Decoration.UNDERGROUND_ORES); + BiomeModifiers.AddFeaturesBiomeModifier oreModiferSmall = new BiomeModifiers.AddFeaturesBiomeModifier(overworldTags, HolderSet.direct(placed.getOrThrow(ProviderPlacedFeatures.ORE_ZEITON_SMALL)), GenerationStep.Decoration.UNDERGROUND_ORES); + + context.register(ZEITON, oreModifer); + context.register(ZEITON_SMALL, oreModiferSmall); + + var tardisRoot = context.lookup(Registries.BIOME).getOrThrow(TagKeys.TARDIS_ROOT_CLUSTER); + + context.register(ADD_TARDIS_ROOT_CLUSTER, new BiomeModifiers.AddFeaturesBiomeModifier( + tardisRoot, + HolderSet.direct(context.lookup(Registries.PLACED_FEATURE).getOrThrow(TARDIS_ROOT_CLUSTER_PLACED_FEATUE)), + GenerationStep.Decoration.LOCAL_MODIFICATIONS + )); } } \ No newline at end of file diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/ItemModelProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/ItemModelProvider.java index a1328ffdd..23867b4d2 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/ItemModelProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/ItemModelProvider.java @@ -7,6 +7,7 @@ import net.neoforged.neoforge.common.data.ExistingFileHelper; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.registry.BlockRegistry; +import whocraft.tardis_refined.registry.ItemRegistry; public class ItemModelProvider extends net.neoforged.neoforge.client.model.generators.ItemModelProvider { @@ -24,6 +25,12 @@ protected void registerModels() { blockItem(BlockRegistry.FOOLS_STONE.getId()); blockItem(BlockRegistry.FLIGHT_DETECTOR.getId()); + blockItem(BlockRegistry.ASTRAL_MANIPULATOR_BLOCK.getId()); + blockItem(BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.getId()); + blockItem(BlockRegistry.ZEITON_FUSED_IRON_BLOCK.getId()); + blockItem(BlockRegistry.ZEITON_ORE.getId()); + blockItem(BlockRegistry.ZEITON_ORE_DEEPSLATE.getId()); + blockItem(BlockRegistry.ZEITON_BLOCK.getId()); ResourceLocation leavesTexture = new ResourceLocation("tardis_refined:block/ars_leaves"); @@ -41,6 +48,12 @@ protected void registerModels() { basicItem(BlockRegistry.ROOT_SHELL_DOOR.getId()); basicItem(BlockRegistry.GLOBAL_DOOR_BLOCK.getId()); basicItem(BlockRegistry.GLOBAL_SHELL_BLOCK.getId()); + basicItem(ItemRegistry.ZEITON_INGOT.getId()); + basicItem(ItemRegistry.RAW_ZEITON.getId()); + + + + } diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java b/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java index 3f97de439..a97e50f34 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java @@ -56,6 +56,12 @@ protected void addTranslations() { add(BlockRegistry.FOOLS_STONE.get(), "Fool's Stone"); add(BlockRegistry.FLIGHT_DETECTOR.get(), "Flight Detector"); add(BlockRegistry.GLOBAL_SHELL_BLOCK.get(), "TARDIS"); + add(BlockRegistry.ASTRAL_MANIPULATOR_BLOCK.get(), "Astral Manipulator"); + add(BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get(), "Zeiton Fused Iron Block"); + add(BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.get(), "Zeiton Fused Copper Block"); + add(BlockRegistry.ZEITON_ORE.get(), "Zeiton Ore"); + add(BlockRegistry.ZEITON_ORE_DEEPSLATE.get(), "Deepslate Zeiton Ore"); + add(BlockRegistry.ZEITON_BLOCK.get(), "Block of Zeiton"); /*Items*/ add(ItemRegistry.PATTERN_MANIPULATOR.get(), "Pattern Manipulator"); @@ -63,6 +69,12 @@ protected void addTranslations() { add(ItemRegistry.DRILL.get(), "Growth Drill"); add(ModMessages.ITEM_KEYCHAIN, "Tardis Keyset"); add(ModMessages.ITEM_GROUP, "Tardis Refined"); + add(ItemRegistry.SCREWDRIVER.get(), "Amethyst Screwdriver"); + add(ModMessages.TOOLTIP_SCREWDRIVER_DESCRIPTION, "An amethyst frequency manipulator"); + add(ItemRegistry.ZEITON_INGOT.get(), "Zeiton Ingot"); + add(ItemRegistry.RAW_ZEITON.get(), "Raw Zeiton"); + + /*Entity*/ add(EntityRegistry.CONTROL_ENTITY.get(), "Generic Control"); diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderBlockTags.java b/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderBlockTags.java index fcfa26231..b58acacc4 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderBlockTags.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderBlockTags.java @@ -52,13 +52,26 @@ protected void addTags(HolderLookup.Provider provider) { .add(BlockRegistry.LANDING_PAD.get()) .add(BlockRegistry.FLIGHT_DETECTOR.get()) .add(BlockRegistry.TERRAFORMER_BLOCK.get()) + .add(BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()) + .add(BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.get()) + .add(BlockRegistry.ZEITON_ORE_DEEPSLATE.get()) + .add(BlockRegistry.ZEITON_ORE.get()) + .add(BlockRegistry.ASTRAL_MANIPULATOR_BLOCK.get()) + .add(BlockRegistry.ZEITON_BLOCK.get()) .add(BlockRegistry.ROOT_PLANT_BLOCK.get()); tag(BlockTags.NEEDS_IRON_TOOL) .add(BlockRegistry.CONSOLE_CONFIGURATION_BLOCK.get()) .add(BlockRegistry.LANDING_PAD.get()) .add(BlockRegistry.FLIGHT_DETECTOR.get()) - .add(BlockRegistry.TERRAFORMER_BLOCK.get()); + .add(BlockRegistry.TERRAFORMER_BLOCK.get()) + .add(BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()) + .add(BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.get()) + .add(BlockRegistry.ZEITON_ORE_DEEPSLATE.get()) + .add(BlockRegistry.ZEITON_ORE.get()) + .add(BlockRegistry.ASTRAL_MANIPULATOR_BLOCK.get()) + .add(BlockRegistry.ZEITON_BLOCK.get()) + .add(BlockRegistry.ASTRAL_MANIPULATOR_BLOCK.get()); } } diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderConfiguredFeatures.java b/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderConfiguredFeatures.java new file mode 100644 index 000000000..ec5bf8d6b --- /dev/null +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderConfiguredFeatures.java @@ -0,0 +1,57 @@ +package whocraft.tardis_refined.common.data; + +import com.google.common.collect.ImmutableList; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; +import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest; +import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.common.world.Features; +import whocraft.tardis_refined.common.world.feature.NbtTemplateFeature; +import whocraft.tardis_refined.common.world.feature.config.NbtTemplateFeatureConfig; +import whocraft.tardis_refined.registry.BlockRegistry; +import whocraft.tardis_refined.registry.FeatureKeys; + +public class ProviderConfiguredFeatures { + + public static final ResourceKey> ORE_ZEITON = createKey("ore_zeiton"); + public static final ResourceKey> ORE_ZEITON_SMALL = createKey("ore_zeiton_small"); + public static final ResourceKey> TARDIS_ROOT_CLUSTER_CONF_FEATURE = ResourceKey.create(Registries.CONFIGURED_FEATURE, FeatureKeys.TARDIS_ROOT_CLUSTER_RL); + + public static ResourceKey> createKey(String name) { + return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(TardisRefined.MODID, name)); + } + + public static void bootstrap(BootstapContext> context) { + + RuleTest stoneReplaceable = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES); + RuleTest deepslateReplaceable = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES); + + ResourceLocation templateLocation = new ResourceLocation(TardisRefined.MODID, "cave/tardis_root_cluster_deepslate"); + ConfiguredFeature tardisRootCluster = new ConfiguredFeature<>(Features.NBT_FEATURE.get(), new NbtTemplateFeatureConfig(templateLocation, 0)); + + HolderGetter> configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE); + register(context, ORE_ZEITON, Feature.ORE, new OreConfiguration(ImmutableList.of(OreConfiguration.target(stoneReplaceable, BlockRegistry.ZEITON_ORE.get().defaultBlockState()), OreConfiguration.target(deepslateReplaceable, BlockRegistry.ZEITON_ORE_DEEPSLATE.get().defaultBlockState())), 9)); + register(context, ORE_ZEITON_SMALL, Feature.ORE, new OreConfiguration(ImmutableList.of(OreConfiguration.target(stoneReplaceable,BlockRegistry.ZEITON_ORE.get().defaultBlockState()), OreConfiguration.target(deepslateReplaceable, BlockRegistry.ZEITON_ORE_DEEPSLATE.get().defaultBlockState())), 4)); + context.register(TARDIS_ROOT_CLUSTER_CONF_FEATURE, tardisRootCluster); + } + + public static void register(BootstapContext> context, ResourceKey> key, Feature feature) { + register(context, key, feature, FeatureConfiguration.NONE); + } + + public static > void register(BootstapContext> context, ResourceKey> key, F feature, FC configuration) { + context.register(key, new ConfiguredFeature<>(feature, configuration)); + } + + +} diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderLootTable.java b/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderLootTable.java index 3c5366b16..850f8df11 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderLootTable.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderLootTable.java @@ -11,8 +11,10 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.registry.BlockRegistry; import whocraft.tardis_refined.registry.EntityRegistry; +import whocraft.tardis_refined.registry.ItemRegistry; import java.util.ArrayList; import java.util.List; @@ -36,6 +38,9 @@ protected void generate() { for (Block block : getKnownBlocks()) { dropSelf(block); } + + this.add(BlockRegistry.ZEITON_ORE.get(), (block) -> createOreDrop(block, ItemRegistry.RAW_ZEITON.get())); + this.add(BlockRegistry.ZEITON_ORE_DEEPSLATE.get(), (block) -> createOreDrop(block, ItemRegistry.RAW_ZEITON.get())); } @Override diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderPlacedFeatures.java b/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderPlacedFeatures.java new file mode 100644 index 000000000..5a1959a6d --- /dev/null +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/ProviderPlacedFeatures.java @@ -0,0 +1,62 @@ +package whocraft.tardis_refined.common.data; + +import net.minecraft.core.Holder; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.VerticalAnchor; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.placement.*; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.registry.FeatureKeys; + +import java.util.List; + +import static whocraft.tardis_refined.common.data.ProviderConfiguredFeatures.TARDIS_ROOT_CLUSTER_CONF_FEATURE; + +public class ProviderPlacedFeatures { + + public static final ResourceKey TARDIS_ROOT_CLUSTER_PLACED_FEATUE = ResourceKey.create(Registries.PLACED_FEATURE, FeatureKeys.TARDIS_ROOT_CLUSTER_RL); + public static final ResourceKey ORE_ZEITON = createKey("ore_zeiton"); + public static final ResourceKey ORE_ZEITON_SMALL = createKey("ore_zeiton_small"); + + + public static void bootstrap(BootstapContext context) { + HolderGetter> configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE); + + context.register(TARDIS_ROOT_CLUSTER_PLACED_FEATUE, new PlacedFeature + (context.lookup(Registries.CONFIGURED_FEATURE).getOrThrow(TARDIS_ROOT_CLUSTER_CONF_FEATURE), + List.of( + RarityFilter.onAverageOnceEvery(25), + InSquarePlacement.spread(), + HeightRangePlacement.uniform(VerticalAnchor.absolute(-50), VerticalAnchor.absolute(20)))) + ); + + + register(context, ORE_ZEITON, configuredFeatures.getOrThrow(ProviderConfiguredFeatures.ORE_ZEITON), List.copyOf(commonOrePlacement(10, HeightRangePlacement.triangle(VerticalAnchor.absolute(-24), VerticalAnchor.absolute(56))))); + register(context, ORE_ZEITON_SMALL, configuredFeatures.getOrThrow(ProviderConfiguredFeatures.ORE_ZEITON_SMALL), List.copyOf(commonOrePlacement(10, HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(72))))); + + } + + public static ResourceKey createKey(String name) { + return ResourceKey.create(Registries.PLACED_FEATURE, new ResourceLocation(TardisRefined.MODID, name)); + } + + private static List orePlacement(PlacementModifier plMod, PlacementModifier plMod2) { + return List.of(plMod, InSquarePlacement.spread(), plMod2, BiomeFilter.biome(), RarityFilter.onAverageOnceEvery(3)); + } + + public static List commonOrePlacement(int amt, PlacementModifier plMod) { + return orePlacement(CountPlacement.of(amt), plMod); + } + + public static void register(BootstapContext context, ResourceKey key, Holder> configuration, List modifiers) { + context.register(key, new PlacedFeature(configuration, List.copyOf(modifiers))); + } + + public static void register(BootstapContext context, ResourceKey key, Holder> configuration, PlacementModifier... modifiers) { + register(context, key, configuration, List.of(modifiers)); + } +} diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/RecipeProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/RecipeProvider.java index f819fe41a..9cdc691c5 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/RecipeProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/RecipeProvider.java @@ -2,12 +2,12 @@ import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; -import net.minecraft.data.recipes.RecipeCategory; -import net.minecraft.data.recipes.RecipeOutput; -import net.minecraft.data.recipes.ShapedRecipeBuilder; -import net.minecraft.data.recipes.ShapelessRecipeBuilder; +import net.minecraft.data.recipes.*; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.Blocks; +import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.registry.BlockRegistry; import whocraft.tardis_refined.registry.ItemRegistry; @@ -21,17 +21,25 @@ public RecipeProvider(DataGenerator arg, CompletableFuture lookupProvider) { + super(output, lookupProvider, BUILDER, Set.of(TardisRefined.MODID)); + } + + public static HolderLookup.Provider createLookup() { + return BUILDER.buildPatch(RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY), VanillaRegistries.createLookup()); + } + +} diff --git a/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientModBus.java b/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientModBus.java index 51ffcae38..9cae4def7 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientModBus.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/ClientModBus.java @@ -19,6 +19,7 @@ import whocraft.tardis_refined.client.neoforge.ModelRegistryImpl; import whocraft.tardis_refined.client.renderer.blockentity.RootPlantRenderer; import whocraft.tardis_refined.client.renderer.blockentity.console.GlobalConsoleRenderer; +import whocraft.tardis_refined.client.renderer.blockentity.device.AstralManipulatorRenderer; import whocraft.tardis_refined.client.renderer.blockentity.device.ConsoleConfigurationRenderer; import whocraft.tardis_refined.client.renderer.blockentity.door.BulkHeadDoorRenderer; import whocraft.tardis_refined.client.renderer.blockentity.door.GlobalDoorRenderer; @@ -68,6 +69,7 @@ public static void onClientSetup(FMLClientSetupEvent event) { BlockEntityRenderers.register(BlockEntityRegistry.ARS_EGG.get(), ArsEggRenderer::new); BlockEntityRenderers.register(BlockEntityRegistry.BULK_HEAD_DOOR.get(), BulkHeadDoorRenderer::new); BlockEntityRenderers.register(BlockEntityRegistry.CONSOLE_CONFIGURATION.get(), ConsoleConfigurationRenderer::new); + BlockEntityRenderers.register(BlockEntityRegistry.ASTRAL_MANIPULATOR.get(), AstralManipulatorRenderer::new); EntityRenderers.register(EntityRegistry.CONTROL_ENTITY.get(), ControlEntityRenderer::new); } diff --git a/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java b/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java index 16a20f4d0..c8b493a53 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java @@ -47,6 +47,7 @@ public void onGatherData(GatherDataEvent e) { /*Data Pack*/ generator.addProvider(e.includeServer(), new ProviderBlockTags(generator.getPackOutput(), e.getLookupProvider(), e.getExistingFileHelper())); + generator.addProvider(e.includeServer(), new WorldGenProvider(generator.getPackOutput(), e.getLookupProvider())); generator.addProvider(e.includeServer(), new ProviderLootTable(generator.getPackOutput())); generator.addProvider(e.includeServer(), new RecipeProvider(generator, e.getLookupProvider())); generator.addProvider(e.includeServer(), new ConsolePatternProvider(generator)); @@ -59,7 +60,5 @@ public void onGatherData(GatherDataEvent e) { generator.addProvider(e.includeServer(), new ProviderEntityTags(generator.getPackOutput(), e.getLookupProvider(), e.getExistingFileHelper())); - //World Gen - BiomeModifierProvider.genBiomeModifiers(e); } } \ No newline at end of file