net.minecraft.fluid.FluidState Java Examples
The following examples show how to use
net.minecraft.fluid.FluidState.
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: WitchWaterFluid.java From the-hallow with MIT License | 6 votes |
@Override @Environment(EnvType.CLIENT) public void randomDisplayTick(World world, BlockPos blockPos, FluidState fluidState, Random random) { if (random.nextInt(10) == 0) { world.addParticle(ParticleTypes.BUBBLE_POP, (double) blockPos.getX() + 0.5D + (random.nextFloat() - 0.5F), (double) blockPos.getY() + (fluidState.getHeight(world, blockPos) * (1F / 7F)) + 1F, (double) blockPos.getZ() + 0.5D + (random.nextFloat() - 0.5F), 0.0D, 0.0D, 0.0D ); } if (random.nextInt(15) == 0) { world.addParticle(ParticleTypes.BUBBLE, (double) blockPos.getX() + 0.5D + (random.nextFloat() - 0.5F), (double) blockPos.getY() + (fluidState.getHeight(world, blockPos) * (1F / 7F)) + 1F, (double) blockPos.getZ() + 0.5D + (random.nextFloat() - 0.5F), 0.0D, 0.0D, 0.0D ); } }
Example #2
Source File: BlockWrapper.java From Sandbox with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean tryFillWithFluid(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1, FluidState fluidState_1) { return ((org.sandboxpowered.sandbox.api.state.BlockState) blockState_1).getComponent( WrappingUtil.convert(iWorld_1), (Position) blockPos_1, Components.FLUID_COMPONENT ).map(container -> { FluidStack filled = FluidStack.of(WrappingUtil.convert(fluidState_1.getFluid()), 1000); FluidStack ret = container.insert(filled, true); if (ret.isEmpty()) { container.insert(filled); return true; } else { return false; } }).orElse(false); }
Example #3
Source File: MixinFluidRenderer.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "render", at = @At("HEAD"), cancellable = true) public void render(BlockRenderView extendedBlockView_1, BlockPos blockPos_1, VertexConsumer vertexConsumer_1, FluidState fluidState_1, CallbackInfoReturnable<Boolean> callbackInfo) { Xray xray = (Xray) ModuleManager.getModule(Xray.class); if (xray.getSettings().get(0).toToggle().state) return; if (xray.isToggled() && !xray.isVisible(fluidState_1.getBlockState().getBlock())) { callbackInfo.setReturnValue(false); callbackInfo.cancel(); } }
Example #4
Source File: CameraMixin.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Inject(at = {@At("HEAD")}, method = {"getSubmergedFluidState()Lnet/minecraft/fluid/FluidState;"}, cancellable = true) private void getSubmergedFluidState(CallbackInfoReturnable<FluidState> cir) { if(WurstClient.INSTANCE.getHax().noOverlayHack.isEnabled()) cir.setReturnValue(Fluids.EMPTY.getDefaultState()); }
Example #5
Source File: MixinBlockState.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(at = @At("RETURN"), method = "getLuminance", cancellable = true) public void onGetLuminance(CallbackInfoReturnable<Integer> info) { FluidState fluidState = getFluidState(); if (fluidState.getFluid() != Fluids.EMPTY) { BlockState fluidBlockState = fluidState.getBlockState(); if (fluidBlockState != (BlockState) (Object) this) { info.setReturnValue(Math.max(info.getReturnValue(), fluidBlockState.getLuminance())); } } }
Example #6
Source File: MixinBlockState.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(at = @At("HEAD"), method = "getStateForNeighborUpdate") public void onGetStateForNeighborUpdate(Direction direction_1, BlockState blockState_1, IWorld iWorld_1, BlockPos blockPos_1, BlockPos blockPos_2, CallbackInfoReturnable<BlockState> info) { FluidState state = getFluidState(); if (!state.isEmpty()) { iWorld_1.getFluidTickScheduler().schedule(blockPos_1, state.getFluid(), state.getFluid().getTickRate(iWorld_1)); } }
Example #7
Source File: MixinBlock.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
/** * @author B0undarybreaker */ @Deprecated @Inject(method = "getFluidState", at = @At("HEAD"), cancellable = true) private void getWaterloggedFluidState(BlockState state, CallbackInfoReturnable<FluidState> info) { if (state.contains(Properties.WATERLOGGED)) info.setReturnValue(state.get(Properties.WATERLOGGED) ? Fluids.WATER.getDefaultState() : Fluids.EMPTY.getDefaultState()); }
Example #8
Source File: FuelFluid.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override @Environment(EnvType.CLIENT) public void randomDisplayTick(World world, BlockPos blockPos, FluidState fluidState, Random random) { if (random.nextInt(10) == 0) { world.addParticle(GalacticraftParticles.DRIPPING_FUEL_PARTICLE, (double) blockPos.getX() + 0.5D - random.nextGaussian() + random.nextGaussian(), (double) blockPos.getY() + 1.1F, (double) blockPos.getZ() + 0.5D - random.nextGaussian() + random.nextGaussian(), 0.0D, 0.0D, 0.0D); } }
Example #9
Source File: ObsidianBlock.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void scheduledTick(BlockState blockState_1, ServerWorld serverWorld_1, BlockPos blockPos_1, Random random_1) { for (Direction dir : Direction.values()) { FluidState neighbor = serverWorld_1.getFluidState(blockPos_1.offset(dir)); if (neighbor.getFluid() != Fluids.LAVA || !neighbor.isStill()) return; } if (random_1.nextInt(10) == 0) { serverWorld_1.setBlockState(blockPos_1, Blocks.LAVA.getDefaultState()); } }
Example #10
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 5 votes |
@Override public boolean tryFillWithFluid(IWorld world, BlockPos pos, BlockState blockState, FluidState fluidState) { if (blockState.contains(Properties.WATERLOGGED)) { return Waterloggable.super.tryFillWithFluid(world, pos, blockState, fluidState); } else { return false; } }
Example #11
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 5 votes |
@Override public BlockState getPlacementState(ItemPlacementContext placementContext) { final BlockState blockState = this.getDefaultState().with(FACING, placementContext.getPlayerFacing().getOpposite()); if (blockState.contains(Properties.WATERLOGGED)) { final FluidState fluidState = placementContext.getWorld().getFluidState(placementContext.getBlockPos()); return blockState.with(Properties.WATERLOGGED, fluidState.getFluid() == Fluids.WATER); } return blockState; }
Example #12
Source File: MixinFluidRenderer.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "tesselate", at = @At("HEAD"), cancellable = true) public void tesselate(ExtendedBlockView extendedBlockView_1, BlockPos blockPos_1, BufferBuilder bufferBuilder_1, FluidState fluidState_1, CallbackInfoReturnable<Boolean> callbackInfo) { Xray xray = (Xray) ModuleManager.getModule(Xray.class); if (xray.getSettings().get(0).toToggle().state) return; if (xray.isToggled() && !xray.isVisible(fluidState_1.getBlockState().getBlock())) { callbackInfo.setReturnValue(false); callbackInfo.cancel(); } }
Example #13
Source File: MixinFluidRenderer.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "render", at = @At("HEAD"), cancellable = true) public void render(BlockRenderView extendedBlockView_1, BlockPos blockPos_1, VertexConsumer vertexConsumer_1, FluidState fluidState_1, CallbackInfoReturnable<Boolean> callbackInfo) { Xray xray = (Xray) ModuleManager.getModule(Xray.class); if (xray.getSettings().get(0).toToggle().state) return; if (xray.isToggled() && !xray.isVisible(fluidState_1.getBlockState().getBlock())) { callbackInfo.setReturnValue(false); callbackInfo.cancel(); } }
Example #14
Source File: FluidLoggableBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override default boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) { if (state.get(FLUID).equals(new Identifier("empty"))) { if (!world.isClient()) { world.setBlockState(pos, state.with(FLUID, Registry.FLUID.getId(fluidState.getFluid())) .with(FlowableFluid.LEVEL, Math.max(fluidState.getLevel(), 1)), 3); world.getFluidTickScheduler().schedule(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world)); } return true; } else { return false; } }
Example #15
Source File: CrudeOilFluid.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override @Environment(EnvType.CLIENT) public void randomDisplayTick(World world, BlockPos blockPos, FluidState fluidState, Random random) { if (random.nextInt(10) == 0) { world.addParticle(GalacticraftParticles.DRIPPING_CRUDE_OIL_PARTICLE, (double) blockPos.getX() + 0.5D - random.nextGaussian() + random.nextGaussian(), (double) blockPos.getY() + 1.1F, (double) blockPos.getZ() + 0.5D - random.nextGaussian() + random.nextGaussian(), 0.0D, 0.0D, 0.0D); } }
Example #16
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 #17
Source File: Walkway.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public FluidState getFluidState(BlockState state) { FluidState state1 = Registry.FLUID.get(state.get(FLUID)).getDefaultState(); if (state1.getEntries().containsKey(FlowableFluid.LEVEL)) { state1 = state1.with(FlowableFluid.LEVEL, state.get(FlowableFluid.LEVEL)); } return state1; }
Example #18
Source File: Walkway.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public BlockState getPlacementState(ItemPlacementContext context) { FluidState fluidState = context.getWorld().getFluidState(context.getBlockPos()); return this.getDefaultState() .with(FLUID, Registry.FLUID.getId(fluidState.getFluid())) .with(FlowableFluid.LEVEL, Math.max(fluidState.getLevel(), 1)); }
Example #19
Source File: GratingBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public FluidState getFluidState(BlockState state) { FluidState state1 = Registry.FLUID.get(state.get(FLUID)).getDefaultState(); if (state1.getEntries().containsKey(FlowableFluid.LEVEL)) { state1 = state1.with(FlowableFluid.LEVEL, state.get(FlowableFluid.LEVEL)); } return state1; }
Example #20
Source File: GratingBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public BlockState getPlacementState(ItemPlacementContext context) { FluidState fluidState = context.getWorld().getFluidState(context.getBlockPos()); BlockState blockState = this.getDefaultState().with(GRATING_STATE, GratingState.LOWER) .with(FLUID, Registry.FLUID.getId(fluidState.getFluid())) .with(FlowableFluid.LEVEL, Math.max(fluidState.getLevel(), 1)); BlockPos blockPos = context.getBlockPos(); Direction direction = context.getPlayerFacing(); return direction != Direction.DOWN && (direction == Direction.UP || context.getBlockPos().getY() - (double) blockPos.getY() <= 0.5D) ? blockState : blockState.with(GRATING_STATE, GratingState.UPPER); }
Example #21
Source File: MixinFluidRenderer.java From Sandbox with GNU Lesser General Public License v3.0 | 4 votes |
@Inject(at = @At("RETURN"), method = "render") public void removeLocal(BlockRenderView view, BlockPos pos, VertexConsumer bufferBuilder, FluidState state, CallbackInfoReturnable<Boolean> info) { stateThreadLocal.remove(); }
Example #22
Source File: FluidWrapper.java From Sandbox with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void appendProperties(StateManager.Builder<net.minecraft.fluid.Fluid, FluidState> stateFactory$Builder_1) { super.appendProperties(stateFactory$Builder_1); if (fluid != null) fluid.appendProperties(((SandboxInternal.StateFactoryBuilder) stateFactory$Builder_1).getSboxBuilder()); }
Example #23
Source File: BloodFluid.java From the-hallow with MIT License | 4 votes |
@Override public boolean isStill(FluidState fluidState) { return false; }
Example #24
Source File: MixinEntity.java From multiconnect with MIT License | 4 votes |
@Inject(method = "updateMovementInFluid", at = @At("HEAD"), cancellable = true) private void modifyFluidMovementBoundingBox(Tag<Fluid> fluidTag, double d, CallbackInfoReturnable<Boolean> ci) { if (ConnectionInfo.protocolVersion > Protocols.V1_12_2) return; Box box = getBoundingBox().expand(0, -0.4, 0).contract(0.001); int minX = MathHelper.floor(box.minX); int maxX = MathHelper.ceil(box.maxX); int minY = MathHelper.floor(box.minY); int maxY = MathHelper.ceil(box.maxY); int minZ = MathHelper.floor(box.minZ); int maxZ = MathHelper.ceil(box.maxZ); if (!world.isRegionLoaded(minX, minY, minZ, maxX, maxY, maxZ)) ci.setReturnValue(false); double waterHeight = 0; boolean foundFluid = false; Vec3d pushVec = Vec3d.ZERO; BlockPos.Mutable mutable = new BlockPos.Mutable(); for (int x = minX; x < maxX; x++) { for (int y = minY - 1; y < maxY; y++) { for (int z = minZ; z < maxZ; z++) { mutable.set(x, y, z); FluidState state = world.getFluidState(mutable); if (state.isIn(fluidTag)) { double height = y + state.getHeight(world, mutable); if (height >= box.minY - 0.4) waterHeight = Math.max(height - box.minY + 0.4, waterHeight); if (y >= minY && maxY >= height) { foundFluid = true; pushVec = pushVec.add(state.getVelocity(world, mutable)); } } } } } if (pushVec.length() > 0) { pushVec = pushVec.normalize().multiply(0.014); setVelocity(getVelocity().add(pushVec)); } this.fluidHeight.put(fluidTag, waterHeight); ci.setReturnValue(foundFluid); }
Example #25
Source File: WitchWaterBubbleColumnBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public FluidState getFluidState(BlockState state) { return HallowedFluids.WITCH_WATER.getStill(false); }
Example #26
Source File: WitchWaterBubbleColumnBlock.java From the-hallow with MIT License | 4 votes |
public static boolean isStillWater(IWorld world, BlockPos pos) { FluidState state = world.getFluidState(pos); return world.getBlockState(pos).getBlock() == HallowedBlocks.WITCH_WATER_BLOCK && state.getLevel() >= 8 && state.isStill(); }
Example #27
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public FluidState getFluidState(BlockState blockState) { return blockState.contains(Properties.WATERLOGGED) && blockState.get(Properties.WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(blockState); }
Example #28
Source File: BloodFluid.java From the-hallow with MIT License | 4 votes |
@Override public boolean isStill(FluidState fluidState) { return true; }
Example #29
Source File: BloodFluid.java From the-hallow with MIT License | 4 votes |
@Override public int getLevel(FluidState fluidState) { return 8; }
Example #30
Source File: BloodFluid.java From the-hallow with MIT License | 4 votes |
@Override public boolean isStill(FluidState fluidState) { return false; }