move conductor hat information to resource packs

This commit is contained in:
GizmoTheMoonPig 2024-02-28 17:20:35 -07:00
parent a41053b896
commit 1a4e71cb0d
Failed to generate hash of commit
62 changed files with 715 additions and 183 deletions

View file

@ -187,6 +187,8 @@ dependencies {
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}+${curios_minecraft_version}:api")
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}+${curios_minecraft_version}")
runtimeOnly fg.deobf("curse.maven:commandstructures-565119:4711641")
if (cc_tweaked_enable.toBoolean()) {
compileOnly("cc.tweaked:cc-tweaked-${cc_tweaked_minecraft_version}-core-api:${cc_tweaked_version}")
compileOnly fg.deobf("cc.tweaked:cc-tweaked-${cc_tweaked_minecraft_version}-forge-api:${cc_tweaked_version}")

View file

@ -1,4 +1,4 @@
// 1.20.1 2023-09-20T19:40:25.374215 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
// 1.20.1 2024-02-27T19:56:37.1999052 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
60bbdf92d2ac9824ea6144955c74043a6005f79d assets/create/blockstates/acacia_window.json
6a67703c2697d81b7dc83e9d72a66f9c9ff08383 assets/create/blockstates/acacia_window_pane.json
c3ae87b62e81d8e9476eccd793bb1548d74c66a1 assets/create/blockstates/adjustable_chain_gearshift.json
@ -585,8 +585,8 @@ b0d8f08968763a5f74e5cd5644377a76a9f39753 assets/create/blockstates/yellow_toolbo
fe8c497aacc641c2f01cec90bba9f19e59cc2ed2 assets/create/blockstates/yellow_valve_handle.json
e819e93fdcbe9fd9c050a052d2718ff3b3539365 assets/create/blockstates/zinc_block.json
64121dcb216381c83b4fe28aa361ea07c24c9ad0 assets/create/blockstates/zinc_ore.json
79a43e6c997dbfa078c6aa8e4ab0c4386aaf4dd9 assets/create/lang/en_ud.json
d8d0f395ae53d72ea0d5047b9167569fe87c870d assets/create/lang/en_us.json
5bc2e2c67a554384431fbc4b916493fec7203a63 assets/create/lang/en_ud.json
cb0c666d2a6d52e2c4871d84e9b648103f65b4e2 assets/create/lang/en_us.json
a97e1060e00ae701a02e39cd4ef8054cf345fac4 assets/create/models/block/acacia_window.json
103e032c0b1a0a6a27c67da8c91179a564bd281c assets/create/models/block/acacia_window_pane_noside.json
fb00b627abda76ad4fea867ca57dbfadd24fffa3 assets/create/models/block/acacia_window_pane_noside_alt.json
@ -4189,6 +4189,7 @@ a5874f73c7dc0a3ae12999e6ae8abf45bc7fb9be data/create/tags/blocks/passive_boiler_
da739ad2160e7df4e0e5cc89587670ce5e9450c3 data/create/tags/blocks/valve_handles.json
72143286fb5cb372a0696550e2eac76ca50e6fbc data/create/tags/blocks/windmill_sails.json
58987ea71d488cc48192ceb00c00aa2903e51304 data/create/tags/blocks/wrench_pickup.json
76c0522664726c09461ad4565b6fba80b4f816b2 data/create/tags/entity_types/blaze_burner_capturable.json
35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/create/tags/entity_types/ignore_seat.json
894e1e4fd1e32712abdda18ec64ab13750d3c039 data/create/tags/fluids/bottomless/allow.json
35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/create/tags/fluids/bottomless/deny.json

View file

@ -0,0 +1,52 @@
// 1.20.1 2024-02-28T16:56:53.0452139 Create Train Hat Information
be16d47aa64e673b1107a36ce06475016e316fca assets/minecraft/train_hat_info/axolotl.json
b8ae6d9c8014439f4049622e0d6e79b9d6716260 assets/minecraft/train_hat_info/bat.json
5053a6c9fb412dfac1bf17eb0f57f9fd314198e4 assets/minecraft/train_hat_info/bee.json
2157404eccf602f1b88eb18b073fcd2969ef9fad assets/minecraft/train_hat_info/blaze.json
95947423dc367c0c60e06ca0b8dd26d563c8419c assets/minecraft/train_hat_info/camel.json
19da83a3ee2d9629bf7ca07909fe07e2b1f22248 assets/minecraft/train_hat_info/cat.json
59ad9206c8deafe586c6dd84d518cc1fa40e274b assets/minecraft/train_hat_info/cave_spider.json
044062def9766f4552e7017af866d55e6818827a assets/minecraft/train_hat_info/chicken.json
c39106b8c17896da6277aaa62dd41adfbabe6661 assets/minecraft/train_hat_info/cod.json
ce1baa5cfa30ab912b72fd771db10aa943c7385e assets/minecraft/train_hat_info/cow.json
4de138fbba2cce34eeccda8cad8aace6d7501788 assets/minecraft/train_hat_info/dolphin.json
e524c61954660d3cb605f01395edb25572b59a1c assets/minecraft/train_hat_info/donkey.json
e87dfc580ae1dcc8fcfc88c06f35c783ac415c0e assets/minecraft/train_hat_info/elder_guardian.json
3f49938e00491599e58c2a05137b36ce194badab assets/minecraft/train_hat_info/endermite.json
06d87ca89d4eb5d15427868a08a591270157ab8e assets/minecraft/train_hat_info/fox.json
2fabb0c86b122fb09ec3ab0c650d43d17417ba9f assets/minecraft/train_hat_info/frog.json
6c1ba6bc216700dc38e9079c9b321cc6f7bd0859 assets/minecraft/train_hat_info/ghast.json
6c1ba6bc216700dc38e9079c9b321cc6f7bd0859 assets/minecraft/train_hat_info/glow_squid.json
d1a10e368f5d0abe92fede6208aab41208dcd773 assets/minecraft/train_hat_info/goat.json
e87dfc580ae1dcc8fcfc88c06f35c783ac415c0e assets/minecraft/train_hat_info/guardian.json
daac75dcadb6e00db5cf1a5b30a450f137da54ae assets/minecraft/train_hat_info/hoglin.json
e524c61954660d3cb605f01395edb25572b59a1c assets/minecraft/train_hat_info/horse.json
272e5169bac1bc2ded2a70db171cdf6fa8d1a63f assets/minecraft/train_hat_info/iron_golem.json
e9b7fc5ec7ed936c6651b59adccfa8c4cbbfd9b4 assets/minecraft/train_hat_info/magma_cube.json
946ce1cdb07b0896b3dbf202c4fc95353f635b2f assets/minecraft/train_hat_info/mooshroom.json
e524c61954660d3cb605f01395edb25572b59a1c assets/minecraft/train_hat_info/mule.json
19da83a3ee2d9629bf7ca07909fe07e2b1f22248 assets/minecraft/train_hat_info/ocelot.json
e1d5b218a5d406bf55038cc89163fe95c5006625 assets/minecraft/train_hat_info/panda.json
f8f55c50becee5cce88755bc1a6d0f13f0b19d8e assets/minecraft/train_hat_info/parrot.json
e237f1a6383b02a45e05676a37987795b4165b35 assets/minecraft/train_hat_info/phantom.json
fb2a3022eac273b99abfea0bb85b81f7de91c7fe assets/minecraft/train_hat_info/pig.json
b8ae6d9c8014439f4049622e0d6e79b9d6716260 assets/minecraft/train_hat_info/polar_bear.json
f394d3dbb39e1603efed1f64d904752c2dd01098 assets/minecraft/train_hat_info/pufferfish.json
1d7b61ae0006a7aed61d1934d042255f16eef9d8 assets/minecraft/train_hat_info/ravager.json
5a0d53f4320bfe187abc5ce3332a3af740fa9062 assets/minecraft/train_hat_info/salmon.json
855f16860193440c1ccde244e81eac2107a298e0 assets/minecraft/train_hat_info/sheep.json
82634fddb5303bc6062a4297c202ebb102d004d9 assets/minecraft/train_hat_info/silverfish.json
e524c61954660d3cb605f01395edb25572b59a1c assets/minecraft/train_hat_info/skeleton_horse.json
8fcf064b7a73a3eb9f31724f1c2075a26706d6b7 assets/minecraft/train_hat_info/slime.json
1990e7eb3ba24f2f64eb5aeea6e6e1d4002ca69f assets/minecraft/train_hat_info/sniffer.json
59ad9206c8deafe586c6dd84d518cc1fa40e274b assets/minecraft/train_hat_info/spider.json
6c1ba6bc216700dc38e9079c9b321cc6f7bd0859 assets/minecraft/train_hat_info/squid.json
527ea95992502de466eb64d81b7c3a365e3a2c59 assets/minecraft/train_hat_info/strider.json
282f1517834c77175e874148c92c40efb19a8f5b assets/minecraft/train_hat_info/tadpole.json
509913e06b456fe6fbefd0c4516713e423bce285 assets/minecraft/train_hat_info/tropical_fish.json
fd85007f98c57b2f57b16cd8dff43d0cf029cd36 assets/minecraft/train_hat_info/turtle.json
78950a0bb66d28d1939049400a8cfd194f92f906 assets/minecraft/train_hat_info/warden.json
12eba791d433f9bd8cc9781cb2b2a9c587ae6b70 assets/minecraft/train_hat_info/wither.json
bd87188334d5f189f7c05a02813307a3e3dc601c assets/minecraft/train_hat_info/wolf.json
daac75dcadb6e00db5cf1a5b30a450f137da54ae assets/minecraft/train_hat_info/zoglin.json
e524c61954660d3cb605f01395edb25572b59a1c assets/minecraft/train_hat_info/zombie_horse.json

View file

@ -0,0 +1,9 @@
{
"model_part": "head",
"offset": [
0.0,
1.0,
-2.0
],
"scale": 0.75
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
3.0,
0.0
]
}

