Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.compat.rei.machines.ReiMachineRecipes;
import aztech.modern_industrialization.compat.viewer.abstraction.ViewerCategory;
import aztech.modern_industrialization.machines.multiblocks.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.member.MultiblockMemberState;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
Expand All @@ -42,7 +43,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

public class MultiblockCategory extends ViewerCategory<MultiblockCategory.Recipe> {
Expand Down Expand Up @@ -92,9 +92,10 @@ public Recipe(ResourceLocation controller, ShapeTemplate shapeTemplate, @Nullabl
this.controller = BuiltInRegistries.ITEM.get(controller).getDefaultInstance();
SortedMap<Item, Integer> materials = new TreeMap<>(Comparator.comparing(BuiltInRegistries.ITEM::getKey));

for (var entry : shapeTemplate.simpleMembers.entrySet()) {
BlockState state = entry.getValue().getPreviewState();
Item item = state.getBlock().asItem();
for (var entry : shapeTemplate.members().entrySet()) {
// TODO SWEDZ MULTIBLOCKS: account for nbt
MultiblockMemberState state = entry.getValue().getPreviewState();
Item item = state.state().getBlock().asItem();
if (item != Items.AIR) {
materials.put(item, 1 + materials.getOrDefault(item, 0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.machines.multiblocks;

import aztech.modern_industrialization.machines.multiblocks.shape.member.MultiblockMemberState;
import aztech.modern_industrialization.util.RenderHelper;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.ByteBufferBuilder;
Expand All @@ -32,21 +33,20 @@
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
import net.neoforged.neoforge.common.NeoForge;
import org.jetbrains.annotations.Nullable;

public class MultiblockErrorHighlight {
private static final Map<BlockPos, @Nullable BlockState> highlightQueue = new HashMap<>();
private static final Map<BlockPos, @Nullable MultiblockMemberState> highlightQueue = new HashMap<>();
private static final MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(new ByteBufferBuilder(128));

public static void init() {
NeoForge.EVENT_BUS.addListener(MultiblockErrorHighlight::end);
}

public static void enqueueHighlight(BlockPos pos, @Nullable BlockState state) {
public static void enqueueHighlight(BlockPos pos, @Nullable MultiblockMemberState state) {
highlightQueue.put(pos.immutable(), state);
}

Expand All @@ -59,7 +59,7 @@ private static void end(RenderLevelStageEvent event) {
var poseStack = event.getPoseStack();
poseStack.pushPose();
poseStack.mulPose(event.getModelViewMatrix());
for (Map.Entry<BlockPos, @Nullable BlockState> entry : highlightQueue.entrySet()) {
for (Map.Entry<BlockPos, @Nullable MultiblockMemberState> entry : highlightQueue.entrySet()) {
poseStack.pushPose();
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
BlockPos pos = entry.getKey();
Expand All @@ -69,11 +69,12 @@ private static void end(RenderLevelStageEvent event) {
poseStack.translate(x + 0.25, y + 0.25, z + 0.25);
poseStack.scale(0.5f, 0.5f, 0.5f);

BlockState state = entry.getValue();
MultiblockMemberState state = entry.getValue();
if (state == null) {
RenderHelper.drawCube(poseStack, immediate, 1, 50f / 256, 50f / 256, 15728880, OverlayTexture.NO_OVERLAY);
} else {
Minecraft.getInstance().getBlockRenderer().renderSingleBlock(state, poseStack, immediate, 15728880,
// TODO SWEDZ MULTIBLOCKS: account for nbt + rotation
Minecraft.getInstance().getBlockRenderer().renderSingleBlock(state.state(), poseStack, immediate, 15728880,
OverlayTexture.NO_OVERLAY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import aztech.modern_industrialization.config.MIClientConfig;
import aztech.modern_industrialization.machines.MachineBlock;
import aztech.modern_industrialization.machines.MachineBlockEntityRenderer;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeMatcher;
import aztech.modern_industrialization.machines.multiblocks.shape.member.HatchMultiblockMember;
import aztech.modern_industrialization.util.RenderHelper;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -68,9 +70,9 @@ public void render(MultiblockMachineBlockEntity be, float tickDelta, PoseStack m
matrices.pushPose();
matrices.translate(pos.getX() - be.getBlockPos().getX(), pos.getY() - be.getBlockPos().getY(), pos.getZ() - be.getBlockPos().getZ());

HatchFlags hatchFlag = matcher.getHatchFlags(pos);
if (hatchType != null) {
if (MIClientConfig.INSTANCE.hatchPlacementOverlay.getAsBoolean() && hatchFlag != null && hatchFlag.allows(hatchType)) {
var member = matcher.getMember(pos);
if (hatchType != null && member instanceof HatchMultiblockMember hatchMember) {
if (MIClientConfig.INSTANCE.hatchPlacementOverlay.getAsBoolean() && hatchMember.hatchFlags().allows(hatchType)) {
// Highlight placeable hatches in green
matrices.translate(-0.005, -0.005, -0.005);
matrices.scale(1.01f, 1.01f, 1.01f);
Expand All @@ -82,7 +84,7 @@ public void render(MultiblockMachineBlockEntity be, float tickDelta, PoseStack m
var existingState = be.getLevel().getBlockState(pos);
if (existingState.isAir() || /* approximate check for e.g. grass and snow */ existingState.canBeReplaced()) {
// Enqueue state preview
MultiblockErrorHighlight.enqueueHighlight(pos, matcher.getSimpleMember(pos).getPreviewState());
MultiblockErrorHighlight.enqueueHighlight(pos, matcher.getMember(pos).getPreviewState());
} else {
// Enqueue red cube
MultiblockErrorHighlight.enqueueHighlight(pos, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import aztech.modern_industrialization.machines.init.MultiblockMachines;
import aztech.modern_industrialization.machines.init.SingleBlockCraftingMachines;
import aztech.modern_industrialization.machines.models.MachineCasings;
import aztech.modern_industrialization.machines.multiblocks.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.machines.recipe.MachineRecipeType;
import dev.latvian.mods.kubejs.event.KubeEvent;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
package aztech.modern_industrialization.compat.kubejs.machine;

import aztech.modern_industrialization.machines.models.MachineCasings;
import aztech.modern_industrialization.machines.multiblocks.HatchFlags;
import aztech.modern_industrialization.machines.multiblocks.HatchType;
import aztech.modern_industrialization.machines.multiblocks.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.SimpleMember;
import aztech.modern_industrialization.machines.multiblocks.shape.HatchFlags;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.member.MultiblockMember;
import aztech.modern_industrialization.machines.multiblocks.shape.member.SimpleMultiblockMember;
import net.minecraft.resources.ResourceLocation;

public interface ShapeTemplateHelper {
Expand All @@ -39,8 +40,8 @@ default ShapeTemplate.Builder startShape(String hatchCasing) {
return new ShapeTemplate.Builder(MachineCasings.get(hatchCasing));
}

default SimpleMember memberOfBlock(String blockId) {
return SimpleMember.forBlockId(ResourceLocation.parse(blockId));
default SimpleMultiblockMember memberOfBlock(String blockId) {
return MultiblockMember.simple(ResourceLocation.parse(blockId));
}

default HatchFlags noHatch() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
package aztech.modern_industrialization.compat.rei.machines;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.machines.multiblocks.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.util.Rectangle;
import java.util.*;
import net.minecraft.resources.ResourceLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import aztech.modern_industrialization.machines.MachineBlock;
import aztech.modern_industrialization.machines.multiblocks.HatchType;
import aztech.modern_industrialization.machines.multiblocks.MultiblockMachineBlockEntity;
import aztech.modern_industrialization.machines.multiblocks.shape.member.HatchMultiblockMember;
import guideme.color.SymbolicColor;
import guideme.compiler.PageCompiler;
import guideme.compiler.tags.MdxAttrs;
Expand Down Expand Up @@ -68,28 +69,29 @@ public void compile(GuidebookScene scene, PageCompiler compiler, LytErrorSink er
// Controller
scene.getLevel().setBlockAndUpdate(controllerPos, controller.getRight().defaultBlockState());
// Shape blocks
for (var entry : shape.simpleMembers.entrySet()) {
scene.getLevel().setBlockAndUpdate(entry.getKey().offset(controllerPos), entry.getValue().getPreviewState());
}
// Annotations for allowed hatches
for (var entry : shape.hatchFlags.entrySet()) {
var minCorner = Vec3.atLowerCornerOf(entry.getKey().offset(controllerPos));
var annotation = new InWorldBoxAnnotation(minCorner.toVector3f(), minCorner.add(1, 1, 1).toVector3f(), SymbolicColor.GREEN);
for (var entry : shape.members().entrySet()) {
var member = entry.getValue();
member.getPreviewState().setBlock(scene.getLevel(), entry.getKey().offset(controllerPos));

// Annotations for allowed hatches
if (member instanceof HatchMultiblockMember hatchMember) {
var minCorner = Vec3.atLowerCornerOf(entry.getKey().offset(controllerPos));
var annotation = new InWorldBoxAnnotation(minCorner.toVector3f(), minCorner.add(1, 1, 1).toVector3f(), SymbolicColor.GREEN);

List<Component> tooltipLines = new ArrayList<>();
// Add name of the block because the annotation overrides the usual tooltip
var member = shape.simpleMembers.get(entry.getKey());
tooltipLines.add(member.getPreviewState().getBlock().getName());
List<Component> tooltipLines = new ArrayList<>();
// Add name of the block because the annotation overrides the usual tooltip
tooltipLines.add(member.getPreviewState().state().getBlock().getName());

tooltipLines.add(MIText.AcceptsHatches.text());
var flags = entry.getValue();
for (var type : HatchType.values()) {
if (flags.allows(type)) {
tooltipLines.add(Component.literal("- ").append(type.description()));
tooltipLines.add(MIText.AcceptsHatches.text());
var flags = hatchMember.hatchFlags();
for (var type : HatchType.values()) {
if (flags.allows(type)) {
tooltipLines.add(Component.literal("- ").append(type.description()));
}
}
annotation.setTooltip(new TextTooltip(tooltipLines));
scene.addAnnotation(annotation);
}
annotation.setTooltip(new TextTooltip(tooltipLines));
scene.addAnnotation(annotation);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import aztech.modern_industrialization.machines.guicomponents.ReiSlotLocking;
import aztech.modern_industrialization.machines.models.MachineModelClientData;
import aztech.modern_industrialization.machines.multiblocks.MultiblockMachineBlockEntity;
import aztech.modern_industrialization.machines.multiblocks.ShapeMatcher;
import aztech.modern_industrialization.machines.multiblocks.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeMatcher;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.util.Tickable;

public abstract class AbstractCraftingMultiblockBlockEntity extends MultiblockMachineBlockEntity implements Tickable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import aztech.modern_industrialization.machines.components.*;
import aztech.modern_industrialization.machines.guicomponents.CraftingMultiblockGui;
import aztech.modern_industrialization.machines.multiblocks.HatchBlockEntity;
import aztech.modern_industrialization.machines.multiblocks.ShapeMatcher;
import aztech.modern_industrialization.machines.multiblocks.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeMatcher;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.util.Simulation;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
import aztech.modern_industrialization.machines.init.MachineTier;
import aztech.modern_industrialization.machines.models.MachineCasings;
import aztech.modern_industrialization.machines.multiblocks.*;
import aztech.modern_industrialization.machines.multiblocks.shape.HatchFlags;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.member.MultiblockMember;
import aztech.modern_industrialization.machines.recipe.MachineRecipeType;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -112,8 +115,8 @@ public static void registerReiShapes() {
static {
shapeTemplates = new ShapeTemplate[MAX_HEIGHT];

SimpleMember casing = SimpleMember.forBlock(MIBlock.BLOCK_DEFINITIONS.get(MI.id("clean_stainless_steel_machine_casing")));
SimpleMember pipe = SimpleMember.forBlock(MIBlock.BLOCK_DEFINITIONS.get(MI.id("stainless_steel_machine_casing_pipe")));
var casing = MultiblockMember.simple(MIBlock.BLOCK_DEFINITIONS.get(MI.id("clean_stainless_steel_machine_casing")));
var pipe = MultiblockMember.simple(MIBlock.BLOCK_DEFINITIONS.get(MI.id("stainless_steel_machine_casing_pipe")));
HatchFlags bottom = new HatchFlags.Builder().with(HatchType.ENERGY_INPUT, HatchType.FLUID_INPUT).build();
HatchFlags layer = new HatchFlags.Builder().with(HatchType.FLUID_OUTPUT).build();
for (int i = 0; i < MAX_HEIGHT; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import aztech.modern_industrialization.machines.init.MIMachineRecipeTypes;
import aztech.modern_industrialization.machines.init.MachineTier;
import aztech.modern_industrialization.machines.models.MachineCasings;
import aztech.modern_industrialization.machines.multiblocks.*;
import aztech.modern_industrialization.machines.multiblocks.shape.HatchFlags;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.member.MultiblockMember;
import aztech.modern_industrialization.machines.recipe.MachineRecipe;
import aztech.modern_industrialization.machines.recipe.MachineRecipeType;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -94,8 +96,8 @@ public Component getDisplayName() {

for (int i = 0; i < tiers.size(); ++i) {
var tier = tiers.get(i);
SimpleMember invarCasings = SimpleMember.forBlock(MIBlock.BLOCK_DEFINITIONS.get(MI.id("heatproof_machine_casing")));
SimpleMember coilsBlocks = SimpleMember.forBlockId(tier.coilBlockId());
var invarCasings = MultiblockMember.simple(MIBlock.BLOCK_DEFINITIONS.get(MI.id("heatproof_machine_casing")));
var coilsBlocks = MultiblockMember.simple(tier.coilBlockId());
HatchFlags ebfHatches = new HatchFlags.Builder().with(ITEM_INPUT, ITEM_OUTPUT, FLUID_INPUT, FLUID_OUTPUT, ENERGY_INPUT).build();
ShapeTemplate ebfShape = new ShapeTemplate.Builder(MachineCasings.HEATPROOF)
.add3by3(0, invarCasings, false, ebfHatches)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import aztech.modern_industrialization.machines.components.*;
import aztech.modern_industrialization.machines.guicomponents.SlotPanel;
import aztech.modern_industrialization.machines.init.MachineTier;
import aztech.modern_industrialization.machines.multiblocks.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.machines.recipe.MachineRecipeType;

public class ElectricCraftingMultiblockBlockEntity extends AbstractElectricCraftingMultiblockBlockEntity implements EnergyListComponentHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import aztech.modern_industrialization.machines.components.OrientationComponent;
import aztech.modern_industrialization.machines.guicomponents.SlotPanel;
import aztech.modern_industrialization.machines.init.MIMachineRecipeTypes;
import aztech.modern_industrialization.machines.multiblocks.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.machines.recipe.MachineRecipeType;

public class FusionReactorBlockEntity extends AbstractElectricCraftingMultiblockBlockEntity implements EnergyListComponentHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import aztech.modern_industrialization.machines.models.MachineModelClientData;
import aztech.modern_industrialization.machines.multiblocks.HatchBlockEntity;
import aztech.modern_industrialization.machines.multiblocks.MultiblockMachineBlockEntity;
import aztech.modern_industrialization.machines.multiblocks.ShapeMatcher;
import aztech.modern_industrialization.machines.multiblocks.ShapeTemplate;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeMatcher;
import aztech.modern_industrialization.machines.multiblocks.shape.ShapeTemplate;
import aztech.modern_industrialization.util.Simulation;
import aztech.modern_industrialization.util.Tickable;
import java.util.ArrayList;
Expand Down
Loading