修复瞄准bug,删除假箭,优化无人机

This commit is contained in:
Atsuihsio 2024-11-22 22:00:19 +08:00
parent 61157d28b2
commit 166c6c233e
18 changed files with 130 additions and 346 deletions

View file

@ -119,6 +119,7 @@ public class ClickHandler {
if (button == ModKeyMappings.HOLD_ZOOM.getKey().getValue()) {
handleWeaponZoomPress();
switchZoom = false;
return;
}

View file

@ -1,86 +0,0 @@
package net.mcreator.superbwarfare.client.model.entity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.mcreator.superbwarfare.ModUtils;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
// Made with Blockbench 4.9.4
// Exported for Minecraft version 1.17 or later with Mojang mappings
// Paste this class into your mod and generate all required imports
public class ModelBocekArrow<T extends Entity> extends EntityModel<T> {
// This layer location should be baked with EntityRendererProvider.Context in
// the entity renderer and passed into this model's constructor
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation(ModUtils.MODID, "modelbocekarrow"), "main");
public final ModelPart jian;
public ModelBocekArrow(ModelPart root) {
this.jian = root.getChild("jian");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
PartDefinition jian = partdefinition.addOrReplaceChild("jian", CubeListBuilder.create().texOffs(0, 0).addBox(-0.068F, -0.068F, -12.7575F, 0.1361F, 0.1361F, 25.515F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(-0.0011F, 5.3718F, -0.0975F, -1.5708F, 0.0F, 0.0F));
PartDefinition bone5 = jian.addOrReplaceChild("bone5", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0F, -12.0507F));
PartDefinition cube_r1 = bone5.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.2381F, -0.5783F, 0.068F, 0.2041F, 0.4763F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.504F, 0.3134F, 2.0813F, 0.0F, 0.0F));
PartDefinition cube_r2 = bone5.addOrReplaceChild("cube_r2", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.068F, -0.7144F, 0.068F, 0.2041F, 1.1567F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.3674F, 0.0F, 0.5105F, 0.0F, 0.0F));
PartDefinition bone6 = jian.addOrReplaceChild("bone6", CubeListBuilder.create(), PartPose.offsetAndRotation(0.0F, 0.0F, -12.0507F, 0.0F, 0.0F, 1.5708F));
PartDefinition cube_r3 = bone6.addOrReplaceChild("cube_r3", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.2381F, -0.5783F, 0.068F, 0.2041F, 0.4763F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.504F, 0.3134F, 2.0813F, 0.0F, 0.0F));
PartDefinition cube_r4 = bone6.addOrReplaceChild("cube_r4", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.068F, -0.7144F, 0.068F, 0.2041F, 1.1567F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.3674F, 0.0F, 0.5105F, 0.0F, 0.0F));
PartDefinition bone7 = jian.addOrReplaceChild("bone7", CubeListBuilder.create(), PartPose.offsetAndRotation(0.0F, 0.0F, -12.0507F, 0.0F, 0.0F, -3.1416F));
PartDefinition cube_r5 = bone7.addOrReplaceChild("cube_r5", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.2381F, -0.5783F, 0.068F, 0.2041F, 0.4763F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.504F, 0.3134F, 2.0813F, 0.0F, 0.0F));
PartDefinition cube_r6 = bone7.addOrReplaceChild("cube_r6", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.068F, -0.7144F, 0.068F, 0.2041F, 1.1567F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.3674F, 0.0F, 0.5105F, 0.0F, 0.0F));
PartDefinition bone8 = jian.addOrReplaceChild("bone8", CubeListBuilder.create(), PartPose.offsetAndRotation(0.0F, 0.0F, -12.0507F, 0.0F, 0.0F, -1.5708F));
PartDefinition cube_r7 = bone8.addOrReplaceChild("cube_r7", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.2381F, -0.5783F, 0.068F, 0.2041F, 0.4763F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.504F, 0.3134F, 2.0813F, 0.0F, 0.0F));
PartDefinition cube_r8 = bone8.addOrReplaceChild("cube_r8", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.068F, -0.7144F, 0.068F, 0.2041F, 1.1567F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.3674F, 0.0F, 0.5105F, 0.0F, 0.0F));
PartDefinition bone10 = jian.addOrReplaceChild("bone10", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.5443F, 3.1979F, 0.068F, 0.4763F, 1.3948F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 7.6545F));
PartDefinition cube_r9 = bone10.addOrReplaceChild("cube_r9", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.5443F, 0.034F, 0.068F, 0.1361F, 0.8845F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 0.4145F, 2.7282F, 0.5803F, 0.0F, 0.0F));
PartDefinition cube_r10 = bone10.addOrReplaceChild("cube_r10", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.068F, -0.4252F, 0.068F, 0.1361F, 0.6804F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.2337F, 3.0964F, 0.5803F, 0.0F, 0.0F));
PartDefinition cube_r11 = bone10.addOrReplaceChild("cube_r11", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, 0.2381F, -0.2211F, 0.068F, 0.1361F, 0.4763F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.376F, 3.0032F, 0.5803F, 0.0F, 0.0F));
PartDefinition bone3 = jian.addOrReplaceChild("bone3", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.5443F, 3.1979F, 0.068F, 0.4763F, 1.3948F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 0.0F, 7.6545F, 0.0F, 0.0F, 2.138F));
PartDefinition cube_r12 = bone3.addOrReplaceChild("cube_r12", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, 1.1531F, 2.623F, 0.068F, 0.1361F, 0.8845F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 0.4145F, -0.3677F, 0.5803F, 0.0F, 0.0F));
PartDefinition cube_r13 = bone3.addOrReplaceChild("cube_r13", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, 1.6294F, 2.1637F, 0.068F, 0.1361F, 0.6804F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.2337F, 0.0006F, 0.5803F, 0.0F, 0.0F));
PartDefinition cube_r14 = bone3.addOrReplaceChild("cube_r14", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, 1.9356F, 2.3679F, 0.068F, 0.1361F, 0.4763F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.376F, -0.0927F, 0.5803F, 0.0F, 0.0F));
PartDefinition bone4 = jian.addOrReplaceChild("bone4", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, -0.5443F, 3.1979F, 0.068F, 0.4763F, 1.3948F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 0.0F, 7.6545F, 0.0F, 0.0F, -2.0944F));
PartDefinition cube_r15 = bone4.addOrReplaceChild("cube_r15", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, 1.1531F, 2.623F, 0.068F, 0.1361F, 0.8845F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 0.4145F, -0.3677F, 0.5803F, 0.0F, 0.0F));
PartDefinition cube_r16 = bone4.addOrReplaceChild("cube_r16", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, 1.6294F, 2.1637F, 0.068F, 0.1361F, 0.6804F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.2337F, 0.0006F, 0.5803F, 0.0F, 0.0F));
PartDefinition cube_r17 = bone4.addOrReplaceChild("cube_r17", CubeListBuilder.create().texOffs(0, 0).addBox(-0.034F, 1.9356F, 2.3679F, 0.068F, 0.1361F, 0.4763F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, -0.376F, -0.0927F, 0.5803F, 0.0F, 0.0F));
return LayerDefinition.create(meshdefinition, 64, 64);
}
@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
}
@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
jian.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}
}