View file

@ -0,0 +1,9 @@
{
"model_part": "body",
"offset": [
0.0,
2.0,
-2.0
],
"scale": 0.5
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
4.0,
0.0
]
}

View file

@ -0,0 +1,9 @@
{
"cube_index": 1,
"model_part": "body/head",
"offset": [
0.0,
-8.0,
-11.5
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
1.0,
-0.25
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
2.0,
-3.5
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
0.0,
-0.25
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
1.5,
-2.5
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
2.0,
-1.25
]
}

View file

@ -0,0 +1,9 @@
{
"model_part": "body/head",
"offset": [
0.0,
3.0,
0.0
],
"scale": 0.75
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
0.0,
2.0
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
20.0,
0.0
]
}

View file

@ -0,0 +1,9 @@
{
"model_part": "segment0",
"offset": [
0.0,
2.5,
0.5
],
"scale": 0.75
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.75,
2.5,
-2.0
]
}

View file

@ -0,0 +1,9 @@
{
"model_part": "body/head",
"offset": [
0.0,
-3.0,
-4.25
],
"scale": 0.5
}

View file

@ -0,0 +1,8 @@
{
"model_part": "body",
"offset": [
0.0,
6.0,
0.0
]
}

View file

@ -0,0 +1,8 @@
{
"model_part": "body",
"offset": [
0.0,
6.0,
0.0
]
}

