net.minecraft.tag.FluidTags Java Examples

The following examples show how to use net.minecraft.tag.FluidTags. 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: RestlessCactusBlock.java    From the-hallow with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
	Iterator<Direction> iterator = Direction.Type.HORIZONTAL.iterator();
	
	Direction direction;
	Material material;
	do {
		if (!iterator.hasNext()) {
			Block block = world.getBlockState(pos.down()).getBlock();
			return (block == HallowedBlocks.RESTLESS_CACTUS || block == HallowedBlocks.TAINTED_SAND) && !world.getBlockState(pos.up()).getMaterial().isLiquid();
		}
		
		direction = iterator.next();
		BlockState state2 = world.getBlockState(pos.offset(direction));
		material = state2.getMaterial();
	} while (!material.isSolid() && !world.getFluidState(pos.offset(direction)).matches(FluidTags.LAVA));
	
	return false;
}
 
Example #2
Source File: MobAI.java    From fabric-carpet with MIT License 6 votes vote down vote up
/**
 * Not a replacement for living entity jump() - this barely is to allow other entities that can't jump in vanilla to 'jump'
 * @param e
 */
public static void genericJump(Entity e)
{
    if (!e.onGround && !e.isInFluid(FluidTags.WATER) && !e.isInLava()) return;
    float m = e.world.getBlockState(new BlockPos(e)).getBlock().getJumpVelocityMultiplier();
    float g = e.world.getBlockState(new BlockPos(e.getX(), e.getBoundingBox().y1 - 0.5000001D, e.getZ())).getBlock().getJumpVelocityMultiplier();
    float jumpVelocityMultiplier = (double) m == 1.0D ? g : m;
    float jumpStrength = (0.42F * jumpVelocityMultiplier);
    Vec3d vec3d = e.getVelocity();
    e.setVelocity(vec3d.x, jumpStrength, vec3d.z);
    if (e.isSprinting())
    {
        float u = e.yaw * 0.017453292F;
        e.setVelocity(e.getVelocity().add((-MathHelper.sin(g) * 0.2F), 0.0D, (MathHelper.cos(u) * 0.2F)));
    }
    e.velocityDirty = true;
}
 
Example #3
Source File: LivingEntityMixin.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Inject(method = "baseTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;tickStatusEffects()V", shift = At.Shift.BEFORE))
private void doOxygenChecks(CallbackInfo ci) {
    LivingEntity entity = (LivingEntity) (Object) this;
    //noinspection ConstantConditions
    if (this.isAlive() && !(entity instanceof PlayerEntity && ((PlayerEntity) entity).abilities.invulnerable)) {
        if (CelestialBodyType.getByDimType(world.getRegistryKey()).isPresent() && !CelestialBodyType.getByDimType(world.getRegistryKey()).get().getAtmosphere().getComposition().containsKey(AtmosphericGas.OXYGEN)) {
            updateAir(this);
        } else {
            if (this.isSubmergedIn(FluidTags.WATER) && this.world.getBlockState(new BlockPos(this.getX(), this.getEyeY(), this.getZ())).getBlock() != Blocks.BUBBLE_COLUMN) {
                if (!this.canBreatheInWater() && !StatusEffectUtil.hasWaterBreathing((LivingEntity) (Object) this) && !isInvulnerableTo(DamageSource.DROWN)) {
                    this.setAir(this.getNextAirUnderwater(this.getAir()));
                }
            }
        }

        if (this.getAir() == -20) {
            this.setAir(0);

            if (this.isSubmergedIn(FluidTags.WATER) && this.world.getBlockState(new BlockPos(this.getX(), this.getEyeY(), this.getZ())).getBlock() != Blocks.BUBBLE_COLUMN) {
                if (!this.canBreatheInWater() && !StatusEffectUtil.hasWaterBreathing((LivingEntity) (Object) this) && !isInvulnerableTo(DamageSource.DROWN)) {
                    Vec3d vec3d = this.getVelocity();

                    for (int i = 0; i < 8; ++i) {
                        float f = this.random.nextFloat() - this.random.nextFloat();
                        float g = this.random.nextFloat() - this.random.nextFloat();
                        float h = this.random.nextFloat() - this.random.nextFloat();
                        this.world.addParticle(ParticleTypes.BUBBLE, this.getX() + (double) f, this.getY() + (double) g, this.getZ() + (double) h, vec3d.x, vec3d.y, vec3d.z);
                    }
                }
            }

            this.damage(GalacticraftDamageSource.SUFFOCATION, 2.0F);
        }
    }
}
 
Example #4
Source File: MixinLivingEntity.java    From multiconnect with MIT License 5 votes vote down vote up
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/tag/Tag;)D"))
private double redirectFluidHeight(LivingEntity entity, Tag<Fluid> tag) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2 && tag == FluidTags.WATER) {
        // If you're in water, you're in water, even if you're almost at the surface
        if (entity.getFluidHeight(tag) > 0)
            return 1;
    }
    return entity.getFluidHeight(tag);
}
 
Example #5
Source File: DeceasedGrassBlock.java    From the-hallow with MIT License 4 votes vote down vote up
private static boolean canSpread(BlockState blockState, WorldView viewableWorld, BlockPos blockPos) {
	BlockPos upPos = blockPos.up();
	return canSurvive(blockState, viewableWorld, blockPos) && !viewableWorld.getFluidState(upPos).matches(FluidTags.WATER);
}
 
Example #6
Source File: MixinFluidRenderer.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@ModifyVariable(at = @At(value = "INVOKE", target = "net/minecraft/client/render/block/FluidRenderer.isSameFluid(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/fluid/FluidState;)Z"), method = "render", ordinal = 0)
public boolean isLava(boolean chk) {
    return chk || (stateThreadLocal.get() != null && !stateThreadLocal.get().matches(FluidTags.WATER));
}
 
Example #7
Source File: CoralBlockMixin.java    From fabric-carpet with MIT License 4 votes vote down vote up
public boolean isFertilizable(BlockView var1, BlockPos var2, BlockState var3, boolean var4)
{
    return CarpetSettings.renewableCoral && var3.get(CoralParentBlock.WATERLOGGED) && var1.getFluidState(var2.up()).matches(FluidTags.WATER);
}