Skip to content

Commit

Permalink
Fix damage type thing
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Dec 1, 2023
1 parent e7f5074 commit 525129b
Show file tree
Hide file tree
Showing 33 changed files with 109 additions and 91 deletions.
2 changes: 2 additions & 0 deletions src/generated/resources/assets/malum/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
"enchantment.malum.spirit_plunder": "Spirit Plunder",
"enchantment.malum.spirit_plunder.desc": "Increases the amount of spirits created when shattering a soul.",
"entity.malum.etheric_nitrate": "Etheric Nitrate",
"entity.malum.lash": "Lash",
"entity.malum.natural_spirit": "Natural Spirit",
"entity.malum.night_terror": "Night Terror",
"entity.malum.runewood_boat": "Runewood Boat",
Expand Down Expand Up @@ -399,6 +400,7 @@
"item.malum.soul_stained_steel_hoe": "Soulstained Steel Hoe",
"item.malum.soul_stained_steel_ingot": "Soulstained Steel Ingot",
"item.malum.soul_stained_steel_knife": "Soulstained Steel Knife",
"item.malum.soul_stained_steel_lash": "Soulstained Steel Lash",
"item.malum.soul_stained_steel_leggings": "Soulstained Steel Leggings",
"item.malum.soul_stained_steel_nugget": "Soulstained Steel Nugget",
"item.malum.soul_stained_steel_pickaxe": "Soulstained Steel Pickaxe",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "malum:item/soul_stained_steel_lash"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"malum:voodoo"
]
}
1 change: 1 addition & 0 deletions src/main/java/com/sammy/malum/MalumMod.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sammy.malum;