View file

@ -0,0 +1,9 @@
{
"model_part": "nose",
"offset": [
-0.5,
2.0,
0.0
],
"scale": 0.5
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
20.0,
0.0
]
}

View file

@ -0,0 +1,8 @@
{
"offset": [
0.0,
0.0,
-4.5
],
"scale": 0.5
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
0.0,
2.0
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
-2.0,
-1.5
]
}

View file

@ -0,0 +1,8 @@
{
"model_part": "cube7",
"offset": [
0.0,
16.0,
0.0
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
3.0,
-1.75
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
0.0,
2.0
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
1.0,
-0.25
]
}

View file

@ -0,0 +1,8 @@
{
"offset": [
0.0,
4.0,
0.5
],
"scale": 0.75
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
0.0,
-1.5
]
}

View file

@ -0,0 +1,8 @@
{
"model_part": "body/head",
"offset": [
0.0,
0.0,
-1.0
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
3.0,
-4.0
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
3.0,
0.0
]
}

View file

@ -0,0 +1,9 @@
{
"model_part": "body",
"offset": [
0.0,
-0.5,
0.0
],
"scale": 0.75
}

View file

@ -0,0 +1,8 @@
{
"model_part": "neck/head",
"offset": [
0.0,
0.0,
-5.5
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
1.0,
0.0
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
0.5,
-0.75
]
}

View file

@ -0,0 +1,8 @@
{
"model_part": "segment1",
"offset": [
0.0,
3.0,
0.0
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
0.0,
2.0
]
}

View file

@ -0,0 +1,9 @@
{
"model_part": "cube",
"offset": [
0.0,
12.0,
0.0
],
"scale": 1.25
}

View file

@ -0,0 +1,8 @@
{
"model_part": "bone/body/head",
"offset": [
0.0,
8.0,
-5.0
]
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
2.0,
-3.5
]
}

View file

@ -0,0 +1,8 @@
{
"model_part": "body",
"offset": [
0.0,
6.0,
0.0
]
}

View file

@ -0,0 +1,8 @@
{
"model_part": "body",
"offset": [
0.0,
5.0,
0.0
]
}

View file

@ -0,0 +1,8 @@
{
"model_part": "body",
"offset": [
0.0,
1.0,
1.5
]
}

View file

@ -0,0 +1,9 @@
{
"model_part": "body",
"offset": [
0.0,
1.0,
-2.0
],
"scale": 0.5
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
3.0,
0.0
]
}

View file

@ -0,0 +1,9 @@
{
"model_part": "bone/body/head",
"offset": [
0.0,
-2.0,
0.5
],
"scale": 0.5
}

View file

@ -0,0 +1,8 @@
{
"model_part": "center_head",
"offset": [
0.0,
3.0,
0.0
]
}

View file

@ -0,0 +1,8 @@
{
"model_part": "real_head",
"offset": [
0.5,
2.5,
0.25
]
}