View file

@ -1,41 +0,0 @@
package net.mcreator.superbwarfare.client.renderer.entity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.client.model.entity.ModelBocekArrow;
import net.mcreator.superbwarfare.entity.projectile.BocekArrowEntity;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
public class BocekArrowRenderer extends EntityRenderer<BocekArrowEntity> {
private static final ResourceLocation TEXTURE = new ResourceLocation(ModUtils.MODID, "textures/entity/bocek_arrow.png");
private final ModelBocekArrow<BocekArrowEntity> model;
public BocekArrowRenderer(EntityRendererProvider.Context context) {
super(context);
model = new ModelBocekArrow<>(context.bakeLayer(ModelBocekArrow.LAYER_LOCATION));
}
@Override
public void render(BocekArrowEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
VertexConsumer vb = bufferIn.getBuffer(RenderType.entityCutout(this.getTextureLocation(entityIn)));
poseStack.pushPose();
poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()) - 90));
poseStack.mulPose(Axis.ZP.rotationDegrees(90 + Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
model.renderToBuffer(poseStack, vb, packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 0.0625f);
poseStack.popPose();
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
}
@Override
public ResourceLocation getTextureLocation(BocekArrowEntity entity) {
return TEXTURE;
}
}

View file

@ -53,7 +53,7 @@ public class DroneUIOverlay {
boolean lookAtEntity = false;
double distance = player.distanceTo(entity);
double block_range = entity.position().distanceTo((Vec3.atLowerCornerOf(entity.level().clip(
new ClipContext(entity.getEyePosition(), entity.getEyePosition().add(entity.getLookAngle().scale(520)),
new ClipContext(entity.getEyePosition(), entity.getEyePosition().add(entity.getViewVector(event.getPartialTick()).scale(520)),
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos())));
double entity_range = 0;

View file

@ -56,10 +56,6 @@ import net.minecraftforge.registries.ForgeRegistries;
import software.bernie.geckolib.animatable.GeoEntity;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.core.animation.AnimationController;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.core.animation.RawAnimation;
import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.GeckoLibUtil;
import javax.annotation.Nonnull;
@ -68,7 +64,6 @@ import java.util.Objects;
import java.util.UUID;
public class DroneEntity extends LivingEntity implements GeoEntity {
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.STRING);
public static final EntityDataAccessor<Boolean> LINKED = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<String> CONTROLLER = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.STRING);
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.INT);
@ -83,7 +78,6 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
private boolean move = false;
public String animationprocedure = "empty";
public DroneEntity(PlayMessages.SpawnEntity packet, Level world) {
this(ModEntities.DRONE.get(), world);
@ -100,7 +94,6 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
@Override
protected void defineSynchedData() {
super.defineSynchedData();
this.entityData.define(ANIMATION, "undefined");
this.entityData.define(CONTROLLER, "undefined");
this.entityData.define(LINKED, false);
this.entityData.define(AMMO, 0);
@ -190,14 +183,24 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
@Override
public void baseTick() {
super.baseTick();
if (!this.onGround()) {
if (this.getPersistentData().getBoolean("left")) {
this.entityData.set(MOVE_X, -1.5f);
this.entityData.set(ROT_X, Mth.lerp(0.25f, this.entityData.get(ROT_X), 0.5f));
}
if (this.getPersistentData().getBoolean("right")) {
this.entityData.set(MOVE_X, 1.5f);
this.entityData.set(ROT_X, Mth.lerp(0.25f, this.entityData.get(ROT_X), -0.5f));
}
if (this.getPersistentData().getBoolean("left")) {
this.entityData.set(MOVE_X, -1.5f);
this.entityData.set(ROT_X, Mth.lerp(0.1f, this.entityData.get(ROT_X), 0.5f));
}
if (this.getPersistentData().getBoolean("right")) {
this.entityData.set(MOVE_X, 1.5f);
this.entityData.set(ROT_X, Mth.lerp(0.1f, this.entityData.get(ROT_X), -0.5f));
if (this.getPersistentData().getBoolean("forward")) {
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) - 0.11f);
this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), -0.5f));
}
if (this.getPersistentData().getBoolean("backward")) {
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) + 0.11f);
this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), 0.5f));
}
}
this.entityData.set(ROT_X, Mth.lerp(0.05f, this.entityData.get(ROT_X), 0));
@ -206,15 +209,6 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
this.entityData.set(MOVE_X, Mth.lerp(0.1f, this.entityData.get(MOVE_X), 0));
}
if (this.getPersistentData().getBoolean("forward")) {
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) - 0.11f);
this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), -0.5f));
}
if (this.getPersistentData().getBoolean("backward")) {
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) + 0.11f);
this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), 0.5f));
}
this.entityData.set(ROT_Z, Mth.lerp(0.05f, this.entityData.get(ROT_Z), 0));
this.entityData.set(MOVE_Z, Mth.lerp(0.1f, this.entityData.get(MOVE_Z), 0));
@ -230,7 +224,7 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
this.setDeltaMovement(new Vec3(
this.getDeltaMovement().x + -this.entityData.get(MOVE_Z) * 0.1f * this.getLookAngle().x,
this.getDeltaMovement().y + -this.entityData.get(MOVE_Y) * 0.05f,
this.getDeltaMovement().y + (this.onGround() ? 0.059 : 0) + -this.entityData.get(MOVE_Y) * 0.05f,
this.getDeltaMovement().z + -this.entityData.get(MOVE_Z) * 0.1f * this.getLookAngle().z
));
@ -257,6 +251,8 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
if (stack.getOrCreateTag().getBoolean("Using") && controller instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, ModSounds.DRONE_SOUND.get(), 100, 1);
}
controller.setYRot(controller.getYRot() - 5 * this.entityData.get(ROT_X) * Mth.abs(this.entityData.get(MOVE_Z)));
}
}
@ -280,8 +276,8 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
Level level = player.level();
if (!level.isClientSide()) {
RgoGrenadeEntity rgoGrenadeEntity = new RgoGrenadeEntity(player, level, 160);
rgoGrenadeEntity.setPos(this.getX(), this.getY(), this.getZ());
rgoGrenadeEntity.shoot(0, -1, 0, 0, 0.5f);
rgoGrenadeEntity.setPos(this.getX(), this.getEyeY() - 0.09, this.getZ());
rgoGrenadeEntity.droneShoot(this);
level.addFreshEntity(rgoGrenadeEntity);
}
}
@ -384,22 +380,21 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
this.setRot(this.getYRot(), this.getXRot());
this.yBodyRot = controller.getYRot();
this.yHeadRot = controller.getYRot();
this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED));
float strafe = -this.entityData.get(MOVE_X);
super.travel(new Vec3(2 * strafe, -this.entityData.get(MOVE_Y), -this.entityData.get(MOVE_Z)));
Vec3 vec3 = this.getDeltaMovement();
if (this.onGround()) {
this.setDeltaMovement(vec3.multiply(0.7, 0.98, 0.7));
} else {
this.setDeltaMovement(vec3.multiply(1.04, 0.98, 1.04));
}
if (!this.move) {
this.setDeltaMovement(vec3.multiply(0.9, 0.8, 0.9));
}
return;
}
}
super.travel(dir);
this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED));
float strafe = -this.entityData.get(MOVE_X);
super.travel(new Vec3(2 * strafe, -this.entityData.get(MOVE_Y), -this.entityData.get(MOVE_Z)));
Vec3 vec3 = this.getDeltaMovement();
if (this.onGround()) {
this.setDeltaMovement(vec3.multiply(0.7, 0.98, 0.7));
} else {
this.setDeltaMovement(vec3.multiply(1.04, 0.98, 1.04));
}
if (!this.move) {
this.setDeltaMovement(vec3.multiply(0.9, 0.8, 0.9));
}
}
@Override
@ -457,7 +452,7 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
@Override
public boolean isNoGravity() {
return true;
return !this.onGround();
}
@Override
@ -476,41 +471,8 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
return builder;
}
private PlayState movementPredicate(AnimationState<DroneEntity> event) {
if (this.animationprocedure.equals("empty")) {
if (!this.onGround()) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.drone.fly"));
}
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.drone.idle"));
}
return PlayState.STOP;
}
private PlayState procedurePredicate(AnimationState<DroneEntity> event) {
if (!animationprocedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationprocedure));
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {
this.animationprocedure = "empty";
event.getController().forceAnimationReset();
}
} else if (animationprocedure.equals("empty")) {
return PlayState.STOP;
}
return PlayState.CONTINUE;
}
public String getSyncedAnimation() {
return this.entityData.get(ANIMATION);
}
public void setAnimation(String animation) {
this.entityData.set(ANIMATION, animation);
}
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
data.add(new AnimationController<>(this, "movement", 1, this::movementPredicate));
data.add(new AnimationController<>(this, "procedure", 1, this::procedurePredicate));
}
@Override

