Add Death Messages
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-07-17 16:20:05 -04:00
parent 8c419f9fec
commit c938957dea
5 changed files with 38 additions and 17 deletions

View File

@ -5,11 +5,13 @@ import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock; import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
import com.thebrokenrail.energonrelics.energy.core.EnergyReceiverBlockEntity; import com.thebrokenrail.energonrelics.energy.core.EnergyReceiverBlockEntity;
import com.thebrokenrail.energonrelics.energy.core.util.Action; import com.thebrokenrail.energonrelics.energy.core.util.Action;
import com.thebrokenrail.energonrelics.mixin.DamageSourceAccessor;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity; import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
@ -182,6 +184,8 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
return new ItemEntity(getWorld(), posVec.getX(), posVec.getY(), posVec.getZ()); return new ItemEntity(getWorld(), posVec.getX(), posVec.getY(), posVec.getZ());
} }
private static final DamageSource DAMAGE_SOURCE = DamageSourceAccessor.createDamageSource(EnergonRelics.NAMESPACE + ".defensive_laser").setScaledWithDifficulty().setExplosive();
private void fire(World world, BlockPos pos) { private void fire(World world, BlockPos pos) {
List<LivingEntity> entities = getEntities(entity -> true); List<LivingEntity> entities = getEntities(entity -> true);
Vec3d posVec = getPosVec(pos); Vec3d posVec = getPosVec(pos);
@ -204,20 +208,17 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
collision = result.getPos(); collision = result.getPos();
} }
double distance;
if (collision != null) { if (collision != null) {
world.createExplosion(null, collision.getX(), collision.getY(), collision.getZ(), 2f, Explosion.DestructionType.NONE); world.createExplosion(null, DAMAGE_SOURCE, null, collision.getX(), collision.getY(), collision.getZ(), 2f, false, Explosion.DestructionType.NONE);
distance = posVec.distanceTo(collision); double distance = posVec.distanceTo(collision);
} else {
distance = HardcodedConfig.DEFENSIVE_LASER_RANGE;
}
double multiplier = 4d; double multiplier = 4d;
distance = distance * multiplier; distance = distance * multiplier;
for (int i = 0; i < distance; i++) { for (int i = 0; i < distance; i++) {
Vec3d vec = rotationVec.multiply(i / multiplier).add(posVec); Vec3d vec = rotationVec.multiply(i / multiplier).add(posVec);
((ServerWorld) world).spawnParticles(ParticleTypes.END_ROD, vec.getX(), vec.getY(), vec.getZ(), 1, 0, 0, 0, 0.4f); ((ServerWorld) world).spawnParticles(ParticleTypes.END_ROD, vec.getX(), vec.getY(), vec.getZ(), 1, 0, 0, 0, 0.4f);
}
} }
} }

View File

@ -77,12 +77,16 @@ public abstract class EnergyProviderBlock extends SimpleBlockWithEntity {
return ActionResult.FAIL; return ActionResult.FAIL;
} }
} else if (stack.isEmpty() && hand == Hand.MAIN_HAND) { } else if (stack.isEmpty() && hand == Hand.MAIN_HAND) {
if (!world.isClient()) { if (((EnergyProviderBlockEntity) entity).hasStack()) {
ItemStack newStack = ((EnergyProviderBlockEntity) entity).takeStack(); if (!world.isClient()) {
player.setStackInHand(hand, newStack); ItemStack newStack = ((EnergyProviderBlockEntity) entity).takeStack();
setEnergyProviderSource(world, pos, newStack, true); player.setStackInHand(hand, newStack);
setEnergyProviderSource(world, pos, newStack, true);
}
return ActionResult.SUCCESS;
} else {
return ActionResult.FAIL;
} }
return ActionResult.SUCCESS;
} else { } else {
return ActionResult.PASS; return ActionResult.PASS;
} }

View File

@ -0,0 +1,13 @@
package com.thebrokenrail.energonrelics.mixin;
import net.minecraft.entity.damage.DamageSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(DamageSource.class)
public interface DamageSourceAccessor {
@Invoker
static DamageSource createDamageSource(String name) {
throw new UnsupportedOperationException();
}
}

View File

@ -23,5 +23,7 @@
"item.energonrelics.defensive_laser_core": "Defensive laser Core", "item.energonrelics.defensive_laser_core": "Defensive laser Core",
"block.energonrelics.defensive_laser": "Defensive Laser", "block.energonrelics.defensive_laser": "Defensive Laser",
"text.autoconfig.energonrelics.title": "EnergonRelics", "text.autoconfig.energonrelics.title": "EnergonRelics",
"text.autoconfig.energonrelics.option.textureSet": "Texture Set" "text.autoconfig.energonrelics.option.textureSet": "Texture Set",
"death.attack.energonrelics.defensive_laser": "%s was evaporated by a laser",
"death.attack.energonrelics.defensive_laser.player": "%s was evaporated by a laser whilst fighting %s"
} }

View File

@ -6,6 +6,7 @@
"MixinAbstractFileResourcePack" "MixinAbstractFileResourcePack"
], ],
"mixins": [ "mixins": [
"DamageSourceAccessor",
"MixinDefaultBiomeFeatures", "MixinDefaultBiomeFeatures",
"MixinWorld", "MixinWorld",
"RenderPhaseAccessor" "RenderPhaseAccessor"