完善火炮
This commit is contained in:
parent
3e7b6123ce
commit
1ed281731f
24 changed files with 439 additions and 73 deletions
|
@ -50,11 +50,10 @@ public class ClickHandler {
|
|||
if (Minecraft.getInstance().player.hasEffect(TargetModMobEffects.SHOCK.get())) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
if (player.getMainHandItem().is(TargetModTags.Items.GUN)) {
|
||||
|
||||
TargetMod.PACKET_HANDLER.sendToServer(new ZoomMessage(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onButtonPressed(InputEvent.MouseButton.Pre event) {
|
||||
|
@ -86,7 +85,7 @@ public class ClickHandler {
|
|||
if (Minecraft.getInstance().player.hasEffect(TargetModMobEffects.SHOCK.get())) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
if (player.getMainHandItem().is(TargetModTags.Items.GUN)) {
|
||||
if (player.getMainHandItem().is(TargetModTags.Items.GUN) || (player.isPassenger() && player.getVehicle() instanceof Mk42Entity)) {
|
||||
event.setCanceled(true);
|
||||
TargetMod.PACKET_HANDLER.sendToServer(new ZoomMessage(0));
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.mcreator.target.client.renderer.entity;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.mcreator.target.entity.MortarEntity;
|
||||
import net.mcreator.target.entity.layer.MortarLayer;
|
||||
import net.mcreator.target.entity.model.MortarModel;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -15,6 +16,7 @@ public class MortarRenderer extends GeoEntityRenderer<MortarEntity> {
|
|||
public MortarRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new MortarModel());
|
||||
this.shadowRadius = 0f;
|
||||
this.addRenderLayer(new MortarLayer(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.mcreator.target.client.screens;
|
|||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.mcreator.target.entity.Mk42Entity;
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.client.CameraType;
|
||||
|
@ -28,7 +29,7 @@ public class M79UIOverlay {
|
|||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
if (shouldRenderCrossHair(player)) {
|
||||
if (shouldRenderCrossHair(player) || shouldRenderCrossHair2(player)) {
|
||||
event.getGuiGraphics().blit(new ResourceLocation("target:textures/screens/rex.png"), w / 2 - 16, h / 2 - 16, 0, 0, 32, 32, 32, 32);
|
||||
}
|
||||
RenderSystem.depthMask(true);
|
||||
|
@ -42,7 +43,13 @@ public class M79UIOverlay {
|
|||
if (player == null) return false;
|
||||
return !player.isSpectator()
|
||||
&& player.getMainHandItem().getItem() == TargetModItems.M_79.get()
|
||||
&& Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON
|
||||
&& (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || (player.isPassenger() && player.getVehicle() instanceof Mk42Entity))
|
||||
&& !player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.zooming).orElse(false);
|
||||
}
|
||||
|
||||
private static boolean shouldRenderCrossHair2(Player player) {
|
||||
if (player == null) return false;
|
||||
return !player.isSpectator()
|
||||
&& Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && (player.isPassenger() && player.getVehicle() instanceof Mk42Entity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,15 @@ package net.mcreator.target.client.screens;
|
|||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.mcreator.target.entity.Mk42Entity;
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.item.gun.GunItem;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.mcreator.target.tools.RenderTool;
|
||||
import net.mcreator.target.tools.TraceTool;
|
||||
import net.minecraft.client.CameraType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderGuiEvent;
|
||||
|
@ -17,8 +19,13 @@ import net.minecraftforge.eventbus.api.EventPriority;
|
|||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber({Dist.CLIENT})
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||
public class Mk42UIOverlay {
|
||||
public static final int TEXTURE_WIDTH = 771;
|
||||
public static final int TEXTURE_HEIGHT = 1006;
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public static void eventHandler(RenderGuiEvent.Pre event) {
|
||||
int w = event.getWindow().getGuiScaledWidth();
|
||||
|
@ -31,7 +38,10 @@ public class Mk42UIOverlay {
|
|||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
if (shouldRenderCrossHair(player)) {
|
||||
event.getGuiGraphics().blit(new ResourceLocation("target:textures/screens/mk_42_rex.png"), w / 2 + -407, h / 2 + -146, 0, 0, 813, 293, 813, 293);
|
||||
RenderTool.preciseBlit(event.getGuiGraphics(),
|
||||
new ResourceLocation("target:textures/screens/mk_42_rex.png"),
|
||||
(float) w / 2 - (float) TEXTURE_WIDTH / 10f, (float) h / 2 - (float) TEXTURE_HEIGHT / 10f,
|
||||
0, 0, TEXTURE_WIDTH / 5f, TEXTURE_HEIGHT / 5f, TEXTURE_WIDTH / 5f, TEXTURE_HEIGHT / 5f);
|
||||
}
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.defaultBlendFunc();
|
||||
|
|
|
@ -6,8 +6,6 @@ import net.mcreator.target.network.TargetModVariables;
|
|||
import net.mcreator.target.tools.CustomExplosion;
|
||||
import net.mcreator.target.tools.ParticleTool;
|
||||
import net.mcreator.target.tools.SoundTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
|
@ -34,6 +32,8 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.network.PlayMessages;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
@ -234,8 +234,13 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity {
|
|||
|
||||
if (this.getPersistentData().getInt("fire_cooldown") > 28) {
|
||||
gunner.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.recoilHorizon = 2 * Math.random() - 1;
|
||||
// capability.cannonFiring = 1;
|
||||
|
||||
if (Math.random() < 0.5) {
|
||||
capability.recoilHorizon = -1;
|
||||
} else {
|
||||
capability.recoilHorizon = 1;
|
||||
}
|
||||
|
||||
capability.cannonRecoil = 10;
|
||||
capability.syncPlayerVariables(gunner);
|
||||
});
|
||||
|
@ -402,7 +407,11 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity {
|
|||
Entity gunner = this.getFirstPassenger();
|
||||
var capability = gunner.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null);
|
||||
if (capability.orElse(new TargetModVariables.PlayerVariables()).cannonRecoil > 0) {
|
||||
if (capability.orElse(new TargetModVariables.PlayerVariables()).recoilHorizon == 1) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire"));
|
||||
} else {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire2"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -451,4 +460,22 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity {
|
|||
public AnimatableInstanceCache getAnimatableInstanceCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onEntityAttacked(LivingHurtEvent event) {
|
||||
var damagesource = event.getSource();
|
||||
var entity = event.getEntity();
|
||||
if (damagesource == null || entity == null) return;
|
||||
|
||||
var sourceentity = damagesource.getEntity();
|
||||
if (sourceentity == null) return;
|
||||
|
||||
if (entity instanceof Mk42Entity mk42) {
|
||||
if (mk42.getFirstPassenger() == null) return;
|
||||
Entity gunner = mk42.getFirstPassenger();
|
||||
if (event.getSource().getDirectEntity() == gunner){
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.mcreator.target.init.TargetModAttributes;
|
|||
import net.mcreator.target.init.TargetModEntities;
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.init.TargetModSounds;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
|
@ -163,6 +164,9 @@ public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEn
|
|||
this.yHeadRotO = this.getYRot();
|
||||
}
|
||||
if (mainHandItem.getItem() == TargetModItems.MORTAR_SHELLS.get() && !player.getCooldowns().isOnCooldown(TargetModItems.MORTAR_SHELLS.get()) && !player.isShiftKeyDown()) {
|
||||
|
||||
this.getPersistentData().putInt("fire_time",25);
|
||||
|
||||
player.getCooldowns().addCooldown(TargetModItems.MORTAR_SHELLS.get(), 30);
|
||||
if (!player.isCreative()) {
|
||||
player.getInventory().clearOrCountMatchingItems(p -> TargetModItems.MORTAR_SHELLS.get() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
|
||||
|
@ -179,9 +183,9 @@ public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEn
|
|||
entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ());
|
||||
entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 8, (float) 0.5);
|
||||
level.addFreshEntity(entityToSpawn);
|
||||
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 40, 0.4, 0.4, 0.4,
|
||||
0.01);
|
||||
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY(), this.getZ(), 100, 2.5, 0.04, 2.5, 0.005);
|
||||
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 8, 0.4, 0.4, 0.4,
|
||||
0.007);
|
||||
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY(), this.getZ(), 50, 2, 0.02, 2, 0.0005);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -212,6 +216,10 @@ public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEn
|
|||
Thread Thread = new Thread(Runnable);
|
||||
Thread.start();
|
||||
|
||||
if (this.getPersistentData().getInt("fire_time") > 0) {
|
||||
this.getPersistentData().putInt("fire_time",this.getPersistentData().getInt("fire_time") - 1);
|
||||
}
|
||||
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
|
@ -254,7 +262,7 @@ public class MortarEntity extends PathfinderMob implements GeoEntity, AnimatedEn
|
|||
|
||||
private PlayState movementPredicate(AnimationState event) {
|
||||
if (this.animationProcedure.equals("empty")) {
|
||||
if (this.isShiftKeyDown()) {
|
||||
if (this.getPersistentData().getInt("fire_time") > 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mortar.fire"));
|
||||
}
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mortar.idle"));
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package net.mcreator.target.entity.layer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.mcreator.target.entity.MortarEntity;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.renderer.GeoRenderer;
|
||||
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
|
||||
|
||||
public class MortarLayer extends GeoRenderLayer<MortarEntity> {
|
||||
private static final ResourceLocation LAYER = new ResourceLocation("target", "textures/entity/mortar_e.png");
|
||||
|
||||
public MortarLayer(GeoRenderer<MortarEntity> entityRenderer) {
|
||||
super(entityRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, MortarEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
|
||||
RenderType glowRenderType = RenderType.eyes(LAYER);
|
||||
getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
|
||||
}
|
||||
}
|
|
@ -33,11 +33,14 @@ public class Mk42Model extends GeoModel<Mk42Entity> {
|
|||
EntityModelData entityData = (EntityModelData) animationState.getData(DataTickets.ENTITY_MODEL_DATA);
|
||||
barrle.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
|
||||
|
||||
// CoreGeoBone paoguan = getAnimationProcessor().getBone("paoguan");
|
||||
// if (animatable.getFirstPassenger() == null) return;
|
||||
// Entity gunner = animatable.getFirstPassenger();
|
||||
// var capability = gunner.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null);
|
||||
// paoguan.setPosZ(capability.orElse(new TargetModVariables.PlayerVariables()).cannonRecoil);
|
||||
CoreGeoBone camera = getAnimationProcessor().getBone("camera");
|
||||
|
||||
if (animatable.getFirstPassenger() == null) return;
|
||||
Entity gunner = animatable.getFirstPassenger();
|
||||
|
||||
gunner.getPersistentData().putDouble("cannon_camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
|
||||
gunner.getPersistentData().putDouble("cannon_camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
|
||||
gunner.getPersistentData().putDouble("cannon_camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ClientEventHandler {
|
|||
public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) {
|
||||
ClientLevel level = Minecraft.getInstance().level;
|
||||
Entity entity = event.getCamera().getEntity();
|
||||
if (level != null && entity instanceof LivingEntity living) {
|
||||
if (level != null && entity instanceof LivingEntity living && entity.isPassenger() && entity.getVehicle() instanceof Mk42Entity) {
|
||||
handleCannonCamera(event, living);
|
||||
}
|
||||
if (level != null && entity instanceof LivingEntity living && living.getMainHandItem().is(TargetModTags.Items.GUN)) {
|
||||
|
@ -73,41 +73,10 @@ public class ClientEventHandler {
|
|||
double pitch = event.getPitch();
|
||||
double roll = event.getRoll();
|
||||
|
||||
float fps = Minecraft.getInstance().getFps();
|
||||
if (fps <= 0) {
|
||||
fps = 1f;
|
||||
}
|
||||
event.setPitch((float) (pitch + 1 * data.getDouble("Cannon_xRot") + data.getDouble("cannon_camera_rot_x")));
|
||||
event.setYaw((float) (yaw + 1 * data.getDouble("Cannon_yRot") + data.getDouble("cannon_camera_rot_y")));
|
||||
event.setRoll((float) (roll + data.getDouble("cannon_camera_rot_z")));
|
||||
|
||||
float times = 45f / fps;
|
||||
|
||||
if (entity.getVehicle() != null && entity.getVehicle() instanceof Mk42Entity) {
|
||||
|
||||
var capability = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null);
|
||||
if (capability.orElse(new TargetModVariables.PlayerVariables()).cannonRecoil > 7) {
|
||||
data.putDouble("cannon_fire_shake_time", 0.001);
|
||||
}
|
||||
|
||||
if (0 < data.getDouble("cannon_fire_shake_time") && data.getDouble("cannon_fire_shake_time") < 1.732) {
|
||||
data.putDouble("cannon_fire_shake_time", (data.getDouble("cannon_fire_shake_time") + 0.18 * (1.9 - data.getDouble("cannon_fire_shake_time")) * times));
|
||||
}
|
||||
|
||||
if (0 < data.getDouble("cannon_fire_shake_time") && data.getDouble("cannon_fire_shake_time") < 1.732) {
|
||||
|
||||
float shake = (float) ((1 / 6.3 * (data.getDouble("cannon_fire_shake_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("cannon_fire_shake_time") - 0.5)) * (3 - Math.pow(data.getDouble("cannon_fire_shake_time"), 2)) + 1 * Mth.clamp(0.3 - data.getDouble("cannon_fire_shake_time"), 0, 1) * 0.25 * (2 * Math.random() - 1) * capability.orElse(new TargetModVariables.PlayerVariables()).recoilHorizon);
|
||||
|
||||
event.setYaw((float) (yaw - 13.3 * shake));
|
||||
event.setPitch((float) (pitch + 13.3 * shake));
|
||||
event.setRoll((float) (roll + 15.2 * shake));
|
||||
|
||||
} else {
|
||||
event.setPitch((float) (pitch + 1 * data.getDouble("Cannon_xRot")));
|
||||
event.setYaw((float) (yaw + 1 * data.getDouble("Cannon_yRot")));
|
||||
}
|
||||
|
||||
if (data.getDouble("cannon_fire_shake_time") >= 1.732) {
|
||||
data.putDouble("cannon_fire_shake_time", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -447,7 +416,12 @@ public class ClientEventHandler {
|
|||
|
||||
event.setFOV(event.getFOV() / (1.0 + p * (zoom - 1)));
|
||||
player.getPersistentData().putDouble("fov", event.getFOV());
|
||||
|
||||
return;
|
||||
}
|
||||
if (player.isPassenger() && player.getVehicle() instanceof Mk42Entity) {
|
||||
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zoom) {
|
||||
event.setFOV(event.getFOV() / 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,12 +75,12 @@ public class PlayerEventHandler {
|
|||
}
|
||||
handleDistantRange(player);
|
||||
|
||||
// if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).cannonFiring > 0) {
|
||||
// player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
// capability.cannonFiring = (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).cannonFiring - 0.5;
|
||||
// capability.syncPlayerVariables(player);
|
||||
// });
|
||||
// }
|
||||
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).cannonFiring > 0) {
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.cannonFiring = (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).cannonFiring - 1;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
}
|
||||
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).cannonRecoil > 0) {
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.cannonRecoil = (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).cannonRecoil - 1;
|
||||
|
|
|
@ -186,6 +186,8 @@ public class TargetModSounds {
|
|||
public static final RegistryObject<SoundEvent> MK_42_FAR = REGISTRY.register("mk_42_far", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "mk_42_far")));
|
||||
public static final RegistryObject<SoundEvent> MK_42_VERYFAR = REGISTRY.register("mk_42_veryfar", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "mk_42_veryfar")));
|
||||
public static final RegistryObject<SoundEvent> MK_42_RELOAD = REGISTRY.register("mk_42_reload", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "mk_42_reload")));
|
||||
public static final RegistryObject<SoundEvent> CANNON_ZOOM_IN = REGISTRY.register("cannon_zoom_in", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "cannon_zoom_in")));
|
||||
public static final RegistryObject<SoundEvent> CANNON_ZOOM_OUT = REGISTRY.register("cannon_zoom_out", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "cannon_zoom_out")));
|
||||
|
||||
public static final RegistryObject<SoundEvent> BULLET_SUPPLY = REGISTRY.register("bullet_supply", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "bullet_supply")));
|
||||
public static final RegistryObject<SoundEvent> ADJUST_FOV = REGISTRY.register("adjust_fov", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "adjust_fov")));
|
||||
|
|
27
src/main/java/net/mcreator/target/mixins/CameraMixin.java
Normal file
27
src/main/java/net/mcreator/target/mixins/CameraMixin.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package net.mcreator.target.mixins;
|
||||
|
||||
import net.mcreator.target.entity.Mk42Entity;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Camera.class)
|
||||
public abstract class CameraMixin {
|
||||
@Inject(method = "setup", at = @At("TAIL"))
|
||||
public void ia$setup(BlockGetter area, Entity entity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
|
||||
if (thirdPerson && entity.getVehicle() instanceof Mk42Entity) {
|
||||
move(-getMaxZoom(8), 1.0, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@Shadow
|
||||
protected abstract void move(double x, double y, double z);
|
||||
|
||||
@Shadow
|
||||
protected abstract double getMaxZoom(double desiredCameraDistance);
|
||||
}
|
|
@ -38,8 +38,12 @@ public class MouseHandlerMixin {
|
|||
ItemStack stack = mc.player.getMainHandItem();
|
||||
|
||||
if (player.getVehicle() != null && player.getVehicle() instanceof Mk42Entity) {
|
||||
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zoom) {
|
||||
return 0.12;
|
||||
} else {
|
||||
return 0.23;
|
||||
}
|
||||
}
|
||||
|
||||
if (!stack.is(TargetModTags.Items.GUN)) {
|
||||
return original;
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package net.mcreator.target.network.message;
|
||||
|
||||
import net.mcreator.target.entity.Mk42Entity;
|
||||
import net.mcreator.target.init.TargetModSounds;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.mcreator.target.tools.SoundTool;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
@ -45,6 +49,11 @@ public class ZoomMessage {
|
|||
capability.zoom = true;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
if (entity.isPassenger() && entity.getVehicle() instanceof Mk42Entity) {
|
||||
if (entity instanceof ServerPlayer serverPlayer) {
|
||||
SoundTool.playLocalSound(serverPlayer, TargetModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type == 1) {
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
|
@ -56,6 +65,11 @@ public class ZoomMessage {
|
|||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
entity.getPersistentData().putDouble("zoom_animation_time", 0);
|
||||
if (entity.isPassenger() && entity.getVehicle() instanceof Mk42Entity) {
|
||||
if (entity instanceof ServerPlayer serverPlayer) {
|
||||
SoundTool.playLocalSound(serverPlayer, TargetModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
"flare": {
|
||||
"scale": {
|
||||
"0.0": {
|
||||
"vector": [1, 1, 1],
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutQuad"
|
||||
},
|
||||
"0.0083": {
|
||||
|
@ -51,9 +51,175 @@
|
|||
"vector": [1, 1, 1],
|
||||
"easing": "easeOutQuad"
|
||||
},
|
||||
"0.0667": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.6667": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutQuad"
|
||||
}
|
||||
}
|
||||
},
|
||||
"bone": {
|
||||
"position": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.05": {
|
||||
"vector": [0.1477, 0, 0.175],
|
||||
"easing": "easeInElastic",
|
||||
"easingArgs": [10]
|
||||
},
|
||||
"0.1": {
|
||||
"vector": [-0.07, 0, -0.09],
|
||||
"easing": "easeInElastic",
|
||||
"easingArgs": [10]
|
||||
},
|
||||
"0.15": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeInElastic",
|
||||
"easingArgs": [10]
|
||||
}
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.0083": {
|
||||
"vector": [4, 8, 7.5]
|
||||
},
|
||||
"0.05": {
|
||||
"vector": [-2, -4, -2.5]
|
||||
},
|
||||
"0.0917": {
|
||||
"vector": [1, 2, 1.25]
|
||||
},
|
||||
"0.1333": {
|
||||
"vector": [-0.5, -1, -0.625]
|
||||
},
|
||||
"0.175": {
|
||||
"vector": [0.25, 0.5, 0.31]
|
||||
},
|
||||
"0.2167": {
|
||||
"vector": [-0.12, -0.24, -0.15]
|
||||
},
|
||||
"0.2583": {
|
||||
"vector": [0.06, 0.12, 0.075]
|
||||
},
|
||||
"0.3": {
|
||||
"vector": [-0.03, -0.6, -0.0375]
|
||||
},
|
||||
"0.3417": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"animation.mk42.fire2": {
|
||||
"loop": "hold_on_last_frame",
|
||||
"animation_length": 1,
|
||||
"bones": {
|
||||
"paoguan": {
|
||||
"position": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeInQuad"
|
||||
},
|
||||
"0.05": {
|
||||
"vector": [0, 0, 11],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"0.4917": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeInQuad"
|
||||
},
|
||||
"0.6667": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeInQuad"
|
||||
}
|
||||
}
|
||||
},
|
||||
"flare": {
|
||||
"scale": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutQuad"
|
||||
},
|
||||
"0.0083": {
|
||||
"vector": [110, 110, 110]
|
||||
},
|
||||
"0.025": {
|
||||
"vector": [110, 110, 110]
|
||||
},
|
||||
"0.05": {
|
||||
"vector": [1, 1, 1],
|
||||
"easing": "easeOutQuad"
|
||||
},
|
||||
"0.0667": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.6667": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutQuad"
|
||||
}
|
||||
}
|
||||
},
|
||||
"bone": {
|
||||
"position": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.05": {
|
||||
"vector": [0.1477, 0, 0.175],
|
||||
"easing": "easeInElastic",
|
||||
"easingArgs": [10]
|
||||
},
|
||||
"0.1": {
|
||||
"vector": [-0.07, 0, -0.09],
|
||||
"easing": "easeInElastic",
|
||||
"easingArgs": [10]
|
||||
},
|
||||
"0.15": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeInElastic",
|
||||
"easingArgs": [10]
|
||||
}
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.0083": {
|
||||
"vector": [4, -8, -7.5]
|
||||
},
|
||||
"0.05": {
|
||||
"vector": [-2, 4, 2.5]
|
||||
},
|
||||
"0.0917": {
|
||||
"vector": [1, -2, -1.25]
|
||||
},
|
||||
"0.1333": {
|
||||
"vector": [-0.5, 1, 0.625]
|
||||
},
|
||||
"0.175": {
|
||||
"vector": [0.25, -0.5, -0.31]
|
||||
},
|
||||
"0.2167": {
|
||||
"vector": [-0.12, 0.24, 0.15]
|
||||
},
|
||||
"0.2583": {
|
||||
"vector": [0.06, -0.12, -0.075]
|
||||
},
|
||||
"0.3": {
|
||||
"vector": [-0.03, 0.6, 0.0375]
|
||||
},
|
||||
"0.3417": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,17 @@
|
|||
"scale": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
},
|
||||
"flare": {
|
||||
"scale": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutQuad"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"animation.mortar.fire": {
|
||||
"loop": "hold_on_last_frame",
|
||||
"animation_length": 1.5,
|
||||
"bones": {
|
||||
"shell": {
|
||||
|
@ -49,6 +56,27 @@
|
|||
"easing": "easeInSine"
|
||||
}
|
||||
}
|
||||
},
|
||||
"flare": {
|
||||
"scale": {
|
||||
"1.0": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutQuad"
|
||||
},
|
||||
"1.0083": {
|
||||
"vector": [1200, 1200, 1200]
|
||||
},
|
||||
"1.025": {
|
||||
"vector": [1200, 1200, 1200]
|
||||
},
|
||||
"1.05": {
|
||||
"vector": [1, 1, 1],
|
||||
"easing": "easeOutQuad"
|
||||
},
|
||||
"1.0667": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
"identifier": "geometry.unknown",
|
||||
"texture_width": 64,
|
||||
"texture_height": 64,
|
||||
"visible_bounds_width": 4,
|
||||
"visible_bounds_height": 4,
|
||||
"visible_bounds_width": 103,
|
||||
"visible_bounds_height": 102,
|
||||
"visible_bounds_offset": [0, 1, 0]
|
||||
},
|
||||
"bones": [
|
||||
|
@ -20,6 +20,54 @@
|
|||
"parent": "mortar",
|
||||
"pivot": [0, 3.2, 0]
|
||||
},
|
||||
{
|
||||
"name": "flare",
|
||||
"parent": "paoguan",
|
||||
"pivot": [0, 3.16797, -23.64844],
|
||||
"rotation": [90, 0, 0],
|
||||
"cubes": [
|
||||
{
|
||||
"origin": [-0.00675, 3.16122, -23.64844],
|
||||
"size": [0.0135, 0.0135, 0],
|
||||
"pivot": [0, 3.16797, -23.64844],
|
||||
"rotation": [-90, 0, 0],
|
||||
"uv": {
|
||||
"north": {"uv": [64, 52], "uv_size": [-12, 12]},
|
||||
"south": {"uv": [52, 52], "uv_size": [12, 12]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-0.00075, 3.16122, -23.64844],
|
||||
"size": [0.0375, 0.0135, 0],
|
||||
"pivot": [0, 3.16797, -23.64844],
|
||||
"rotation": [-90, 0, -90],
|
||||
"uv": {
|
||||
"north": {"uv": [62, 52], "uv_size": [-10, 12]},
|
||||
"south": {"uv": [52, 52], "uv_size": [10, 12]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-0.00075, 3.16122, -23.64844],
|
||||
"size": [0.0375, 0.0135, 0],
|
||||
"pivot": [0, 3.16797, -23.64844],
|
||||
"rotation": [-150, 0, -90],
|
||||
"uv": {
|
||||
"north": {"uv": [62, 52], "uv_size": [-10, 12]},
|
||||
"south": {"uv": [52, 52], "uv_size": [10, 12]}
|
||||
}
|
||||
},
|
||||
{
|
||||
"origin": [-0.00075, 3.16122, -23.64844],
|
||||
"size": [0.0375, 0.0135, 0],
|
||||
"pivot": [0, 3.16797, -23.64844],
|
||||
"rotation": [150, 0, -90],
|
||||
"uv": {
|
||||
"north": {"uv": [62, 52], "uv_size": [-10, 12]},
|
||||
"south": {"uv": [52, 52], "uv_size": [10, 12]}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "bone2",
|
||||
"parent": "paoguan",
|
||||
|
|
|
@ -8769,8 +8769,8 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"origin": [15.84, 46.08, -7.2],
|
||||
"size": [7.2, 7.56, 0.36],
|
||||
"origin": [15.84391, 46.08, -7.2],
|
||||
"size": [7.19609, 6.16, 0.36],
|
||||
"pivot": [21.96, 56.52, -7.56],
|
||||
"rotation": [-76, 0, 0],
|
||||
"uv": {
|
||||
|
@ -10172,7 +10172,7 @@
|
|||
},
|
||||
{
|
||||
"origin": [-23.04, 46.08, -7.2],
|
||||
"size": [7.2, 7.56, 0.36],
|
||||
"size": [7.19609, 6.16, 0.36],
|
||||
"pivot": [-21.96, 56.52, -7.56],
|
||||
"rotation": [-76, 0, 0],
|
||||
"uv": {
|
||||
|
@ -11060,6 +11060,10 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "camera",
|
||||
"pivot": [0, 58.76276, 0.97702]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1558,5 +1558,21 @@
|
|||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"cannon_zoom_in": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "target:mk_42/cannon_zoom_in",
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"cannon_zoom_out": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "target:mk_42/cannon_zoom_out",
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
BIN
src/main/resources/assets/target/sounds/mk_42/cannon_zoom_in.ogg
Normal file
BIN
src/main/resources/assets/target/sounds/mk_42/cannon_zoom_in.ogg
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/main/resources/assets/target/textures/entity/mortar_e.png
Normal file
BIN
src/main/resources/assets/target/textures/entity/mortar_e.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 143 KiB |
Binary file not shown.
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 12 KiB |
|
@ -10,6 +10,7 @@
|
|||
"client": [
|
||||
"ItemInHandLayerMixin",
|
||||
"MixinCamera",
|
||||
"CameraMixin",
|
||||
"KeyMappingMixin",
|
||||
"GameRendererMixin",
|
||||
"MouseHandlerMixin"
|
||||
|
|
Loading…
Add table
Reference in a new issue