View file

@ -1,14 +1,23 @@
package net.mcreator.superbwarfare.entity.model;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.entity.DroneEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.model.GeoModel;
import net.minecraft.resources.ResourceLocation;
import net.mcreator.superbwarfare.entity.DroneEntity;
import static net.mcreator.superbwarfare.entity.DroneEntity.*;
import static net.mcreator.superbwarfare.event.ClientEventHandler.droneBodyAngle;
public class DroneModel extends GeoModel<DroneEntity> {
public static float rotX = 0;
public static float rotZ = 0;
public static float rotation = 0;
@Override
public ResourceLocation getAnimationResource(DroneEntity entity) {
@ -44,8 +53,29 @@ public class DroneModel extends GeoModel<DroneEntity> {
ammo1.setHidden(animatable.getEntityData().get(AMMO) <= 0);
shell.setHidden(!animatable.getEntityData().get(KAMIKAZE));
float times = (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8);
rotX = Mth.lerp(0.5f * times, rotX, animatable.getEntityData().get(ROT_X));
rotZ = Mth.lerp(0.5f * times, rotZ, animatable.getEntityData().get(ROT_Z));
body.setRotZ(rotX);
body.setRotX(rotZ);
droneBodyAngle(rotX, rotZ);
//螺旋桨控制
CoreGeoBone wingFL = getAnimationProcessor().getBone("wingFL");
CoreGeoBone wingFR = getAnimationProcessor().getBone("wingFR");
CoreGeoBone wingBL = getAnimationProcessor().getBone("wingBL");
CoreGeoBone wingBR = getAnimationProcessor().getBone("wingBR");
rotation = (float) Mth.lerp(times, rotation, animatable.onGround() ? 0 : 0.08 - 0.1 * animatable.getEntityData().get(MOVE_Y));
wingFL.setRotY(wingFL.getRotY() - rotation);
wingFR.setRotY(wingFL.getRotY() - rotation);
wingBL.setRotY(wingFL.getRotY() - rotation);
wingBR.setRotY(wingFL.getRotY() - rotation);
body.setRotZ(animatable.getEntityData().get(ROT_X));
body.setRotX(animatable.getEntityData().get(ROT_Z));
}
}

View file

@ -1,83 +0,0 @@
package net.mcreator.superbwarfare.entity.projectile;
import net.mcreator.superbwarfare.init.ModEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.ItemSupplier;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PlayMessages;
@OnlyIn(value = Dist.CLIENT, _interface = ItemSupplier.class)
public class BocekArrowEntity extends AbstractArrow implements ItemSupplier {
public static final ItemStack PROJECTILE_ITEM = new ItemStack(Items.ARROW);
public BocekArrowEntity(EntityType<? extends BocekArrowEntity> type, Level world) {
super(type, world);
}
public BocekArrowEntity(LivingEntity entity, Level level) {
super(ModEntities.BOCEK_ARROW.get(), entity, level);
}
public BocekArrowEntity(PlayMessages.SpawnEntity packet, Level world) {
super(ModEntities.BOCEK_ARROW.get(), world);
}
@Override
public Packet<ClientGamePacketListener> getAddEntityPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
@Override
@OnlyIn(Dist.CLIENT)
public ItemStack getItem() {
return PROJECTILE_ITEM;
}
@Override
protected ItemStack getPickupItem() {
return PROJECTILE_ITEM;
}
@Override
protected void doPostHurtEffects(LivingEntity entity) {
super.doPostHurtEffects(entity);
entity.setArrowCount(entity.getArrowCount() - 1);
}
@Override
public void onHitBlock(BlockHitResult blockHitResult) {
super.onHitBlock(blockHitResult);
BlockPos resultPos = blockHitResult.getBlockPos();
BlockState state = this.level().getBlockState(resultPos);
if (state.getBlock() instanceof BellBlock bell) {
bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection());
}
}
@Override
protected void onHitEntity(EntityHitResult result) {
this.discard();
}
@Override
public void tick() {
super.tick();
if (this.tickCount > 100) {
this.discard();
}
}
}

