Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
48d5120
Merge "Various internal machine api improvements" (#900)
Swedz Nov 21, 2024
7c90a8b
Add structure-like support for multiblock shapes
Swedz Nov 21, 2024
c86c38b
Blockstates respect orientation in ShapeMatcher
Swedz Nov 21, 2024
37a07f3
Properly handle template and in-world block state rotations
Swedz Nov 22, 2024
41c2d80
Add show bounds toggle to the controller
Swedz Nov 22, 2024
1f05126
Use file exists checks
Swedz Nov 22, 2024
61b7fa5
Improve controller bounds checks
Swedz Nov 22, 2024
af8eafb
Check save file success
Swedz Nov 22, 2024
c52957f
Datagen
Swedz Nov 22, 2024
b58ab6c
Handle structure user mistakes and send an informative message
Swedz Nov 22, 2024
8136dda
Refactor structure storing format to store members directly
Swedz Nov 22, 2024
5062c9a
Edit todo comments to use my name so I know which ones are mine
Swedz Nov 22, 2024
f1742c5
Respect rotations in ShapeMatcher build multiblock method
Swedz Nov 22, 2024
c785fe0
Add structures build command for testing structures
Swedz Nov 22, 2024
2985081
Spotless
Swedz Nov 22, 2024
433b30c
Make structure blocks indestructible
Swedz Nov 22, 2024
1014022
Ignore air and void blocks when serializing structure
Swedz Nov 22, 2024
a30f271
Remove unused method
Swedz Nov 22, 2024
b84035a
Include hatch casing in the structure file
Swedz Nov 22, 2024
17eaa18
Parameter null checks
Swedz Nov 22, 2024
3a6eafa
Only store blocks with a member
Swedz Nov 22, 2024
cef0fb4
Fix loading blockstates too early
Swedz Nov 22, 2024
5653a1e
Remove old todo
Swedz Nov 23, 2024
10d4c81
Render error boxes on misconfigured structure blocks when trying to save
Swedz Nov 23, 2024
ce02db2
Add support for reading structure files from both mod jars and the ga…
Swedz Nov 23, 2024
882d1bf
Use correct variable when saving the structure id for a controller
Swedz Nov 23, 2024
c652e5f
Add button to load structures from the controller
Swedz Nov 23, 2024
3b42812
Remove structure multiblock hatch block in favor of the member block …
Swedz Nov 23, 2024
98a2146
Rename StructureMultiblockFormatters to StructureMultiblockInputForma…
Swedz Nov 23, 2024
64025da
Consistent param names
Swedz Nov 23, 2024
24615a7
Add member mode to explicitly require hatch fields when hatch mode is…
Swedz Nov 23, 2024
c2b9576
Make structure member use blockstates to store mode and add variable …
Swedz Nov 24, 2024
c402aca
Use "type" instead of "id" for structure member tests
Swedz Nov 24, 2024
703af39
Move the controller and member structure blocks to their own packages
Swedz Nov 24, 2024
d7dd7ad
Improve wording on variable member mode
Swedz Nov 24, 2024
36ad202
Clean up structure member internals
Swedz Nov 24, 2024
701d04c
Use assertLoaded
Swedz Nov 24, 2024
5b2e4f3
Clean up structure member and member test internals to do proper load…
Swedz Nov 24, 2024
c4ced43
Dont set null values
Swedz Nov 24, 2024
e6b118b
Remove structure test command
Swedz Nov 25, 2024
2152731
Check structure variable member name directly
Swedz Nov 25, 2024
3c7e690
Let controllers save to the current manager so controllers can load n…
Swedz Nov 25, 2024
2cbe7f4
Split simple and literal member types so they are loaded differently
Swedz Nov 25, 2024
d6e1687
Use "hatch_flags" to store hatch flags instead of "flags"
Swedz Nov 25, 2024
560823c
Display data about the member block in the icon and tooltip
Swedz Nov 25, 2024
69bd85f
Clean up structure block item tooltip internals
Swedz Nov 26, 2024
617ddf5
Remove unnecessary variables
Swedz Nov 26, 2024
6f1c3eb
Use codecs to save and read structures as json
Swedz Nov 27, 2024
3fa4c56
Require that structure ids include [0-9a-z_:] only to prevent subdire…
Swedz Nov 27, 2024
f14404d
Retain mode value when resizing edit screen
Swedz Nov 27, 2024
0e6241a
Accurately get width of tooltip lines
Swedz Nov 27, 2024
4885763
Move structure edit screens to better fitting package
Swedz Nov 27, 2024
1bcda12
Remove unnecessary constant fields
Swedz Nov 27, 2024
12015ef
Use Lazy<BlockState> for the lazy blockstate codec instead of a supplier
Swedz Nov 27, 2024
625cf9b
Clean up lazy codec creating
Swedz Nov 27, 2024
404d0b4
Clean up structure member tooltip and make casings render as an item
Swedz Nov 27, 2024
3e1e4b6
Structure member tooltip to use translatable text, blocks to render i…
Swedz Nov 27, 2024
0252246
Render hatch icons on structure member tooltip
Swedz Nov 27, 2024
ac97d87
Account for liquid blocks in the member tooltip
Swedz Nov 27, 2024
502f368
Include casing id in the tooltip
Swedz Nov 27, 2024
574d9b9
Merge "Make machine model api more extensible" (#945)
Swedz Nov 27, 2024
c3c9a92
Use machine casing translations instead of casing id
Swedz Nov 27, 2024
93aeb3b
Merge "Make machine model api more extensible" (#945)
Swedz Nov 27, 2024
6cda560
Adjust text colors to be more consistent with other tooltips
Swedz Nov 27, 2024
9704b49
Display preview block name in tooltip
Swedz Nov 27, 2024
2434caf
Add actual translations for gui
Swedz Nov 28, 2024
4995ce0
Sort MIText
Swedz Nov 28, 2024
20047f2
Allow multiblock structures to save and compare block entity nbt
Swedz Nov 28, 2024
3c54deb
Listen to block entity updates for multiblock rematching
Swedz Nov 29, 2024
84ae34b
Handle block entity matching on the server instead of client
Swedz Nov 29, 2024
c247f26
Consistency
Swedz Nov 29, 2024
148530c
Only send machine update if the mismatching blocks actually changed
Swedz Nov 30, 2024
92dcba5
Fix delay and flickering with multiblock display in world
Swedz Nov 30, 2024
63a7776
Dont try to place blocks outside of the world
Swedz Nov 30, 2024
2e902f8
Force load lazy block states as soon as possible
Swedz Nov 30, 2024
ffdf5bb
Remove field for casing in controller
Swedz Nov 30, 2024
41f556a
Only render controller bounds if in save mode
Swedz Dec 1, 2024
df97b56
Config option to export all mod structure files
Swedz Dec 1, 2024
9742acf
Load cable tiers before structures so that structures can use the cab…
Swedz Dec 1, 2024
9f04d83
Make (most) MI multiblocks use structures!
Swedz Dec 1, 2024
5566517
Add structure wrench item
Swedz Dec 2, 2024
2f2456f
Properly ignore nbt checks if there is no nbt on the member
Swedz Dec 2, 2024
6a11612
Add nbt mode functionality for member blocks and the structure wrench
Swedz Dec 2, 2024
43dd8af
Add item tooltip to structure controller
Swedz Dec 2, 2024
85d96a9
Tooltip wording
Swedz Dec 2, 2024
7c2c6af
Render tooltip to screen when looking at a structure block with wrenc…
Swedz Dec 2, 2024
f69af3a
Only render tooltip to screen if no screen is open
Swedz Dec 2, 2024
26958fa
Merge branch 'refs/heads/1.21.x' into structure-multiblocks
Swedz Feb 9, 2025
85bcad8
Fix conflicts
Swedz Feb 9, 2025
666681f
Allow structure void to be used in structures to define literal air
Swedz Feb 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions src/client/java/aztech/modern_industrialization/MIClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
import aztech.modern_industrialization.blocks.storage.barrel.DeferredBarrelTextRenderer;
import aztech.modern_industrialization.blocks.storage.barrel.client.BarrelTooltipComponent;
import aztech.modern_industrialization.blocks.storage.tank.TankRenderer;
import aztech.modern_industrialization.blocks.structure.StructureMultiblockControllerBER;
import aztech.modern_industrialization.blocks.structure.member.StructureMemberMode;
import aztech.modern_industrialization.blocks.structure.member.StructureMultiblockMemberBlockItem;
import aztech.modern_industrialization.client.MIRenderTypes;
import aztech.modern_industrialization.datagen.MIDatagenClient;
import aztech.modern_industrialization.datagen.MIDatagenServer;
import aztech.modern_industrialization.datagen.model.DelegatingModelBuilder;
import aztech.modern_industrialization.items.ConfigCardItem;
import aztech.modern_industrialization.items.RedstoneControlModuleItem;
import aztech.modern_industrialization.items.SteamDrillHighlight;
import aztech.modern_industrialization.items.SteamDrillItem;
import aztech.modern_industrialization.items.SteamDrillTooltipComponent;
import aztech.modern_industrialization.items.*;
import aztech.modern_industrialization.items.armor.ClientKeyHandler;
import aztech.modern_industrialization.items.armor.HudRenderer;
import aztech.modern_industrialization.items.armor.JetpackParticleAdder;
import aztech.modern_industrialization.items.client.ClientConfigCardTooltip;
import aztech.modern_industrialization.items.client.ClientStructureMemberBlockTooltip;
import aztech.modern_industrialization.machines.MachineBlock;
import aztech.modern_industrialization.machines.MachineBlockEntityRenderer;
import aztech.modern_industrialization.machines.MachineOverlayClient;
Expand Down Expand Up @@ -105,6 +105,7 @@
import net.neoforged.neoforge.data.event.GatherDataEvent;
import net.neoforged.neoforge.event.AddPackFindersEvent;
import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent;
import net.neoforged.neoforge.event.level.LevelEvent;

@EventBusSubscriber(value = Dist.CLIENT, modid = MI.ID, bus = EventBusSubscriber.Bus.MOD)
public class MIClient {
Expand Down Expand Up @@ -151,6 +152,11 @@ private static void init(FMLConstructModEvent ignored) {
}
}
});
NeoForge.EVENT_BUS.addListener(LevelEvent.Unload.class, event -> {
if (event.getLevel().isClientSide()) {
StructureMultiblockControllerBER.setMisconfigured(List.of());
}
});

modBus.addListener(GatherDataEvent.class, event -> {
MIDatagenClient.configure(
Expand Down Expand Up @@ -240,6 +246,7 @@ private static void registerBlockEntityRenderers(FMLClientSetupEvent event) {

BlockEntityRenderers.register(MIRegistries.CREATIVE_BARREL_BE.get(), context -> new BarrelRenderer(0x000000));
BlockEntityRenderers.register(MIRegistries.CREATIVE_TANK_BE.get(), context -> new TankRenderer(0x000000));
BlockEntityRenderers.register(MIRegistries.STRUCTURE_MULTIBLOCK_CONTROLLER_BE.get(), context -> new StructureMultiblockControllerBER());

blockEntityRendererRegistrations.forEach(Runnable::run);
}
Expand All @@ -249,11 +256,14 @@ private static void registerClientTooltipComponents(RegisterClientTooltipCompone
event.register(BarrelTooltipData.class, BarrelTooltipComponent::new);
event.register(ConfigCardItem.TooltipData.class, ClientConfigCardTooltip::new);
event.register(SteamDrillItem.SteamDrillTooltipData.class, SteamDrillTooltipComponent::new);
event.register(StructureMultiblockMemberBlockItem.TooltipData.class, ClientStructureMemberBlockTooltip::new);
}

@SubscribeEvent
private static void registerGuiOverlays(RegisterGuiLayersEvent event) {
event.registerAbove(VanillaGuiLayers.SELECTED_ITEM_NAME, MI.id("activation_status"), HudRenderer::onRenderHud);
event.registerAbove(VanillaGuiLayers.SELECTED_ITEM_NAME, MI.id("structure_multiblock_wrench"),
StructureMultiblockWrenchHighlight::onRenderHud);
}

@SubscribeEvent
Expand All @@ -268,6 +278,18 @@ private static void registerItemProperties(FMLClientSetupEvent event) {
(stack, level, entity, seed) -> {
return RedstoneControlModuleItem.isRequiresLowSignal(stack) ? 0 : 1;
});
ItemProperties.register(MIBlock.STRUCTURE_MULTIBLOCK_MEMBER.asItem(), MI.id("member_mode"),
(stack, level, entity, seed) -> {
StructureMemberMode mode = StructureMultiblockMemberBlockItem.getMode(stack);
if (mode == null) {
return 0;
}
return switch (mode) {
case SIMPLE -> 0.0f;
case HATCH -> 0.5f;
case VARIABLE -> 1.0f;
};
});
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* MIT License
*
* Copyright (c) 2020 Azercoco & Technici4n
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package aztech.modern_industrialization.blocks.structure;

import aztech.modern_industrialization.blocks.structure.controller.StructureControllerBounds;
import aztech.modern_industrialization.blocks.structure.controller.StructureControllerMode;
import aztech.modern_industrialization.blocks.structure.controller.StructureMultiblockControllerBlockEntity;
import aztech.modern_industrialization.util.RenderHelper;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.AABB;

public final class StructureMultiblockControllerBER implements BlockEntityRenderer<StructureMultiblockControllerBlockEntity> {
private static List<BlockPos> MISCONFIGURED_BLOCKS = new ArrayList<>();

public static void setMisconfigured(List<BlockPos> positions) {
MISCONFIGURED_BLOCKS = new ArrayList<>(positions);
}

public static void forgetMisconfigured(List<BlockPos> positions) {
MISCONFIGURED_BLOCKS.removeAll(positions);
}

@Override
public void render(StructureMultiblockControllerBlockEntity be, float tickDelta, PoseStack matrices, MultiBufferSource vcp, int light,
int overlay) {
if (be.getMode() == StructureControllerMode.SAVE) {
BlockPos pos = be.getBlockPos();
StructureControllerBounds bounds = be.getBounds();

AABB box = bounds.aabb();
if (box != null) {
if ((System.currentTimeMillis() / 500L) % 2 == 0) {
AABB worldBox = box.move(pos);
for (BlockPos misconfiguredPos : MISCONFIGURED_BLOCKS) {
if (worldBox.contains(misconfiguredPos.getX(), misconfiguredPos.getY(), misconfiguredPos.getZ())) {
matrices.pushPose();
matrices.translate(misconfiguredPos.getX() - pos.getX(), misconfiguredPos.getY() - pos.getY(),
misconfiguredPos.getZ() - pos.getZ());
matrices.translate(-0.005f, -0.005f, -0.005f);
matrices.scale(1.01f, 1.01f, 1.01f);
// TODO SWEDZ: render red overlay (255, 111, 111)
RenderHelper.drawOverlay(matrices, vcp, overlay);
matrices.popPose();
}
}
}

if (be.shouldShowBounds()) {
matrices.pushPose();
VertexConsumer buffer = vcp.getBuffer(RenderType.lines());
LevelRenderer.renderLineBox(matrices, buffer, box, 1, 1, 1, 1);
matrices.popPose();
}
}
}
}

@Override
public boolean shouldRenderOffScreen(StructureMultiblockControllerBlockEntity be) {
return true;
}

@Override
public AABB getRenderBoundingBox(StructureMultiblockControllerBlockEntity be) {
return AABB.INFINITE;
}
}
Loading
Loading