@@ -101,7 +101,7 @@ public InteractionResult use(
101101 final IColony iColony = IColonyManager .getInstance ().getIColony (worldIn , pos );
102102 if (iColony != null )
103103 {
104- iColony .getServerBuildingManager ().addBuildingExtensionIfMissing (BuildingExtensionRegistries .farmField .get (), pos , player );
104+ iColony .getServerBuildingManager ().addBuildingExtensionIfMissing (BuildingExtensionRegistries .farmField .get (), getFieldBasePos ( state , pos ) , player );
105105 }
106106 // This must succeed in Remote to stop more right click interactions like placing blocks
107107 return InteractionResult .SUCCESS ;
@@ -220,11 +220,25 @@ private void notifyColonyAboutDestruction(final Level worldIn, final BlockPos po
220220 {
221221 if (!worldIn .isClientSide ())
222222 {
223- final IColony colony = IColonyManager .getInstance ().getColonyByPosFromWorld (worldIn , pos );
223+ final BlockPos fieldBasePos = getFieldBasePos (worldIn .getBlockState (pos ), pos );
224+ final IColony colony = IColonyManager .getInstance ().getColonyByPosFromWorld (worldIn , fieldBasePos );
225+
224226 if (colony != null )
225227 {
226- colony .getServerBuildingManager ().removeBuildingExtension (field -> field .getBuildingExtensionType ().equals (BuildingExtensionRegistries .farmField .get ()) && field .getPosition ().equals (pos ));
228+ colony .getServerBuildingManager ().removeBuildingExtension (field -> field .getBuildingExtensionType ().equals (BuildingExtensionRegistries .farmField .get ()) && field .getPosition ().equals (fieldBasePos ));
227229 }
228230 }
229231 }
232+
233+ /**
234+ * Resolve a scarecrow block position to the lower-half block that owns the field data.
235+ *
236+ * @param state the currently interacted scarecrow state.
237+ * @param pos the currently interacted block position.
238+ * @return the lower-half block position.
239+ */
240+ private static BlockPos getFieldBasePos (final BlockState state , final BlockPos pos )
241+ {
242+ return state .getValue (HALF ) == DoubleBlockHalf .UPPER ? pos .below () : pos ;
243+ }
230244}
0 commit comments