Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.lifebinding.effect;
- import com.lifebinding.capability.binding.BindingCapability;
- import com.lifebinding.capability.data.EntityData;
- import net.minecraft.entity.LivingEntity;
- import net.minecraft.nbt.CompoundNBT;
- import net.minecraft.potion.Effect;
- import net.minecraft.potion.EffectType;
- import net.minecraft.world.dimension.DimensionType;
- public class BindingEffect extends Effect {
- public BindingEffect() {
- super(EffectType.HARMFUL, 13315412);
- }
- public void performEffect(LivingEntity entity, int amplifier) {
- if (entity.isPotionActive(this)) {
- for (LivingEntity nearbyEntity : entity.world.getEntitiesWithinAABB(LivingEntity.class, entity.getBoundingBox().grow(2.5D))) {
- if (entity.isPotionActive(this) && nearbyEntity.isPotionActive(this)) {
- if (entity.getServer() != null) {
- entity.getServer().getWorld(DimensionType.OVERWORLD).getCapability(BindingCapability.BOUND).ifPresent((bound) -> {
- if (nearbyEntity != entity) {
- bound.getEntities().computeIfAbsent(entity.getUniqueID(), (orNewId) -> {
- EntityData data = new EntityData(new CompoundNBT());
- data.setId(entity.getUniqueID().toString());
- data.setName(entity.getName().getString());
- data.getBoundPlayer().setName(nearbyEntity.getName().getString());
- data.getBoundPlayer().setId(nearbyEntity.getUniqueID());
- return data;
- });
- bound.getEntities().computeIfAbsent(nearbyEntity.getUniqueID(), (orNewId) -> {
- EntityData data = new EntityData(new CompoundNBT());
- data.setId(nearbyEntity.getUniqueID().toString());
- data.setName(nearbyEntity.getName().getString());
- data.getBoundPlayer().setName(entity.getName().getString());
- data.getBoundPlayer().setId(entity.getUniqueID());
- return data;
- });
- entity.removePotionEffect(this);
- nearbyEntity.removePotionEffect(this);
- }
- });
- }
- }
- }
- }
- }
- public boolean isReady(int duration, int amplifier) {
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement