use of mekanism.common.block.BlockBounding in project Mekanism by mekanism.
the class WorldUtils method makeAdvancedBoundingBlock.
/**
* Places a fake advanced bounding block at the defined location.
*
* @param world world to place block in
* @param boundingLocation coordinates of bounding block
* @param orig original block position
*/
public static void makeAdvancedBoundingBlock(IWorld world, BlockPos boundingLocation, BlockPos orig) {
BlockBounding boundingBlock = MekanismBlocks.ADVANCED_BOUNDING_BLOCK.getBlock();
BlockState newState = BlockStateHelper.getStateForPlacement(boundingBlock, boundingBlock.defaultBlockState(), world, boundingLocation, null, Direction.NORTH);
world.setBlock(boundingLocation, newState, BlockFlags.DEFAULT);
if (!world.isClientSide()) {
TileEntityAdvancedBoundingBlock tile = getTileEntity(TileEntityAdvancedBoundingBlock.class, world, boundingLocation);
if (tile != null) {
tile.setMainLocation(orig);
} else {
Mekanism.logger.warn("Unable to find Advanced Bounding Block Tile at: {}", boundingLocation);
}
}
}
use of mekanism.common.block.BlockBounding in project Mekanism by mekanism.
the class ItemMekaTool method onBlockStartBreak.
@Override
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, PlayerEntity player) {
if (player.level.isClientSide || player.isCreative()) {
return super.onBlockStartBreak(stack, pos, player);
}
IEnergyContainer energyContainer = StorageUtils.getEnergyContainer(stack, 0);
if (energyContainer != null) {
World world = player.level;
BlockState state = world.getBlockState(pos);
boolean silk = isModuleEnabled(stack, MekanismModules.SILK_TOUCH_UNIT);
FloatingLong energyRequired = getDestroyEnergy(stack, state.getDestroySpeed(world, pos), silk);
if (energyContainer.extract(energyRequired, Action.SIMULATE, AutomationType.MANUAL).greaterOrEqual(energyRequired)) {
IModule<ModuleVeinMiningUnit> veinMiningUnit = getModule(stack, MekanismModules.VEIN_MINING_UNIT);
// Even though we now handle breaking bounding blocks properly, don't allow vein mining them
if (veinMiningUnit != null && veinMiningUnit.isEnabled() && !(state.getBlock() instanceof BlockBounding)) {
boolean isOre = state.is(MekanismTags.Blocks.ATOMIC_DISASSEMBLER_ORE);
// If it is extended or should be treated as an ore
if (isOre || veinMiningUnit.getCustomInstance().isExtended()) {
// Don't include bonus energy required by efficiency modules when calculating energy of vein mining targets
FloatingLong baseDestroyEnergy = getDestroyEnergy(silk);
Set<BlockPos> found = ModuleVeinMiningUnit.findPositions(state, pos, world, isOre ? -1 : veinMiningUnit.getCustomInstance().getExcavationRange());
MekanismUtils.veinMineArea(energyContainer, world, pos, (ServerPlayerEntity) player, stack, this, found, isModuleEnabled(stack, MekanismModules.SHEARING_UNIT), hardness -> getDestroyEnergy(baseDestroyEnergy, hardness), distance -> 0.5 * Math.pow(distance, isOre ? 1.5 : 2), state);
}
}
}
}
return super.onBlockStartBreak(stack, pos, player);
}
use of mekanism.common.block.BlockBounding in project Mekanism by mekanism.
the class ItemAtomicDisassembler method onBlockStartBreak.
@Override
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, PlayerEntity player) {
if (player.level.isClientSide || player.isCreative()) {
return super.onBlockStartBreak(stack, pos, player);
}
IEnergyContainer energyContainer = StorageUtils.getEnergyContainer(stack, 0);
if (energyContainer != null && getMode(stack) == DisassemblerMode.VEIN) {
World world = player.level;
BlockState state = world.getBlockState(pos);
FloatingLong baseDestroyEnergy = getDestroyEnergy(stack);
FloatingLong energyRequired = getDestroyEnergy(baseDestroyEnergy, state.getDestroySpeed(world, pos));
if (energyContainer.extract(energyRequired, Action.SIMULATE, AutomationType.MANUAL).greaterOrEqual(energyRequired)) {
// only allow mining things that are considered an ore
if (!(state.getBlock() instanceof BlockBounding) && state.is(MekanismTags.Blocks.ATOMIC_DISASSEMBLER_ORE)) {
List<BlockPos> found = findPositions(state, pos, world);
MekanismUtils.veinMineArea(energyContainer, world, pos, (ServerPlayerEntity) player, stack, this, found, false, hardness -> getDestroyEnergy(baseDestroyEnergy, hardness), distance -> 0.5 * Math.pow(distance, 1.5), state);
}
}
}
return super.onBlockStartBreak(stack, pos, player);
}
Aggregations