View file

@ -0,0 +1,8 @@
{
"offset": [
0.0,
0.0,
-4.5
],
"scale": 0.5
}

View file

@ -0,0 +1,7 @@
{
"offset": [
0.0,
0.0,
2.0
]
}

View file

@ -0,0 +1,67 @@
package com.simibubi.create.api.data;
import com.mojang.serialization.JsonOps;
import com.simibubi.create.Create;
import com.simibubi.create.content.trains.schedule.hat.TrainHatInfo;
import com.simibubi.create.content.trains.schedule.hat.TrainHatInfoReloadListener;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
public abstract class TrainHatInfoProvider implements DataProvider {
private final PackOutput.PathProvider path;
protected final Map<ResourceLocation, TrainHatInfo> trainHatOffsets = new HashMap<>();
public TrainHatInfoProvider(PackOutput output) {
this.path = output.createPathProvider(PackOutput.Target.RESOURCE_PACK, TrainHatInfoReloadListener.HAT_INFO_DIRECTORY);
}
protected abstract void createOffsets();
protected void makeInfoFor(EntityType<?> type, Vec3 offset) {
this.makeInfoFor(type, offset, "", 0, 1.0F);
}
protected void makeInfoFor(EntityType<?> type, Vec3 offset, String part) {
this.makeInfoFor(type, offset, part, 0, 1.0F);
}
protected void makeInfoFor(EntityType<?> type, Vec3 offset, float scale) {
this.makeInfoFor(type, offset, "", 0, scale);
}
protected void makeInfoFor(EntityType<?> type, Vec3 offset, String part, float scale) {
this.makeInfoFor(type, offset, part, 0, scale);
}
protected void makeInfoFor(EntityType<?> type, Vec3 offset, String part, int cubeIndex, float scale) {
this.trainHatOffsets.put(ForgeRegistries.ENTITY_TYPES.getKey(type), new TrainHatInfo(part, cubeIndex, offset, scale));
}
@Override
public CompletableFuture<?> run(CachedOutput output) {
this.trainHatOffsets.clear();
this.createOffsets();
return CompletableFuture.allOf(
this.trainHatOffsets.entrySet().stream().map(entry ->
DataProvider.saveStable(output,
TrainHatInfo.CODEC.encodeStart(JsonOps.INSTANCE, entry.getValue()).resultOrPartial(Create.LOGGER::error).orElseThrow(),
this.path.json(entry.getKey()))
).toArray(CompletableFuture[]::new));
}
@Override
public final String getName() {
return "Create Train Hat Information";
}
}

View file

