Skip to content

Commit 934cca8

Browse files
authored
Built-in connected texture implementation (#4791)
1 parent 53387c0 commit 934cca8

287 files changed

Lines changed: 4774 additions & 827 deletions

File tree

Some content is hidden

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

docs/content/Modpacks/Changes/v8.0.0.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ A large number of machine feature interfaces have been removed, and have had the
125125
- `IFluidRendererMulti` - Use `MultiblockFluidRendererTrait`
126126

127127

128+
## Connected texture reimplementation
129+
The mod's connected texture logic has been reimplemented in GTM proper.
130+
Texture packs, addons, and modpacks will have to change their texture metadata files for connected texures slightly.
131+
A few regexes for fixing all the MCMeta files is follows, run them in order:
132+
133+
1. Match: `"ldlib":([\s\{]*)"connection"(:\s".*?")(?:,\s.*)?`
134+
Replace with: `"gtceu":$1"connection_texture"$2`
135+
2. Match: `\s*\},\s*"shimmer":\s*\{(\s*"bloom":.*)`
136+
Replace with: `,$1`
137+
3. Match: `(\{\s*)"shimmer":(\s*\{\s*"bloom":.*)`
138+
Replace with: `$1"gtceu":$2`
139+
140+
128141
## Other Changes
129142

130143
- `BlastingRecipeBuilder`, `CampfireRecipeBuilder`, `SmeltingRecipeBuilder` and `SmokingRecipeBuilder` have been merged into `SimpleCookingRecipeBuilder`
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Creating Connected Textures
3+
---
4+
5+
**Connected textures** are, as the name would imply, textures that connect with neighboring blocks.
6+
7+
The CTM renderer will draw the block faces by assembling 4 quadrants from the 5 available block textures.
8+
The normal `texture.png` is the block's "unconnected" texture, and is used when CTM is disabled or the block
9+
has nothing to connect to.
10+
`texture.png` has the outside corner quadrants and `texture_ctm.png` contains the connections.
11+
```
12+
┌─────────────────┐ ┌────────────────────────────────┐
13+
│ texture.png │ │ texture_ctm.png │
14+
│ ╔══════╤══════╗ │ │ ──────┼────── ║ ─────┼───── ║ │
15+
│ ║ │ ║ │ │ │ │ │║ │ ║ │
16+
│ ║ 4/4 │ 4/5 ║ │ │ │ 0/0 │ 0/1 │║ 0/2 │ 0/3 ║ │
17+
│ ╟──────┼──────╢ │ │ ┼──────┼──────┼╟──────┼──────╢ │
18+
│ ║ │ ║ │ │ │ │ │║ │ ║ │
19+
│ ║ 5/4 │ 5/5 ║ │ │ │ 1/0 │ 1/1 │║ 1/2 │ 1/3 ║ │
20+
│ ╚══════╧══════╝ │ │ ──────┼────── ║ ─────┼───── ║ │
21+
└─────────────────┘ │ ═══════╤═══════╝ ─────┼───── ╚ │
22+
│ │ │ ││ │ │ │
23+
│ │ 2/0 │ 2/1 ││ 2/2 │ 2/3 │ │
24+
│ ┼──────┼──────┼┼──────┼──────┼ │
25+
│ │ │ ││ │ │ │
26+
│ │ 3/0 │ 3/1 ││ 3/2 │ 3/3 │ │
27+
│ ═══════╧═══════╗ ─────┼───── ╔ │
28+
└────────────────────────────────┘
29+
```
30+
31+
For example, combining sections 4/4, 2/1, 5/4, and 3/1, we can generate a texture connected to the right!
32+
```
33+
╔══════╤═══════
34+
║ │ │
35+
║ 4/4 │ 2/1 │
36+
╟──────┼──────┼
37+
║ │ │
38+
║ 5/4 │ 3/1 │
39+
╚══════╧═══════
40+
```
41+
Combining sections 0/2, 2/3, 5/4, and 3/1, we can generate a texture in the shape of an L (connected to the right and up):
42+
```
43+
║ ─────┼───── ╚
44+
║ │ │
45+
║ 0/2 │ 2/3 │
46+
╟──────┼──────┼
47+
║ │ │
48+
║ 5/4 │ 3/1 │
49+
╚══════╧═══════
50+
```
51+
52+
53+
??? example "Example MCMeta file"
54+
(For a texture `mypack/assets/textures/blocks/texture.png` with a ctm texture `mypack/assets/textures/blocks/texture_ctm.png`)
55+
```json title="mypack:blocks/texture.png.mcmeta"
56+
{
57+
"gtceu": {
58+
"connection_texture": "mypack:blocks/texture_ctm"
59+
}
60+
}
61+
```
62+
The CTM texture layout is [here](https://github.com/GregTechCEu/GregTech-Modern/blob/1.20.1/src/main/resources/assets/gtceu/textures/block/ctm_test.png) for the unconnected texture and [here](https://github.com/GregTechCEu/GregTech-Modern/blob/1.20.1/src/main/resources/assets/gtceu/textures/block/ctm_test_ctm.png) for its connections.
63+
Its MCMeta metadata file is [this one](https://github.com/GregTechCEu/GregTech-Modern/blob/1.20.1/src/main/resources/assets/gtceu/textures/block/ctm_test.png.mcmeta).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"variants": {
3+
"": {
4+
"model": "gtceu:block/ctm_test"
5+
}
6+
}
7+
}

src/generated/resources/assets/gtceu/lang/en_ud.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
"block.gtceu.creative_tank": "ʞuɐ⟘ ǝʌıʇɐǝɹƆ",
188188
"block.gtceu.creosote": "ǝʇosoǝɹƆ",
189189
"block.gtceu.crushing_wheels": "sןǝǝɥM buıɥsnɹƆ",
190+
"block.gtceu.ctm_test": "ʞɔoןᗺ ʇsǝ⟘ ǝɹnʇxǝ⟘ pǝʇɔǝuuoƆ",
190191
"block.gtceu.cupronickel_coil_block": "ʞɔoןᗺ ןıoƆ ןǝʞɔıuoɹdnƆ",
191192
"block.gtceu.cyan_borderless_lamp": "dɯɐꞀ ssǝןɹǝpɹoᗺ uɐʎƆ",
192193
"block.gtceu.cyan_lamp": "dɯɐꞀ uɐʎƆ",

src/generated/resources/assets/gtceu/lang/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
"block.gtceu.creative_tank": "Creative Tank",
188188
"block.gtceu.creosote": "Creosote",
189189
"block.gtceu.crushing_wheels": "Crushing Wheels",
190+
"block.gtceu.ctm_test": "Connected Texture Test Block",
190191
"block.gtceu.cupronickel_coil_block": "Cupronickel Coil Block",
191192
"block.gtceu.cyan_borderless_lamp": "Cyan Borderless Lamp",
192193
"block.gtceu.cyan_lamp": "Cyan Lamp",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "minecraft:block/cube_all",
3+
"textures": {
4+
"all": "gtceu:block/ctm_test"
5+
}
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"parent": "gtceu:block/ctm_test"
3+
}

