Skip to content

Commit

Permalink
Remove old vital methods and rename ofNullable
Browse files Browse the repository at this point in the history
  • Loading branch information
dhyces committed Apr 3, 2024
1 parent 4b0bf0e commit 3b0f826
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static Optional<VitalHealthHolder> of(Entity context) {
return Optional.ofNullable(AylythEntityApi.VITAL_HOLDER.find(context, null));
}

static VitalHealthHolder ofNullable(Entity context) {
static VitalHealthHolder find(Entity context) {
return AylythEntityApi.VITAL_HOLDER.find(context, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static void tick(World world, BlockPos pos, BlockState state, VitalThurib
double newMax = modifier == null ? 2 : modifier.getValue() + 2;
instance.removeModifier(VitalThuribleBlock.MAX_VITAL_MODIFIER);
instance.addPersistentModifier(new EntityAttributeModifier(VitalThuribleBlock.MAX_VITAL_MODIFIER, "Vital Thurible Buff", newMax, EntityAttributeModifier.Operation.ADDITION));
VitalHealthHolder.ofNullable(player).set(VitalHealthHolder.ofNullable(player).get()+2);
VitalHealthHolder.find(player).set(VitalHealthHolder.find(player).get()+2);
}
}

Expand Down
29 changes: 0 additions & 29 deletions src/main/java/moriyashiine/aylyth/common/util/AylythUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public class AylythUtil {
public static final int MAX_TRIES = 8;
public static final TrackedData<Optional<UUID>> HIND_UUID = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.OPTIONAL_UUID);

private static final List<EntityAttributeModifier> VITAL_ATTRIBUTES = new ArrayList<>(genAtt());

public static Identifier id(String string){
return new Identifier(Aylyth.MOD_ID, string);
}
Expand All @@ -64,19 +62,6 @@ public static void decreaseStack(ItemStack stack, @Nullable LivingEntity living)
stack.decrement(1);
}

/**
* Generates a list of unique health attributes for the vital thurible
* @return the generated list
*/
private static List<EntityAttributeModifier> genAtt(){
List<EntityAttributeModifier> VITAL = new ArrayList<>();
for(int i = 0; i < 10; i++){
VITAL.add(new EntityAttributeModifier(UUID.fromString(i + "ee98b0b-7181-46ac-97ce-d8f7307bffb1"), "vital_modifier_1", 2, EntityAttributeModifier.Operation.ADDITION));
}
return VITAL;
}


public static BlockPos getSafePosition(World world, BlockPos.Mutable pos, int tries) {
if (tries >= MAX_TRIES) {
return world.getSpawnPos();
Expand Down Expand Up @@ -140,20 +125,6 @@ public static double distanceIfNearSeep(LivingEntity livingEntity, int radius) {
return -1;
}

/**
* Removes and restored all health modifiers depending on the level
* @param healthAttribute type of health attribute
* @param level level of health to be added
*/
public static void handleVital(EntityAttributeInstance healthAttribute, int level) {
for(EntityAttributeModifier attributes : VITAL_ATTRIBUTES){
healthAttribute.removeModifier(attributes);
}
for(int i = 0; i < level; i++){
healthAttribute.addPersistentModifier(VITAL_ATTRIBUTES.get(i));
}
}

/**
* Check if the DamageSource is to be considered all forms of ympe
* @param source source of damage
Expand Down

0 comments on commit 3b0f826

Please sign in to comment.