mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Give stable doors their internals back
This commit is contained in:
parent
956b55dc30
commit
54db20a623
4 changed files with 116 additions and 1 deletions
|
@ -30,6 +30,8 @@ public interface BlockModels {
|
|||
Model STRAIGHT_STAIRS = block("seethrough_stairs", TextureKey.BOTTOM, TextureKey.TOP, TextureKey.SIDE, STEP);
|
||||
Model INNER_STAIRS = block("inner_seethrough_stairs", "_inner", TextureKey.BOTTOM, TextureKey.TOP, TextureKey.SIDE, STEP);
|
||||
Model OUTER_STAIRS = block("outer_seethrough_stairs", "_outer", TextureKey.BOTTOM, TextureKey.TOP, TextureKey.SIDE, STEP);
|
||||
Model DOOR_LEFT = block("door_left", TextureKey.BOTTOM, TextureKey.TOP);
|
||||
Model DOOR_RIGHT = block("door_right", TextureKey.BOTTOM, TextureKey.TOP);
|
||||
|
||||
Factory CROP = Factory.of(TextureMap::crop, Models.CROP);
|
||||
Factory CUBE_ALL = Factory.of(TextureMap::all, Models.CUBE_ALL);
|
||||
|
|
|
@ -18,7 +18,10 @@ import com.minelittlepony.unicopia.server.world.Tree;
|
|||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.enums.DoorHinge;
|
||||
import net.minecraft.block.enums.DoubleBlockHalf;
|
||||
import net.minecraft.data.client.BlockStateModelGenerator;
|
||||
import net.minecraft.data.client.BlockStateSupplier;
|
||||
import net.minecraft.data.client.BlockStateVariant;
|
||||
import net.minecraft.data.client.BlockStateVariantMap;
|
||||
import net.minecraft.data.client.Model;
|
||||
|
@ -75,7 +78,7 @@ public class UBlockStateModelGenerator extends BlockStateModelGenerator {
|
|||
registerAll((g, block) -> g.registerParentedItemModel(block, ModelIds.getBlockModelId(block)), UBlocks.SHAPING_BENCH, UBlocks.SURFACE_CHITIN);
|
||||
registerAll(UBlockStateModelGenerator::registerSimpleState, UBlocks.SHAPING_BENCH, UBlocks.BANANAS);
|
||||
// doors
|
||||
registerAll(UBlockStateModelGenerator::registerDoor, UBlocks.STABLE_DOOR, UBlocks.DARK_OAK_DOOR, UBlocks.CRYSTAL_DOOR, UBlocks.CLOUD_DOOR);
|
||||
registerAll(UBlockStateModelGenerator::registerStableDoor, UBlocks.STABLE_DOOR, UBlocks.DARK_OAK_DOOR, UBlocks.CRYSTAL_DOOR, UBlocks.CLOUD_DOOR);
|
||||
|
||||
// cloud blocks
|
||||
createCustomTexturePool(UBlocks.CLOUD, TexturedModel.CUBE_ALL).same(UBlocks.UNSTABLE_CLOUD).slab(UBlocks.CLOUD_SLAB).stairs(UBlocks.CLOUD_STAIRS);
|
||||
|
@ -311,6 +314,78 @@ public class UBlockStateModelGenerator extends BlockStateModelGenerator {
|
|||
super.registerBed(bed, particleSource);
|
||||
}
|
||||
|
||||
public void registerStableDoor(Block door) {
|
||||
TextureMap topTextures = TextureMap.topBottom(door);
|
||||
TextureMap bottomTextures = topTextures.copyAndAdd(TextureKey.TOP, topTextures.getTexture(TextureKey.BOTTOM));
|
||||
registerItemModel(door.asItem());
|
||||
blockStateCollector.accept(createStableDoorBlockState(door,
|
||||
BlockModels.DOOR_LEFT.upload(door, "_bottom_left", bottomTextures, modelCollector),
|
||||
BlockModels.DOOR_RIGHT.upload(door, "_bottom_right", bottomTextures, modelCollector),
|
||||
BlockModels.DOOR_LEFT.upload(door, "_top_left", topTextures, modelCollector),
|
||||
BlockModels.DOOR_RIGHT.upload(door, "_top_right", topTextures, modelCollector)
|
||||
));
|
||||
}
|
||||
|
||||
public static BlockStateSupplier createStableDoorBlockState(Block doorBlock, Identifier bottomLeftHingeClosedModelId, Identifier bottomRightHingeClosedModelId, Identifier topLeftHingeClosedModelId, Identifier topRightHingeClosedModelId) {
|
||||
var variants = BlockStateVariantMap.create(Properties.HORIZONTAL_FACING, Properties.DOUBLE_BLOCK_HALF, Properties.DOOR_HINGE, Properties.OPEN);
|
||||
fillStableDoorVariantMap(variants, DoubleBlockHalf.LOWER, bottomLeftHingeClosedModelId, bottomRightHingeClosedModelId);
|
||||
fillStableDoorVariantMap(variants, DoubleBlockHalf.UPPER, topLeftHingeClosedModelId, topRightHingeClosedModelId);
|
||||
return VariantsBlockStateSupplier.create(doorBlock).coordinate(variants);
|
||||
}
|
||||
|
||||
public static BlockStateVariantMap.QuadrupleProperty<Direction, DoubleBlockHalf, DoorHinge, Boolean> fillStableDoorVariantMap(
|
||||
BlockStateVariantMap.QuadrupleProperty<Direction, DoubleBlockHalf, DoorHinge, Boolean> variantMap,
|
||||
DoubleBlockHalf targetHalf, Identifier leftModelId, Identifier rightModelId) {
|
||||
return variantMap
|
||||
.register(Direction.EAST, targetHalf, DoorHinge.LEFT, false, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, leftModelId))
|
||||
.register(Direction.SOUTH, targetHalf, DoorHinge.LEFT, false, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, leftModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R90))
|
||||
.register(Direction.WEST, targetHalf, DoorHinge.LEFT, false, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, leftModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R180))
|
||||
.register(Direction.NORTH, targetHalf, DoorHinge.LEFT, false, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, leftModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R270))
|
||||
|
||||
.register(Direction.EAST, targetHalf, DoorHinge.RIGHT, false, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, rightModelId))
|
||||
.register(Direction.SOUTH, targetHalf, DoorHinge.RIGHT, false, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, rightModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R90))
|
||||
.register(Direction.WEST, targetHalf, DoorHinge.RIGHT, false, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, rightModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R180))
|
||||
.register(Direction.NORTH, targetHalf, DoorHinge.RIGHT, false, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, rightModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R270))
|
||||
|
||||
.register(Direction.EAST, targetHalf, DoorHinge.LEFT, true, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, rightModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R90))
|
||||
.register(Direction.SOUTH, targetHalf, DoorHinge.LEFT, true, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, rightModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R180))
|
||||
.register(Direction.WEST, targetHalf, DoorHinge.LEFT, true, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, rightModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R270))
|
||||
.register(Direction.NORTH, targetHalf, DoorHinge.LEFT, true, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, rightModelId))
|
||||
|
||||
.register(Direction.EAST, targetHalf, DoorHinge.RIGHT, true, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, leftModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R270))
|
||||
.register(Direction.SOUTH, targetHalf, DoorHinge.RIGHT, true, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, leftModelId))
|
||||
.register(Direction.WEST, targetHalf, DoorHinge.RIGHT, true, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, leftModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R90))
|
||||
.register(Direction.NORTH, targetHalf, DoorHinge.RIGHT, true, BlockStateVariant.create()
|
||||
.put(VariantSettings.MODEL, leftModelId)
|
||||
.put(VariantSettings.Y, VariantSettings.Rotation.R180));
|
||||
}
|
||||
|
||||
public void registerHiveBlock(Block hive) {
|
||||
Identifier core = ModelIds.getBlockSubModelId(hive, "_core");
|
||||
Identifier side = ModelIds.getBlockSubModelId(hive, "_side");
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"ambientocclusion": false,
|
||||
"textures": {
|
||||
"particle": "#top"
|
||||
},
|
||||
"elements": [
|
||||
{ "from": [ 0, 0, 0 ],
|
||||
"to": [ 3, 16, 16 ],
|
||||
"faces": {
|
||||
"up": { "uv": [ 13, 0, 16, 16 ], "texture": "#bottom", "cullface": "up" },
|
||||
"down": { "uv": [ 13, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
|
||||
"north": { "uv": [ 3, 0, 0, 16 ], "texture": "#top", "cullface": "north" },
|
||||
"south": { "uv": [ 0, 0, 3, 16 ], "texture": "#top", "cullface": "south" },
|
||||
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "cullface": "west" },
|
||||
"east": { "uv": [ 16, 0, 0, 16 ], "texture": "#top", "cullface": "east" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"ambientocclusion": false,
|
||||
"textures": {
|
||||
"particle": "#top"
|
||||
},
|
||||
"elements": [
|
||||
{ "from": [ 0, 0, 0 ],
|
||||
"to": [ 3, 16, 16 ],
|
||||
"faces": {
|
||||
"up": { "uv": [ 13, 0, 16, 16 ], "texture": "#bottom", "cullface": "up" },
|
||||
"down": { "uv": [ 13, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
|
||||
"north": { "uv": [ 3, 0, 0, 16 ], "texture": "#top", "cullface": "north" },
|
||||
"south": { "uv": [ 0, 0, 3, 16 ], "texture": "#top", "cullface": "south" },
|
||||
"west": { "uv": [ 16, 0, 0, 16 ], "texture": "#top", "cullface": "west" },
|
||||
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "cullface": "east" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue