more config options + fix prev. commit breaking arrows
This commit is contained in:
9 files changed
+72
-42
No files matched your search
@@ -15,11 +15,11 @@ public class baseArrow extends AbstractArrow {
|
||||
super(pEntityType, pLevel);
|
||||
}
|
||||
|
||||
public baseArrow(Level pLevel, double pX, double pY, double pZ, EntityType<? extends baseArrow> pEntityType) {
|
||||
super(pEntityType, pX, pY, pZ, pLevel);
|
||||
public baseArrow(Level pLevel, LivingEntity pShooter, EntityType<? extends baseArrow> pEntityType) {
|
||||
super(pEntityType, pShooter, pLevel);
|
||||
}
|
||||
|
||||
public baseArrow(Level pLevel, LivingEntity pShooter, EntityType<? extends baseArrow> pEntityType) {
|
||||
public baseArrow(Level pLevel, EntityType<? extends baseArrow> pEntityType) {
|
||||
super(pEntityType, pLevel);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
import com.jenny.enhancedexplosives.config.ConfigServer;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.damagesource.DamageType;
|
||||
import net.minecraft.world.damagesource.DamageTypes;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -20,13 +20,13 @@ public class carpetArrowPart extends baseArrow {
|
||||
}
|
||||
|
||||
public carpetArrowPart(Level pLevel, LivingEntity pShooter) {
|
||||
super(pLevel, pShooter, entities.ARROW_CARPET_PART.get());
|
||||
super(pLevel, entities.ARROW_CARPET_PART.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.inGround || this.hurtMarked) {
|
||||
if (this.inGround || (this.hurtMarked && !this.level().isClientSide && ConfigServer.carpetCompactDetonation.get())) {
|
||||
explode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jenny.enhancedexplosives.entities.arrows;
|
||||
|
||||
import com.jenny.enhancedexplosives.config.ConfigServer;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.items.items;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -9,7 +10,7 @@ import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class claymoreArrow extends baseArrow{
|
||||
private final int r = level().isClientSide ? 0 : level().getRandom().nextInt(0, 20);
|
||||
private final int r = level().isClientSide ? 0 : (ConfigServer.claymoreInstantDespawn.get() ? -20 : level().getRandom().nextInt(0, 20));
|
||||
|
||||
public claymoreArrow(EntityType<claymoreArrow> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
|
||||
@@ -43,11 +43,9 @@ public class tunnelArrow extends baseArrow{
|
||||
}
|
||||
|
||||
protected void explode() {
|
||||
// sync();
|
||||
Vec3 rot = getTargetVec( - getXRot(), - getYRot(), 0);
|
||||
for (int i = 0; i < explosionCount; i++) {
|
||||
Vec3 pos = position().add(rot.multiply(i * spacing, i * spacing, i * spacing));
|
||||
System.out.println(level().isClientSide + "|" + i + "|" + pos + "|" + getXRot() + "|" + getYRot());
|
||||
level().explode(this, pos.x, pos.y, pos.z,
|
||||
power, Level.ExplosionInteraction.TNT);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
package com.jenny.enhancedexplosives.entities.tnt;
|
||||
|
||||
import com.jenny.enhancedexplosives.blocks.blocks;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import com.jenny.enhancedexplosives.config.ConfigServer;
|
||||
import com.jenny.enhancedexplosives.entities.entities;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class homingPrimedTNT extends basePrimedTNT {
|
||||
private static final EntityDataAccessor<Float> DATA_SPEED_ID = SynchedEntityData.defineId(homingPrimedTNT.class, EntityDataSerializers.FLOAT);
|
||||
@@ -51,10 +53,34 @@ public class homingPrimedTNT extends basePrimedTNT {
|
||||
}
|
||||
|
||||
public void findTarget() {
|
||||
target = closestEntity(getEntities());
|
||||
}
|
||||
|
||||
private LivingEntity closestEntity(List<LivingEntity> entities) {
|
||||
double dist = Double.MAX_VALUE;
|
||||
LivingEntity target = null;
|
||||
for (LivingEntity e : entities) {
|
||||
double newDist = e.position().distanceTo(position());
|
||||
if (newDist < dist) {
|
||||
target = e;
|
||||
dist = newDist;
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
protected List<LivingEntity> getEntities() {
|
||||
List<LivingEntity> ret_list = new ArrayList<>();
|
||||
Vec3 corner1 = this.position().subtract(15, 15, 15);
|
||||
Vec3 corner2 = this.position().add(15, 15, 15);
|
||||
AABB boundingBox = new AABB(corner1, corner2);
|
||||
target = this.level().getNearestEntity(LivingEntity.class, TargetingConditions.forNonCombat(), null, this.getX(), this.getY(), this.getZ(), boundingBox);
|
||||
|
||||
for (LivingEntity entity : level().getEntitiesOfClass(LivingEntity.class, boundingBox)) {
|
||||
if (level().getPlayerByUUID(entity.getUUID()) == null || ConfigServer.homingAtPlayers.get()) { // prevent aiming at player if config says so
|
||||
ret_list.add(entity);
|
||||
}
|
||||
}
|
||||
return ret_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user