diff --git a/src/main/java/fi/dy/masa/tweakeroo/tweaks/PlacementHandler.java b/src/main/java/fi/dy/masa/tweakeroo/tweaks/PlacementHandler.java index 64a05dea0..4d030e715 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/tweaks/PlacementHandler.java +++ b/src/main/java/fi/dy/masa/tweakeroo/tweaks/PlacementHandler.java @@ -39,9 +39,8 @@ public class PlacementHandler Properties.INVERTED, Properties.OPEN, //Properties.PERSISTENT, - // TODO --> TEST (Boolean) - Properties.POWERED, - Properties.LOCKED, + //Properties.POWERED, + //Properties.LOCKED, //Properties.WATERLOGGED // EnumProperty: // ATTACHMENT - Bells @@ -82,6 +81,14 @@ public class PlacementHandler Properties.ROTATION ); + /** + * BlackList for Block States. Entries here will be reset to their default value. + */ + public static final ImmutableSet> BLACKLISTED_PROPERTIES = ImmutableSet.of( + Properties.WATERLOGGED, + Properties.POWERED + ); + public static EasyPlacementProtocol getEffectiveProtocolVersion() { EasyPlacementProtocol protocol = (EasyPlacementProtocol) Configs.Generic.ACCURATE_PLACEMENT_PROTOCOL_MODE.getOptionListValue(); @@ -232,9 +239,23 @@ public static > BlockState applyPlacementProtocolV3(Bloc { for (Property p : propList) { + //System.out.printf("[PHv3] check property [%s], whitelisted [%s], blacklisted [%s]\n", p.getName(), WHITELISTED_PROPERTIES.contains(p), BLACKLISTED_PROPERTIES.contains(p)); + if ((property.isPresent() && !property.get().equals(p)) || (property.isEmpty()) && WHITELISTED_PROPERTIES.contains(p)) + //WHITELISTED_PROPERTIES.contains(p) && + //!BLACKLISTED_PROPERTIES.contains(p)) + + /* + if (property.isPresent() && property.get().equals(p)) + { + //System.out.printf("[PHv3] skipping prot val: 0x%08X [Property %s]\n", protocolValue, p.getName()); + continue; + } + else if (WHITELISTED_PROPERTIES.contains(p) && + !BLACKLISTED_PROPERTIES.contains(p)) + */ { @SuppressWarnings("unchecked") Property prop = (Property) p; @@ -278,6 +299,20 @@ public static > BlockState applyPlacementProtocolV3(Bloc Tweakeroo.logger.warn("Exception trying to apply placement protocol value", e); } + // Strip Blacklisted properties, and use the Block's default state. + // This needs to be done after the initial loop, or it breaks compatibility + for (Property p : BLACKLISTED_PROPERTIES) + { + if (state.contains(p)) + { + @SuppressWarnings("unchecked") + Property prop = (Property) p; + BlockState def = state.getBlock().getDefaultState(); + state = state.with(prop, def.get(prop)); + //System.out.printf("[PHv3] blacklisted state [%s] found, setting default value\n", prop.getName()); + } + } + if (state.canPlaceAt(context.getWorld(), context.getPos())) { //System.out.printf("validator passed for \"%s\"\n", state);