Skip to content

Commit 4dba056

Browse files
committed
Merge branch '21.1/feature/pipelines' into 21.1/main
2 parents fcee352 + 9e651ba commit 4dba056

File tree

46 files changed

+1031
-852
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1031
-852
lines changed

core/src/main/java/dev/compactmods/gander/core/utility/RaytraceHelper.java

Lines changed: 0 additions & 116 deletions
This file was deleted.

core/src/main/java/dev/compactmods/gander/core/utility/VecHelper.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

levels/src/main/java/dev/compactmods/gander/level/VirtualLevel.java

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package dev.compactmods.gander.level;
22

33
import java.util.List;
4+
import java.util.function.Consumer;
45
import java.util.function.Supplier;
56

7+
import net.neoforged.neoforge.client.model.data.ModelData;
8+
import net.neoforged.neoforge.client.model.data.ModelDataManager;
9+
610
import org.jetbrains.annotations.NotNull;
711
import org.jetbrains.annotations.Nullable;
812

@@ -65,35 +69,53 @@ public class VirtualLevel extends Level implements WorldGenLevel, TickingLevel {
6569
private BoundingBox bounds;
6670
private VirtualEntitySystem entities;
6771
private final Holder<Biome> biome;
72+
private final Consumer<VirtualLevel> onBlockUpdate;
73+
private final ModelDataManager modelDataManager;
74+
75+
public VirtualLevel(RegistryAccess access, boolean isClientside) {
76+
this(access, isClientside, newLevel -> {});
77+
}
6878

69-
public VirtualLevel(RegistryAccess access, boolean isClientside) {
79+
public VirtualLevel(RegistryAccess access, boolean isClientside, Consumer<VirtualLevel> onBlockUpdate) {
7080
this(
7181
VirtualLevelUtils.LEVEL_DATA, Level.OVERWORLD, access,
7282
access.registryOrThrow(Registries.DIMENSION_TYPE).getHolderOrThrow(BuiltinDimensionTypes.OVERWORLD),
7383
VirtualLevelUtils.PROFILER, isClientside, false,
74-
0, 0);
84+
0, 0, onBlockUpdate);
7585
}
7686

7787
private VirtualLevel(WritableLevelData pLevelData, ResourceKey<Level> pDimension,
78-
RegistryAccess pRegistryAccess, Holder<DimensionType> pDimensionTypeRegistration,
79-
Supplier<ProfilerFiller> pProfiler, boolean pIsClientSide, boolean pIsDebug, long pBiomeZoomSeed,
80-
int pMaxChainedNeighborUpdates) {
88+
RegistryAccess pRegistryAccess, Holder<DimensionType> pDimensionTypeRegistration,
89+
Supplier<ProfilerFiller> pProfiler, boolean pIsClientSide, boolean pIsDebug, long pBiomeZoomSeed,
90+
int pMaxChainedNeighborUpdates, Consumer<VirtualLevel> onBlockUpdate) {
8191
super(pLevelData, pDimension, pRegistryAccess, pDimensionTypeRegistration, pProfiler, pIsClientSide, pIsDebug,
8292
pBiomeZoomSeed, pMaxChainedNeighborUpdates);
8393
this.access = pRegistryAccess;
84-
this.chunkSource = new VirtualChunkSource(this);
94+
this.onBlockUpdate = onBlockUpdate;
95+
this.chunkSource = new VirtualChunkSource(this);
8596
this.blocks = new VirtualBlockSystem(this);
8697
this.scoreboard = new Scoreboard();
8798
this.bounds = BoundingBox.fromCorners(BlockPos.ZERO, BlockPos.ZERO);
8899
this.entities = new VirtualEntitySystem();
89100
this.biome = pRegistryAccess.registryOrThrow(Registries.BIOME).getHolderOrThrow(Biomes.PLAINS);
101+
this.modelDataManager = new ModelDataManager(this);
90102
}
91103

92104
public Holder<Biome> getBiome() {
93105
return biome;
94106
}
95107

96-
@Override
108+
@Override
109+
public ModelData getModelData(BlockPos pos) {
110+
return modelDataManager.getAt(pos);
111+
}
112+
113+
@Override
114+
public @Nullable ModelDataManager getModelDataManager() {
115+
return modelDataManager;
116+
}
117+
118+
@Override
97119
public PotionBrewing potionBrewing() {
98120
// Minecraft, why?
99121
return PotionBrewing.EMPTY;
@@ -273,6 +295,7 @@ public float getShade(Direction pDirection, boolean pShade) {
273295

274296
@Override
275297
public void sendBlockUpdated(BlockPos pPos, BlockState pOldState, BlockState pNewState, int pFlags) {
298+
this.onBlockUpdate.accept(this);
276299
}
277300

278301
@Override
@@ -401,4 +424,9 @@ public int getMinBuildHeight() {
401424
public BoundingBox getBounds() {
402425
return bounds;
403426
}
427+
428+
public void refreshBlockEntityModels() {
429+
blocks.blockAndFluidStorage().blockEntities()
430+
.forEach(modelDataManager::requestRefresh);
431+
}
404432
}

levels/src/main/java/dev/compactmods/gander/level/chunk/VirtualChunk.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,6 @@ public boolean isUnsaved() {
156156
return false;
157157
}
158158

159-
// TODO: Is there some other overload for this?
160-
/*@Override
161-
public ChunkStatus getStatus() {
162-
return ChunkStatus.LIGHT;
163-
}*/
164-
165159
@Override
166160
public void removeBlockEntity(BlockPos pos) {
167161
virtualLevel.removeBlockEntity(pos);

rendering/src/main/java/dev/compactmods/gander/render/RenderTypes.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import net.minecraft.client.renderer.RenderType;
99
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
1010

11-
import org.jetbrains.annotations.Nullable;
12-
1311
import java.util.Map;
1412
import java.util.Set;
1513
import java.util.function.Function;
@@ -23,12 +21,6 @@ public class RenderTypes extends RenderStateShard {
2321
.stream()
2422
.collect(Collectors.toMap(RenderLevelStageEvent.Stage::fromRenderType, Function.identity()));
2523

26-
public static final Set<RenderLevelStageEvent.Stage> STATIC_GEOMETRY_STAGES = Set.of(
27-
RenderLevelStageEvent.Stage.AFTER_SOLID_BLOCKS,
28-
RenderLevelStageEvent.Stage.AFTER_CUTOUT_MIPPED_BLOCKS_BLOCKS,
29-
RenderLevelStageEvent.Stage.AFTER_CUTOUT_BLOCKS
30-
);
31-
3224
protected static final RenderStateShard.ShaderStateShard BLOCK_SHADER =
3325
new RenderStateShard.ShaderStateShard(GameRenderer::getRendertypeTranslucentMovingBlockShader);
3426

@@ -59,8 +51,4 @@ public static RenderType getFluid() {
5951
private RenderTypes() {
6052
super(null, null, null);
6153
}
62-
63-
public static boolean isStaticGeometryStage(RenderLevelStageEvent.Stage stage) {
64-
return STATIC_GEOMETRY_STAGES.contains(stage);
65-
}
6654
}

rendering/src/main/java/dev/compactmods/gander/render/geometry/LevelBakery.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,11 @@ private static void createBlockGeometry(Level level, BlockPos pos, PoseStack pos
8181
pose.pushPose();
8282
pose.translate(pos.getX(), pos.getY(), pos.getZ());
8383

84-
ModelData modelData = ModelData.EMPTY;
84+
ModelData modelData;
8585
if (state.getRenderShape() == RenderShape.MODEL) {
8686
BakedModel model = dispatcher.getBlockModel(state);
8787

88-
if (state.hasBlockEntity()) {
89-
BlockEntity blockEntity = level.getBlockEntity(pos);
90-
modelData = blockEntity != null ? blockEntity.getModelData() : ModelData.EMPTY;
91-
}
92-
88+
modelData = level.getModelData(pos);
9389
modelData = model.getModelData(level, pos, state, modelData);
9490

9591
long seed = state.getSeed(pos);

0 commit comments

Comments
 (0)