Skip to content

Commit

Permalink
Update for MC 1.21.2 mappings
Browse files Browse the repository at this point in the history
Changes taken from gnembon/carpet-extra#333
  • Loading branch information
alext committed Nov 15, 2024
1 parent 68065b0 commit 88e621f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/carpetabp/utils/BlockPlacer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.minecraft.block.enums.ComparatorMode;
import net.minecraft.block.enums.SlabType;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.state.property.Property;
import net.minecraft.util.math.BlockPos;
Expand All @@ -31,7 +31,7 @@ public static BlockState alternativeBlockPlacement(Block block, ItemPlacementCon

// It would be nice if relativeHitX was adjusted in context to original range from 0.0 to 1.0,
// since some blocks are actually using it.
DirectionProperty directionProp = getFirstDirectionProperty(state);
EnumProperty<Direction> directionProp = getFirstDirectionProperty(state);
int protocolValue = ((int) relativeHitX - 2) / 2;

if (directionProp != null)
Expand Down Expand Up @@ -110,14 +110,18 @@ else if (state.contains(Properties.SLAB_TYPE) &&
return state;
}

@SuppressWarnings("unchecked")
@Nullable
public static DirectionProperty getFirstDirectionProperty(BlockState state)
public static EnumProperty<Direction> getFirstDirectionProperty(BlockState state)
{
for (Property<?> prop : state.getProperties())
{
if (prop instanceof DirectionProperty)
if (prop instanceof EnumProperty<?> enumProperty)
{
return (DirectionProperty) prop;
if (enumProperty.getType().equals(Direction.class))
{
return (EnumProperty<Direction>) enumProperty;
}
}
}

Expand Down

0 comments on commit 88e621f

Please sign in to comment.