use of com.minecolonies.coremod.tileentities.ScarecrowTileEntity in project minecolonies by Minecolonies.
the class BuildingFarmer method freeField.
/**
* Method called to free a field.
*
* @param position id of the field.
*/
public void freeField(final BlockPos position) {
//Get the field with matching id, if none found return null.
final Field tempField = farmerFields.stream().filter(field -> field.getID().equals(position)).findFirst().orElse(null);
if (tempField != null) {
farmerFields.remove(tempField);
final Field field = getColony().getField(position);
field.setTaken(false);
field.setOwner("");
final ScarecrowTileEntity scarecrowTileEntity = (ScarecrowTileEntity) getColony().getWorld().getTileEntity(field.getID());
getColony().getWorld().notifyBlockUpdate(scarecrowTileEntity.getPos(), getColony().getWorld().getBlockState(scarecrowTileEntity.getPos()), getColony().getWorld().getBlockState(scarecrowTileEntity.getPos()), BLOCK_UPDATE_FLAG);
scarecrowTileEntity.setName(LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_SCARECROW_USER, LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_SCARECROW_USER_NOONE)));
}
}
use of com.minecolonies.coremod.tileentities.ScarecrowTileEntity in project minecolonies by Minecolonies.
the class BuildingFarmer method onDestroyed.
@Override
public void onDestroyed() {
super.onDestroyed();
for (@NotNull final Field field : farmerFields) {
final Field tempField = getColony().getField(field.getID());
if (tempField != null) {
tempField.setTaken(false);
tempField.setOwner("");
if (getColony().getWorld() != null) {
final ScarecrowTileEntity scarecrowTileEntity = (ScarecrowTileEntity) getColony().getWorld().getTileEntity(field.getID());
getColony().getWorld().notifyBlockUpdate(scarecrowTileEntity.getPos(), getColony().getWorld().getBlockState(scarecrowTileEntity.getPos()), getColony().getWorld().getBlockState(scarecrowTileEntity.getPos()), BLOCK_UPDATE_FLAG);
scarecrowTileEntity.setName(LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_SCARECROW_USER, LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_SCARECROW_USER_NOONE)));
}
}
}
}
Aggregations