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.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,14 +208,10 @@ 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;
|
||||||
@ -220,6 +220,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
|
|||||||
((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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tickEnergy() {
|
protected void tickEnergy() {
|
||||||
|
@ -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 (((EnergyProviderBlockEntity) entity).hasStack()) {
|
||||||
if (!world.isClient()) {
|
if (!world.isClient()) {
|
||||||
ItemStack newStack = ((EnergyProviderBlockEntity) entity).takeStack();
|
ItemStack newStack = ((EnergyProviderBlockEntity) entity).takeStack();
|
||||||
player.setStackInHand(hand, newStack);
|
player.setStackInHand(hand, newStack);
|
||||||
setEnergyProviderSource(world, pos, newStack, true);
|
setEnergyProviderSource(world, pos, newStack, true);
|
||||||
}
|
}
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
|
} else {
|
||||||
|
return ActionResult.FAIL;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return ActionResult.PASS;
|
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",
|
"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"
|
||||||
}
|
}
|
@ -6,6 +6,7 @@
|
|||||||
"MixinAbstractFileResourcePack"
|
"MixinAbstractFileResourcePack"
|
||||||
],
|
],
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"DamageSourceAccessor",
|
||||||
"MixinDefaultBiomeFeatures",
|
"MixinDefaultBiomeFeatures",
|
||||||
"MixinWorld",
|
"MixinWorld",
|
||||||
"RenderPhaseAccessor"
|
"RenderPhaseAccessor"
|
||||||
|
Reference in New Issue
Block a user