View file

@ -582,8 +582,11 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
return this.damage;
}
public void shoot(double p_37266_, double p_37267_, double p_37268_, float p_37269_, float p_37270_) {
Vec3 vec3 = (new Vec3(p_37266_, p_37267_, p_37268_)).normalize().add(this.random.triangle(0.0D, 0.0172275D * (double) p_37270_), this.random.triangle(0.0D, 0.0172275D * (double) p_37270_), this.random.triangle(0.0D, 0.0172275D * (double) p_37270_)).scale(p_37269_);
public void shoot(Player player, double vecX, double vecY, double vecZ, float velocity, float spread) {
Vec3 vec3 = (new Vec3(vecX, vecY, vecZ)).normalize().
add(this.random.triangle(0.0D, 0.0172275D * (double) spread), this.random.triangle(0.0D, 0.0172275D * (double) spread), this.random.triangle(0.0D, 0.0172275D * (double) spread)).
add(player.getDeltaMovement().x, player.getDeltaMovement().y() + 0.078, player.getDeltaMovement().z).
scale(velocity);
this.setDeltaMovement(vec3);
double d0 = vec3.horizontalDistance();
this.setYRot((float) (Mth.atan2(vec3.x, vec3.z) * (double) (180F / (float) Math.PI)));

View file

@ -18,6 +18,8 @@ import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
@ -27,6 +29,7 @@ import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.network.PlayMessages;
@ -80,7 +83,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
if (state.getBlock() instanceof BellBlock bell) {
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
}
if (this.tickCount > 2) {
if (this.tickCount > 4) {
ProjectileTool.causeCustomExplode(this, 135f, 6.75f, 1.5f);
}
@ -93,7 +96,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
}
}
if (this.tickCount > 2) {
if (this.tickCount > 4) {
ProjectileTool.causeCustomExplode(this, 150f, 4.75f, 2f);
}
break;
@ -114,9 +117,11 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
}
}
if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.SMOKE, this.xo, this.yo, this.zo,
1, 0, 0, 0, 0.01, true);
if (this.tickCount > 4) {
if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.SMOKE, this.xo, this.yo, this.zo,
1, 0, 0, 0, 0.01, true);
}
}
}
@ -146,4 +151,14 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.cache;
}
public void droneShoot(Entity drone) {
Vec3 vec3 = (new Vec3(0.5 * drone.getDeltaMovement().x, drone.getDeltaMovement().y, 0.5 * drone.getDeltaMovement().z));
this.setDeltaMovement(vec3);
double d0 = vec3.horizontalDistance();
this.setYRot((float) (Mth.atan2(vec3.x, vec3.z) * (double) (180F / (float) Math.PI)));
this.setXRot((float) (Mth.atan2(vec3.y, d0) * (double) (180F / (float) Math.PI)));
this.yRotO = this.getYRot();
this.xRotO = this.getXRot();
}
}