@ -1,109 +0,0 @@
package com.simibubi.create.content.trains.schedule;
import net.minecraft.client.model.AgeableListModel;
import net.minecraft.client.model.AxolotlModel;
import net.minecraft.client.model.BeeModel;
import net.minecraft.client.model.BlazeModel;
import net.minecraft.client.model.ChickenModel;
import net.minecraft.client.model.CowModel;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.FoxModel;
import net.minecraft.client.model.FrogModel;
import net.minecraft.client.model.GuardianModel;
import net.minecraft.client.model.HierarchicalModel;
import net.minecraft.client.model.HoglinModel;
import net.minecraft.client.model.IronGolemModel;
import net.minecraft.client.model.LavaSlimeModel;
import net.minecraft.client.model.OcelotModel;
import net.minecraft.client.model.PandaModel;
import net.minecraft.client.model.ParrotModel;
import net.minecraft.client.model.PigModel;
import net.minecraft.client.model.QuadrupedModel;
import net.minecraft.client.model.SheepModel;
import net.minecraft.client.model.SlimeModel;
import net.minecraft.client.model.SnowGolemModel;
import net.minecraft.client.model.SpiderModel;
import net.minecraft.client.model.WardenModel;
import net.minecraft.client.model.WolfModel;
import net.minecraft.world.phys.Vec3;
public class TrainHatOffsets {
// sorry
public static Vec3 getOffset(EntityModel<?> model) {
float x = 0;
float y = 0;
float z = 0;
if (model instanceof AgeableListModel) {
if (model instanceof WolfModel) {
x += .5f;
y += 1.5f;
z += .25f;
} else if (model instanceof OcelotModel) {
y += 1f;
z -= .25f;
} else if (model instanceof ChickenModel) {
z -= .25f;
} else if (model instanceof FoxModel) {
x += .5f;
y += 2f;
z -= 1f;
} else if (model instanceof QuadrupedModel) {
y += 2f;
if (model instanceof CowModel)
z -= 1.25f;
else if (model instanceof PandaModel)
z += .5f;
else if (model instanceof PigModel)
z -= 2f;
else if (model instanceof SheepModel) {
z -= .75f;
y -= 1.5f;
}
} else if (model instanceof HoglinModel)
z -= 4.5f;
else if (model instanceof BeeModel) {
z -= .75f;
y -= 4f;
} else if (model instanceof AxolotlModel) {
z -= 5f;
y += .5f;
}
}
if (model instanceof HierarchicalModel) {
if (model instanceof BlazeModel)
y += 4;
else if (model instanceof GuardianModel)
y += 20;
else if (model instanceof IronGolemModel) {
z -= 1.5f;
y -= 2f;
} else if (model instanceof SnowGolemModel) {
z -= .75f;
y -= 3f;
} else if (model instanceof SlimeModel || model instanceof LavaSlimeModel) {
y += 22;
} else if (model instanceof SpiderModel) {
z -= 3.5f;
y += 2f;
} else if (model instanceof ParrotModel) {
z -= 1.5f;
} else if (model instanceof WardenModel) {
y += 3.5f;
z += .5f;
} else if (model instanceof FrogModel) {
y += 16.75f;
z -= .25f;
}
}
return new Vec3(x, y, z);
}
}

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.trains.schedule;
package com.simibubi.create.content.trains.schedule.hat;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
@ -11,14 +11,8 @@ import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.utility.Couple;
import net.minecraft.client.model.AgeableListModel;
import net.minecraft.client.model.AxolotlModel;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.FrogModel;
import net.minecraft.client.model.HierarchicalModel;
import net.minecraft.client.model.LavaSlimeModel;
import net.minecraft.client.model.SlimeModel;
import net.minecraft.client.model.WardenModel;
import net.minecraft.client.model.WolfModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.ModelPart.Cube;
import net.minecraft.client.renderer.MultiBufferSource;
@ -30,6 +24,7 @@ import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
@ -37,20 +32,19 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import java.util.ArrayList;
import java.util.List;
public class TrainHatArmorLayer<T extends LivingEntity, M extends EntityModel<T>> extends RenderLayer<T, M> {
private Vec3 offset;
public TrainHatArmorLayer(RenderLayerParent<T, M> renderer, Vec3 offset) {
public TrainHatArmorLayer(RenderLayerParent<T, M> renderer) {
super(renderer);
this.offset = offset;
}
@Override
public void render(PoseStack ms, MultiBufferSource buffer, int light, LivingEntity entity, float yaw, float pitch,
float pt, float p_225628_8_, float p_225628_9_, float p_225628_10_) {
public void render(PoseStack ms, MultiBufferSource buffer, int light, LivingEntity entity, float limbSwing, float limbSwingAmount,
float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
if (!shouldRenderOn(entity))
return;
@ -58,9 +52,9 @@ public class TrainHatArmorLayer<T extends LivingEntity, M extends EntityModel<T>
RenderType renderType = Sheets.cutoutBlockSheet();
ms.pushPose();
boolean valid = false;
TransformStack msr = TransformStack.cast(ms);
float scale = 1;
TrainHatInfo info = TrainHatInfoReloadListener.getHatInfoFor(entity.getType());
List<ModelPart> partsToHead = new ArrayList<>();
if (entityModel instanceof AgeableListModel<?> model) {
if (model.young) {
@ -73,56 +67,26 @@ public class TrainHatArmorLayer<T extends LivingEntity, M extends EntityModel<T>
ModelPart head = getHeadPart(model);
if (head != null) {
head.translateAndRotate(ms);
partsToHead.addAll(TrainHatInfo.getAdjustedPart(info, head, ""));
}
} else if (entityModel instanceof HierarchicalModel<?> model) {
partsToHead.addAll(TrainHatInfo.getAdjustedPart(info, model.root(), "head"));
}
if (model instanceof WolfModel)
head = head.getChild("real_head");
if (model instanceof AxolotlModel)
head = head.getChild("head");
if (!partsToHead.isEmpty()) {
partsToHead.forEach(part -> part.translateAndRotate(ms));
ms.translate(offset.x / 16f, offset.y / 16f, offset.z / 16f);
if (!head.isEmpty()) {
Cube cube = head.cubes.get(0);
ms.translate(offset.x / 16f, (cube.minY - cube.maxY + offset.y) / 16f, offset.z / 16f);
float max = Math.max(cube.maxX - cube.minX, cube.maxZ - cube.minZ) / 8f;
ModelPart lastChild = partsToHead.get(partsToHead.size() - 1);
if (!lastChild.isEmpty()) {
Cube cube = lastChild.cubes.get(Mth.clamp(info.cubeIndex(), 0, lastChild.cubes.size() - 1));
ms.translate(info.offset().x() / 16.0F, (cube.minY - cube.maxY + info.offset().y()) / 16.0F, info.offset().z() / 16.0F);
float max = Math.max(cube.maxX - cube.minX, cube.maxZ - cube.minZ) / 8.0F * info.scale();
ms.scale(max, max, max);
}
valid = true;
}
}
else if (entityModel instanceof HierarchicalModel<?> model) {
boolean slime = model instanceof SlimeModel || model instanceof LavaSlimeModel;
ModelPart head = model.root().children.get(slime ? "cube" : "head");
if (model instanceof WardenModel)
head = model.root().children.get("bone").children.get("body").children.get("head");
if (model instanceof FrogModel) {
head = model.root().children.get("body").children.get("head");
scale = .5f;
}
if (head != null) {
head.translateAndRotate(ms);
if (!head.isEmpty()) {
Cube cube = head.cubes.get(0);
ms.translate(offset.x, (cube.minY - cube.maxY + offset.y) / 16f, offset.z / 16f);
float max = Math.max(cube.maxX - cube.minX, cube.maxZ - cube.minZ) / (slime ? 6.5f : 8f) * scale;
ms.scale(max, max, max);
}
valid = true;
}
}
if (valid) {
ms.scale(1, -1, -1);
ms.translate(0, -2.25f / 16f, 0);
msr.rotateX(-8.5f);
ms.translate(0, -2.25F / 16.0F, 0);
msr.rotateX(-8.5F);
BlockState air = Blocks.AIR.defaultBlockState();
CachedBufferer.partial(AllPartialModels.TRAIN_HAT, air)
.forEntityRender()
@ -169,7 +133,7 @@ public class TrainHatArmorLayer<T extends LivingEntity, M extends EntityModel<T>
registerOn(renderer);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public static void registerOn(EntityRenderer<?> entityRenderer) {
if (!(entityRenderer instanceof LivingEntityRenderer<?, ?> livingRenderer))
return;
@ -179,9 +143,7 @@ public class TrainHatArmorLayer<T extends LivingEntity, M extends EntityModel<T>
if (!(model instanceof HierarchicalModel) && !(model instanceof AgeableListModel))
return;
Vec3 offset = TrainHatOffsets.getOffset(model);
TrainHatArmorLayer<?, ?> layer = new TrainHatArmorLayer<>(livingRenderer, offset);
livingRenderer.addLayer((TrainHatArmorLayer) layer);
livingRenderer.addLayer((TrainHatArmorLayer) new TrainHatArmorLayer<>(livingRenderer));
}
private static ModelPart getHeadPart(AgeableListModel<?> model) {

View file

@ -0,0 +1,40 @@
package com.simibubi.create.content.trains.schedule.hat;
import java.util.ArrayList;
import java.util.List;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.world.phys.Vec3;
public record TrainHatInfo(String part, int cubeIndex, Vec3 offset, float scale) {
public static final Codec<TrainHatInfo> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.STRING.optionalFieldOf("model_part", "").forGetter(TrainHatInfo::part),
Codec.INT.optionalFieldOf("cube_index", 0).forGetter(TrainHatInfo::cubeIndex),
Vec3.CODEC.fieldOf("offset").forGetter(TrainHatInfo::offset),
Codec.FLOAT.optionalFieldOf("scale", 1.0F).forGetter(TrainHatInfo::scale)
).apply(instance, TrainHatInfo::new));
public static List<ModelPart> getAdjustedPart(TrainHatInfo info, ModelPart root, String defaultPart) {
List<ModelPart> finalParts = new ArrayList<>();
finalParts.add(root);
ModelPart parent = root;
if (!info.part().isEmpty() && !info.part().equals(defaultPart)) {
String[] partList = info.part().split("/");
for (String part : partList) {
if (parent.children.containsKey(part)) {
finalParts.add(parent.children.get(part));
parent = parent.children.get(part);
}
}
} else {
if (parent.children.containsKey(defaultPart)) {
finalParts.add(parent.children.get(defaultPart));
}
}
return finalParts;
}
}

View file

@ -0,0 +1,52 @@
package com.simibubi.create.content.trains.schedule.hat;
import java.io.BufferedReader;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.JsonObject;
import com.mojang.serialization.JsonOps;
import com.simibubi.create.Create;
import net.minecraft.resources.FileToIdConverter;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.registries.ForgeRegistries;
public class TrainHatInfoReloadListener {
private static final Map<EntityType<?>, TrainHatInfo> ENTITY_INFO_MAP = new HashMap<>();
public static final String HAT_INFO_DIRECTORY = "train_hat_info";
public static final ResourceManagerReloadListener LISTENER = TrainHatInfoReloadListener::registerOffsetOverrides;
private static final TrainHatInfo DEFAULT = new TrainHatInfo("", 0, Vec3.ZERO, 1.0F);
private static void registerOffsetOverrides(ResourceManager manager) {
ENTITY_INFO_MAP.clear();
FileToIdConverter converter = FileToIdConverter.json(HAT_INFO_DIRECTORY);
converter.listMatchingResources(manager).forEach((location, resource) -> {
String[] splitPath = location.getPath().split("/");
ResourceLocation entityName = new ResourceLocation(location.getNamespace(), splitPath[splitPath.length - 1].replace(".json", ""));
if (!ForgeRegistries.ENTITY_TYPES.containsKey(entityName)) {
Create.LOGGER.error("Failed to load train hat info for entity {} as it does not exist.", entityName);
return;
}
try (BufferedReader reader = resource.openAsReader()) {
JsonObject json = GsonHelper.parse(reader);
ENTITY_INFO_MAP.put(ForgeRegistries.ENTITY_TYPES.getValue(entityName), TrainHatInfo.CODEC.parse(JsonOps.INSTANCE, json).resultOrPartial(Create.LOGGER::error).orElseThrow());
} catch (Exception e) {
Create.LOGGER.error("Failed to read train hat info for entity {}!", entityName, e);
}
});
Create.LOGGER.info("Loaded {} train hat configurations.", ENTITY_INFO_MAP.size());
}
public static TrainHatInfo getHatInfoFor(EntityType<?> type) {
return ENTITY_INFO_MAP.getOrDefault(type, DEFAULT);
}
}

View file

@ -41,7 +41,8 @@ import com.simibubi.create.content.trains.TrainHUD;
import com.simibubi.create.content.trains.entity.CarriageContraptionEntity;
import com.simibubi.create.content.trains.entity.CarriageCouplingRenderer;
import com.simibubi.create.content.trains.entity.TrainRelocator;
import com.simibubi.create.content.trains.schedule.TrainHatArmorLayer;
import com.simibubi.create.content.trains.schedule.hat.TrainHatArmorLayer;
import com.simibubi.create.content.trains.schedule.hat.TrainHatInfoReloadListener;
import com.simibubi.create.content.trains.track.CurvedTrackInteraction;
import com.simibubi.create.content.trains.track.TrackBlockOutline;
import com.simibubi.create.content.trains.track.TrackPlacement;
@ -333,6 +334,7 @@ public class ClientEvents {
@SubscribeEvent
public static void registerClientReloadListeners(RegisterClientReloadListenersEvent event) {
event.registerReloadListener(CreateClient.RESOURCE_RELOAD_LISTENER);
event.registerReloadListener(TrainHatInfoReloadListener.LISTENER);
}
@SubscribeEvent

View file

@ -52,6 +52,7 @@ public class CreateDatagen {
generator.addProvider(true, new StandardRecipeGen(output));
generator.addProvider(true, new MechanicalCraftingRecipeGen(output));
generator.addProvider(true, new SequencedAssemblyRecipeGen(output));
generator.addProvider(true, new VanillaHatOffsetGenerator(output));
ProcessingRecipeGen.registerAll(generator, output);
}
}

View file

@ -0,0 +1,68 @@
package com.simibubi.create.infrastructure.data;
import com.simibubi.create.api.data.TrainHatInfoProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.phys.Vec3;
public class VanillaHatOffsetGenerator extends TrainHatInfoProvider {
public VanillaHatOffsetGenerator(PackOutput output) {
super(output);
}
@Override
protected void createOffsets() {
this.makeInfoFor(EntityType.AXOLOTL, new Vec3(0.0F, 1.0F, -2.0F), "head", 0.75F);
this.makeInfoFor(EntityType.BAT, new Vec3(0.0F, 3.0F, 0.0F));
this.makeInfoFor(EntityType.BEE, new Vec3(0.0F, 2.0F, -2.0F), "body", 0.5F);
this.makeInfoFor(EntityType.BLAZE, new Vec3(0.0F, 4.0F, 0.0F));
this.makeInfoFor(EntityType.CAMEL, new Vec3(0.0F, -8.0F, -11.5F), "body/head", 1, 1.0F);
this.makeInfoFor(EntityType.CAT, new Vec3(0.0F, 1.0F, -0.25F));
this.makeInfoFor(EntityType.CAVE_SPIDER, new Vec3(0.0F, 2.0F, -3.5F));
this.makeInfoFor(EntityType.CHICKEN, new Vec3(0.0F, 0.0F, -0.25F));
this.makeInfoFor(EntityType.COD, new Vec3(0.0F, 10.0F, 0.0F));
this.makeInfoFor(EntityType.COW, new Vec3(0.0F, 2.0F, -1.25F));
this.makeInfoFor(EntityType.DOLPHIN, new Vec3(0.0F, 3.0F, 0.0F), "body/head", 0.75F);
this.makeInfoFor(EntityType.DONKEY, new Vec3(0.0F, 0.0F, 2.0F));
this.makeInfoFor(EntityType.ELDER_GUARDIAN, new Vec3(0.0F, 20.0F, 0.0F));
this.makeInfoFor(EntityType.ENDERMITE, new Vec3(0.0F, 2.5F, 0.5F), "segment0", 0.75F);
this.makeInfoFor(EntityType.FOX, new Vec3(0.75F, 2.5F, -2.0F));
this.makeInfoFor(EntityType.FROG, new Vec3(0.0F, -3.0F, -4.25F), "body/head", 0.5F);
this.makeInfoFor(EntityType.GHAST, new Vec3(0.0F, 6.0F, 0.0F), "body");
this.makeInfoFor(EntityType.GLOW_SQUID, new Vec3(0.0F, 6.0F, 0.0F), "body");
this.makeInfoFor(EntityType.GOAT, new Vec3(-0.5F, 2.0F, 0.0F), "nose", 0.5F);
this.makeInfoFor(EntityType.GUARDIAN, new Vec3(0.0F, 20.0F, 0.0F));
this.makeInfoFor(EntityType.HOGLIN, new Vec3(0.0F, 0.0F, -4.5F), 0.5F);
this.makeInfoFor(EntityType.HORSE, new Vec3(0.0F, 0.0F, 2.0F));
this.makeInfoFor(EntityType.IRON_GOLEM, new Vec3(0.0F, -2.0F, -1.5F));
this.makeInfoFor(EntityType.MAGMA_CUBE, new Vec3(0.0F, 16.0F, 0.0F), "cube7");
this.makeInfoFor(EntityType.MOOSHROOM, new Vec3(0.0F, 3.0F, -1.75F));
this.makeInfoFor(EntityType.MULE, new Vec3(0.0F, 0.0F, 2.0F));
this.makeInfoFor(EntityType.OCELOT, new Vec3(0.0F, 1.0F, -0.25F));
this.makeInfoFor(EntityType.PANDA, new Vec3(0.0F, 4.0F, 0.5F), 0.75F);
this.makeInfoFor(EntityType.PARROT, new Vec3(0.0F, 0.0F, -1.5F));
this.makeInfoFor(EntityType.PHANTOM, new Vec3(0.0F, 0.0F, -1.0F), "body/head");
this.makeInfoFor(EntityType.PIG, new Vec3(0.0F, 3.0F, -4.0F));
this.makeInfoFor(EntityType.POLAR_BEAR, new Vec3(0.0F, 3.0F, 0.0F));
this.makeInfoFor(EntityType.PUFFERFISH, new Vec3(0.0F, -0.5F, 0.0F), "body", 0.75F);
this.makeInfoFor(EntityType.RAVAGER, new Vec3(0.0F, 0.0F, -5.5F), "neck/head");
this.makeInfoFor(EntityType.SALMON, new Vec3(0.0F, 1.0F, 0.0F));
this.makeInfoFor(EntityType.SHEEP, new Vec3(0.0F, 0.5F, -0.75F));
this.makeInfoFor(EntityType.SILVERFISH, new Vec3(0.0F, 3.0F, 0.0F), "segment1");
this.makeInfoFor(EntityType.SKELETON_HORSE, new Vec3(0.0F, 0.0F, 2.0F));
this.makeInfoFor(EntityType.SLIME, new Vec3(0.0F, 12.0F, 0.0F), "cube", 1.25F);
this.makeInfoFor(EntityType.SNIFFER, new Vec3(0.0F, 8.0F, -5.0F), "bone/body/head");
this.makeInfoFor(EntityType.SPIDER, new Vec3(0.0F, 2.0F, -3.5F));
this.makeInfoFor(EntityType.SQUID, new Vec3(0.0F, 6.0F, 0.0F), "body");
this.makeInfoFor(EntityType.STRIDER, new Vec3(0.0F, 5.0F, 0.0F), "body");
this.makeInfoFor(EntityType.TADPOLE, new Vec3(0.0F, 1.0F, 1.5F), "body");
this.makeInfoFor(EntityType.TROPICAL_FISH, new Vec3(0.0F, 0.0F, 0.0F), "body", 0.5F);
this.makeInfoFor(EntityType.TURTLE, new Vec3(0.0F, 2.0F, 0.0F));
this.makeInfoFor(EntityType.WARDEN, new Vec3(0.0F, 3.5F, 0.5F), "bone/body/head", 0.5F);
this.makeInfoFor(EntityType.WITHER, new Vec3(0.0F, -5.0F, 0.0F));
this.makeInfoFor(EntityType.WOLF, new Vec3(0.5F, 1.5F, 0.25F));
this.makeInfoFor(EntityType.ZOGLIN, new Vec3(0.0F, 0.0F, -4.5F), 0.5F);
this.makeInfoFor(EntityType.ZOMBIE_HORSE, new Vec3(0.0F, 0.0F, 2.0F));
}
}