This commit is contained in:
parent
8c419f9fec
commit
c938957dea
@ -5,11 +5,13 @@ import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
|
||||
import com.thebrokenrail.energonrelics.energy.core.EnergyReceiverBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.energy.core.util.Action;
|
||||
import com.thebrokenrail.energonrelics.mixin.DamageSourceAccessor;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
@ -182,6 +184,8 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
|
||||
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) {
|
||||
List<LivingEntity> entities = getEntities(entity -> true);
|
||||
Vec3d posVec = getPosVec(pos);
|
||||
@ -204,20 +208,17 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
|
||||
collision = result.getPos();
|
||||
}
|
||||
|
||||
double distance;
|
||||
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);
|
||||
} else {
|
||||
distance = HardcodedConfig.DEFENSIVE_LASER_RANGE;
|
||||
}
|
||||
double distance = posVec.distanceTo(collision);
|
||||
|
||||
double multiplier = 4d;
|
||||
distance = distance * multiplier;
|
||||
for (int i = 0; i < distance; i++) {
|
||||
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);
|
||||
double multiplier = 4d;
|
||||
distance = distance * multiplier;
|
||||
for (int i = 0; i < distance; i++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,12 +77,16 @@ public abstract class EnergyProviderBlock extends SimpleBlockWithEntity {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
} else if (stack.isEmpty() && hand == Hand.MAIN_HAND) {
|
||||
if (!world.isClient()) {
|
||||
ItemStack newStack = ((EnergyProviderBlockEntity) entity).takeStack();
|
||||
player.setStackInHand(hand, newStack);
|
||||
setEnergyProviderSource(world, pos, newStack, true);
|
||||
if (((EnergyProviderBlockEntity) entity).hasStack()) {
|
||||
if (!world.isClient()) {
|
||||
ItemStack newStack = ((EnergyProviderBlockEntity) entity).takeStack();
|
||||
player.setStackInHand(hand, newStack);
|
||||
setEnergyProviderSource(world, pos, newStack, true);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -23,5 +23,7 @@
|
||||
"item.energonrelics.defensive_laser_core": "Defensive laser Core",
|
||||
"block.energonrelics.defensive_laser": "Defensive Laser",
|
||||
"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"
|
||||
}
|
@ -6,6 +6,7 @@
|
||||
"MixinAbstractFileResourcePack"
|
||||
],
|
||||
"mixins": [
|
||||
"DamageSourceAccessor",
|
||||
"MixinDefaultBiomeFeatures",
|
||||
"MixinWorld",
|
||||
"RenderPhaseAccessor"
|
||||
|
Reference in New Issue
Block a user