use of net.minecraft.block.FlowingFluidBlock in project MCMOD-Industria by M-Marvin.
the class TileEntityMHeaterBase method tick.
@SuppressWarnings("deprecation")
@Override
public void tick() {
if (!this.level.isClientSide()) {
this.isWorking = false;
Direction facing = getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING);
powered = this.level.hasNeighborSignal(worldPosition) || this.level.hasNeighborSignal(worldPosition.offset(facing.getOpposite().getNormal())) || this.level.hasNeighborSignal(worldPosition.offset(facing.getClockWise().getNormal())) || this.level.hasNeighborSignal(worldPosition.offset(facing.getClockWise().getNormal()).offset(facing.getOpposite().getNormal()));
if (powered) {
updateWorkState();
if (isWorking ? this.level.getGameTime() % 10 == 0 : false) {
int xMin = Math.min(this.worldPosition.offset(facing.getOpposite().getNormal()).getX(), this.worldPosition.getX()) - 2;
int xMax = Math.max(this.worldPosition.offset(facing.getOpposite().getNormal()).getX(), this.worldPosition.getX()) + 2;
int zMin = Math.min(this.worldPosition.offset(facing.getClockWise().getNormal()).getZ(), this.worldPosition.getZ()) - 2;
int zMax = Math.max(this.worldPosition.offset(facing.getClockWise().getNormal()).getZ(), this.worldPosition.getZ()) + 2;
for (int y = 1; y <= 6; y++) {
for (int x = xMin; x <= xMax; x++) {
for (int z = zMin; z <= zMax; z++) {
if (this.level.random.nextInt(6) == 0) {
BlockPos pos2 = new BlockPos(x, this.getBlockPos().getY() + y, z);
FluidState sourceFluid = this.level.getFluidState(pos2);
if (this.level.getBlockState(pos2).getBlock() instanceof FlowingFluidBlock) {
if (sourceFluid.getType() == Fluids.WATER) {
if (this.level.random.nextInt(5) == 0) {
BlockState bottomState = this.level.getBlockState(pos2.below());
if (bottomState.getBlock() == ModItems.limestone_sheet) {
this.level.setBlockAndUpdate(pos2, ModItems.limestone_sheet.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, true));
this.level.setBlockAndUpdate(pos2.below(), ModItems.limestone.defaultBlockState());
} else if (bottomState.getFluidState().getType() == Fluids.EMPTY && !bottomState.isAir()) {
this.level.setBlockAndUpdate(pos2, ModItems.limestone_sheet.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, true));
}
} else {
this.level.setBlockAndUpdate(pos2, ModFluids.STEAM.getPreasurized().createLegacyBlock());
}
} else if (sourceFluid.getType() == ModFluids.DESTILLED_WATER) {
if (sourceFluid.getValue(FluidDestilledWater.HOT)) {
this.level.setBlockAndUpdate(pos2, ModFluids.STEAM.getPreasurized().createLegacyBlock());
} else {
this.level.setBlockAndUpdate(pos2, ModFluids.DESTILLED_WATER.getHot().createLegacyBlock());
}
}
}
}
}
}
}
}
}
} else {
MachineSoundHelper.startSoundIfNotRunning(this, ModSoundEvents.GENERATOR_LOOP);
if (this.isWorking) {
IParticleData paricle = ParticleTypes.FLAME;
Direction facing = getBlockState().getValue(BlockMultipart.FACING);
float ox = 0;
float oz = 0;
switch(facing) {
default:
case NORTH:
oz = 1F;
ox = 1F;
break;
case EAST:
ox = 0F;
oz = 1F;
break;
case SOUTH:
ox = 0F;
oz = 0F;
break;
case WEST:
ox = 1F;
oz = 0F;
break;
}
;
float width = 0.9F;
float x = this.worldPosition.getX() + ox + (level.random.nextFloat() - 0.5F) * width;
float y = this.worldPosition.getY() + 1.1F;
float z = this.worldPosition.getZ() + oz + (level.random.nextFloat() - 0.5F) * width;
this.level.addParticle(paricle, x, y, z, 0, 0, 0);
}
}
}
use of net.minecraft.block.FlowingFluidBlock in project dynmap by webbukkit.
the class DynmapExpCommand method initializeBlockStates.
/**
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
*/
public void initializeBlockStates() {
// Simple map - scale as needed
stateByID = new DynmapBlockState[512 * 32];
// Default to air
Arrays.fill(stateByID, DynmapBlockState.AIR);
ObjectIntIdentityMap<BlockState> bsids = Block.BLOCK_STATE_IDS;
DynmapBlockState basebs = null;
Block baseb = null;
int baseidx = 0;
Iterator<BlockState> iter = bsids.iterator();
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
while (iter.hasNext()) {
BlockState bs = iter.next();
int idx = bsids.get(bs);
if (idx >= stateByID.length) {
int plen = stateByID.length;
// grow array by 10%
stateByID = Arrays.copyOf(stateByID, idx * 11 / 10);
Arrays.fill(stateByID, plen, stateByID.length, DynmapBlockState.AIR);
}
Block b = bs.getBlock();
// If this is new block vs last, it's the base block state
if (b != baseb) {
basebs = null;
baseidx = idx;
baseb = b;
}
ResourceLocation ui = b.getRegistryName();
if (ui == null) {
continue;
}
String bn = ui.getNamespace() + ":" + ui.getPath();
// Only do defined names, and not "air"
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
Material mat = bs.getMaterial();
String statename = "";
for (IProperty p : bs.getProperties()) {
if (statename.length() > 0) {
statename += ",";
}
statename += p.getName() + "=" + bs.get(p).toString();
}
int lightAtten = bs.isOpaqueCube(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 0 : 1);
// Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
// Fill in base attributes
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
if (mat.isSolid()) {
bld.setSolid();
}
if (mat == Material.AIR) {
bld.setAir();
}
if (mat == Material.WOOD) {
bld.setLog();
}
if (mat == Material.LEAVES) {
bld.setLeaves();
}
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FlowingFluidBlock)) {
bld.setWaterlogged();
}
// Build state
DynmapBlockState dbs = bld.build();
stateByID[idx] = dbs;
if (basebs == null) {
basebs = dbs;
}
}
}
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(gidx);
// Log.info(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
}
}
use of net.minecraft.block.FlowingFluidBlock in project Enigmatic-Legacy by Aizistral-Studios.
the class Megasponge method absorbWaterBlock.
public static void absorbWaterBlock(BlockPos pos, BlockState state, World world) {
if (state.getBlock() instanceof IBucketPickupHandler && ((IBucketPickupHandler) state.getBlock()).pickupFluid(world, pos, state) != Fluids.EMPTY) {
// Whatever
} else if (state.getBlock() instanceof FlowingFluidBlock) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
} else if (state.getMaterial() == Material.OCEAN_PLANT || state.getMaterial() == Material.SEA_GRASS) {
TileEntity tileentity = state.hasTileEntity() ? world.getTileEntity(pos) : null;
Block.spawnDrops(state, world, pos, tileentity);
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
}
}
use of net.minecraft.block.FlowingFluidBlock in project FrostedHeart by TeamMoegMC.
the class BiomeMixin method doesWaterFreeze.
public boolean doesWaterFreeze(IWorldReader worldIn, BlockPos water, boolean mustBeAtEdge) {
if (this.getTemperature(water) >= 0.15F) {
return false;
}
if (water.getY() >= 0 && water.getY() < 256 && worldIn.getLightFor(LightType.BLOCK, water) < 10 && ChunkData.getTemperature(worldIn, water) < 0) {
BlockState blockstate = worldIn.getBlockState(water);
FluidState fluidstate = worldIn.getFluidState(water);
if (fluidstate.getFluid() == Fluids.WATER && blockstate.getBlock() instanceof FlowingFluidBlock) {
if (!mustBeAtEdge) {
return true;
}
boolean flag = worldIn.hasWater(water.west()) && worldIn.hasWater(water.east()) && worldIn.hasWater(water.north()) && worldIn.hasWater(water.south());
if (!flag) {
return true;
}
}
}
return false;
}
use of net.minecraft.block.FlowingFluidBlock in project endergetic by team-abnormals.
the class PuffBugBottleItem method use.
@Override
public ActionResult<ItemStack> use(World worldIn, PlayerEntity playerIn, Hand handIn) {
ItemStack itemstack = playerIn.getItemInHand(handIn);
if (worldIn.isClientSide) {
return new ActionResult<>(ActionResultType.PASS, itemstack);
} else {
RayTraceResult raytraceresult = getPlayerPOVHitResult(worldIn, playerIn, RayTraceContext.FluidMode.SOURCE_ONLY);
if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) {
return new ActionResult<>(ActionResultType.PASS, itemstack);
} else {
BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult) raytraceresult;
BlockPos blockpos = blockraytraceresult.getBlockPos();
if (!(worldIn.getBlockState(blockpos).getBlock() instanceof FlowingFluidBlock)) {
return new ActionResult<>(ActionResultType.PASS, itemstack);
} else if (worldIn.mayInteract(playerIn, blockpos) && playerIn.mayUseItemAt(blockpos, blockraytraceresult.getDirection(), itemstack)) {
EntityType<?> entitytype = EEEntities.PUFF_BUG.get();
if (entitytype.spawn((ServerWorld) worldIn, itemstack, playerIn, blockpos, SpawnReason.SPAWN_EGG, false, false) == null) {
return new ActionResult<>(ActionResultType.PASS, itemstack);
} else {
if (!playerIn.abilities.instabuild) {
this.emptyBottle(playerIn, handIn);
}
playerIn.awardStat(Stats.ITEM_USED.get(this));
return new ActionResult<>(ActionResultType.SUCCESS, itemstack);
}
} else {
return new ActionResult<>(ActionResultType.FAIL, itemstack);
}
}
}
}
Aggregations