Skip to content

Commit

Permalink
Merge branch 'dev/1.21' into dev/1.21.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
#	polymer-resource-pack/src/main/java/eu/pb4/polymer/resourcepack/api/ResourcePackBuilder.java
#	polymer-resource-pack/src/main/java/eu/pb4/polymer/resourcepack/impl/generation/DefaultRPBuilder.java
  • Loading branch information
Patbox committed Oct 20, 2024
2 parents 812aac5 + df0e2ae commit 177c7a4
Show file tree
Hide file tree
Showing 25 changed files with 512 additions and 152 deletions.
44 changes: 38 additions & 6 deletions docs/polymer-blocks/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,41 @@ blocks on client yet.

Every block type has its own functionality and behaviour:

- `FULL_BLOCK` - Noteblocks, have full collision and don't allow transparency, (limit: 799)
- `TRANSPARENT_BLOCK` - Mostly leaves, allow "cutout" textures, (limit: 104)
- `FARMLAND_BLOCK` - Farmland blocks, (limit: 5!)
- `FULL_BLOCK` - Noteblocks, have full collision and don't allow transparency, (limit: 1149)
- `TRANSPARENT_BLOCK` - Leaf blocks, allow "cutout" textures, (limit: 52)
- `TRANSPARENT_BLOCK_WATERLOGGED` - Waterlogged leaf blocks, allow "cutout" textures, (limit: 52)
- `BIOME_TRANSPARENT_BLOCK` - Biome tinted leaf blocks, (limit: 78)
- `BIOME_TRANSPARENT_BLOCK_WATERLOGGED` Waterlogged biome tinted leaf blocks- (limit: 65)
- `FARMLAND_BLOCK` - Farmland blocks, (limit: 5)
- `VINES_BLOCK` - All centered vine blocks, Cave Vines, Twisted Vines and Weeping Vines, (limit: 100)
- `PLANT_BLOCK` - Small plant blocks, sugarcane and saplings, (limit: 21)
- `PLANT_BLOCK` - Small plant blocks, mostly saplings, (limit: 7)
- `BIOME_PLANT_BLOCK` - Biome tinted plant blocks, mostly sugarcane (limit: 15)
- `KELP_BLOCK` - Just kelp, (limit: 25)
- `CACTUS_BLOCK` - Just cactus, (limit: 15!)
- `CACTUS_BLOCK` - Just cactus, (limit: 15)
- `SCULK_SENSOR_BLOCK` - Sculk-sensor and it's calibarated variant, half block high, allows transparency, (limit: 150)
- `SCULK_SENSOR_BLOCK_WATERLOGGED` - Waterlogged sculk-sensor and it's calibarated variant, half block high, allows transparency, (limit: 150)
- `TRIPWIRE_BLOCK` - Just Tripwire, allows transparency, (limit: 32)
- `TRIPWIRE_BLOCK_FLAT` - Flat tripwire block, allows transparency, (limit: 32)
- `TOP_SLAB` - Top-slabs, (limit: 5)
- `TOP_SLAB_WATERLOGGED` - Waterlogged top-slabs (limit: 5)
- `BOTTOM_SLAB` - Bottom slabs, don't allow transparency, (limit: 5)
- `BOTTOM_SLAB_WATERLOGGED` - Waterlogged bottom-slabs, don't allow transparency (limit: 5)
- `TOP_TRAPDOOR` - Closed top trapdoor, (limit: 20)
- `BOTTOM_TRAPDOOR` - Closed bottom trapdoor, (limit: 20)
- `NORTH_TRAPDOOR` - Open trapdoor facing north, (limit: 20)
- `EAST_TRAPDOOR` - Open trapdoor facing east, (limit: 20)
- `SOUTH_TRAPDOOR` - Open trapdoor facing south, (limit: 20)
- `WEST_TRAPDOOR` - Open trapdoor facing west, (limit: 20)
- `TOP_TRAPDOOR_WATERLOGGED` - Waterlogged closed top trapdoor, (limit: 20)
- `BOTTOM_TRAPDOOR_WATERLOGGED` - Waterlogged closed bottom top trapdoor, (limit: 20)
- `NORTH_TRAPDOOR_WATERLOGGED` - Waterlogged open trapdoor facing north, (limit: 20)
- `EAST_TRAPDOOR_WATERLOGGED` - Waterlogged open trapdoor facing east, (limit: 20)
- `SOUTH_TRAPDOOR_WATERLOGGED` - Waterlogged open trapdoor facing south, (limit: 20)
- `WEST_TRAPDOOR_WATERLOGGED` - Waterlogged open trapdoor facing west, (limit: 20)
- `NORTH_DOOR` - Door-half facing north, (limit: 160)
- `EAST_DOOR` - Door-half facing east, (limit: 160)
- `SOUTH_DOOR` - Door-half facing south, (limit: 160)
- `WEST_DOOR` - Door-half facing west, (limit: 160)