import com.mojang.blaze3d.systems.*;
import com.sammy.malum.compability.create.CreateCompat;
import com.sammy.malum.compability.farmersdelight.FarmersDelightCompat;
import com.sammy.malum.config.ClientConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public static void applyWobble(Vector3f[] offsets, float initialOffset) {
public static void applyWobble(Vector3f[] offsets, float initialOffset, float strength) {
float value = initialOffset;
for (Vector3f vector3f : offsets) {
float sine = Mth.sin((float) (Minecraft.getInstance().level.getGameTime() / 10.0F + (value * Math.PI * 2))) * strength;
double time = ((Minecraft.getInstance().level.getGameTime() / 40.0F) % Math.PI * 2);
float sine = Mth.sin((float) (time + (value * Math.PI * 2))) * strength;
vector3f.add(sine, -sine, sine);
value += 0.25f;
}
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/com/sammy/malum/common/effect/GluttonyEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ public static void canApplyPotion(MobEffectEvent.Applicable event) {
}
}

public static void finishEating(LivingEntityUseItemEvent.Finish event) {
ItemStack stack = event.getResultStack();
if (stack.is(GROSS_FOODS)) {
LivingEntity entity = event.getEntity();
MobEffectInstance effect = entity.getEffect(MobEffectRegistry.GLUTTONY.get());
if (effect != null) {
EntityHelper.extendEffect(effect, entity, 200, 1000);
Level level = entity.level();
level.playSound(null, entity.blockPosition(), SoundRegistry.HUNGRY_BELT_FEEDS.get(), SoundSource.PLAYERS, 1.7f, 1.2f + level.random.nextFloat() * 0.5f);
}
}
}

@Override
public void applyEffectTick(LivingEntity entityLivingBaseIn, int amplifier) {
if (entityLivingBaseIn instanceof Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.sammy.malum.common.capability.MalumLivingEntityDataCapability;
import com.sammy.malum.core.handlers.TouchOfDarknessHandler;
import com.sammy.malum.registry.common.DamageSourceRegistry;
import com.sammy.malum.registry.common.DamageTypeRegistry;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -21,7 +21,7 @@ public void applyEffectTick(LivingEntity pLivingEntity, int pAmplifier) {
TouchOfDarknessHandler handler = MalumLivingEntityDataCapability.getCapability(pLivingEntity).touchOfDarknessHandler;
handler.afflict(20);
if (pLivingEntity.level().getGameTime() % 60L == 0) {
pLivingEntity.hurt(DamageSourceRegistry.create(pLivingEntity.level(), DamageSourceRegistry.VOODOO), 1);
pLivingEntity.hurt(DamageTypeRegistry.create(pLivingEntity.level(), DamageTypeRegistry.VOODOO), 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sammy.malum.common.enchantment;

import com.sammy.malum.registry.common.DamageSourceRegistry;
import com.sammy.malum.registry.common.DamageTypeRegistry;
import com.sammy.malum.registry.common.item.EnchantmentRegistry;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
Expand All @@ -17,7 +17,7 @@ public void doPostAttack(LivingEntity user, Entity target, int level) {
if (target instanceof LivingEntity entity) {
if (entity.isAlive()) {
entity.invulnerableTime = 0;
entity.hurt(DamageSourceRegistry.create(user.level(), DamageSourceRegistry.VOODOO, user), level + 1);
entity.hurt(DamageTypeRegistry.create(user.level(), DamageTypeRegistry.VOODOO, user), level + 1);
}
}
super.doPostAttack(user, target, level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,25 @@ public int getMaxLevel() {
}

public static void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
if (true) {
Player player = event.getEntity();
ItemStack stack = event.getItemStack();
if (EnchantmentHelper.getItemEnchantmentLevel(EnchantmentRegistry.REBOUND.get(), stack) > 0) {
Level level = player.level();
if (!level.isClientSide) {
player.setItemInHand(event.getHand(), ItemStack.EMPTY);
float baseDamage = (float) player.getAttributes().getValue(Attributes.ATTACK_DAMAGE);
float magicDamage = (float) player.getAttributes().getValue(LodestoneAttributeRegistry.MAGIC_DAMAGE.get());
Player player = event.getEntity();
ItemStack stack = event.getItemStack();
if (EnchantmentHelper.getItemEnchantmentLevel(EnchantmentRegistry.REBOUND.get(), stack) > 0) {
Level level = player.level();
if (!level.isClientSide) {
player.setItemInHand(event.getHand(), ItemStack.EMPTY);
float baseDamage = (float) player.getAttributes().getValue(Attributes.ATTACK_DAMAGE);
float magicDamage = (float) player.getAttributes().getValue(LodestoneAttributeRegistry.MAGIC_DAMAGE.get());

int slot = event.getHand() == InteractionHand.OFF_HAND ? player.getInventory().getContainerSize() - 1 : player.getInventory().selected;
ScytheBoomerangEntity entity = new ScytheBoomerangEntity(level, player.position().x, player.position().y + player.getBbHeight() / 2f, player.position().z);
entity.setData(player, baseDamage, magicDamage, slot);
entity.setItem(stack);
int slot = event.getHand() == InteractionHand.OFF_HAND ? player.getInventory().getContainerSize() - 1 : player.getInventory().selected;
ScytheBoomerangEntity entity = new ScytheBoomerangEntity(level, player.position().x, player.position().y + player.getBbHeight() / 2f, player.position().z);
entity.setData(player, baseDamage, magicDamage, slot);
entity.setItem(stack);

entity.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, (float) (1.5F + player.getAttributeValue(AttributeRegistry.SCYTHE_PROFICIENCY.get()) * 0.125f), 0F);
level.addFreshEntity(entity);
}
player.awardStat(Stats.ITEM_USED.get(stack.getItem()));
entity.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, (float) (1.5F + player.getAttributeValue(AttributeRegistry.SCYTHE_PROFICIENCY.get()) * 0.125f), 0F);
level.addFreshEntity(entity);
}
player.awardStat(Stats.ITEM_USED.get(stack.getItem()));
}
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.sammy.malum.common.entity.boomerang;

import com.sammy.malum.common.item.curiosities.weapons.MalumScytheItem;
import com.sammy.malum.registry.common.DamageSourceRegistry;
import com.sammy.malum.registry.common.DamageTypeRegistry;
import com.sammy.malum.registry.common.SoundRegistry;
import com.sammy.malum.registry.common.entity.EntityRegistry;
import com.sammy.malum.registry.common.item.EnchantmentRegistry;
Expand Down Expand Up @@ -126,7 +126,7 @@ protected void onHitEntity(EntityHitResult result) {
if (magicDamage > 0) {
if (livingentity.isAlive()) {
livingentity.invulnerableTime = 0;
livingentity.hurt(DamageSourceRegistry.create(level(), DamageSourceRegistry.VOODOO, scytheOwner), magicDamage);
livingentity.hurt(DamageTypeRegistry.create(level(), DamageTypeRegistry.VOODOO, scytheOwner), magicDamage);
}
}

Expand Down Expand Up @@ -212,11 +212,6 @@ public void shootFromRotation(Entity shooter, float rotationPitch, float rotatio
this.setDeltaMovement(this.getDeltaMovement().add(vec3.x, 0, vec3.z));
}

@Override
public Packet<ClientGamePacketListener> getAddEntityPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}

@Override
public boolean isNoGravity() {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sammy.malum.common.entity.night_terror;

import com.sammy.malum.registry.common.DamageSourceRegistry;
import com.sammy.malum.registry.common.DamageTypeRegistry;
import com.sammy.malum.registry.common.SoundRegistry;
import com.sammy.malum.registry.common.entity.EntityRegistry;
import net.minecraft.nbt.CompoundTag;
Expand Down Expand Up @@ -110,7 +110,7 @@ protected void onHitEntity(EntityHitResult result) {
if (level().isClientSide) {
return;
}
DamageSource source = DamageSourceRegistry.create(level(), DamageSourceRegistry.VOODOO, scytheOwner);
DamageSource source = DamageTypeRegistry.create(level(), DamageTypeRegistry.VOODOO, scytheOwner);
target.hurt(source, magicDamage);
if (age < fadeoutStart) {
fadeoutStart += 4;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sammy.malum.common.entity.nitrate;

import com.sammy.malum.registry.common.DamageSourceRegistry;
import com.sammy.malum.registry.common.DamageTypeRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
Expand Down Expand Up @@ -39,9 +39,9 @@ public EthericExplosion(Level pLevel, @Nullable Entity pSource, @Nullable Damage
@Override
public DamageSource getDamageSource() {
if (getDirectSourceEntity() != null) {
return DamageSourceRegistry.create(getDirectSourceEntity().level(), DamageSourceRegistry.VOODOO, getDirectSourceEntity());
return DamageTypeRegistry.create(getDirectSourceEntity().level(), DamageTypeRegistry.VOODOO, getDirectSourceEntity());
}
return DamageSourceRegistry.create(getDirectSourceEntity().level(), DamageSourceRegistry.VOODOO);
return DamageTypeRegistry.create(getDirectSourceEntity().level(), DamageTypeRegistry.VOODOO);
}

public static void processExplosion(ExplosionEvent.Detonate event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public void pickupSpirit(LivingEntity collector, ItemStack stack, double arcaneR
MobEffect gluttony = MobEffectRegistry.GLUTTONY.get();
MobEffectInstance effect = collector.getEffect(gluttony);
if (effect == null) {
collector.addEffect(new MobEffectInstance(gluttony, 100 + (int) (arcaneResonance * 100), 0, true, true, true));
collector.addEffect(new MobEffectInstance(gluttony, 600 + (int) (arcaneResonance * 600), 0, true, true, true));
} else {
EntityHelper.extendEffect(effect, collector, 50, 200 + (int) (arcaneResonance * 200));
EntityHelper.amplifyEffect(effect, collector, 1, 9);
}
Level level = collector.level();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import com.google.common.collect.Multimap;
import com.sammy.malum.common.item.curiosities.curios.MalumCurioItem;
import com.sammy.malum.registry.common.MobEffectRegistry;
import com.sammy.malum.registry.common.*;
import com.sammy.malum.registry.common.item.ItemRegistry;
import net.minecraft.sounds.*;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.*;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.*;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
import team.lodestar.lodestone.helpers.CurioHelper;
import team.lodestar.lodestone.helpers.EntityHelper;
import team.lodestar.lodestone.helpers.*;
import top.theillusivec4.curios.api.SlotContext;

import static com.sammy.malum.registry.common.item.ItemTagRegistry.GROSS_FOODS;
Expand All @@ -39,21 +39,23 @@ public static void accelerateEating(LivingEntityUseItemEvent.Start event) {
}
}
}

public static void finishEating(LivingEntityUseItemEvent.Finish event) {
if (event.getEntity() instanceof Player player) {
ItemStack stack = event.getResultStack();
if (CurioHelper.hasCurioEquipped(player, ItemRegistry.RING_OF_DESPERATE_VORACITY.get())) {
if (stack.is(GROSS_FOODS)) {
double arcaneResonance = player.getAttribute(AttributeRegistry.ARCANE_RESONANCE.get()).getValue();
Level level = player.level();
MobEffectInstance gluttony = player.getEffect(MobEffectRegistry.GLUTTONY.get());
MobEffectInstance hunger = player.getEffect(MobEffects.HUNGER);
if (gluttony != null) {
player.getFoodData().eat(1, 0.25f * (gluttony.amplifier + 1));
EntityHelper.extendEffect(gluttony, player, 300, 600 + (int) (arcaneResonance * 600));
}
player.getFoodData().eat(1, 1f);
MobEffectInstance hunger = player.getEffect(MobEffects.HUNGER);
if (hunger != null) {
EntityHelper.shortenEffect(hunger, player, 150);
}
player.getFoodData().eat(1, 1f);
level.playSound(null, player.blockPosition(), SoundRegistry.HUNGRY_BELT_FEEDS.get(), SoundSource.PLAYERS, 1.7f, RandomHelper.randomBetween(level.random, 0.8f, 1.2f));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.sammy.malum.common.entity.boomerang.ScytheBoomerangEntity;
import com.sammy.malum.core.systems.item.IMalumEventResponderItem;
import com.sammy.malum.registry.client.ParticleRegistry;
import com.sammy.malum.registry.common.DamageSourceRegistry;
import com.sammy.malum.registry.common.DamageTypeRegistry;
import com.sammy.malum.registry.common.SoundRegistry;
import com.sammy.malum.registry.common.item.ItemRegistry;
import net.minecraft.core.particles.SimpleParticleType;
Expand All @@ -12,7 +12,6 @@
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -46,15 +45,15 @@ public void hurtEvent(LivingHurtEvent event, LivingEntity attacker, LivingEntity
attacker.level().playSound(null, target.getX(), target.getY(), target.getZ(), sound, attacker.getSoundSource(), 1, 1);
}

if (!canSweep || event.getSource().is(LodestoneDamageTypeTags.IS_MAGIC) || event.getSource().getMsgId().equals(DamageSourceRegistry.SCYTHE_SWEEP_IDENTIFIER)) {
if (!canSweep || event.getSource().is(LodestoneDamageTypeTags.IS_MAGIC) || event.getSource().getMsgId().equals(DamageTypeRegistry.SCYTHE_SWEEP_IDENTIFIER)) {
return;
}
int level = EnchantmentHelper.getEnchantmentLevel(Enchantments.SWEEPING_EDGE, attacker);
float damage = event.getAmount() * (0.5f + EnchantmentHelper.getSweepingDamageRatio(attacker));
target.level().getEntities(attacker, target.getBoundingBox().inflate(1 + level * 0.25f)).forEach(e -> {
if (e instanceof LivingEntity livingEntity) {
if (livingEntity.isAlive()) {
livingEntity.hurt((DamageSourceRegistry.create(attacker.level(), DamageSourceRegistry.SCYTHE_SWEEP, attacker)), damage);
livingEntity.hurt((DamageTypeRegistry.create(attacker.level(), DamageTypeRegistry.SCYTHE_SWEEP, attacker)), damage);
livingEntity.knockback(0.4F, Mth.sin(attacker.getYRot() * ((float) Math.PI / 180F)), (-Mth.cos(attacker.getYRot() * ((float) Math.PI / 180F))));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import com.sammy.malum.common.packets.particle.curiosities.rite.generic.MajorEntityEffectParticlePacket;
import com.sammy.malum.core.helper.SpiritHelper;
import com.sammy.malum.core.systems.item.IMalumEventResponderItem;
import com.sammy.malum.registry.common.DamageSourceRegistry;
import com.sammy.malum.registry.common.DamageTypeRegistry;
import com.sammy.malum.registry.common.SoundRegistry;
import com.sammy.malum.registry.common.SpiritTypeRegistry;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -39,7 +38,7 @@ public void hurtEvent(LivingHurtEvent event, LivingEntity attacker, LivingEntity

if (target.isAlive()) {
target.invulnerableTime = 0;
target.hurt(DamageSourceRegistry.create(attacker.level(), DamageSourceRegistry.VOODOO, attacker), spiritCount);
target.hurt(DamageTypeRegistry.create(attacker.level(), DamageTypeRegistry.VOODOO, attacker), spiritCount);
}
attacker.level().playSound(null, target.blockPosition(), SoundRegistry.VOID_SLASH.get(), SoundSource.PLAYERS, 1, 1f + target.level().random.nextFloat() * 0.25f);
MALUM_CHANNEL.send(PacketDistributor.TRACKING_ENTITY.with(() -> target), new MajorEntityEffectParticlePacket(SpiritTypeRegistry.ELDRITCH_SPIRIT.getPrimaryColor(), target.getX(), target.getY() + target.getBbHeight() / 2, target.getZ()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.sammy.malum.core.systems.rites.MalumRiteEffect;
import com.sammy.malum.core.systems.rites.MalumRiteType;
import com.sammy.malum.registry.common.DamageSourceRegistry;
import com.sammy.malum.registry.common.DamageTypeRegistry;
import com.sammy.malum.registry.common.ParticleEffectTypeRegistry;
import com.sammy.malum.visual_effects.networked.data.ColorEffectData;
import net.minecraft.world.effect.MobEffectInstance;
Expand All @@ -27,9 +27,9 @@ public MalumRiteEffect getNaturalRiteEffect() {
@Override
public void doRiteEffect(TotemBaseBlockEntity totemBase) {
getNearbyEntities(totemBase, LivingEntity.class, e -> !(e instanceof Player)).forEach(e -> {
if (e.getHealth() > 2.5f && !e.isInvulnerableTo(DamageSourceRegistry.create(e.level(), DamageSourceRegistry.VOODOO))) {
if (e.getHealth() > 2.5f && !e.isInvulnerableTo(DamageTypeRegistry.create(e.level(), DamageTypeRegistry.VOODOO))) {
ParticleEffectTypeRegistry.HEXING_SMOKE.createEntityEffect(e, new ColorEffectData(WICKED_SPIRIT.getPrimaryColor()));
e.hurt(DamageSourceRegistry.create(e.level(), DamageSourceRegistry.VOODOO), 2);
e.hurt(DamageTypeRegistry.create(e.level(), DamageTypeRegistry.VOODOO), 2);
}
});
}
Expand Down
Loading

0 comments on commit 525129b

Please sign in to comment.