Skip to content

Commit

Permalink
workin on the config
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Jan 5, 2024
1 parent 8b404d8 commit 7cf61f2
Show file tree
Hide file tree
Showing 14 changed files with 1,409 additions and 712 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ dependencies {
modLocalRuntime libs.spruceui

// modmenu
modLocalRuntime libs.modmenu
modImplementation libs.modmenu

// LazyDFU
modLocalRuntime libs.lazydfu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public static class SupporterStorage {

@Override
public void onInitialize(ModContainer mod) {
// MidnightConfig.init(MOD_ID, ArcanusConfig.class);
configurator.registerConfig(ArcanusConfig.class);

RegistryService registryService = RegistryService.get();
Expand Down
1,498 changes: 1,241 additions & 257 deletions src/main/java/dev/cammiescorner/arcanuscontinuum/ArcanusConfig.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.cammiescorner.arcanuscontinuum.client.gui.screens;

import com.teamresourceful.resourcefulconfig.client.ConfigScreen;
import com.teamresourceful.resourcefulconfig.common.config.ResourcefulConfig;
import org.jetbrains.annotations.Nullable;

public class ArcanusConfigScreen extends ConfigScreen {
public ArcanusConfigScreen(@Nullable ConfigScreen configScreen, ResourcefulConfig config) {
super(configScreen, config);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package dev.cammiescorner.arcanuscontinuum.common.compat;

import com.teamresourceful.resourcefulconfig.client.ConfigScreen;
import com.teamresourceful.resourcefulconfig.common.config.ResourcefulConfig;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import dev.cammiescorner.arcanuscontinuum.Arcanus;
import dev.cammiescorner.arcanuscontinuum.ArcanusConfig;

public class ModMenuCompat implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> {
ResourcefulConfig config = Arcanus.configurator.getConfig(ArcanusConfig.class);

if(config == null)
return null;

return new ConfigScreen(null, config);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void addWardedBlock(PlayerEntity player, BlockPos pos) {
}

public void removeWardedBlock(PlayerEntity player, BlockPos pos) {
boolean canOtherPlayersRemoveBlock = ArcanusConfig.wardingEffectProperties.getProperty("canBeRemovedByOthers");
boolean canOtherPlayersRemoveBlock = ArcanusConfig.WardingEffectProperties.canBeRemovedByOthers;

if(canOtherPlayersRemoveBlock || isOwnerOfBlock(player, pos)) {
wardedBlocks.remove(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected void onEntityHit(EntityHitResult entityHitResult) {
for(SpellEffect effect : new HashSet<>(effects))
effect.effect(getCaster(), this, getWorld(), entityHitResult, effects, stack, potency);

SpellShape.castNext(getCaster(), getTarget().getPos(), entityHitResult.getEntity(), (ServerWorld) getWorld(), stack, groups, groupIndex, potency);
SpellShape.castNext(getCaster(), getPos(), entityHitResult.getEntity(), (ServerWorld) getWorld(), stack, groups, groupIndex, potency);

kill();
}
Expand All @@ -110,7 +110,7 @@ protected void onBlockHit(BlockHitResult blockHitResult) {
for(SpellEffect effect : new HashSet<>(effects))
effect.effect(getCaster(), this, getWorld(), blockHitResult, effects, stack, potency);

SpellShape.castNext(getCaster(), getTarget().getPos(), this, (ServerWorld) getWorld(), stack, groups, groupIndex, potency);
SpellShape.castNext(getCaster(), getPos(), this, (ServerWorld) getWorld(), stack, groups, groupIndex, potency);

super.onBlockHit(blockHitResult);
kill();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dev.cammiescorner.arcanuscontinuum.common.entities.magic;

import dev.cammiescorner.arcanuscontinuum.Arcanus;
import dev.cammiescorner.arcanuscontinuum.ArcanusConfig;
import dev.cammiescorner.arcanuscontinuum.api.entities.Targetable;
import dev.cammiescorner.arcanuscontinuum.api.spells.SpellEffect;
import dev.cammiescorner.arcanuscontinuum.api.spells.SpellGroup;
import dev.cammiescorner.arcanuscontinuum.api.spells.SpellShape;
import dev.cammiescorner.arcanuscontinuum.ArcanusConfig;
import dev.cammiescorner.arcanuscontinuum.common.registry.ArcanusComponents;
import dev.cammiescorner.arcanuscontinuum.common.registry.ArcanusSpellComponents;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -42,7 +42,7 @@ public MagicProjectileEntity(EntityType<? extends PersistentProjectileEntity> en

@Override
public void tick() {
int lifeSpan = ArcanusConfig.projectileShapeProperties.getProperty("lifeSpan");
int lifeSpan = ArcanusConfig.ProjectileShapeProperties.baseLifeSpan;

if(!getWorld().isClient() && (getOwner() == null || !getOwner().isAlive() || (ArcanusSpellComponents.PROJECTILE.is(getShape()) && age >= lifeSpan))) {
kill();
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.TypeFilter;
import net.minecraft.util.hit.HitResult;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
Expand All @@ -31,30 +29,22 @@ public NecromancySpellEffect(boolean isEnabled, SpellType type, Weight weight, d
@Override
public void effect(@Nullable LivingEntity caster, @Nullable Entity sourceEntity, World world, HitResult target, List<SpellEffect> effects, ItemStack stack, double potency) {
if(target.getType() != HitResult.Type.MISS && caster != null) {
NecroSkeletonEntity skeleton = ArcanusEntities.NECRO_SKELETON.get().create(world);
int effectCount = (int) effects.stream().filter(ArcanusSpellComponents.NECROMANCY::is).count();
double healthModifier = (effectCount - 1) / 10F;
List<? extends NecroSkeletonEntity> list = ((ServerWorld) world).getEntitiesByType(TypeFilter.instanceOf(NecroSkeletonEntity.class), necroSkeletonEntity -> necroSkeletonEntity.getOwnerId().equals(caster.getUuid()));

for(int i = 0; i < effectCount; i++) {
if(list.size() + i >= 20)
return;
if(skeleton != null) {
EntityAttributeInstance damage = skeleton.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE);

NecroSkeletonEntity skeleton = ArcanusEntities.NECRO_SKELETON.get().create(world);
skeleton.setPosition(target.getPos());
skeleton.setMaxHealth((10 + effectCount) * potency);
skeleton.setOwner(caster);
skeleton.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.STONE_AXE));
skeleton.equipStack(EquipmentSlot.HEAD, new ItemStack(ArcanusItems.WIZARD_HAT.get()));

if(skeleton != null) {
EntityAttributeInstance damage = skeleton.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE);
if(damage != null)
damage.addPersistentModifier(new EntityAttributeModifier("Attack Damage", (effectCount / 2d) * potency, EntityAttributeModifier.Operation.ADDITION));

skeleton.setPosition(target.getPos());
skeleton.setMaxHealth((11 - healthModifier) * potency);
skeleton.setOwner(caster);
skeleton.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.STONE_AXE));
skeleton.equipStack(EquipmentSlot.HEAD, new ItemStack(ArcanusItems.WIZARD_HAT.get()));

if(damage != null)
damage.addPersistentModifier(new EntityAttributeModifier("Attack Damage", -(effectCount / 2D) / potency, EntityAttributeModifier.Operation.ADDITION));

world.spawnEntity(skeleton);
}
world.spawnEntity(skeleton);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public BoltSpellShape(boolean isEnabled, Weight weight, double manaCost, double
@Override
public void cast(@Nullable LivingEntity caster, Vec3d castFrom, @Nullable Entity castSource, ServerWorld world, ItemStack stack, List<SpellEffect> effects, List<SpellGroup> spellGroups, int groupIndex, double potency) {
potency += getPotencyModifier();
double range = ArcanusConfig.boltShapeProperties.getProperty("range");
double range = ArcanusConfig.BoltShapeProperties.range;
Entity sourceEntity = castSource != null ? castSource : caster;
Box box = new Box(castFrom.add(-range, -range, -range), castFrom.add(range, range, range));
List<Entity> affectedEntities = world.getOtherEntities(sourceEntity, box);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public ProjectileSpellShape(boolean isEnabled, Weight weight, double manaCost, d

@Override
public void cast(@Nullable LivingEntity caster, Vec3d castFrom, @Nullable Entity castSource, ServerWorld world, ItemStack stack, List<SpellEffect> effects, List<SpellGroup> spellGroups, int groupIndex, double potency) {
float projectileSpeed = ArcanusConfig.projectileShapeProperties.getProperty("projectileSpeed");
float lobSpeed = ArcanusConfig.lobShapeProperties.getProperty("projectileSpeed");
float projectileSpeed = ArcanusConfig.ProjectileShapeProperties.projectileSpeed;
float lobSpeed = ArcanusConfig.LobShapeProperties.projectileSpeed;
potency += getPotencyModifier();

if(caster != null) {
Expand Down
Loading

0 comments on commit 7cf61f2

Please sign in to comment.