Skip to content

Commit

Permalink
Add Entity get status effect
Browse files Browse the repository at this point in the history
  • Loading branch information
pisaiah committed May 11, 2024
1 parent 8076243 commit 41964f0
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.entity.TntEntity;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -61,5 +62,18 @@ else if (mc instanceof ArmorStandEntity) {
/**
*/
public void IC$add_status_effect(StatusEffect effect, int duration, int amp, boolean ambient, boolean particles);


/**
*/
public void IC$remove_status_effect(StatusEffect effect);

/**
*/
public StatusEffectInstance IC$get_status_effect(int type);

/**
*/
public int IC$get_status_effect_id(StatusEffectInstance effect);

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.text.Text;
import net.minecraft.util.registry.Registry;

@SupportedVersion({"1.17"})
@Mixin(Entity.class)
Expand Down Expand Up @@ -86,5 +87,36 @@ public boolean isRemoved() {
LivingEntity entity = (LivingEntity) thiz;
entity.addStatusEffect(new StatusEffectInstance(effect, duration, amp, ambient, particles));
}

@Override
public void IC$remove_status_effect(StatusEffect effect) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return;
}
LivingEntity entity = (LivingEntity) thiz;
entity.removeStatusEffect(effect);
}

@Override
public StatusEffectInstance IC$get_status_effect(int typeId) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return null;
}
LivingEntity entity = (LivingEntity) thiz;
StatusEffect effect = Registry.STATUS_EFFECT.get(typeId);
StatusEffectInstance handle = entity.getStatusEffect(effect);
return handle;
}

@Override
public int IC$get_status_effect_id(StatusEffectInstance handle) {
StatusEffect effect = handle.getEffectType();
return Registry.STATUS_EFFECT.getRawId(effect);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.registry.Registries;
import net.minecraft.text.Text;

@SupportedVersion({"1.17"})
Expand Down Expand Up @@ -86,5 +87,36 @@ public boolean isRemoved() {
LivingEntity entity = (LivingEntity) thiz;
entity.addStatusEffect(new StatusEffectInstance(effect, duration, amp, ambient, particles));
}

@Override
public void IC$remove_status_effect(StatusEffect effect) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return;
}
LivingEntity entity = (LivingEntity) thiz;
entity.removeStatusEffect(effect);
}

@Override
public StatusEffectInstance IC$get_status_effect(int typeId) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return null;
}
LivingEntity entity = (LivingEntity) thiz;
StatusEffect effect = Registries.STATUS_EFFECT.get(typeId);
StatusEffectInstance handle = entity.getStatusEffect(effect);
return handle;
}

@Override
public int IC$get_status_effect_id(StatusEffectInstance handle) {
StatusEffect effect = handle.getEffectType();
return Registries.STATUS_EFFECT.getRawId(effect);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.text.Text;
import net.minecraft.util.registry.Registry;

@SupportedVersion({"1.17"})
@Mixin(Entity.class)
Expand Down Expand Up @@ -86,5 +87,35 @@ public boolean isRemoved() {
LivingEntity entity = (LivingEntity) thiz;
entity.addStatusEffect(new StatusEffectInstance(effect, duration, amp, ambient, particles));
}

@Override
public void IC$remove_status_effect(StatusEffect effect) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return;
}
LivingEntity entity = (LivingEntity) thiz;
entity.removeStatusEffect(effect);
}

@Override
public StatusEffectInstance IC$get_status_effect(int typeId) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return null;
}
LivingEntity entity = (LivingEntity) thiz;
StatusEffect effect = Registry.STATUS_EFFECT.get(typeId);
StatusEffectInstance handle = entity.getStatusEffect(effect);
return handle;
}

@Override
public int IC$get_status_effect_id(StatusEffectInstance handle) {
StatusEffect effect = handle.getEffectType();
return Registry.STATUS_EFFECT.getRawId(effect);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.registry.Registries;
import net.minecraft.text.Text;

@SupportedVersion({"1.17"})
Expand Down Expand Up @@ -86,5 +87,37 @@ public boolean isRemoved() {
LivingEntity entity = (LivingEntity) thiz;
entity.addStatusEffect(new StatusEffectInstance(effect, duration, amp, ambient, particles));
}

@Override
public void IC$remove_status_effect(StatusEffect effect) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return;
}
LivingEntity entity = (LivingEntity) thiz;
entity.removeStatusEffect(effect);
}

@Override
public StatusEffectInstance IC$get_status_effect(int typeId) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return null;
}
LivingEntity entity = (LivingEntity) thiz;
StatusEffect effect = Registries.STATUS_EFFECT.get(typeId);
StatusEffectInstance handle = entity.getStatusEffect(effect);
return handle;
}

@Override
public int IC$get_status_effect_id(StatusEffectInstance handle) {
StatusEffect effect = handle.getEffectType();
return Registries.STATUS_EFFECT.getRawId(effect);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,35 @@ public boolean isRemoved() {
LivingEntity entity = (LivingEntity) thiz;
entity.addStatusEffect(new StatusEffectInstance(effect, duration, amp, ambient, particles));
}

@Override
public void IC$remove_status_effect(StatusEffect effect) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return;
}
LivingEntity entity = (LivingEntity) thiz;
entity.removeStatusEffect(effect);
}

@Override
public StatusEffectInstance IC$get_status_effect(int typeId) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return null;
}
LivingEntity entity = (LivingEntity) thiz;
StatusEffect effect = Registries.STATUS_EFFECT.get(typeId);
StatusEffectInstance handle = entity.getStatusEffect(effect);
return handle;
}

@Override
public int IC$get_status_effect_id(StatusEffectInstance handle) {
StatusEffect effect = handle.getEffectType();
return Registries.STATUS_EFFECT.getRawId(effect);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,38 @@ public boolean isRemoved() {

}

@Override
public void IC$remove_status_effect(StatusEffect effect) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return;
}
LivingEntity entity = (LivingEntity) thiz;
RegistryEntry<StatusEffect> reg = Registries.STATUS_EFFECT.getEntry(effect);
entity.removeStatusEffect(reg);

}

@Override
public StatusEffectInstance IC$get_status_effect(int typeId) {
Entity thiz = (Entity) (Object) this;
if (!(thiz instanceof LivingEntity)) {
ICommonMod.LOGGER.info("ERROR: Entity is not living enitity");
return null;
}
LivingEntity entity = (LivingEntity) thiz;

// StatusEffectInstance handle = entity.getStatusEffect(Registries.STATUS_EFFECT.get(typeId));
RegistryEntry<StatusEffect> reg = Registries.STATUS_EFFECT.getEntry(Registries.STATUS_EFFECT.get(typeId));
StatusEffectInstance handle = entity.getStatusEffect(reg);
return handle;
}

@Override
public int IC$get_status_effect_id(StatusEffectInstance handle) {
StatusEffect effect = handle.getEffectType().comp_349();
return Registries.STATUS_EFFECT.getRawId(effect);
}

}

0 comments on commit 41964f0

Please sign in to comment.