net.minecraft.fluid.Fluids Java Examples
The following examples show how to use
net.minecraft.fluid.Fluids.
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: RenderBlockTileEntity.java From MiningGadgets with MIT License | 6 votes |
private void freeze(ItemStack stack) { for (Direction side : Direction.values()) { BlockPos sidePos = pos.offset(side); IFluidState state = world.getFluidState(sidePos); int freezeCost = Config.UPGRADECOST_FREEZE.get() * -1; if (state.getFluid().isEquivalentTo(Fluids.LAVA) && state.getFluid().isSource(state)) { world.setBlockState(sidePos, Blocks.OBSIDIAN.getDefaultState()); stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(e -> e.receiveEnergy(freezeCost, false)); } else if (state.getFluid().isEquivalentTo(Fluids.WATER) && state.getFluid().isSource(state)) { world.setBlockState(sidePos, Blocks.PACKED_ICE.getDefaultState()); stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(e -> e.receiveEnergy(freezeCost, false)); } else if ((state.getFluid().isEquivalentTo(Fluids.WATER) || state.getFluid().isEquivalentTo(Fluids.LAVA)) && !state.getFluid().isSource(state)) { world.setBlockState(sidePos, Blocks.COBBLESTONE.getDefaultState()); stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(e -> e.receiveEnergy(freezeCost, false)); } } }
Example #2
Source File: CavernousVineBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public BlockState getStateForNeighborUpdate(BlockState blockState, Direction direction, BlockState neighborBlockState, WorldAccess world, BlockPos blockPos, BlockPos neighborBlockPos) { if (blockState.get(WATERLOGGED)) { world.getFluidTickScheduler().schedule(blockPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } return super.getStateForNeighborUpdate(blockState, direction, neighborBlockState, world, blockPos, neighborBlockPos); }
Example #3
Source File: MCDataInput.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * Reads a {@link FluidStack} from the stream. * * @return The {@link FluidStack}. */ default FluidStack readFluidStack() { if (!readBoolean()) { return FluidStack.EMPTY; } else { Fluid fluid = readRegistryIdUnsafe(ForgeRegistries.FLUIDS); int amount = readVarInt(); CompoundNBT tag = readCompoundNBT(); if (fluid == Fluids.EMPTY) { return FluidStack.EMPTY; } return new FluidStack(fluid, amount, tag); } }
Example #4
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 #5
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 5 votes |
@SuppressWarnings("deprecation") @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState otherState, IWorld world, BlockPos pos, BlockPos otherPos) { if (state.contains(Properties.WATERLOGGED) && state.get(Properties.WATERLOGGED)) { world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } return super.getStateForNeighborUpdate(state, direction, otherState, world, pos, otherPos); }
Example #6
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 5 votes |
@Override public Fluid tryDrainFluid(IWorld world, BlockPos pos, BlockState state) { if (state.contains(Properties.WATERLOGGED)) { return Waterloggable.super.tryDrainFluid(world, pos, state); } else { return Fluids.EMPTY; } }
Example #7
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 #8
Source File: FluidLoggableBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override default Fluid tryDrainFluid(WorldAccess world, BlockPos pos, BlockState state) { if (!state.get(FLUID).equals(new Identifier("empty"))) { world.setBlockState(pos, state.with(FLUID, new Identifier("empty")), 3); if (Registry.FLUID.get(state.get(FLUID)).getDefaultState().isStill()) { return Registry.FLUID.get(state.get(FLUID)); } } return Fluids.EMPTY; }
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: 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 #11
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 #12
Source File: MiningGadget.java From MiningGadgets with MIT License | 5 votes |
public List<BlockPos> findSources(World world, List<BlockPos> coords) { List<BlockPos> sources = new ArrayList<>(); for (BlockPos coord : coords) { for (Direction side : Direction.values()) { BlockPos sidePos = coord.offset(side); IFluidState state = world.getFluidState(sidePos); if ((state.getFluid().isEquivalentTo(Fluids.LAVA) || state.getFluid().isEquivalentTo(Fluids.WATER))) if (!sources.contains(sidePos)) sources.add(sidePos); } } return sources; }
Example #13
Source File: Protocol_1_12_2.java From multiconnect with MIT License | 4 votes |
@Override public void addExtraFluidTags(TagRegistry<Fluid> tags) { tags.add(FluidTags.WATER, Fluids.WATER, Fluids.FLOWING_WATER); tags.add(FluidTags.LAVA, Fluids.LAVA, Fluids.FLOWING_LAVA); super.addExtraFluidTags(tags); }
Example #14
Source File: RenderEnqueue.java From XRay-Mod with GNU General Public License v3.0 | 4 votes |
/** * Use Controller.requestBlockFinder() to trigger a scan. */ private void blockFinder() { HashMap<UUID, BlockData> blocks = Controller.getBlockStore().getStore(); if ( blocks.isEmpty() ) { if( !Render.syncRenderList.isEmpty() ) Render.syncRenderList.clear(); return; // no need to scan the region if there's nothing to find } final World world = XRay.mc.world; final PlayerEntity player = XRay.mc.player; if( world == null || player == null ) return; final List<RenderBlockProps> renderQueue = new ArrayList<>(); int lowBoundX, highBoundX, lowBoundY, highBoundY, lowBoundZ, highBoundZ; // Used for cleaning up the searching process BlockState currentState; FluidState currentFluid; ResourceLocation block; Pair<BlockData, UUID> dataWithUUID; // Loop on chunks (x, z) for ( int chunkX = box.minChunkX; chunkX <= box.maxChunkX; chunkX++ ) { // Pre-compute the extend bounds on X int x = chunkX << 4; // lowest x coord of the chunk in block/world coordinates lowBoundX = (x < box.minX) ? box.minX - x : 0; // lower bound for x within the extend highBoundX = (x + 15 > box.maxX) ? box.maxX - x : 15;// and higher bound. Basically, we clamp it to fit the radius. for ( int chunkZ = box.minChunkZ; chunkZ <= box.maxChunkZ; chunkZ++ ) { // Time to getStore the chunk (16x256x16) and split it into 16 vertical extends (16x16x16) if (!world.chunkExists(chunkX, chunkZ)) { continue; // We won't find anything interesting in unloaded chunks } Chunk chunk = world.getChunk( chunkX, chunkZ ); ChunkSection[] extendsList = chunk.getSections(); // Pre-compute the extend bounds on Z int z = chunkZ << 4; lowBoundZ = (z < box.minZ) ? box.minZ - z : 0; highBoundZ = (z + 15 > box.maxZ) ? box.maxZ - z : 15; // Loop on the extends around the player's layer (6 down, 2 up) for ( int curExtend = box.minChunkY; curExtend <= box.maxChunkY; curExtend++ ) { ChunkSection ebs = extendsList[curExtend]; if (ebs == null) // happens quite often! continue; // Pre-compute the extend bounds on Y int y = curExtend << 4; lowBoundY = (y < box.minY) ? box.minY - y : 0; highBoundY = (y + 15 > box.maxY) ? box.maxY - y : 15; // Now that we have an extend, let's check all its blocks for ( int i = lowBoundX; i <= highBoundX; i++ ) { for ( int j = lowBoundY; j <= highBoundY; j++ ) { for ( int k = lowBoundZ; k <= highBoundZ; k++ ) { currentState = ebs.getBlockState(i, j, k); currentFluid = currentState.getFluidState(); if( (currentFluid.getFluid() == Fluids.LAVA || currentFluid.getFluid() == Fluids.FLOWING_LAVA) && Controller.isLavaActive() ) { renderQueue.add(new RenderBlockProps(x + i, y + j, z + k, 0xff0000)); continue; } // Reject blacklisted blocks if( Controller.blackList.contains(currentState.getBlock()) ) continue; block = currentState.getBlock().getRegistryName(); if( block == null ) continue; dataWithUUID = Controller.getBlockStore().getStoreByReference(block.toString()); if( dataWithUUID == null ) continue; if( dataWithUUID.getKey() == null || !dataWithUUID.getKey().isDrawing() ) // fail safe continue; // Push the block to the render queue renderQueue.add(new RenderBlockProps(x + i, y + j, z + k, dataWithUUID.getKey().getColor())); } } } } } } final BlockPos playerPos = player.func_233580_cy_(); // @mcp: func_233580_cy_ = getPosition (blockPos) renderQueue.sort((t, t1) -> Double.compare(t1.distanceSq(playerPos), t.distanceSq(playerPos))); Render.syncRenderList.clear(); Render.syncRenderList.addAll( renderQueue ); // Add all our found blocks to the Render.syncRenderList list. To be use by Render when drawing. }
Example #15
Source File: MixinFluid.java From Sandbox with GNU Lesser General Public License v3.0 | 4 votes |
public Fluid sbx$asFlowing() { if ((Object) this instanceof BaseFluid) return WrappingUtil.convert(((BaseFluid) (Object) this).getFlowing()); return WrappingUtil.convert(Fluids.EMPTY); }
Example #16
Source File: MixinFluid.java From Sandbox with GNU Lesser General Public License v3.0 | 4 votes |
public Fluid sbx$asStill() { if ((Object) this instanceof BaseFluid) return WrappingUtil.convert(((BaseFluid) (Object) this).getStill()); return WrappingUtil.convert(Fluids.EMPTY); }
Example #17
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 #18
Source File: CavernousVineBlock.java From Galacticraft-Rewoven with MIT License | 4 votes |
@Override public FluidState getFluidState(BlockState blockState) { return blockState.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(blockState); }
Example #19
Source File: CavernousVineBlock.java From Galacticraft-Rewoven with MIT License | 4 votes |
@Override public BlockState getPlacementState(ItemPlacementContext context) { FluidState fluidState = context.getWorld().getFluidState(context.getBlockPos()); return super.getPlacementState(context).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER).with(VINES, VineTypes.VINE_0); }