use of com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock in project ResourcefulBees by Resourceful-Bees.
the class ApiaryController method runCreativeBuild.
public void runCreativeBuild(ServerPlayer player) {
if (this.level != null) {
buildStructureBlockList();
boolean addedStorage = false;
for (BlockPos pos : structureBlocks) {
Block block = this.level.getBlockState(pos).getBlock();
if (!(block instanceof ApiaryBlock)) {
if (addedStorage) {
this.level.setBlockAndUpdate(pos, Blocks.GLASS.defaultBlockState());
} else {
this.level.setBlockAndUpdate(pos, ModBlocks.APIARY_STORAGE_BLOCK.get().defaultBlockState());
addedStorage = true;
}
}
}
runStructureValidation(player);
}
}
use of com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock in project ResourcefulBees by Resourceful-Bees.
the class ApiaryUpgradeRecipe method getRemainingItems.
@Override
@NotNull
public NonNullList<ItemStack> getRemainingItems(@NotNull CraftingContainer inventory) {
NonNullList<ItemStack> remainingItems = super.getRemainingItems(inventory);
for (int i = 0; i < inventory.getContainerSize(); i++) {
ItemStack item = inventory.getItem(i);
Block block = Block.byItem(item.getItem());
if (block instanceof ApiaryBlock || block instanceof BeehiveBlock) {
ItemStack box = getBeeBoxFromHive(item);
if (box == null)
continue;
remainingItems.set(i, box);
}
}
return remainingItems;
}
use of com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock in project ResourcefulBees by Resourceful-Bees.
the class ApiaryController method validateBlocks.
private boolean validateBlocks(AtomicBoolean isStructureValid, Level worldIn, @Nullable ServerPlayer validatingPlayer) {
structureBlocks.forEach(pos -> {
Block block = worldIn.getBlockState(pos).getBlock();
if (block.is(BeeInfoUtils.getValidApiaryTag()) || block instanceof ApiaryBreederBlock || block instanceof ApiaryStorageBlock || block instanceof ApiaryBlock) {
BlockEntity tile = worldIn.getBlockEntity(pos);
linkStorageAndBreeder(tile);
} else {
isStructureValid.set(false);
if (validatingPlayer != null)
validatingPlayer.displayClientMessage(new TextComponent(String.format("Block at position (X: %1$s Y: %2$s Z: %3$s) is invalid!", pos.getX(), pos.getY(), pos.getZ())), false);
}
});
return isStructureValid.get();
}
use of com.teamresourceful.resourcefulbees.block.multiblocks.apiary.ApiaryBlock in project ResourcefulBees by Resourceful-Bees.
the class PreviewHandler method onWorldRenderLast.
public static void onWorldRenderLast(RenderWorldLastEvent event) {
Level world = Minecraft.getInstance().level;
PoseStack ms = event.getMatrixStack();
MultiBufferSource.BufferSource buffers = Minecraft.getInstance().renderBuffers().bufferSource();
VertexConsumer buffer = buffers.getBuffer(RenderType.translucent());
if (apiaryPos != null && enabled) {
if (world != null && world.getBlockState(apiaryPos).getBlock() instanceof ApiaryBlock) {
if (world.getBlockEntity(apiaryPos) instanceof ApiaryTileEntity) {
ApiaryTileEntity apiaryTE = (ApiaryTileEntity) world.getBlockEntity(apiaryPos);
if (apiaryTE != null && apiaryTE.isPreviewed())
for (BlockPos pos : STRUCTURE_PREVIEW_POS) {
if (world.getBlockState(pos).equals(Blocks.AIR.defaultBlockState()))
renderBlockAt(ms, buffer, ModBlocks.PREVIEW_BLOCK.get().defaultBlockState(), pos);
else {
if (BeeInfoUtils.getBlockTag("resourcefulbees:valid_apiary") != null && !world.getBlockState(pos).is(BeeInfoUtils.getBlockTag("resourcefulbees:valid_apiary"))) {
renderBlockAt(ms, buffer, ModBlocks.ERRORED_PREVIEW_BLOCK.get().defaultBlockState(), pos);
}
}
}
}
} else {
STRUCTURE_PREVIEW_POS.clear();
apiaryPos = null;
PreviewHandler.enabled = false;
}
}
buffers.endBatch(RenderType.translucent());
}
Aggregations