优化迫击炮角度调整
This commit is contained in:
parent
b816adc06c
commit
4e01d34071
12 changed files with 104 additions and 122 deletions
|
@ -3,7 +3,6 @@ package net.mcreator.target.entity;
|
||||||
import net.mcreator.target.TargetMod;
|
import net.mcreator.target.TargetMod;
|
||||||
import net.mcreator.target.init.TargetModEntities;
|
import net.mcreator.target.init.TargetModEntities;
|
||||||
import net.mcreator.target.init.TargetModItems;
|
import net.mcreator.target.init.TargetModItems;
|
||||||
import net.mcreator.target.procedures.MedexpProcedure;
|
|
||||||
import net.minecraft.commands.CommandSource;
|
import net.minecraft.commands.CommandSource;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -267,7 +266,10 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
|
||||||
if (!condition) continue;
|
if (!condition) continue;
|
||||||
|
|
||||||
if (!level.isClientSide()) {
|
if (!level.isClientSide()) {
|
||||||
MedexpProcedure.execute(this.level(), this.getX(), this.getY(), this.getZ());
|
if (!this.level().isClientSide() && this.getServer() != null) {
|
||||||
|
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
||||||
|
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "target:mediumexp");
|
||||||
|
}
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
target.getPersistentData().putDouble("claymore", 5);
|
target.getPersistentData().putDouble("claymore", 5);
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.target.headshot.BoundingBoxManager;
|
||||||
import net.mcreator.target.headshot.IHeadshotBox;
|
import net.mcreator.target.headshot.IHeadshotBox;
|
||||||
import net.mcreator.target.init.TargetModEntities;
|
import net.mcreator.target.init.TargetModEntities;
|
||||||
import net.mcreator.target.network.TargetModVariables;
|
import net.mcreator.target.network.TargetModVariables;
|
||||||
import net.mcreator.target.procedures.MedexpProcedure;
|
|
||||||
import net.minecraft.commands.CommandSource;
|
import net.minecraft.commands.CommandSource;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
@ -89,9 +88,13 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getPersistentData().getDouble("baoxian") > 0) {
|
if (this.getPersistentData().getDouble("baoxian") > 0) {
|
||||||
|
|
||||||
if (this.level() instanceof ServerLevel level) {
|
if (this.level() instanceof ServerLevel level) {
|
||||||
level.explode(this, (this.getX()), (this.getY()), (this.getZ()), 5.5f, Level.ExplosionInteraction.NONE);
|
level.explode(this, (this.getX()), (this.getY()), (this.getZ()), 5.5f, Level.ExplosionInteraction.NONE);
|
||||||
MedexpProcedure.execute(this.level(), (this.getX()), (this.getY()), (this.getZ()));
|
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||||
|
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||||
|
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "target:mediumexp");
|
||||||
|
}
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,8 +149,6 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
|
||||||
if (this.getPersistentData().getDouble("baoxian") > 0) {
|
if (this.getPersistentData().getDouble("baoxian") > 0) {
|
||||||
if (this.level() instanceof ServerLevel level) {
|
if (this.level() instanceof ServerLevel level) {
|
||||||
this.level().explode(this, this.getX(), this.getY(), this.getZ(), 5.5f, Level.ExplosionInteraction.NONE);
|
this.level().explode(this, this.getX(), this.getY(), this.getZ(), 5.5f, Level.ExplosionInteraction.NONE);
|
||||||
MedexpProcedure.execute(level, this.getX(), this.getY(), this.getZ());
|
|
||||||
this.discard();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,38 +164,15 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
|
||||||
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
||||||
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "particle minecraft:campfire_cosy_smoke ~ ~ ~ 0 0 0 0 1 force");
|
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "particle minecraft:campfire_cosy_smoke ~ ~ ~ 0 0 0 0 1 force");
|
||||||
}
|
}
|
||||||
|
if (this.inGround) {
|
||||||
|
if (!this.level().isClientSide() && this.getServer() != null) {
|
||||||
|
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
||||||
|
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "target:mediumexp");
|
||||||
|
}
|
||||||
|
this.discard();
|
||||||
|
}
|
||||||
if (this.tickCount > 200) {
|
if (this.tickCount > 200) {
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GunGrenadeEntity shoot(Level world, LivingEntity entity, RandomSource source) {
|
|
||||||
return shoot(world, entity, source, 1f, 5, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GunGrenadeEntity shoot(Level world, LivingEntity entity, RandomSource random, float power, double damage, int knockback) {
|
|
||||||
GunGrenadeEntity entityarrow = new GunGrenadeEntity(TargetModEntities.GUN_GRENADE.get(), entity, world);
|
|
||||||
entityarrow.shoot(entity.getViewVector(1).x, entity.getViewVector(1).y, entity.getViewVector(1).z, power * 2, 0);
|
|
||||||
entityarrow.setSilent(true);
|
|
||||||
entityarrow.setCritArrow(false);
|
|
||||||
entityarrow.setBaseDamage(damage);
|
|
||||||
entityarrow.setKnockback(knockback);
|
|
||||||
world.addFreshEntity(entityarrow);
|
|
||||||
return entityarrow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GunGrenadeEntity shoot(LivingEntity entity, LivingEntity target) {
|
|
||||||
GunGrenadeEntity entityarrow = new GunGrenadeEntity(TargetModEntities.GUN_GRENADE.get(), entity, entity.level());
|
|
||||||
double dx = target.getX() - entity.getX();
|
|
||||||
double dy = target.getY() + target.getEyeHeight() - 1.1;
|
|
||||||
double dz = target.getZ() - entity.getZ();
|
|
||||||
entityarrow.shoot(dx, dy - entityarrow.getY() + Math.hypot(dx, dz) * 0.2F, dz, 1f * 2, 12.0F);
|
|
||||||
entityarrow.setSilent(true);
|
|
||||||
entityarrow.setBaseDamage(5);
|
|
||||||
entityarrow.setKnockback(5);
|
|
||||||
entityarrow.setCritArrow(false);
|
|
||||||
entity.level().addFreshEntity(entityarrow);
|
|
||||||
return entityarrow;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.mcreator.target.entity;
|
||||||
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.mcreator.target.TargetMod;
|
import net.mcreator.target.TargetMod;
|
||||||
|
import net.mcreator.target.init.TargetModAttributes;
|
||||||
import net.mcreator.target.init.TargetModEntities;
|
import net.mcreator.target.init.TargetModEntities;
|
||||||
import net.mcreator.target.init.TargetModItems;
|
import net.mcreator.target.init.TargetModItems;
|
||||||
import net.mcreator.target.init.TargetModSounds;
|
import net.mcreator.target.init.TargetModSounds;
|
||||||
|
@ -52,6 +53,7 @@ import software.bernie.geckolib.core.object.PlayState;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEntity {
|
public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEntity {
|
||||||
public static final EntityDataAccessor<Boolean> SHOOT = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.BOOLEAN);
|
public static final EntityDataAccessor<Boolean> SHOOT = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.BOOLEAN);
|
||||||
|
@ -222,7 +224,7 @@ public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEn
|
||||||
entityToSpawn.setBaseDamage(100);
|
entityToSpawn.setBaseDamage(100);
|
||||||
entityToSpawn.setKnockback(0);
|
entityToSpawn.setKnockback(0);
|
||||||
entityToSpawn.setSilent(true);
|
entityToSpawn.setSilent(true);
|
||||||
entityToSpawn.setPos(this.getX(), this.getEyeY() - 0.1, this.getZ());
|
entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ());
|
||||||
entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 8, (float) 0.5);
|
entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 8, (float) 0.5);
|
||||||
level.addFreshEntity(entityToSpawn);
|
level.addFreshEntity(entityToSpawn);
|
||||||
|
|
||||||
|
@ -238,6 +240,26 @@ public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEn
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
double[] Timer = {0};
|
||||||
|
double totalTime = 4;
|
||||||
|
int sleepTime = 2;
|
||||||
|
double Duration = totalTime / sleepTime;
|
||||||
|
Runnable Runnable = () -> {
|
||||||
|
while (Timer[0] < Duration) {
|
||||||
|
|
||||||
|
this.setXRot((float) -this.getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue());
|
||||||
|
|
||||||
|
Timer[0]++;
|
||||||
|
try {
|
||||||
|
Thread.sleep(sleepTime);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Thread Thread = new Thread(Runnable);
|
||||||
|
Thread.start();
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +293,7 @@ public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEn
|
||||||
public static AttributeSupplier.Builder createAttributes() {
|
public static AttributeSupplier.Builder createAttributes() {
|
||||||
return Mob.createMobAttributes()
|
return Mob.createMobAttributes()
|
||||||
.add(Attributes.MOVEMENT_SPEED, 0)
|
.add(Attributes.MOVEMENT_SPEED, 0)
|
||||||
.add(Attributes.MAX_HEALTH, 10)
|
.add(Attributes.MAX_HEALTH, 100)
|
||||||
.add(Attributes.ARMOR, 0)
|
.add(Attributes.ARMOR, 0)
|
||||||
.add(Attributes.ATTACK_DAMAGE, 0)
|
.add(Attributes.ATTACK_DAMAGE, 0)
|
||||||
.add(Attributes.FOLLOW_RANGE, 16)
|
.add(Attributes.FOLLOW_RANGE, 16)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.mcreator.target.entity;
|
package net.mcreator.target.entity;
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModEntities;
|
import net.mcreator.target.init.TargetModEntities;
|
||||||
import net.mcreator.target.procedures.MedexpProcedure;
|
|
||||||
import net.minecraft.commands.CommandSource;
|
import net.minecraft.commands.CommandSource;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
@ -10,6 +9,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||||
|
@ -70,20 +70,27 @@ public class MortarShellEntity extends AbstractArrow implements ItemSupplier {
|
||||||
@Override
|
@Override
|
||||||
public void onHitEntity(EntityHitResult entityHitResult) {
|
public void onHitEntity(EntityHitResult entityHitResult) {
|
||||||
super.onHitEntity(entityHitResult);
|
super.onHitEntity(entityHitResult);
|
||||||
onHit();
|
Entity entity = entityHitResult.getEntity();
|
||||||
}
|
|
||||||
|
|
||||||
private void onHit() {
|
if (this.level() instanceof ServerLevel level) {
|
||||||
if (this.level() instanceof ServerLevel server) {
|
level.explode(this, (this.getX()), (this.getY()), (this.getZ()), 10, Level.ExplosionInteraction.NONE);
|
||||||
MedexpProcedure.execute(this.level(), this.getX(), getY(), getZ());
|
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||||
server.explode(this, (this.getX()), (this.getY()), (this.getZ()), 7.5f, Level.ExplosionInteraction.NONE);
|
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||||
|
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "target:mediumexp");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHitBlock(BlockHitResult blockHitResult) {
|
public void onHitBlock(BlockHitResult blockHitResult) {
|
||||||
super.onHitBlock(blockHitResult);
|
super.onHitBlock(blockHitResult);
|
||||||
onHit();
|
|
||||||
|
if (this.getPersistentData().getDouble("time") > 0) {
|
||||||
|
if (this.level() instanceof ServerLevel level) {
|
||||||
|
level.explode(this, this.getX(), this.getY(), this.getZ(), 10, Level.ExplosionInteraction.NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,7 +101,13 @@ public class MortarShellEntity extends AbstractArrow implements ItemSupplier {
|
||||||
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
||||||
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "particle minecraft:campfire_cosy_smoke ~ ~ ~ 0 0 0 0 2 force");
|
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "particle minecraft:campfire_cosy_smoke ~ ~ ~ 0 0 0 0 2 force");
|
||||||
}
|
}
|
||||||
if (this.inGround) this.discard();
|
if (this.inGround) {
|
||||||
|
if (!this.level().isClientSide() && this.getServer() != null) {
|
||||||
|
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
||||||
|
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "target:mediumexp");
|
||||||
|
}
|
||||||
|
this.discard();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MortarShellEntity shoot(Level world, LivingEntity entity, RandomSource source) {
|
public static MortarShellEntity shoot(Level world, LivingEntity entity, RandomSource source) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.target.headshot.BoundingBoxManager;
|
||||||
import net.mcreator.target.headshot.IHeadshotBox;
|
import net.mcreator.target.headshot.IHeadshotBox;
|
||||||
import net.mcreator.target.init.TargetModEntities;
|
import net.mcreator.target.init.TargetModEntities;
|
||||||
import net.mcreator.target.network.TargetModVariables;
|
import net.mcreator.target.network.TargetModVariables;
|
||||||
import net.mcreator.target.procedures.MedexpProcedure;
|
|
||||||
import net.minecraft.commands.CommandSource;
|
import net.minecraft.commands.CommandSource;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
@ -100,7 +99,11 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
|
||||||
if (this.level() instanceof ServerLevel level) {
|
if (this.level() instanceof ServerLevel level) {
|
||||||
level.explode(this, this.getX(), this.getY(), this.getZ(), 4, Level.ExplosionInteraction.NONE);
|
level.explode(this, this.getX(), this.getY(), this.getZ(), 4, Level.ExplosionInteraction.NONE);
|
||||||
|
|
||||||
MedexpProcedure.execute(level, this.getX(), this.getY(), this.getZ());
|
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||||
|
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||||
|
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "target:mediumexp");
|
||||||
|
}
|
||||||
|
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,17 +164,9 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
|
||||||
if (this.getPersistentData().getDouble("time") > 0) {
|
if (this.getPersistentData().getDouble("time") > 0) {
|
||||||
if (this.level() instanceof ServerLevel level) {
|
if (this.level() instanceof ServerLevel level) {
|
||||||
level.explode(this, this.getX(), this.getY(), this.getZ(), 6, Level.ExplosionInteraction.NONE);
|
level.explode(this, this.getX(), this.getY(), this.getZ(), 6, Level.ExplosionInteraction.NONE);
|
||||||
MedexpProcedure.execute(level, this.getX(), this.getY(), this.getZ());
|
|
||||||
}
|
}
|
||||||
if (!this.level().isClientSide())
|
|
||||||
this.discard();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RpgRocketEntity shoot(Level world, LivingEntity entity, RandomSource source) {
|
|
||||||
return shoot(world, entity, source, 1f, 5, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
@ -196,28 +191,21 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
|
||||||
}
|
}
|
||||||
if (life >= 90) {
|
if (life >= 90) {
|
||||||
if (!this.level().isClientSide() && this.getServer() != null) {
|
if (!this.level().isClientSide() && this.getServer() != null) {
|
||||||
MedexpProcedure.execute(this.level(), this.getX(), this.getY(), this.getZ());
|
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
||||||
|
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "target:mediumexp");
|
||||||
}
|
}
|
||||||
if (!this.level().isClientSide())
|
if (!this.level().isClientSide())
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
if (this.inGround) {
|
||||||
|
if (!this.level().isClientSide() && this.getServer() != null) {
|
||||||
|
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
|
||||||
|
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "target:mediumexp");
|
||||||
|
}
|
||||||
|
this.discard();
|
||||||
|
}
|
||||||
if (this.tickCount > 100) {
|
if (this.tickCount > 100) {
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RpgRocketEntity shoot(LivingEntity entity, LivingEntity target) {
|
|
||||||
RpgRocketEntity entityarrow = new RpgRocketEntity(TargetModEntities.RPG_ROCKET.get(), entity, entity.level());
|
|
||||||
double dx = target.getX() - entity.getX();
|
|
||||||
double dy = target.getY() + target.getEyeHeight() - 1.1;
|
|
||||||
double dz = target.getZ() - entity.getZ();
|
|
||||||
entityarrow.shoot(dx, dy - entityarrow.getY() + Math.hypot(dx, dz) * 0.2F, dz, 1f * 2, 12.0F);
|
|
||||||
entityarrow.setSilent(true);
|
|
||||||
entityarrow.setBaseDamage(5);
|
|
||||||
entityarrow.setKnockback(5);
|
|
||||||
entityarrow.setCritArrow(false);
|
|
||||||
entity.level().addFreshEntity(entityarrow);
|
|
||||||
return entityarrow;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ public class GunEventHandler {
|
||||||
projectile.beast();
|
projectile.beast();
|
||||||
}
|
}
|
||||||
|
|
||||||
projectile.setPos((player.getX() + (-0.5) * player.getLookAngle().x), (player.getEyeY() - 0.1 + (-0.5) * player.getLookAngle().y), (player.getZ() + (-0.5) * player.getLookAngle().z));
|
projectile.setPos(player.getX() - 0.1 * player.getLookAngle().x, player.getEyeY() - 0.1 - 0.1 * player.getLookAngle().y, player.getZ() + -0.1 * player.getLookAngle().z);
|
||||||
projectile.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, 1 * (float) heldItem.getOrCreateTag().getDouble("velocity"),
|
projectile.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, 1 * (float) heldItem.getOrCreateTag().getDouble("velocity"),
|
||||||
(float) player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()));
|
(float) player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()));
|
||||||
player.level().addFreshEntity(projectile);
|
player.level().addFreshEntity(projectile);
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
/*
|
|
||||||
* MCreator note: This file will be REGENERATED on each build.
|
|
||||||
*/
|
|
||||||
package net.mcreator.target.init;
|
package net.mcreator.target.init;
|
||||||
|
|
||||||
import net.mcreator.target.TargetMod;
|
import net.mcreator.target.TargetMod;
|
||||||
|
@ -19,7 +17,7 @@ import net.minecraftforge.registries.RegistryObject;
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public class TargetModAttributes {
|
public class TargetModAttributes {
|
||||||
public static final DeferredRegister<Attribute> ATTRIBUTES = DeferredRegister.create(ForgeRegistries.ATTRIBUTES, TargetMod.MODID);
|
public static final DeferredRegister<Attribute> ATTRIBUTES = DeferredRegister.create(ForgeRegistries.ATTRIBUTES, TargetMod.MODID);
|
||||||
public static final RegistryObject<Attribute> MOTARPITCH = ATTRIBUTES.register("motar_pitch", () -> (new RangedAttribute("attribute." + TargetMod.MODID + ".motar_pitch", 70, 20, 90)).setSyncable(true));
|
public static final RegistryObject<Attribute> MORTAR_PITCH = ATTRIBUTES.register("mortar_pitch", () -> (new RangedAttribute("attribute." + TargetMod.MODID + ".mortar_pitch", 70, 20, 89)).setSyncable(true));
|
||||||
public static final RegistryObject<Attribute> SPREAD = ATTRIBUTES.register("spread", () -> (new RangedAttribute("attribute." + TargetMod.MODID + ".spread", 0, 0, 1024)).setSyncable(true));
|
public static final RegistryObject<Attribute> SPREAD = ATTRIBUTES.register("spread", () -> (new RangedAttribute("attribute." + TargetMod.MODID + ".spread", 0, 0, 1024)).setSyncable(true));
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -31,7 +29,7 @@ public class TargetModAttributes {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void addAttributes(EntityAttributeModificationEvent event) {
|
public static void addAttributes(EntityAttributeModificationEvent event) {
|
||||||
event.add(TargetModEntities.MORTAR.get(), MOTARPITCH.get());
|
event.add(TargetModEntities.MORTAR.get(), MORTAR_PITCH.get());
|
||||||
event.add(EntityType.PLAYER, SPREAD.get());
|
event.add(EntityType.PLAYER, SPREAD.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ public class MortarDeployerItem extends Item {
|
||||||
entityToSpawn.setYRot(player.getYRot());
|
entityToSpawn.setYRot(player.getYRot());
|
||||||
entityToSpawn.setYBodyRot(player.getYRot());
|
entityToSpawn.setYBodyRot(player.getYRot());
|
||||||
entityToSpawn.setYHeadRot(player.getYRot());
|
entityToSpawn.setYHeadRot(player.getYRot());
|
||||||
entityToSpawn.setXRot(-70);
|
|
||||||
entityToSpawn.setDeltaMovement(0, 0, 0);
|
entityToSpawn.setDeltaMovement(0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,9 @@ import com.google.common.collect.Multimap;
|
||||||
import net.mcreator.target.client.renderer.item.RocketItemRenderer;
|
import net.mcreator.target.client.renderer.item.RocketItemRenderer;
|
||||||
import net.mcreator.target.init.TargetModItems;
|
import net.mcreator.target.init.TargetModItems;
|
||||||
import net.mcreator.target.item.AnimatedItem;
|
import net.mcreator.target.item.AnimatedItem;
|
||||||
import net.mcreator.target.procedures.MedexpProcedure;
|
|
||||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||||
|
import net.minecraft.commands.CommandSource;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
@ -121,7 +122,10 @@ public class Rocket extends Item implements GeoItem, AnimatedItem {
|
||||||
level.explode(sourceentity, sourceentity.getX(), sourceentity.getY() + 1, sourceentity.getZ(), 6, Level.ExplosionInteraction.NONE);
|
level.explode(sourceentity, sourceentity.getX(), sourceentity.getY() + 1, sourceentity.getZ(), 6, Level.ExplosionInteraction.NONE);
|
||||||
level.explode(null, sourceentity.getX(), sourceentity.getY() + 1, sourceentity.getZ(), 6, Level.ExplosionInteraction.NONE);
|
level.explode(null, sourceentity.getX(), sourceentity.getY() + 1, sourceentity.getZ(), 6, Level.ExplosionInteraction.NONE);
|
||||||
|
|
||||||
MedexpProcedure.execute(level, sourceentity.getX(), sourceentity.getY(), sourceentity.getZ());
|
if (!sourceentity.level().isClientSide() && sourceentity.getServer() != null) {
|
||||||
|
sourceentity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, sourceentity.position(), sourceentity.getRotationVector(), sourceentity.level() instanceof ServerLevel ? (ServerLevel) sourceentity.level() : null, 4,
|
||||||
|
sourceentity.getName().getString(), sourceentity.getDisplayName(), sourceentity.level().getServer(), sourceentity), "playsound target:target:mediumexp");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sourceentity instanceof Player player) {
|
if (sourceentity instanceof Player player) {
|
||||||
player.getInventory().clearOrCountMatchingItems(p -> TargetModItems.ROCKET.get() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
|
player.getInventory().clearOrCountMatchingItems(p -> TargetModItems.ROCKET.get() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
|
||||||
|
|
|
@ -5,13 +5,16 @@ import net.mcreator.target.tools.TraceTool;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
|
import net.mcreator.target.init.TargetModAttributes;
|
||||||
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@ -66,63 +69,38 @@ public class MortarGUIButtonMessage {
|
||||||
Entity looking = TraceTool.findLookingEntity(player, 6);
|
Entity looking = TraceTool.findLookingEntity(player, 6);
|
||||||
if (looking == null) return;
|
if (looking == null) return;
|
||||||
|
|
||||||
boolean validXRot = true;
|
|
||||||
|
|
||||||
switch (buttonID) {
|
switch (buttonID) {
|
||||||
case 0 -> {
|
case 0 -> {
|
||||||
if (looking.getXRot() <= -88) {
|
if (((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() < 89) {
|
||||||
validXRot = false;
|
((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).setBaseValue((((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() + 1));
|
||||||
} else {
|
|
||||||
looking.setXRot(looking.getXRot() - 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 1 -> {
|
case 1 -> {
|
||||||
if (looking.getXRot() >= -20) {
|
if (((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() > 21) {
|
||||||
validXRot = false;
|
((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).setBaseValue((((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() - 1));
|
||||||
} else {
|
|
||||||
looking.setXRot(looking.getXRot() + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 2 -> {
|
case 2 -> {
|
||||||
if (looking.getXRot() <= -78) {
|
if (((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() < 78) {
|
||||||
validXRot = false;
|
((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).setBaseValue((((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() + 10));
|
||||||
} else {
|
|
||||||
looking.setXRot(looking.getXRot() - 10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 3 -> {
|
case 3 -> {
|
||||||
if (looking.getXRot() >= -30) {
|
if (((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() > 31) {
|
||||||
validXRot = false;
|
((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).setBaseValue((((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() - 10));
|
||||||
} else {
|
|
||||||
looking.setXRot(looking.getXRot() + 10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 4 -> {
|
case 4 -> {
|
||||||
if (looking.getXRot() >= -20.5) {
|
if (((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() > 20.5) {
|
||||||
validXRot = false;
|
((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).setBaseValue((((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() - 0.5));
|
||||||
} else {
|
|
||||||
looking.setXRot(looking.getXRot() + 0.5f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 5 -> {
|
case 5 -> {
|
||||||
if (looking.getXRot() <= -87.5) {
|
if (((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() < 88.5) {
|
||||||
validXRot = false;
|
((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).setBaseValue((((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).getBaseValue() + 0.5));
|
||||||
} else {
|
|
||||||
looking.setXRot(looking.getXRot() - 0.5f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validXRot) return;
|
|
||||||
looking.setYRot(looking.getYRot());
|
|
||||||
looking.setYBodyRot(looking.getYRot());
|
|
||||||
looking.setYHeadRot(looking.getYRot());
|
|
||||||
looking.yRotO = looking.getYRot();
|
|
||||||
looking.xRotO = looking.getXRot();
|
|
||||||
if (looking instanceof LivingEntity living) {
|
|
||||||
living.yBodyRotO = living.getYRot();
|
|
||||||
living.yHeadRotO = living.getYRot();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class GunsTool {
|
||||||
if (tag.getBoolean("beast")) {
|
if (tag.getBoolean("beast")) {
|
||||||
projectile.beast();
|
projectile.beast();
|
||||||
}
|
}
|
||||||
projectile.setPos(player.getX() + -0.5 * player.getLookAngle().x, player.getEyeY() - 0.1 + (-0.5) * player.getLookAngle().y, player.getZ() + (-0.5) * player.getLookAngle().z);
|
projectile.setPos(player.getX() - 0.1 * player.getLookAngle().x, player.getEyeY() - 0.1 - 0.1 * player.getLookAngle().y, player.getZ() + -0.1 * player.getLookAngle().z);
|
||||||
|
|
||||||
if (heldItem.getItem() == TargetModItems.BOCEK.get()) {
|
if (heldItem.getItem() == TargetModItems.BOCEK.get()) {
|
||||||
damage = 0.008333333 * tag.getDouble("damage") * tag.getDouble("speed") * tag.getDouble("damageadd");
|
damage = 0.008333333 * tag.getDouble("damage") * tag.getDouble("speed") * tag.getDouble("damageadd");
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class MortarGUIMenu extends AbstractContainerMenu implements Supplier<Map
|
||||||
}
|
}
|
||||||
|
|
||||||
if (20 <= converted && converted <= 90) {
|
if (20 <= converted && converted <= 90) {
|
||||||
((LivingEntity) looking).getAttribute(TargetModAttributes.MOTARPITCH.get()).setBaseValue(converted);
|
((LivingEntity) looking).getAttribute(TargetModAttributes.MORTAR_PITCH.get()).setBaseValue(converted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue