Skip to content

Commit

Permalink
Merge branch '1.19.2' into 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
iron431 committed Jul 17, 2024
2 parents 810f3d2 + b477ef2 commit 4fd8122
Show file tree
Hide file tree
Showing 27 changed files with 165 additions and 112 deletions.
30 changes: 23 additions & 7 deletions LATEST_CHANGES.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@
-

### Changes
- Updated Japanese Translations, thanks to SAGA
- Updated Korean Translations, thanks to smoong
- Updated Russian Translations, thanks to Tefnya
- Large Balance Changes
- Armor
- School Armor now gives +10% school spell power per piece (previously +8%)
- School Armor and Netherite Battlemage Armor now gives +5% Spell Power per piece
- School Armor and Netherite Battlemage Armor now gives +125 Max Mana (previously +100)
- Scarecrow Armor now gives +75 Max Mana (previously +50)
- Scrolls
- Increased stack size to 64
- Upgrading scrolls now requires one ink per level, instead of a scroll of equal level
- The rarity of the ink is equal to the rarity of the resulting scroll rarity
- Spellbooks
- Spellbooks now give max mana
- "High Tier" spellbooks (spellbooks with spell power buffs) now give +200 Max Mana
- Enchanted Spell Book and Ruined Spell Book now gives +100 Max Mana
- Apprentice Spell Book now gives +50 Max Mana
- Tweaked Alchemist Cauldron Texture
- Removed strict hold-to-cast mechanics from scrolls and casting implements
- Adjusted Cone of Cold particles

### Fixes
- Fixed world upgrader code resetting spellbook slot NBT on relog after using Spell Slot Improvement item
- Fixed visual bug with the cast command resetting an item's use progress
- Fixed config loading incompatibility with Modernfix
- Fixed Arcane Anvil JEI recipe memory usage
- Fixed JEI Scroll Upgrade recipes showing one additional level past max level
- Fixed Long Casts going on cooldown if the cast was cancelled by opening a menu
- Fixed the Dead King dropping a loot table of ink, instead of always Legendary Ink
- Fixed ground height algorithm used in Target Area rendering
- Fixed spell rarity of a spell over its max level appearing as common

### API
-
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ public SpellRarity getRarity(int level) {
int maxRarity = getMaxRarity();
if (maxLevel == 1)
return SpellRarity.values()[getMinRarity()];
if (level >= maxLevel) {
return SpellRarity.LEGENDARY;
}
double percentOfMaxLevel = (double) level / (double) maxLevel;

//irons_spellbooks.LOGGER.debug("getRarity: {} {} {} {} {} {}", this.toString(), rarityRawWeights, rarityWeights, percentOfMaxLevel, minRarity, maxRarity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ public enum CastType {
NONE(0),
INSTANT(1),
LONG(2),
CONTINUOUS(3)/*,
CHARGE(4)*/;
CONTINUOUS(3);

private final int value;

Expand All @@ -17,11 +16,12 @@ public int getValue() {
return value;
}

@Deprecated(forRemoval = true)
public boolean holdToCast() {
return this == CONTINUOUS/* || this == LONG*/;
return false;//this == CONTINUOUS/* || this == LONG*/;
}

public boolean immediatelySuppressRightClicks() {
return this == LONG;
return this == LONG || this == CONTINUOUS;
}
}
15 changes: 2 additions & 13 deletions src/main/java/io/redspace/ironsspellbooks/api/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ public static boolean validAntiMagicTarget(Entity entity) {
/**
* From the given start position, this finds the first non-suffocating y level within +/- maxSteps, biased towards the ground
*/
public static int findRelativeGroundLevel(Level level, Vec3 start, int maxSteps) {
public static float findRelativeGroundLevel(Level level, Vec3 start, int maxSteps) {
if (level.getBlockState(BlockPos.containing(start)).isSuffocating(level, BlockPos.containing(start))) {
for (int i = 0; i < maxSteps; i++) {
start = start.add(0, 1, 0);
Expand All @@ -577,18 +577,7 @@ public static int findRelativeGroundLevel(Level level, Vec3 start, int maxSteps)
}
}
}
// //Vec3 upper = level.clip(new ClipContext(start, start.add(0, maxSteps, 0), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, null)).getLocation();
// Vec3 lower = level.clip(new ClipContext(start, start.add(0, maxSteps * -2, 0), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, null)).getLocation();
// return (int) (lower.y + .76f);
for (int i = 0; i < maxSteps; i++) {
BlockPos pos = BlockPos.containing(start).below();
if (level.getBlockState(pos).isSuffocating(level, pos)) {
break;
}
start = start.add(0, -1, 0);
}
return (int) start.y;

return (float) level.clip(new ClipContext(start, start.add(0, -maxSteps, 0), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, null)).getLocation().y;
}

public static Vec3 moveToRelativeGroundLevel(Level level, Vec3 start, int maxSteps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public boolean regenPlayerMana(ServerPlayer serverPlayer, MagicData playerMagicD
var mana = playerMagicData.getMana();
if (mana != playerMaxMana) {
float playerManaRegenMultiplier = (float) serverPlayer.getAttributeValue(MANA_REGEN.get());
var increment = playerMaxMana * playerManaRegenMultiplier * .01f;
// var increment = (1 + (playerMaxMana - 100) * 0.005f) * playerManaRegenMultiplier;
var increment = playerMaxMana * 0.01f * playerManaRegenMultiplier;
playerMagicData.setMana(Mth.clamp(playerMagicData.getMana() + increment, 0, playerMaxMana));
return true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public void spawnParticles() {
double y = pos.y + owner.getEyeHeight() * .9f;
double z = pos.z;

double speed = random.nextDouble() * .4 + .45;
for (int i = 0; i < 10; i++) {
double speed = random.nextDouble() * .7 + .15;
double offset = .125;
double ox = Math.random() * 2 * offset - offset;
double oy = Math.random() * 2 * offset - offset;
Expand All @@ -50,10 +50,10 @@ public void spawnParticles() {
level.addParticle(Math.random() > .15 ? ParticleHelper.SNOW_DUST : ParticleHelper.SNOWFLAKE, x + ox, y + oy, z + oz, result.x, result.y, result.z);

}
if (tickCount % 12 == 0) {
var forward = rotation.scale(.5f);
level.addParticle(ParticleRegistry.RING_SMOKE_PARTICLE.get(), x, y, z, forward.x, forward.y, forward.z);
}
// if (tickCount % 12 == 0) {
// var forward = rotation.scale(.5f);
// level.addParticle(ParticleRegistry.RING_SMOKE_PARTICLE.get(), x, y, z, forward.x, forward.y, forward.z);
// }
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import net.minecraft.core.particles.ParticleType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;

public class TargetAreaRenderer extends EntityRenderer<TargetedAreaEntity> {
public TargetAreaRenderer(EntityRendererProvider.Context pContext) {
Expand Down Expand Up @@ -49,7 +51,11 @@ public void render(TargetedAreaEntity entity, float pEntityYaw, float pPartialTi
int degrees = i * 60;
float x = radius * Mth.cos(degrees * Mth.DEG_TO_RAD);
float z = radius * Mth.sin(degrees * Mth.DEG_TO_RAD);
heights[i] = Utils.findRelativeGroundLevel(entity.level, entity.position().add(x, entity.getBbHeight(), z), (int) (entity.getBbHeight() * 4)) - entityY;
float y = Utils.findRelativeGroundLevel(entity.level, entity.position().add(x, entity.getBbHeight(), z), (int) (entity.getBbHeight() * 4));
heights[i] = y - entityY;
if (entity.level.collidesWithSuffocatingBlock(null, AABB.ofSize(new Vec3(x, y, z), .1, .1, .1))) {
heights[i] = 0;
}
//entity.level.addParticle(ParticleHelper.EMBERS, x + entity.getX(), heights[i] + entityY, z + entity.getZ(), 0, 0, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,24 @@ public void createResult() {
ItemStack modifierItemStack = inputSlots.getItem(1);
if (!baseItemStack.isEmpty() && !modifierItemStack.isEmpty()) {
//Scroll Merging
if (baseItemStack.getItem() instanceof Scroll && modifierItemStack.getItem() instanceof Scroll) {
if (baseItemStack.getItem() instanceof Scroll && modifierItemStack.getItem() instanceof InkItem inkItem/*Scroll*/) {
var spell1 = ISpellContainer.get(baseItemStack).getSpellAtIndex(0);
var spell2 = ISpellContainer.get(modifierItemStack).getSpellAtIndex(0);

if (spell1.equals(spell2)) {
if (spell1.getLevel() < ServerConfigs.getSpellConfig(spell1.getSpell()).maxLevel()) {
if (spell1.getLevel() < spell1.getSpell().getMaxLevel()) {
var baseRarity = spell1.getRarity();
var nextRarity = spell1.getSpell().getRarity(spell1.getLevel() + 1);
if (nextRarity.equals(inkItem.getRarity())) {
result = new ItemStack(ItemRegistry.SCROLL.get());
ISpellContainer.createScrollContainer(spell1.getSpell(), spell1.getLevel() + 1, result);
}
}
//var spell2 = ISpellContainer.get(modifierItemStack).getSpellAtIndex(0);

//if (spell1.equals(spell2)) {
// if (spell1.getLevel() < ServerConfigs.getSpellConfig(spell1.getSpell()).maxLevel()) {
// result = new ItemStack(ItemRegistry.SCROLL.get());
// ISpellContainer.createScrollContainer(spell1.getSpell(), spell1.getLevel() + 1, result);
// }
//}
}
//Unique Weapon Improving
else if (baseItemStack.getItem() instanceof UniqueItem && modifierItemStack.getItem() instanceof Scroll scroll) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera
var castingSlot = hand.ordinal() == 0 ? SpellSelectionManager.MAINHAND : SpellSelectionManager.OFFHAND;

if (spellData.getSpell().attemptInitiateCast(itemStack, spellLevel, level, player, selectionOption.getCastSource(), true, castingSlot)) {
if (spellData.getSpell().getCastType().holdToCast()) {
player.startUsingItem(hand);
}
//IronsSpellbooks.LOGGER.debug("CastingItem.Use.5 {} {}", level.isClientSide, hand);

return InteractionResultHolder.consume(itemStack);
} else {
//IronsSpellbooks.LOGGER.debug("CastingItem.Use.6 {} {}", level.isClientSide, hand);
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/redspace/ironsspellbooks/item/InkItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.redspace.ironsspellbooks.item;

import io.redspace.ironsspellbooks.api.spells.SpellRarity;
import io.redspace.ironsspellbooks.registries.ItemRegistry;
import io.redspace.ironsspellbooks.util.ItemPropertiesHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
Expand All @@ -24,6 +25,17 @@ public SpellRarity getRarity() {
return rarity;
}

public static InkItem getInkForRarity(SpellRarity rarity) {
return switch (rarity) {
case COMMON -> (InkItem) ItemRegistry.INK_COMMON.get();
case UNCOMMON -> (InkItem) ItemRegistry.INK_UNCOMMON.get();
case RARE -> (InkItem) ItemRegistry.INK_RARE.get();
case EPIC -> (InkItem) ItemRegistry.INK_EPIC.get();
case LEGENDARY -> (InkItem) ItemRegistry.INK_LEGENDARY.get();
default -> (InkItem) ItemRegistry.INK_COMMON.get();
};
}

@Override
public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> lines, TooltipFlag pIsAdvanced) {
super.appendHoverText(pStack, pLevel, lines, pIsAdvanced);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.UUID;

public class NecronomiconSpellBook extends UniqueSpellBook {
public NecronomiconSpellBook() {
Expand All @@ -30,7 +31,7 @@ public NecronomiconSpellBook() {
new SpellDataRegistryHolder(SpellRegistry.BLAZE_STORM_SPELL, 5)
), 6, () -> {
ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
//builder.put(AttributeRegistry.EVOCATION_SPELL_POWER.get(), new AttributeModifier(UUID.fromString("667ad88f-901d-4691-b2a2-3664e42026d3"), "Weapon modifier", .10, AttributeModifier.Operation.MULTIPLY_BASE));
builder.put(AttributeRegistry.MAX_MANA.get(), new AttributeModifier(UUID.fromString("667ad88f-901d-4691-b2a2-3664e42026d3"), "Weapon modifier", 200, AttributeModifier.Operation.ADDITION));
return builder.build();
});
}
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/io/redspace/ironsspellbooks/item/Scroll.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class Scroll extends Item implements IScroll {

public Scroll() {
super(new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON));
super(new Item.Properties().rarity(Rarity.UNCOMMON));
}

private AbstractSpell getSpellFromStack(ItemStack itemStack) {
Expand Down Expand Up @@ -69,9 +69,6 @@ public static void attemptRemoveScrollAfterCast(ServerPlayer serverPlayer) {
var castingSlot = hand.ordinal() == 0 ? SpellSelectionManager.MAINHAND : SpellSelectionManager.OFFHAND;

if (spell.attemptInitiateCast(stack, spell.getLevelFor(spellSlot.getLevel(), player), level, player, CastSource.SCROLL, false, castingSlot)) {
if (spell.getCastType().holdToCast()) {
player.startUsingItem(hand);
}
return InteractionResultHolder.consume(stack);
} else {
return InteractionResultHolder.fail(stack);
Expand Down
Loading

0 comments on commit 4fd8122

Please sign in to comment.