Skip to content

Commit

Permalink
fix: fully compare properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dordsor21 committed Nov 4, 2024
1 parent 219cd15 commit 2c1a212
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2788,7 +2788,7 @@ public int thaw(BlockVector3 position, double radius, int height)
if (setBlock(mutable, air)) {
if (y > getMinY()) {
BlockState block = getBlock(mutable2);
if (block.getBlockType().hasPropertyOfType(snowy.getKey(), snowy.getClass())) {
if (block.getBlockType().hasProperty(snowy)) {
if (setBlock(mutable2, block.with(snowy, false))) {
affected++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public boolean apply(BlockVector3 position, int depth) throws WorldEditException
return false;
} else if (!block.getBlockType().getMaterial().isFullCube()) {
BlockType type = block.getBlockType();
if (type.hasPropertyOfType(slab.getKey(), slab.getClass()) && block.getState(slab).equalsIgnoreCase("bottom")) {
if (type.hasProperty(slab) && block.getState(slab).equalsIgnoreCase("bottom")) {
return false;
} else if ((type.hasPropertyOfType(trapdoorOpen.getKey(), trapdoorOpen.getClass()) && block.getState(trapdoorOpen)) ||
(type.hasPropertyOfType(trapdoor.getKey(), trapdoor.getClass()) && block.getState(trapdoor).equalsIgnoreCase("bottom"))) {
} else if ((type.hasProperty(trapdoorOpen) && block.getState(trapdoorOpen)) ||
(type.hasProperty(trapdoor) && block.getState(trapdoor).equalsIgnoreCase("bottom"))) {
return false;
} else if (type.hasPropertyOfType(stair.getKey(), stair.getClass()) && block.getState(stair).equalsIgnoreCase("bottom")) {
} else if (type.hasProperty(stair) && block.getState(stair).equalsIgnoreCase("bottom")) {
return false;
} else {
return false;
Expand All @@ -143,14 +143,14 @@ public boolean apply(BlockVector3 position, int depth) throws WorldEditException
// We've hit the highest layer (If it doesn't contain current + 2 it means it's 1 away from full)
if (!snowLayersProperty.getValues().contains(currentHeight + 2)) {
if (this.extent.setBlock(abovePosition, snowBlock)) {
if (block.getBlockType().hasPropertyOfType(snowy.getKey(), snowy.getClass())) {
if (block.getBlockType().hasProperty(snowy)) {
this.extent.setBlock(position, block.with(snowy, true));
}
this.affected++;
}
} else {
if (this.extent.setBlock(abovePosition, above.with(snowLayersProperty, currentHeight + 1))) {
if (block.getBlockType().hasPropertyOfType(snowy.getKey(), snowy.getClass())) {
if (block.getBlockType().hasProperty(snowy)) {
this.extent.setBlock(position, block.with(snowy, true));
}
this.affected++;
Expand All @@ -159,7 +159,7 @@ public boolean apply(BlockVector3 position, int depth) throws WorldEditException
return false;
}
if (this.extent.setBlock(abovePosition, snow)) {
if (block.getBlockType().hasPropertyOfType(snowy.getKey(), snowy.getClass())) {
if (block.getBlockType().hasProperty(snowy)) {
this.extent.setBlock(position, block.with(snowy, true));
}
this.affected++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public void setName(final String name) {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Property)) {
if (!(obj instanceof Property property)) {
return false;
}
return getName().equals(((Property<?>) obj).getName());
return getName().equals(property.getName()) && property.getValues().equals(getValues());
}
//FAWE end
}
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public <V> BlockState withProperties(final BlockState other) {
BlockState newState = this;
for (Property<?> prop : ot.getProperties()) {
PropertyKey key = prop.getKey();
if (blockType.hasPropertyOfType(key, prop.getClass())) {
if (blockType.hasProperty(prop)) {
newState = newState.with(key, other.getState(key));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,17 @@ public boolean hasProperty(PropertyKey key) {
}

/**
* {@return whether this block type has a property with given key of the given type}
* {@return whether this block type has a given property}
*
* @param key the key identifying the property
* @param propertyType the expected type of the property
* @param property the expected property
* @since TODO
*/
@SuppressWarnings("rawtypes")
public boolean hasPropertyOfType(PropertyKey key, Class<? extends Property> propertyType) {
int ordinal = key.getId();
Property<?> property;
public boolean hasProperty(Property<?> property) {
int ordinal = property.getKey().getId();
Property<?> selfProperty;
return this.settings.propertiesMapArr.length > ordinal
&& (property = this.settings.propertiesMapArr[ordinal]) != null
&& property.getClass() == propertyType;
&& (selfProperty = this.settings.propertiesMapArr[ordinal]) != null
&& selfProperty == property;
}

public <V> Property<V> getProperty(PropertyKey key) {
Expand Down

0 comments on commit 2c1a212

Please sign in to comment.