src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,22 @@
3838
import com.gregtechceu.gtceu.api.transfer.fluid.IFluidHandlerModifiable;
3939
import com.gregtechceu.gtceu.client.model.IBlockEntityRendererBakedModel;
4040
import com.gregtechceu.gtceu.client.model.machine.MachineRenderState;
41-
import com.gregtechceu.gtceu.client.util.ModelUtils;
41+
import com.gregtechceu.gtceu.client.util.RenderUtil;
4242
import com.gregtechceu.gtceu.common.cover.FluidFilterCover;
4343
import com.gregtechceu.gtceu.common.cover.ItemFilterCover;
4444
import com.gregtechceu.gtceu.common.cover.data.ManualIOMode;
4545
import com.gregtechceu.gtceu.common.machine.owner.MachineOwner;
4646
import com.gregtechceu.gtceu.common.machine.owner.PlayerOwner;
4747
import com.gregtechceu.gtceu.common.machine.trait.AutoOutputTrait;
4848
import com.gregtechceu.gtceu.utils.ExtendedUseOnContext;
49+
import com.gregtechceu.gtceu.utils.GTStringUtils;
4950
import com.gregtechceu.gtceu.utils.data.TagCompatibilityFixer;
5051

5152
import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture;
5253
import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture;
5354
import com.lowdragmc.lowdraglib.utils.DummyWorld;
5455

