-
Notifications
You must be signed in to change notification settings - Fork 754
/
FlexMobEffectLiquidBlock.java
33 lines (29 loc) · 1.42 KB
/
FlexMobEffectLiquidBlock.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package slimeknights.tconstruct.plugin.jsonthings.block;
import dev.gigaherz.jsonthings.things.blocks.FlexLiquidBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.material.FlowingFluid;
import java.util.ArrayList;
import java.util.Map;
import java.util.function.Supplier;
/** Json Things version of {@link slimeknights.tconstruct.fluids.block.BurningLiquidBlock} */
public class FlexMobEffectLiquidBlock extends FlexLiquidBlock {
private final Supplier<MobEffectInstance> effect;
public FlexMobEffectLiquidBlock(Properties properties, Map<Property<?>,Comparable<?>> propertyDefaultValues, Supplier<FlowingFluid> fluidSupplier, Supplier<MobEffectInstance> effect) {
super(properties, propertyDefaultValues, fluidSupplier);
this.effect = effect;
}
@Override
public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
if (entity.getFluidTypeHeight(getFluid().getFluidType()) > 0 && entity instanceof LivingEntity living) {
MobEffectInstance effect = this.effect.get();
effect.setCurativeItems(new ArrayList<>());
living.addEffect(effect);
}
}
}