They all are accessible from `BlockModelType` enum.

Expand All @@ -35,4 +63,8 @@ server resource pack. Remember that you still need to register your assets with

### Just keep in mind
Some block model types have very small amount of free BlockStates. For that reason, while making public registering blocks globally,
please allow for disabling of them and handle running out of them for best compatibility and mod support!
please allow for disabling of them and handle running out of them for best compatibility and mod support!

It is also possible to request an empty blockstate for a BlockModelType using `PolymerBlockResourceUtils.requestEmpty(BlockModelType type)`. This can be used to display custom blocks using display entities. Just be aware that display entities have a much higher performance impact on clients than normal blocks!

Empty models are shared between mods.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,28 @@ public enum BlockModelType {
BIOME_PLANT_BLOCK,
KELP_BLOCK,
CACTUS_BLOCK,
SCULK_SENSOR_BLOCK,
SCULK_SENSOR_BLOCK_WATERLOGGED,
TRIPWIRE_BLOCK,
TRIPWIRE_BLOCK_FLAT,
TOP_SLAB,
TOP_SLAB_WATERLOGGED,
BOTTOM_SLAB,
BOTTOM_SLAB_WATERLOGGED
BOTTOM_SLAB_WATERLOGGED,
TOP_TRAPDOOR,
BOTTOM_TRAPDOOR,
NORTH_TRAPDOOR,
EAST_TRAPDOOR,
SOUTH_TRAPDOOR,
WEST_TRAPDOOR,
TOP_TRAPDOOR_WATERLOGGED,
BOTTOM_TRAPDOOR_WATERLOGGED,
NORTH_TRAPDOOR_WATERLOGGED,
EAST_TRAPDOOR_WATERLOGGED,
SOUTH_TRAPDOOR_WATERLOGGED,
WEST_TRAPDOOR_WATERLOGGED,
NORTH_DOOR,
EAST_DOOR,
SOUTH_DOOR,
WEST_DOOR
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import eu.pb4.polymer.core.impl.PolymerImpl;
import eu.pb4.polymer.resourcepack.api.ResourcePackCreator;
import eu.pb4.polymer.resourcepack.impl.generation.DefaultRPBuilder;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.Waterloggable;
Expand All @@ -25,6 +26,7 @@
public final class BlockResourceCreator {
private static final PolymerBlockModel EMPTY = PolymerBlockModel.of(Identifier.of("polymer", "block/empty"));
private final Map<BlockModelType, List<BlockState>> states;
private final Set<Block> hasRequested = Collections.newSetFromMap(new IdentityHashMap<>());
final Map<BlockState, PolymerBlockModel[]> models;
private final ResourcePackCreator creator;
private final Runnable onRegister;
Expand Down Expand Up @@ -89,6 +91,7 @@ public BlockState requestBlock(BlockModelType type, PolymerBlockModel... model)
this.registerEvent();
var state = states.removeFirst();
models.put(state, model);
this.hasRequested.add(state.getBlock());

if (state.getBlock() instanceof Waterloggable) {
this.blockMapper.stateMap.put(state, DefaultModelData.SPECIAL_REMAPS
Expand Down Expand Up @@ -120,6 +123,9 @@ private void generateResources(DefaultRPBuilder builder, List<String> credits) {
var map = new HashMap<String, HashMap<String, JsonArray>>();

for (var blockStateEntry : this.models.entrySet()) {
if (!this.hasRequested.contains(blockStateEntry.getKey().getBlock())) {
continue;
}
var state = blockStateEntry.getKey();
var models = blockStateEntry.getValue();

Expand All @@ -128,7 +134,7 @@ private void generateResources(DefaultRPBuilder builder, List<String> credits) {
var stateName = PolymerBlocksInternal.generateStateName(state);
var array = PolymerBlocksInternal.createJsonElement(models);

map.computeIfAbsent("assets/" + id.getNamespace() + "/blockstates/" + id.getPath() + ".json", (s) -> new HashMap<>()).put(stateName, array);
map.computeIfAbsent("assets/" + id.getNamespace() + "/blockstates/" + id.getPath() + ".json", (s) -> new HashMap<>()).put(stateName, array);
}

for (var baseEntry : map.entrySet()) {
Expand All @@ -138,7 +144,7 @@ private void generateResources(DefaultRPBuilder builder, List<String> credits) {
var variants = new JsonObject();

var values = new ArrayList<>(baseEntry.getValue().entrySet());
values.sort(Comparator.comparing(e -> e.getKey()));
values.sort(Map.Entry.comparingByKey());
for (var entries : values) {
variants.add(entries.getKey(), entries.getValue());
}
Expand Down
Loading

0 comments on commit 177c7a4

Please sign in to comment.