Skip to content

Commit

Permalink
fix: duplicate id error on server versions pre 1.13.2 (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingrim4 authored Mar 30, 2024
1 parent 43b6807 commit 709e987
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ private Builder(NamespacedKey key) {
}

public Builder withBlockState(BlockStateProperties blockState) {
if (!blockStates.add(blockState)) {
return this.withBlockState(blockState, false);
}

/** dumb version for dumb id systems (pre 1.13.2) */
@Deprecated
public Builder withBlockState(BlockStateProperties blockState, boolean ignoreDuplicates) {
if (!blockStates.add(blockState) && !ignoreDuplicates) {
throw new IllegalStateException(String.format("duplicate block state id (%s) for block: %s", blockState.getId(), key));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public NmsManager(Config config) {
.withIsDefaultState(Objects.equals(block.getBlockData(), blockState))
.build();

builder.withBlockState(properties);
builder.withBlockState(properties, true);
}

this.registerBlockProperties(builder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public NmsManager(Config config) {
.withIsDefaultState(Objects.equals(block.getBlockData(), blockState))
.build();

builder.withBlockState(properties);
builder.withBlockState(properties, true);
}

this.registerBlockProperties(builder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public NmsManager(Config config) {
.withIsDefaultState(Objects.equals(block.getBlockData(), blockState))
.build();

builder.withBlockState(properties);
builder.withBlockState(properties, true);
}

this.registerBlockProperties(builder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public NmsManager(Config config) {
.withIsDefaultState(Objects.equals(block.getBlockData(), blockState))
.build();

builder.withBlockState(properties);
builder.withBlockState(properties, false);
}

this.registerBlockProperties(builder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,14 @@ public NmsManager(Config config) {
BlockProperties.Builder builder = BlockProperties.builder(namespacedKey);

for (IBlockData blockState : possibleBlockStates) {

BlockStateProperties properties = BlockStateProperties.builder(getBlockId(blockState))
.withIsAir(block instanceof BlockAir)
.withIsOccluding(material.isOccluding())
.withIsBlockEntity(block.isTileEntity())
.withIsDefaultState(Objects.equals(block.getBlockData(), blockState))
.build();

builder.withBlockState(properties);
builder.withBlockState(properties, true);
}

this.registerBlockProperties(builder.build());
Expand Down

0 comments on commit 709e987

Please sign in to comment.