use of com.minecolonies.coremod.colony.buildings.BuildingWareHouse in project minecolonies by Minecolonies.
the class TileEntityWareHouse method update.
@Override
public void update() {
super.update();
if (ticksPassed != WAIT_TICKS) {
ticksPassed++;
return;
}
ticksPassed = 0;
final AbstractBuilding wareHouseBuilding = getBuilding();
if (getColony() != null && wareHouseBuilding instanceof BuildingWareHouse && !((BuildingWareHouse) wareHouseBuilding).getRegisteredDeliverymen().isEmpty()) {
final Map<BlockPos, AbstractBuilding> buildingMap = getColony().getBuildings();
if (buildingMap.size() < this.index) {
this.index = 1;
}
int i = 1;
for (@NotNull final Map.Entry<BlockPos, AbstractBuilding> buildingEntry : buildingMap.entrySet()) {
if (i == index) {
if (!taskSet.contains(buildingEntry.getValue()) && buildingEntry.getValue().needsAnything()) {
checkInWareHouse(buildingEntry.getValue(), true);
}
this.index++;
}
i++;
}
}
}
use of com.minecolonies.coremod.colony.buildings.BuildingWareHouse in project minecolonies by Minecolonies.
the class UpgradeWarehouseMessage method messageOnServerThread.
@Override
public void messageOnServerThread(final UpgradeWarehouseMessage message, final EntityPlayerMP player) {
final Colony colony = ColonyManager.getColony(message.colonyId);
if (colony == null) {
Log.getLogger().warn("UpgradeWarehouseMessage colony is null");
return;
}
if (!colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) {
return;
}
final AbstractBuilding building = colony.getBuildingManager().getBuilding(message.buildingId);
if (!(building instanceof BuildingWareHouse)) {
Log.getLogger().warn("UpgradeWarehouseMessage building is not a Warehouse");
return;
}
((BuildingWareHouse) building).upgradeContainers(player.world);
final boolean isCreative = player.capabilities.isCreativeMode;
if (!isCreative) {
final int slot = InventoryUtils.findFirstSlotInItemHandlerWith(new InvWrapper(player.inventory), itemStack -> itemStack.isItemEqual(new ItemStack(Blocks.EMERALD_BLOCK)));
player.inventory.decrStackSize(slot, 1);
}
}
Aggregations