5556
import net.minecraft.ChatFormatting;
56-
import net.minecraft.client.Minecraft;
57-
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
5857
import net.minecraft.client.resources.model.BakedModel;
5958
import net.minecraft.core.BlockPos;
6059
import net.minecraft.core.Direction;
@@ -679,7 +678,7 @@ public void addDebugOverlayText(Consumer<String> lines) {
679678
// add render state info
680679
MachineRenderState renderState = this.getRenderState();
681680
for (var property : renderState.getValues().entrySet()) {
682-
lines.accept(ModelUtils.getPropertyValueString(property));
681+
lines.accept(GTStringUtils.getPropertyValueString(property));
683682
}
684683
}
685684

@@ -1029,8 +1028,7 @@ public int getDefaultPaintingColor() {
10291028
@OnlyIn(Dist.CLIENT)
10301029
@Override
10311030
public AABB getRenderBoundingBox() {
1032-
BlockRenderDispatcher blockRenderDispatcher = Minecraft.getInstance().getBlockRenderer();
1033-
BakedModel model = blockRenderDispatcher.getBlockModel(this.getBlockState());
1031+
BakedModel model = RenderUtil.getModelForState(this.getBlockState());
10341032

10351033
if (model instanceof IBlockEntityRendererBakedModel<?> modelWithBER) {
10361034
if (modelWithBER.getBlockEntityType() == this.getType()) {

src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.gregtechceu.gtceu.client.renderer.machine.DynamicRenderManager;
3131
import com.gregtechceu.gtceu.client.renderer.machine.impl.*;
3232
import com.gregtechceu.gtceu.client.renderer.machine.impl.BoilerMultiPartRender;
33+
import com.gregtechceu.gtceu.client.util.ModelEventHelper;
3334
import com.gregtechceu.gtceu.common.CommonEventListener;
3435
import com.gregtechceu.gtceu.common.CommonProxy;
3536
import com.gregtechceu.gtceu.common.data.GTBlockEntities;
@@ -72,6 +73,8 @@
7273
import com.google.common.collect.BiMap;
7374
import com.google.common.collect.HashBiMap;
7475

76+
import java.util.*;
77+
7578
public class ClientProxy extends CommonProxy {
7679

7780
public static final BiMap<ResourceLocation, GTOreDefinition> CLIENT_ORE_VEINS = HashBiMap.create();
@@ -91,6 +94,7 @@ public static void init() {
9194
CommonEventListener.registerCapes(new RegisterGTCapesEvent());
9295
}
9396
initializeDynamicRenders();
97+
ModelEventHelper.initInternalAssetReloadListeners();
9498
}
9599

96100
@SubscribeEvent
@@ -158,7 +162,7 @@ public void onClientSetup(FMLClientSetupEvent event) {
158162
}
159163
}
160164

161-
public static void initializeDynamicRenders() {
165+
private static void initializeDynamicRenders() {
162166
DynamicRenderManager.register(GTCEu.id("quantum_tank_fluid"), QuantumTankFluidRender.TYPE);
163167
DynamicRenderManager.register(GTCEu.id("quantum_chest_item"), QuantumChestItemRender.TYPE);
164168

src/main/java/com/gregtechceu/gtceu/client/model/GTModelProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class GTModelProperties {
1313

1414
public static final ModelProperty<BlockAndTintGetter> LEVEL = new ModelProperty<>();
1515
public static final ModelProperty<BlockPos> POS = new ModelProperty<>();
16+
public static final ModelProperty<ModelData> PARENT_MODEL_DATA = new ModelProperty<>();
1617

1718
public static final ModelProperty<Map<Direction, ModelData>> COVER_MODEL_DATA = new ModelProperty<>();
1819

0 commit comments

Comments
 (0)