View file

@ -1,6 +1,7 @@
package net.mcreator.superbwarfare.event;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.client.ClickHandler;
import net.mcreator.superbwarfare.config.client.DisplayConfig;
import net.mcreator.superbwarfare.entity.DroneEntity;
import net.mcreator.superbwarfare.entity.ICannonEntity;
@ -49,8 +50,6 @@ import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import static net.mcreator.superbwarfare.entity.DroneEntity.ROT_X;
import static net.mcreator.superbwarfare.entity.DroneEntity.ROT_Z;
import static net.mcreator.superbwarfare.event.PlayerEventHandler.isProne;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
@ -85,8 +84,6 @@ public class ClientEventHandler {
public static double recoilHorizon = 0;
public static double recoilY = 0;
public static double droneCameraRotX = 0;
public static double droneCameraRotY = 0;
public static double droneRotX = 0;
public static double droneRotZ = 0;
public static double breathTime = 0;
@ -144,9 +141,6 @@ public class ClientEventHandler {
turnRot[0] = Mth.clamp(0.05 * xRot, -5, 5) * (1 - 0.75 * zoomTime);
turnRot[1] = Mth.clamp(0.05 * yRot, -10, 10) * (1 - 0.75 * zoomTime) + 1.5f * (Mth.DEG_TO_RAD * recoilHorizon) * (0.5 + 0.4 * fireSpread);
turnRot[2] = Mth.clamp(0.1 * yRot, -10, 10) * (1 - zoomTime);
droneCameraRotX = Mth.clamp(0.25f * xRot, -10, 10);
droneCameraRotY = Mth.clamp(0.25f * yRot, -20, 10);
}
private static boolean notInGame() {
@ -202,6 +196,10 @@ public class ClientEventHandler {
if (miniGunRot > 0) {
miniGunRot -= 1;
}
if (notInGame() && !ClickHandler.switchZoom) {
zoom = false;
}
}
@SubscribeEvent
@ -562,21 +560,25 @@ public class ClientEventHandler {
}
}
public static void droneBodyAngle(float RotX, float RotZ) {
LocalPlayer player = Minecraft.getInstance().player;
if (player != null) {
droneRotX = RotX;
droneRotZ = RotZ;
}
}
private static void handleDroneCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) {
ItemStack stack = entity.getMainHandItem();
float times = (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 1.6);
double pitch = event.getPitch();
double roll = event.getRoll();
DroneEntity drone = EntityFindUtil.findDrone(entity.level(), stack.getOrCreateTag().getString("LinkedDrone"));
if (drone != null) {
droneRotZ = Mth.lerp(0.1 * times, droneRotZ, drone.getEntityData().get(ROT_Z));
droneRotX = Mth.lerp(0.1 * times, droneRotX, drone.getEntityData().get(ROT_X));
event.setPitch((float) (pitch + droneCameraRotX - 0.15f * Mth.RAD_TO_DEG * droneRotZ));
event.setRoll((float) (roll + droneCameraRotY - 0.5f * Mth.RAD_TO_DEG * droneRotX));
event.setPitch((float) (pitch - Mth.RAD_TO_DEG * droneRotZ));
event.setRoll((float) (roll - Mth.RAD_TO_DEG * droneRotX));
}
if (drone != null && stack.getOrCreateTag().getBoolean("Using")) {
@ -965,7 +967,7 @@ public class ClientEventHandler {
angle = Math.atan(Mth.abs((float) cameraLocation) / (lookDistance + 2.9)) * Mth.RAD_TO_DEG;
}
if (player.getMainHandItem().is(ModTags.Items.GUN) || (player.getVehicle() != null && (player.getVehicle() instanceof ICannonEntity))) {
if (player.getMainHandItem().is(ModTags.Items.GUN)) {
event.setPitch((float) (pitch + cameraRot[0] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.2 : 0) * turnRot[0] + 3 * velocityY));
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1] - (cameraLocation > 0 ? 1 : -1) * angle * zoomPos));

