use of net.minecraft.block.BlockShulkerBox in project RFTools by McJty.
the class BuilderTileEntity method commonQuarryBlock.
private boolean commonQuarryBlock(boolean silk, int rfNeeded, BlockPos srcPos, IBlockState srcState) {
Block block = srcState.getBlock();
int xCoord = getPos().getX();
int yCoord = getPos().getY();
int zCoord = getPos().getZ();
int sx = srcPos.getX();
int sy = srcPos.getY();
int sz = srcPos.getZ();
if (sx >= xCoord - 1 && sx <= xCoord + 1 && sy >= yCoord - 1 && sy <= yCoord + 1 && sz >= zCoord - 1 && sz <= zCoord + 1) {
// Skip a 3x3x3 block around the builder.
return skip();
}
if (isEmpty(srcState, block)) {
return skip();
}
if (block.getBlockHardness(srcState, getWorld(), srcPos) >= 0) {
boolean clear = getCardType().isClearing();
if ((!clear) && srcState == getReplacementBlock()) {
// We can skip dirt if we are not clearing.
return skip();
}
if ((!BuilderConfiguration.quarryTileEntities) && getWorld().getTileEntity(srcPos) != null) {
// Skip tile entities
return skip();
}
FakePlayer fakePlayer = getHarvester();
if (allowedToBreak(srcState, getWorld(), srcPos, fakePlayer)) {
ItemStack filter = getStackInSlot(BuilderContainer.SLOT_FILTER);
if (!filter.isEmpty()) {
getFilterCache();
if (filterCache != null) {
boolean match = filterCache.match(block.getItem(getWorld(), srcPos, srcState));
if (!match) {
consumeEnergy(Math.min(rfNeeded, BuilderConfiguration.builderRfPerSkipped));
// Skip this
return skip();
}
}
}
if (!getCachedVoidableBlocks().contains(block)) {
List<ItemStack> drops;
if (silk && block.canSilkHarvest(getWorld(), srcPos, srcState, fakePlayer)) {
ItemStack drop;
try {
drop = (ItemStack) CommonProxy.Block_getSilkTouch.invoke(block, srcState);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
drops = new ArrayList<>();
if (!drop.isEmpty()) {
drops.add(drop);
}
net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(drops, getWorld(), srcPos, srcState, 0, 1.0f, true, fakePlayer);
} else {
int fortune = getCardType().isFortune() ? 3 : 0;
if (block instanceof BlockShulkerBox) {
// Shulker boxes drop in setBlockState, rather than anywhere sensible. Work around this.
drops = new ArrayList<>();
TileEntity te = getWorld().getTileEntity(srcPos);
if (te instanceof TileEntityShulkerBox) {
TileEntityShulkerBox teShulkerBox = (TileEntityShulkerBox) te;
ItemStack stack = new ItemStack(Item.getItemFromBlock(block));
teShulkerBox.saveToNbt(stack.getOrCreateSubCompound("BlockEntityTag"));
if (teShulkerBox.hasCustomName()) {
stack.setStackDisplayName(teShulkerBox.getName());
}
drops.add(stack);
}
} else {
drops = block.getDrops(getWorld(), srcPos, srcState, fortune);
}
net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(drops, getWorld(), srcPos, srcState, fortune, 1.0f, false, fakePlayer);
}
if (!checkAndInsertItems(block, drops)) {
// Not enough room. Wait
return waitOrSkip("Not enough room!\nor no usable storage\non top or below!");
}
}
clearOrDirtBlock(rfNeeded, srcPos, srcState, clear);
}
}
return silk ? skip() : false;
}
Aggregations