use of com.wuest.prefab.structures.predefined.StructureBasic in project MC-Prefab by Brian-Wuest.
the class BasicStructureConfiguration method ConfigurationSpecificBuildStructure.
/**
* This is used to actually build the structure as it creates the structure instance and calls build structure.
*
* @param player The player which requested the build.
* @param world The world instance where the build will occur.
* @param hitBlockPos This hit block position.
*/
@Override
protected void ConfigurationSpecificBuildStructure(Player player, ServerLevel world, BlockPos hitBlockPos) {
String assetLocation = "";
if (!this.IsCustomStructure()) {
assetLocation = this.chosenOption.getAssetLocation();
}
StructureBasic structure = StructureBasic.CreateInstance(assetLocation, StructureBasic.class);
if (structure.BuildStructure(this, world, hitBlockPos, player)) {
ItemStack stack = ItemBasicStructure.getBasicStructureItemInHand(player);
if (!stack.isDamageableItem()) {
if (stack.getCount() == 1) {
player.getInventory().removeItem(stack);
} else {
stack.setCount(stack.getCount() - 1);
}
player.containerMenu.broadcastChanges();
} else {
// The item has durability; damage it since the building was constructed.
this.DamageHeldItem(player, stack.getItem());
}
}
}
Aggregations