View file

@ -236,7 +236,7 @@ public class GunEventHandler {
}
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 + 0.001f, player.getLookAngle().z, heldItem.is(ModTags.Items.SHOTGUN) && perk == ModPerks.INCENDIARY_BULLET.get() ? 4.5f : velocity,
projectile.shoot(player, player.getLookAngle().x, player.getLookAngle().y + 0.001f, player.getLookAngle().z, heldItem.is(ModTags.Items.SHOTGUN) && perk == ModPerks.INCENDIARY_BULLET.get() ? 4.5f : velocity,
(float) spared);
player.level().addFreshEntity(projectile);
}

View file

@ -47,8 +47,6 @@ public class ModEntities {
EntityType.Builder.<RpgRocketEntity>of(RpgRocketEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(1).setCustomClientFactory(RpgRocketEntity::new).sized(0.5f, 0.5f));
public static final RegistryObject<EntityType<MortarShellEntity>> MORTAR_SHELL = register("projectile_mortar_shell",
EntityType.Builder.<MortarShellEntity>of(MortarShellEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(1).setCustomClientFactory(MortarShellEntity::new).sized(0.5f, 0.5f));
public static final RegistryObject<EntityType<BocekArrowEntity>> BOCEK_ARROW = register("projectile_bocekarrow",
EntityType.Builder.<BocekArrowEntity>of(BocekArrowEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setCustomClientFactory(BocekArrowEntity::new).setTrackingRange(512).setUpdateInterval(1).sized(0.5f, 0.5f));
public static final RegistryObject<EntityType<ProjectileEntity>> PROJECTILE = register("projectile",
EntityType.Builder.<ProjectileEntity>of(ProjectileEntity::new, MobCategory.MISC).setCustomClientFactory(ProjectileEntity::new).setTrackingRange(512).sized(0.5f, 0.5f));
public static final RegistryObject<EntityType<CannonShellEntity>> CANNON_SHELL = register("projectile_cannon_shell",

View file

@ -20,7 +20,6 @@ public class ModEntityRenderers {
event.registerEntityRenderer(ModEntities.RPG_ROCKET.get(), RpgRocketRenderer::new);
event.registerEntityRenderer(ModEntities.MORTAR_SHELL.get(), MortarShellRenderer::new);
event.registerEntityRenderer(ModEntities.CANNON_SHELL.get(), CannonShellRenderer::new);
event.registerEntityRenderer(ModEntities.BOCEK_ARROW.get(), BocekArrowRenderer::new);
event.registerEntityRenderer(ModEntities.PROJECTILE.get(), ProjectileEntityRenderer::new);
event.registerEntityRenderer(ModEntities.MK_42.get(), Mk42Renderer::new);
event.registerEntityRenderer(ModEntities.DRONE.get(), DroneRenderer::new);

View file

@ -1,6 +1,9 @@
package net.mcreator.superbwarfare.init;
import net.mcreator.superbwarfare.client.model.entity.*;
import net.mcreator.superbwarfare.client.model.entity.ModelGrenade;
import net.mcreator.superbwarfare.client.model.entity.ModelHandGrenade;
import net.mcreator.superbwarfare.client.model.entity.ModelMortarShell;
import net.mcreator.superbwarfare.client.model.entity.ModelTaserRod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -13,7 +16,6 @@ public class ModModels {
event.registerLayerDefinition(ModelMortarShell.LAYER_LOCATION, ModelMortarShell::createBodyLayer);
event.registerLayerDefinition(ModelTaserRod.LAYER_LOCATION, ModelTaserRod::createBodyLayer);
event.registerLayerDefinition(ModelGrenade.LAYER_LOCATION, ModelGrenade::createBodyLayer);
event.registerLayerDefinition(ModelBocekArrow.LAYER_LOCATION, ModelBocekArrow::createBodyLayer);
event.registerLayerDefinition(ModelHandGrenade.LAYER_LOCATION, ModelHandGrenade::createBodyLayer);
}
}

View file

@ -49,11 +49,9 @@ public abstract class CameraMixin {
yRot += 360;
}
yRot = yRot + 90 % 360;
var CameraPos = new Vector3d(0.20375, 0.103125, 0);
var CameraPos = new Vector3d(0.22, 0.075, 0);
CameraPos.rotateZ(-drone.getXRot() * Mth.DEG_TO_RAD);
CameraPos.rotateY(-yRot * Mth.DEG_TO_RAD);
setRotation(drone.getViewYRot(partialTicks), drone.getViewXRot(partialTicks));
setPosition(Mth.lerp(partialTicks, drone.xo + CameraPos.x, drone.getX() + CameraPos.x), Mth.lerp(partialTicks, drone.yo + CameraPos.y, drone.getY() + CameraPos.y), Mth.lerp(partialTicks, drone.zo + CameraPos.z, drone.getZ() + CameraPos.z));
info.cancel();

View file

@ -2,6 +2,7 @@ package net.mcreator.superbwarfare.mixins;
import net.mcreator.superbwarfare.entity.ICannonEntity;
import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModItems;
import net.mcreator.superbwarfare.init.ModMobEffects;
import net.mcreator.superbwarfare.init.ModTags;
import net.minecraft.client.CameraType;
@ -43,6 +44,10 @@ public class MouseHandlerMixin {
}
}
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
return 0.32;
}
if (!stack.is(ModTags.Items.GUN)) {
return original;
}

View file

@ -26,7 +26,6 @@ import net.minecraft.util.Mth;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
@ -190,7 +189,6 @@ public class FireMessage {
stack.getOrCreateTag().putDouble("speed", stack.getOrCreateTag().getDouble("power"));
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom) {
spawnBullet(player);
spawnFakeArrow(player);
SoundTool.playLocalSound(player, ModSounds.BOCEK_ZOOM_FIRE_1P.get(), 10, 1);
player.playSound(ModSounds.BOCEK_ZOOM_FIRE_3P.get(), 2, 1);
@ -298,32 +296,13 @@ public class FireMessage {
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, (!zoom && perk == ModPerks.INCENDIARY_BULLET.get() ? 0.2f : 1) * velocity, spread);
projectile.shoot(player, player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, (!zoom && perk == ModPerks.INCENDIARY_BULLET.get() ? 0.2f : 1) * velocity, spread);
projectile.damage((float) damage);
player.level().addFreshEntity(projectile);
}
private static void spawnFakeArrow(Player player) {
ItemStack heldItem = player.getMainHandItem();
CompoundTag tag = heldItem.getOrCreateTag();
float velocity = 2 * (float) tag.getDouble("speed") * (float) perkSpeed(heldItem);
BocekArrowEntity arrow = new BocekArrowEntity(player, player.level());
arrow.setBaseDamage(0);
arrow.setKnockback(0);
arrow.setSilent(true);
arrow.setPierceLevel((byte) 2);
arrow.pickup = AbstractArrow.Pickup.DISALLOWED;
arrow.setPos(player.getX(), player.getEyeY() - 0.1, player.getZ());
arrow.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, velocity, 0);
player.level().addFreshEntity(arrow);
}
private static void handleTaserFire(Player player) {
if (player.isSpectator()) return;

View file

@ -382,7 +382,7 @@
]
},
{
"name": "wing",
"name": "wingFL",
"parent": "0",
"pivot": [4.87422, 3, -2.96641],
"cubes": [
@ -445,7 +445,7 @@
]
},
{
"name": "wing2",
"name": "wingFR",
"parent": "0",
"pivot": [-4.87422, 3, -2.96641],
"cubes": [
@ -508,7 +508,7 @@
]
},
{
"name": "wing3",
"name": "wingBR",
"parent": "0",
"pivot": [-4.10859, 3, 3.93984],
"cubes": [
@ -571,7 +571,7 @@
]
},
{
"name": "wing4",
"name": "wingBL",
"parent": "0",
"pivot": [4.10859, 3, 3.93984],
"cubes": [