Package ml.pluto7073.chemicals.handlers
Class ConsumableChemicalHandler
java.lang.Object
ml.pluto7073.chemicals.handlers.ConsumableChemicalHandler
- Direct Known Subclasses:
HalfLifeChemicalHandler,LinearChemicalHandler
The base class representing a Chemical
Two pre-made handlers already exist, HalfLifeChemicalHandler and LinearChemicalHandler
HalfLifeChemicalHandler
The most realistic of the two. Exponentially ticks down the amount of the chemical in the player's body based on the half life in ticks specified
LinearChemicalHandler
The simplest handler. Removed a set amount of chemical from the player each tick, until the amount reaches 0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final net.minecraft.network.syncher.EntityDataAccessor<Float>static final ConsumableChemicalHandler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(net.minecraft.world.entity.player.Player player, float amount) Adds the chemical to a playervoidappendTooltip(List<net.minecraft.network.chat.Component> tooltip, float amount, net.minecraft.world.item.ItemStack stack) voiddefineDataForPlayer(net.minecraft.network.syncher.SynchedEntityData data) floatget(net.minecraft.world.entity.player.Player player) Gets the current amount of the chemical in the playerabstract Collection<net.minecraft.world.effect.MobEffectInstance>getEffectsForAmount(float amount, net.minecraft.world.level.Level level) Get a list of effects associated with an amount of this chemicalnet.minecraft.resources.ResourceLocationgetId()voidset(net.minecraft.world.entity.player.Player player, float amount) Sets amount of chemical in a playerabstract voidtickPlayer(net.minecraft.world.entity.player.Player player) Updates the current amount of the chemical in the specified player
-
Field Details
-
EMPTY
-
accessor
-
-
Constructor Details
-
ConsumableChemicalHandler
public ConsumableChemicalHandler()
-
-
Method Details
-
tickPlayer
public abstract void tickPlayer(net.minecraft.world.entity.player.Player player) Updates the current amount of the chemical in the specified player- Parameters:
player- The player to update
-
get
public float get(net.minecraft.world.entity.player.Player player) Gets the current amount of the chemical in the player- Parameters:
player- The player to retrieve- Returns:
- Amount of the chemical
-
add
public void add(net.minecraft.world.entity.player.Player player, float amount) Adds the chemical to a player- Parameters:
player- The player to add toamount- The amount of the chemical to add
-
set
public void set(net.minecraft.world.entity.player.Player player, float amount) Sets amount of chemical in a player- Parameters:
player- The player to setamount- Amount of chemical
-
getEffectsForAmount
public abstract Collection<net.minecraft.world.effect.MobEffectInstance> getEffectsForAmount(float amount, net.minecraft.world.level.Level level) Get a list of effects associated with an amount of this chemical- Parameters:
amount- Amount of the chemicallevel- The current Level, for utility purposes- Returns:
- A list of
MobEffectInstances
-
defineDataForPlayer
public void defineDataForPlayer(net.minecraft.network.syncher.SynchedEntityData data) -
appendTooltip
public void appendTooltip(List<net.minecraft.network.chat.Component> tooltip, float amount, net.minecraft.world.item.ItemStack stack) -
getId
public net.minecraft.resources.ResourceLocation getId()
-