use of com.ldtteam.structurize.management.StructureName in project minecolonies by ldtteam.
the class WorkOrderBuildDecoration method onCompleted.
@Override
public void onCompleted(final IColony colony, ICitizenData citizen) {
super.onCompleted(colony, citizen);
final StructureName structureName = new StructureName(getStructureName());
if (this instanceof WorkOrderBuildBuilding) {
final int level = ((WorkOrderBuildBuilding) this).getUpgradeLevel();
AdvancementUtils.TriggerAdvancementPlayersForColony(colony, player -> AdvancementTriggers.COMPLETE_BUILD_REQUEST.trigger(player, structureName, level));
} else {
AdvancementUtils.TriggerAdvancementPlayersForColony(colony, player -> AdvancementTriggers.COMPLETE_BUILD_REQUEST.trigger(player, structureName, 0));
}
}
use of com.ldtteam.structurize.management.StructureName in project minecolonies by ldtteam.
the class BuildToolPasteMessage method onExecute.
@Override
public void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer) {
final StructureName sn = new StructureName(structureName);
final ServerPlayerEntity player = ctxIn.getSender();
if (!Structures.hasMD5(sn)) {
player.sendMessage(new StringTextComponent("Can not build " + workOrderName + ": schematic missing!"), player.getUUID());
return;
}
if (player.isCreative()) {
if (isHut) {
handleHut(CompatibilityUtils.getWorldFromEntity(player), player, sn, rotation, pos, mirror, state, complete);
CreativeBuildingStructureHandler.loadAndPlaceStructureWithRotation(player.level, structureName, pos, BlockPosUtil.getRotationFromRotations(rotation), mirror ? Mirror.FRONT_BACK : Mirror.NONE, !complete, player);
@Nullable final IBuilding building = IColonyManager.getInstance().getBuilding(CompatibilityUtils.getWorldFromEntity(player), pos);
if (building != null) {
final WorkOrderBuildBuilding workOrder = new WorkOrderBuildBuilding(building, 1);
ConstructionTapeHelper.removeConstructionTape(workOrder, CompatibilityUtils.getWorldFromEntity(player));
}
} else {
StructurePlacementUtils.loadAndPlaceStructureWithRotation(ctxIn.getSender().level, structureName, pos, BlockPosUtil.getRotationFromRotations(rotation), mirror ? Mirror.FRONT_BACK : Mirror.NONE, !complete, ctxIn.getSender());
}
} else if (structureName.contains("supply")) {
if (player.getStats().getValue(Stats.ITEM_USED.get(ModItems.supplyChest)) > 0 && !MineColonies.getConfig().getServer().allowInfiniteSupplyChests.get() && !isFreeInstantPlacementMH(player)) {
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.error.supplyChestAlreadyPlaced");
return;
}
Predicate<ItemStack> searchPredicate = stack -> !stack.isEmpty();
if (structureName.contains("supplyship")) {
searchPredicate = searchPredicate.and(stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, new ItemStack(ModItems.supplyChest), true, false));
}
if (structureName.contains("supplycamp")) {
searchPredicate = searchPredicate.and(stack -> ItemStackUtils.compareItemStacksIgnoreStackSize(stack, new ItemStack(ModItems.supplyCamp), true, false));
}
if (isFreeInstantPlacementMH(player)) {
searchPredicate = searchPredicate.and(stack -> stack.hasTag() && stack.getTag().get(PLACEMENT_NBT) != null && stack.getTag().getString(PLACEMENT_NBT).equals(INSTANT_PLACEMENT));
}
final int slot = InventoryUtils.findFirstSlotInItemHandlerNotEmptyWith(new InvWrapper(player.inventory), searchPredicate);
if (slot != -1 && !ItemStackUtils.isEmpty(player.inventory.removeItemNoUpdate(slot))) {
if (player.getStats().getValue(Stats.ITEM_USED.get(ModItems.supplyChest)) < 1) {
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.progress.supplies_placed");
player.awardStat(Stats.ITEM_USED.get(ModItems.supplyChest), 1);
AdvancementTriggers.PLACE_SUPPLY.trigger(player);
}
CreativeBuildingStructureHandler.loadAndPlaceStructureWithRotation(player.level, structureName, pos, BlockPosUtil.getRotationFromRotations(rotation), mirror ? Mirror.FRONT_BACK : Mirror.NONE, !complete, player);
} else {
LanguageHandler.sendPlayerMessage(player, "item.supplyChestDeployer.missing");
}
}
}
use of com.ldtteam.structurize.management.StructureName in project minecolonies by ldtteam.
the class BuildToolPlaceMessage method onExecute.
@Override
public void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer) {
final PlayerEntity player = ctxIn.getSender();
final StructureName sn = new StructureName(structureName);
if (!Structures.hasMD5(sn)) {
player.sendMessage(new StringTextComponent("Can not build " + workOrderName + ": schematic missing!"), player.getUUID());
return;
}
if (isHut) {
handleHut(CompatibilityUtils.getWorldFromEntity(player), player, sn, rotation, pos, mirror, state);
} else {
handleDecoration(CompatibilityUtils.getWorldFromEntity(player), player, sn, workOrderName, rotation, pos, mirror, builder);
}
}
Aggregations