Skip to content

Commit

Permalink
Code Cleanup, Fixed Bee Attributes, Attributions, Optimised Imports, …
Browse files Browse the repository at this point in the history
…Version Bump

 - Cleaned up `AreaEffectCloudEntity` spawns by combining `AOECloudHelper#spawnStatusCloud` and `AOECloudHelper#spawnPickyStatusCloud` into one method: `AOECloudHelper#spawnAreaEffectCloudEntityWithAttributes`
 - Cleaned up Predicate Registration for Bows and Crossbows in `McdwClient`, reducing it from 5 methods to 3
 - Fixed `SummonedBeeEntity` not having attributes
 - Added Contribution attributions to `fabric.mod.json`
  • Loading branch information
chronosacaria committed Dec 21, 2023
1 parent ce0b1e7 commit f73b29e
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 194 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.14.21

# Mod Properties
mod_version=8.1.0
mod_version=9.0.0
maven_group=chronosacaria
archives_base_name=mcdw

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import chronosacaria.mcdw.Mcdw;
import chronosacaria.mcdw.enums.SettingsID;
import net.minecraft.enchantment.*;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.NotNull;
Expand Down
35 changes: 13 additions & 22 deletions src/main/java/chronosacaria/mcdw/api/util/AOECloudHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,23 @@

public class AOECloudHelper {

public static void spawnStatusCloud(LivingEntity user, LivingEntity center, StatusEffect statusEffect, int amplifier) {
public static void spawnAreaEffectCloudEntityWithAttributes(LivingEntity user, LivingEntity center, float cloudRadius,
int cloudWaitTime, int cloudDuration,
StatusEffect statusEffect, int effectDuration, int effectAmplifier,
boolean isPicky, boolean exclOwner,
boolean exclAllies, boolean exclEnemy
) {
AreaEffectCloudEntity areaEffectCloudEntity = new AreaEffectCloudEntity(
center.getWorld(), center.getX(), center.getY(), center.getZ());
areaEffectCloudEntity.setOwner(user);
areaEffectCloudEntity.setRadius(5.0F);
areaEffectCloudEntity.setRadiusOnUse(-0.5F);
areaEffectCloudEntity.setWaitTime(10);
areaEffectCloudEntity.setDuration(60);
areaEffectCloudEntity.addEffect(new StatusEffectInstance(
statusEffect, 60, amplifier));
center.getWorld().spawnEntity(areaEffectCloudEntity);
}

public static void spawnPickyStatusCloud(LivingEntity user, LivingEntity center,
StatusEffect statusEffect, int duration, int amplifier,
boolean exclOwner, boolean exclAllies, boolean exclEnemy) {
AreaEffectCloudEntity areaEffectCloudEntity = new AreaEffectCloudEntity(
center.getWorld(), center.getX(), center.getY(), center.getZ());
areaEffectCloudEntity.setOwner(user);
areaEffectCloudEntity.setRadius(5.0F);
areaEffectCloudEntity.setRadiusOnUse(-0.5F);
areaEffectCloudEntity.setWaitTime(10);
areaEffectCloudEntity.setDuration(60);
areaEffectCloudEntity.setRadius(cloudRadius);
areaEffectCloudEntity.setRadiusOnUse((cloudRadius / 10) * -1);
areaEffectCloudEntity.setWaitTime(cloudWaitTime);
areaEffectCloudEntity.setDuration(cloudDuration);
areaEffectCloudEntity.addEffect(new StatusEffectInstance(
statusEffect, duration, amplifier));
((IExclusiveAOECloud) areaEffectCloudEntity).mcdw$setExclusions(exclOwner, exclAllies, exclEnemy);
statusEffect, effectDuration, effectAmplifier));
if (isPicky)
((IExclusiveAOECloud) areaEffectCloudEntity).mcdw$setExclusions(exclOwner, exclAllies, exclEnemy);
center.getWorld().spawnEntity(areaEffectCloudEntity);
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/chronosacaria/mcdw/api/util/AOEHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class AOEHelper {
// Owner is center
public static List<LivingEntity> getEntitiesByConfig(LivingEntity center, float distance) {
int permissionLevel = Mcdw.CONFIG.mcdwEnchantmentSettingsConfig.aoePermission;
//noinspection DuplicatedCode
Predicate<? super LivingEntity> predicate = livingEntity -> AbilityHelper.isAoeTarget(center, livingEntity) &&
switch (permissionLevel) {
case 1 -> !AbilityHelper.isTrueAlly(center, livingEntity);
Expand All @@ -33,6 +34,7 @@ public static List<LivingEntity> getEntitiesByConfig(LivingEntity center, float
// Owner and center are different
public static List<LivingEntity> getEntitiesByConfig(LivingEntity center, LivingEntity owner, float distance) {
int permissionLevel = Mcdw.CONFIG.mcdwEnchantmentSettingsConfig.aoePermission;
//noinspection DuplicatedCode
Predicate<? super LivingEntity> predicate = livingEntity -> AbilityHelper.isAoeTarget(center, owner, livingEntity) &&
switch (permissionLevel) {
case 1 -> !AbilityHelper.isTrueAlly(owner, livingEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionUtil;

Expand Down
Loading

0 comments on commit f73b29e

Please sign in to comment.