Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the patterning #2689

Draft
wants to merge 64 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0b4392e
scuffed commit, more red than lines changed
vrejhead Jul 13, 2024
5de619b
IT COMPILES!!!! debugging time
vrejhead Jul 14, 2024
4ba4503
spotless n stuff
vrejhead Jul 14, 2024
4a45b62
it actually kinda works
vrejhead Jul 15, 2024
49bdb1d
caching and stuff
vrejhead Jul 15, 2024
2694a0a
spotless, deprecations, and not nulls
vrejhead Jul 15, 2024
96078bb
iterable, apparently this is like 20x faster than the blockpos iterable
vrejhead Jul 16, 2024
0419271
step 1 of 13918238091 to making previews work
vrejhead Jul 16, 2024
b0bdbd0
groundwork for hell
vrejhead Jul 16, 2024
f7e76e6
time for hell
vrejhead Jul 16, 2024
0f21cf7
free from terminal
vrejhead Jul 17, 2024
47a7737
shoutout to crtl-slash i love you
vrejhead Jul 17, 2024
f9e4ccb
startoffset stuff
vrejhead Jul 17, 2024
d9dc706
default impls
vrejhead Jul 17, 2024
45691e8
the third dimension
vrejhead Jul 18, 2024
9645487
use hashmap pt1 + spotless
vrejhead Jul 18, 2024
cc0e227
javadocs + default cause lazy + fix yo stuff
vrejhead Jul 19, 2024
3de4af5
the list thing works + hopefully lbb works
vrejhead Jul 20, 2024
96d472c
hopefully it works fr(still didn't test)
vrejhead Jul 20, 2024
f0bd6dd
:reading:
vrejhead Jul 20, 2024
6c82b0a
smallest arch commit
vrejhead Aug 3, 2024
8f7f1c1
misc stuff
vrejhead Aug 3, 2024
fc20c37
reversed patterns
vrejhead Aug 11, 2024
5e182d6
cleanroom part 0
vrejhead Aug 12, 2024
07519df
assembly line and cleanroom
vrejhead Aug 12, 2024
9b50b62
assembly line and cleanroom but they work
vrejhead Aug 14, 2024
22e979b
central monitor stuff
vrejhead Aug 15, 2024
25abc28
java 11 method :sob:
vrejhead Aug 15, 2024
f09a0b6
charcoal pile igniter and refactor
vrejhead Aug 16, 2024
d65a1a7
persistent nbt data
vrejhead Aug 17, 2024
f8f014c
default pattern got real
vrejhead Aug 17, 2024
9fd8202
arch code is like an onion......
vrejhead Aug 18, 2024
ec3f7f8
zpotlezz
vrejhead Aug 18, 2024
6842647
predicate tooltips and candidates
vrejhead Aug 18, 2024
0ba18a3
in world preview part 1
vrejhead Aug 18, 2024
b8ce93f
part 2 ft. extended rotation
vrejhead Aug 18, 2024
d0abbd8
cleanup
vrejhead Aug 19, 2024
33f2c96
relative direction refactor(central monitor doesnt work again, as exp…
vrejhead Aug 20, 2024
82d30ed
central monitor but it works(and half the things that didn't work bef…
vrejhead Aug 21, 2024
5f49bc7
autobuild but it doesn't work(and dot blocks)
vrejhead Aug 26, 2024
dd9455a
spotless yet again
vrejhead Aug 28, 2024
088d6eb
fix conflicts, and part 1 of autobuild
vrejhead Sep 8, 2024
1b3368d
multi aisling
vrejhead Sep 23, 2024
befb7cf
but it works
vrejhead Sep 23, 2024
cc5211b
generify default pattern generation, and multi aisles
vrejhead Sep 28, 2024
d60c59b
the worst code this has even seen
vrejhead Oct 13, 2024
8ab848f
spotlessApply spotlessApply spotlessApply spotlessApply spotlessApply…
vrejhead Oct 13, 2024
1df1c2d
the calm before the refactor
vrejhead Dec 22, 2024
fbc55ac
"it compiles at least"
vrejhead Dec 23, 2024
36863b7
"it works”
vrejhead Dec 24, 2024
8f9537d
the todo crusade
vrejhead Dec 25, 2024
40c8276
MultiblockShapeInfo is half dead
vrejhead Dec 26, 2024
99c6dcd
spotless and stuff
vrejhead Dec 26, 2024
d3c6865
bruh
vrejhead Dec 26, 2024
1c15477
addressing the deprecations
vrejhead Dec 26, 2024
7d57405
not beating the n squared allegations
vrejhead Dec 27, 2024
0be978c
vrej
vrejhead Dec 27, 2024
fc6acde
:moyai:
vrejhead Dec 27, 2024
b2eebd8
lowercase
vrejhead Dec 27, 2024
f0798f1
constant + oops
vrejhead Dec 27, 2024
a58923f
how it feels to spotless
vrejhead Dec 27, 2024
98979da
the great unboxing
vrejhead Dec 27, 2024
14ae70e
caught
vrejhead Dec 28, 2024
c8ba33f
stuff
vrejhead Jan 1, 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
Prev Previous commit
Next Next commit
charcoal pile igniter and refactor
  • Loading branch information
vrejhead committed Dec 26, 2024
commit f09a0b6ae0afa6d73f2faaa00c71b4baeb4ac523
Original file line number Diff line number Diff line change
@@ -9,11 +9,11 @@
import gregtech.api.metatileentity.MetaTileEntityHolder;
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.pattern.BlockWorldState;
import gregtech.api.pattern.GreggyBlockPos;
import gregtech.api.pattern.MultiblockShapeInfo;
import gregtech.api.pattern.TraceabilityPredicate;
import gregtech.api.pattern.pattern.IBlockPattern;
import gregtech.api.pattern.pattern.PatternState;
import gregtech.api.pattern.pattern.PreviewBlockPattern;
import gregtech.api.pipenet.tile.IPipeTile;
import gregtech.api.unification.material.Material;
import gregtech.api.util.BlockInfo;
@@ -73,12 +73,12 @@
import java.util.Objects;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static gregtech.api.capability.GregtechDataCodes.*;

@@ -88,10 +88,6 @@ public abstract class MultiblockControllerBase extends MetaTileEntity implements
MetaTileEntity mte = (MetaTileEntity) part;
return ((long) multiblockPartSorter().apply(mte.getPos()) << 32) | mte.getPos().hashCode();
});
/**
* Null until the first time {@link MultiblockControllerBase#getMatchingShapes()} is called, if it is not overriden
*/
protected PreviewBlockPattern defaultPattern;

private final Map<MultiblockAbility<Object>, List<Object>> multiblockAbilities = new HashMap<>();

@@ -140,7 +136,7 @@ public void update() {
/**
* @return structure pattern of this multiblock
*/
// todo fix central monitor, charcoal pile igniter, (and vacuum freezer)
// todo fix central monitor, and vacuum freezer
@NotNull
protected abstract IBlockPattern createStructurePattern();

@@ -528,10 +524,11 @@ protected void registerMultiblockAbility(IMultiblockAbilityPart<Object> part) {
part.registerAbilities(abilityList);
}

protected void forEachFormed(String name, Consumer<BlockInfo> action) {
protected void forEachFormed(String name, BiConsumer<BlockInfo, GreggyBlockPos> action) {
Long2ObjectMap<BlockInfo> cache = getSubstructure(name).getCache();
for (BlockInfo info : cache.values()) {
action.accept(info);
GreggyBlockPos pos = new GreggyBlockPos();
for (Long2ObjectMap.Entry<BlockInfo> entry : cache.long2ObjectEntrySet()) {
action.accept(entry.getValue(), pos.fromLong(entry.getLongKey()));
}
}

@@ -777,30 +774,23 @@ public List<MultiblockShapeInfo> getMatchingShapes() {
* The new(and better) way of getting shapes for in world, jei, and autobuild. Default impl just converts
* {@link MultiblockControllerBase#getMatchingShapes()}, if not empty, to this. If getMatchingShapes is empty, uses
* a default generated structure pattern, it's not very good which is why you should override this.
*
* @param keyMap A map for autobuild, or null if it is an in world or jei preview.
*
* @param keyMap A map for autobuild, or null if it is an in world or jei preview. Note that for in world and jei
* previews you can return a singleton list(only the first element will be used anyway).
* @param hatches This is whether you should put hatches, JEI previews need hatches, but autobuild and in world
* previews shouldn't(unless the hatch is necessary and only has one valid spot, such as EBF)
* previews shouldn't(unless the hatch is necessary and only has one valid spot, such as EBF muffler)
*/
// todo add use for the keyMap with the multiblock builder
public List<PreviewBlockPattern> getBuildableShapes(@Nullable Object2IntMap<String> keyMap, boolean hatches) {
// todo maybe add name arg for building substructures
public List<MultiblockShapeInfo> getBuildableShapes(@Nullable Object2IntMap<String> keyMap, boolean hatches) {
List<MultiblockShapeInfo> infos = getMatchingShapes();

// if there is no overriden getMatchingShapes() just return the default one
if (infos.isEmpty()) {
if (defaultPattern == null) {

// only generate for the first pattern, if you have more than 1 pattern you better override this
defaultPattern = getSubstructure("MAIN").getDefaultShape();

if (defaultPattern == null) return Collections.emptyList();
}

return Collections.singletonList(defaultPattern);
return Collections.singletonList(getSubstructure("MAIN").getDefaultShape());
}

// otherwise just convert them all the preview block pattern and return
return getMatchingShapes().stream().map(PreviewBlockPattern::new).collect(Collectors.toList());
return infos;
}

@SideOnly(Side.CLIENT)
17 changes: 0 additions & 17 deletions src/main/java/gregtech/api/pattern/MultiblockShapeInfo.java
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.MetaTileEntityHolder;
import gregtech.api.pattern.pattern.PatternAisle;
import gregtech.api.pattern.pattern.PreviewBlockPattern;
import gregtech.api.util.BlockInfo;

import net.minecraft.block.state.IBlockState;
@@ -12,18 +11,12 @@

import it.unimi.dsi.fastutil.chars.Char2ObjectMap;
import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap;
import org.jetbrains.annotations.ApiStatus;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

@Deprecated
public class MultiblockShapeInfo {

/**
* Array of aisles, you should use {@link PreviewBlockPattern} instead
*/
protected final PatternAisle[] aisles;
protected final Char2ObjectMap<BlockInfo> symbols;

@@ -36,16 +29,6 @@ public static Builder builder() {
return new Builder();
}

@ApiStatus.Internal
public PatternAisle[] getAisles() {
return aisles;
}

@ApiStatus.Internal
public Char2ObjectMap<BlockInfo> getSymbols() {
return symbols;
}

public static class Builder {

private List<PatternAisle> shape = new ArrayList<>();
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.pattern.BlockWorldState;
import gregtech.api.pattern.GreggyBlockPos;
import gregtech.api.pattern.MultiblockShapeInfo;
import gregtech.api.pattern.OriginOffset;
import gregtech.api.pattern.TraceabilityPredicate;
import gregtech.api.util.BlockInfo;
@@ -296,7 +297,7 @@ public boolean checkAisle(GreggyBlockPos controllerPos, EnumFacing frontFacing,

@Override
// todo get real
public PreviewBlockPattern getDefaultShape() {
public MultiblockShapeInfo getDefaultShape() {
char[][][] pattern = new char[dimensions[2]][dimensions[1]][dimensions[0]];

for (PatternAisle aisle : aisles) {
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.pattern.BlockWorldState;
import gregtech.api.pattern.GreggyBlockPos;
import gregtech.api.pattern.MultiblockShapeInfo;
import gregtech.api.pattern.OriginOffset;
import gregtech.api.pattern.TraceabilityPredicate;
import gregtech.api.util.BlockInfo;
@@ -172,7 +173,7 @@ public boolean checkPatternAt(World world, BlockPos centerPos, EnumFacing frontF
}

@Override
public PreviewBlockPattern getDefaultShape() {
public MultiblockShapeInfo getDefaultShape() {
// todo undo
return null;
}
12 changes: 7 additions & 5 deletions src/main/java/gregtech/api/pattern/pattern/IBlockPattern.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gregtech.api.pattern.pattern;

import gregtech.api.metatileentity.multiblock.MultiblockControllerBase;
import gregtech.api.pattern.MultiblockShapeInfo;
import gregtech.api.pattern.OriginOffset;
import gregtech.api.util.BlockInfo;
import gregtech.api.util.RelativeDirection;
@@ -11,6 +12,7 @@

import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public interface IBlockPattern {

@@ -46,9 +48,11 @@ boolean checkPatternAt(World world, BlockPos centerPos, EnumFacing frontFacing,
boolean isFlipped);

/**
* Gets the default shape, if the multiblock does not specify one.
* Gets the default shape, if the multiblock does not specify one. Return null to represent the default shape does
* not exist.
*/
PreviewBlockPattern getDefaultShape();
@Nullable
MultiblockShapeInfo getDefaultShape();

/**
* Gets the internal pattern state, you should use the one returned from
@@ -65,9 +69,7 @@ default void clearCache() {
}

/**
* Gets the cache, if you modify literally anything in the cache except clearing it(in which case you should use
* clearCache())
* then GTCEu is now licensed under ARR just for you, so close your IDE or else.
* Gets the cache, do not modify. Note that the cache stores everything in the AABB of the substructure, except for any() TraceabilityPredicates.
*
* @return The cache for rapid pattern checking.
*/
Loading