net.minecraft.world.BlockView Java Examples
The following examples show how to use
net.minecraft.world.BlockView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EatBreadcrumbsGoal.java From the-hallow with MIT License | 6 votes |
private BlockPos tweakToProperPos(BlockPos pos, BlockView blockView) { if (blockView.getBlockState(pos).getBlock() == this.targetBlock) { return pos; } else { BlockPos[] blockPoss = new BlockPos[]{pos.down(), pos.west(), pos.east(), pos.north(), pos.south(), pos.down().down()}; BlockPos[] var4 = blockPoss; int var5 = blockPoss.length; for (int var6 = 0; var6 < var5; ++var6) { BlockPos blockPos2 = var4[var6]; if (blockView.getBlockState(blockPos2).getBlock() == this.targetBlock) { return blockPos2; } } return null; } }
Example #2
Source File: MixinFarmlandBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Inject(method = "hasCrop", cancellable = true, at = @At("HEAD")) private static void onHasCrop(BlockView world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) { final BlockState ourState = world.getBlockState(pos); final BlockState cropState = world.getBlockState(pos.up()); if (cropState.getBlock() instanceof IPlantable && ((IForgeBlockState) ourState).canSustainPlant(world, pos, Direction.UP, (IPlantable) cropState.getBlock())) { cir.setReturnValue(true); cir.cancel(); } }
Example #3
Source File: ConfigurableElectricMachineBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override @Environment(EnvType.CLIENT) public ItemStack getPickStack(BlockView blockView_1, BlockPos blockPos_1, BlockState blockState_1) { ItemStack stack = super.getPickStack(blockView_1, blockPos_1, blockState_1); CompoundTag tag = (stack.getTag() != null ? stack.getTag() : new CompoundTag()); if (blockView_1.getBlockEntity(blockPos_1) != null) { tag.put("BlockEntityTag", blockView_1.getBlockEntity(blockPos_1).toTag(new CompoundTag())); } stack.setTag(tag); return stack; }
Example #4
Source File: MixinFluidRenderer.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "isSideCovered", at = @At("HEAD"), cancellable = true) private static void isSideCovered(BlockView blockView_1, BlockPos blockPos_1, Direction direction_1, float float_1, CallbackInfoReturnable<Boolean> callbackInfo) { Xray xray = (Xray) ModuleManager.getModule(Xray.class); if (xray.getSettings().get(0).toToggle().state) return; if (xray.isToggled() && xray.isVisible(blockView_1.getBlockState(blockPos_1).getBlock())) { callbackInfo.setReturnValue(false); callbackInfo.cancel(); } }
Example #5
Source File: MixinBlock.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "shouldDrawSide", at = @At("HEAD"), cancellable = true) private static void shouldDrawSide(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1, Direction direction_1, CallbackInfoReturnable<Boolean> callback) { try { Xray xray = (Xray) ModuleManager.getModule(Xray.class); if (xray.isToggled()) { callback.setReturnValue(xray.isVisible(blockState_1.getBlock())); callback.cancel(); } } catch (Exception ignored) {} }
Example #6
Source File: ConfigurableElectricMachineBlockEntity.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public Set<ComponentType<?>> getComponentTypes(BlockView blockView, BlockPos pos, @Nullable Direction side) { Set<ComponentType<?>> set = new HashSet<>(); BlockState state = blockView.getBlockState(pos); SideOption option = ((ConfigurableElectricMachineBlock) state.getBlock()).getOption(state, ConfigurableElectricMachineBlock.BlockFace.toFace(state.get(ConfigurableElectricMachineBlock.FACING), side)); if (option == SideOption.POWER_OUTPUT || option == SideOption.POWER_INPUT) { set.add(UniversalComponents.CAPACITOR_COMPONENT); } return set; }
Example #7
Source File: MixinFluidRenderer.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "method_3344", at = @At("HEAD"), cancellable = true) private static void method_3344(BlockView blockView_1, BlockPos blockPos_1, Direction direction_1, float float_1, CallbackInfoReturnable<Boolean> callbackInfo) { Xray xray = (Xray) ModuleManager.getModule(Xray.class); if (xray.getSettings().get(0).toToggle().state) return; if (xray.isToggled() && xray.isVisible(blockView_1.getBlockState(blockPos_1).getBlock())) { callbackInfo.setReturnValue(false); callbackInfo.cancel(); } }
Example #8
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
/** * Determines if this block can support the passed in plant, allowing it to be planted and grow. * Some examples: * Reeds check if its a reed, or if its sand/dirt/grass and adjacent to water * Cacti checks if its a cacti, or if its sand * Nether types check for soul sand * Crops check for tilled soil * Caves check if it's a solid surface * Plains check if its grass or dirt * Water check if its still water * * @param state The Current state * @param world The current world * @param facing The direction relative to the given position the plant wants to be, typically its UP * @param plantable The plant that wants to check * @return True to allow the plant to be planted/stay. */ default boolean canSustainPlant(BlockState state, BlockView world, BlockPos pos, Direction facing, IPlantable plantable) { BlockState plant = plantable.getPlant(world, pos.offset(facing)); if (plant.getBlock() == Blocks.CACTUS) { return this.getBlock() == Blocks.CACTUS || this.getBlock() == Blocks.SAND || this.getBlock() == Blocks.RED_SAND; } if (plant.getBlock() == Blocks.SUGAR_CANE && this.getBlock() == Blocks.SUGAR_CANE) { return true; } if (plantable instanceof PlantBlock && ((PlantBlockAccessor) plantable).invokeCanPlantOnTop(state, world, pos)) { return true; } switch (plantable.getPlantType(world, pos)) { case Desert: return this.getBlock() == Blocks.SAND || this.getBlock() == Blocks.TERRACOTTA || this.getBlock() instanceof GlazedTerracottaBlock; case Nether: return this.getBlock() == Blocks.SOUL_SAND; case Crop: return this.getBlock() == Blocks.FARMLAND; case Cave: return Block.isSideSolidFullSquare(state, world, pos, Direction.UP); case Plains: return this.getBlock() == Blocks.GRASS_BLOCK || Block.isNaturalDirt(this.getBlock()) || this.getBlock() == Blocks.FARMLAND; case Water: return state.getMaterial() == Material.WATER; case Beach: boolean isBeach = this.getBlock() == Blocks.GRASS_BLOCK || Block.isNaturalDirt(this.getBlock()) || this.getBlock() == Blocks.SAND; boolean hasWater = (world.getBlockState(pos.east()).getMaterial() == Material.WATER || world.getBlockState(pos.west()).getMaterial() == Material.WATER || world.getBlockState(pos.north()).getMaterial() == Material.WATER || world.getBlockState(pos.south()).getMaterial() == Material.WATER); return isBeach && hasWater; } return false; }
Example #9
Source File: AluminumWireBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext context) { ArrayList<VoxelShape> shapes = new ArrayList<>(); if (blockState.get(ATTACHED_NORTH)) { shapes.add(NORTH); } if (blockState.get(ATTACHED_SOUTH)) { shapes.add(SOUTH); } if (blockState.get(ATTACHED_EAST)) { shapes.add(EAST); } if (blockState.get(ATTACHED_WEST)) { shapes.add(WEST); } if (blockState.get(ATTACHED_UP)) { shapes.add(UP); } if (blockState.get(ATTACHED_DOWN)) { shapes.add(DOWN); } if (shapes.isEmpty()) { return NONE; } else { return VoxelShapes.union(NONE, shapes.toArray(new VoxelShape[0])); } }
Example #10
Source File: MixinFluid.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
public Mono<Vec3d> sbx$getVelocity(WorldReader world, Position position, FluidState state) { return Mono.of((Vec3d) getVelocity( (BlockView) world, (BlockPos) position, (net.minecraft.fluid.FluidState) state )); }
Example #11
Source File: AbstractBlockStateMixin.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Inject(at = {@At("TAIL")}, method = { "getAmbientOcclusionLightLevel(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)F"}, cancellable = true) private void onGetAmbientOcclusionLightLevel(BlockView blockView, BlockPos blockPos, CallbackInfoReturnable<Float> cir) { GetAmbientOcclusionLightLevelEvent event = new GetAmbientOcclusionLightLevelEvent((BlockState)(Object)this, cir.getReturnValueF()); WurstClient.INSTANCE.getEventManager().fire(event); cir.setReturnValue(event.getLightLevel()); }
Example #12
Source File: MixinBlockClient.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
public ItemStack sbx$getPickStack(WorldReader reader, Position position, BlockState state) { return WrappingUtil.cast(getPickStack( (BlockView) reader, (BlockPos) position, (net.minecraft.block.BlockState) state ), ItemStack.class); }
Example #13
Source File: FluidWrapper.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Vec3d getVelocity(BlockView blockView_1, BlockPos blockPos_1, FluidState fluidState_1) { Mono<org.sandboxpowered.sandbox.api.util.math.Vec3d> mono = fluid.getVelocity( (WorldReader) blockView_1, (Position) blockPos_1, (org.sandboxpowered.sandbox.api.state.FluidState) fluidState_1 ); return mono.map(WrappingUtil::convert).orElseGet(() -> super.getVelocity(blockView_1, blockPos_1, fluidState_1)); }
Example #14
Source File: MixinPlantBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Override public BlockState getPlant(BlockView world, BlockPos pos) { final BlockState blockState = world.getBlockState(pos); if (blockState.getBlock() != (Object) this) { return ((Block) (Object) this).getDefaultState(); } return blockState; }
Example #15
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
/** * Determines if this block is can be destroyed by the specified entities normal behavior. * * @param state The current state * @param world The current world * @param pos Block position in world * @return True to allow the entity to destroy this block */ default boolean canEntityDestroy(BlockState state, BlockView world, BlockPos pos, Entity entity) { if (entity instanceof EnderDragonEntity) { return !BlockTags.DRAGON_IMMUNE.contains(this.getBlock()); } else if ((entity instanceof WitherEntity) || (entity instanceof WitherSkullEntity)) { return ((IForgeBlockState) state).isAir(world, pos) || WitherEntity.canDestroy(state); } return true; }
Example #16
Source File: BlockWrapper.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean canFillWithFluid(BlockView blockView_1, BlockPos blockPos_1, BlockState blockState_1, Fluid fluid_1) { return ((org.sandboxpowered.sandbox.api.state.BlockState) blockState_1).getComponent( WrappingUtil.convert(blockView_1), (Position) blockPos_1, Components.FLUID_COMPONENT ).map(container -> container.insert(FluidStack.of(WrappingUtil.convert(fluid_1), 1000), true).isEmpty() ).orElse(false); }
Example #17
Source File: BlockMixin.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Inject(at = {@At("HEAD")}, method = { "shouldDrawSide(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;)Z"}, cancellable = true) private static void onShouldDrawSide(BlockState state, BlockView blockView, BlockPos blockPos, Direction side, CallbackInfoReturnable<Boolean> cir) { ShouldDrawSideEvent event = new ShouldDrawSideEvent(state); WurstClient.INSTANCE.getEventManager().fire(event); if(event.isRendered() != null) cir.setReturnValue(event.isRendered()); }
Example #18
Source File: MixinBlock.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "isFullOpaque", at = @At("HEAD"), cancellable = true) public void isFullOpaque(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1, CallbackInfoReturnable<Boolean> callback) { try { Xray xray = (Xray) ModuleManager.getModule(Xray.class); if (xray.isToggled()) { callback.setReturnValue(xray.isVisible(blockState_1.getBlock())); callback.cancel(); } } catch (Exception ignored) {} }
Example #19
Source File: TombstoneBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getCollisionShape(BlockState state, BlockView blockView, BlockPos blockPos, EntityContext entityContext) { return SHAPES.get(state.get(FACING)); }
Example #20
Source File: BlockWrapper.java From Sandbox with GNU Lesser General Public License v3.0 | 4 votes |
@Nullable @Override public BlockEntity createBlockEntity(BlockView var1) { return WrappingUtil.convert(getBlock().createBlockEntity((WorldReader) var1)); }
Example #21
Source File: FluidWrapper.java From Sandbox with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected boolean method_15777(FluidState var1, BlockView var2, BlockPos var3, net.minecraft.fluid.Fluid var4, Direction var5) { return var5 == Direction.DOWN && !var4.matchesType(this); }
Example #22
Source File: MixinBedBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Override public boolean isBed(BlockState state, BlockView world, BlockPos pos, @Nullable Entity player) { return true; }
Example #23
Source File: RestlessCactusBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public boolean canPlaceAtSide(BlockState state, BlockView view, BlockPos pos, BlockPlacementEnvironment environment) { return false; }
Example #24
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPosition, EntityContext entityContext) { return Y_SHAPE; }
Example #25
Source File: BloodFluid.java From the-hallow with MIT License | 4 votes |
@Override public boolean method_15777(FluidState fluidState, BlockView blockView, BlockPos blockPos, Fluid fluid, Direction direction) { return direction == Direction.DOWN && !fluid.matches(HallowedTags.Fluids.BLOOD); }
Example #26
Source File: FuelFluid.java From Galacticraft-Rewoven with MIT License | 4 votes |
@Override public boolean canBeReplacedWith(FluidState fluidState, BlockView blockView, BlockPos blockPos, Fluid fluid, Direction direction) { return direction == Direction.DOWN && !fluid.matchesType(GalacticraftFluids.FUEL); }
Example #27
Source File: CoalGeneratorBlock.java From Galacticraft-Rewoven with MIT License | 4 votes |
@Override public ConfigurableElectricMachineBlockEntity createBlockEntity(BlockView blockView) { return new CoalGeneratorBlockEntity(); }
Example #28
Source File: EnergyStorageModuleBlock.java From Galacticraft-Rewoven with MIT License | 4 votes |
@Override public ConfigurableElectricMachineBlockEntity createBlockEntity(BlockView blockView) { return new EnergyStorageModuleBlockEntity(); }
Example #29
Source File: EnergyStorageModuleBlock.java From Galacticraft-Rewoven with MIT License | 4 votes |
@Override public Text machineInfo(ItemStack itemStack_1, BlockView blockView_1, TooltipContext tooltipContext_1) { return new TranslatableText("tooltip.galacticraft-rewoven.energy_storage_module").setStyle(Style.EMPTY.withColor(Formatting.GRAY)); }
Example #30
Source File: MixinFlowerPotBlock.java From multiconnect with MIT License | 4 votes |
@Override public BlockEntity createBlockEntity(BlockView view) { return hasBlockEntity() ? new FlowerPotBlockEntity() : null; }