尝试调整开火位置
This commit is contained in:
parent
053803492c
commit
eacc541282
4 changed files with 24 additions and 25 deletions
|
@ -1,7 +1,6 @@
|
||||||
package net.mcreator.superbwarfare.block;
|
package net.mcreator.superbwarfare.block;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.entity.Mk42Entity;
|
import net.mcreator.superbwarfare.entity.ICannonEntity;
|
||||||
import net.mcreator.superbwarfare.entity.Mle1934Entity;
|
|
||||||
import net.mcreator.superbwarfare.entity.TargetEntity;
|
import net.mcreator.superbwarfare.entity.TargetEntity;
|
||||||
import net.mcreator.superbwarfare.init.ModSounds;
|
import net.mcreator.superbwarfare.init.ModSounds;
|
||||||
import net.mcreator.superbwarfare.network.ModVariables;
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
|
@ -23,6 +22,7 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class JumpPadBlock extends Block {
|
public class JumpPadBlock extends Block {
|
||||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ public class JumpPadBlock extends Block {
|
||||||
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
|
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) {
|
public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -79,7 +78,7 @@ public class JumpPadBlock extends Block {
|
||||||
super.entityInside(blockstate, level, pos, entity);
|
super.entityInside(blockstate, level, pos, entity);
|
||||||
|
|
||||||
// 禁止套娃
|
// 禁止套娃
|
||||||
if (entity instanceof TargetEntity || entity instanceof Mk42Entity || entity instanceof Mle1934Entity) return;
|
if (entity instanceof TargetEntity || entity instanceof ICannonEntity) return;
|
||||||
|
|
||||||
boolean zooming = entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.zooming).orElse(false);
|
boolean zooming = entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.zooming).orElse(false);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class ClickHandler {
|
||||||
int button = event.getButton();
|
int button = event.getButton();
|
||||||
if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new FireMessage(1));
|
ModUtils.PACKET_HANDLER.sendToServer(new FireMessage(1));
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleFireMessage(0));
|
|
||||||
}
|
}
|
||||||
if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) {
|
if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) {
|
||||||
if (Minecraft.getInstance().player.hasEffect(ModMobEffects.SHOCK.get())) {
|
if (Minecraft.getInstance().player.hasEffect(ModMobEffects.SHOCK.get())) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
@ -37,7 +36,6 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
import net.minecraftforge.network.PlayMessages;
|
import net.minecraftforge.network.PlayMessages;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
||||||
import software.bernie.geckolib.core.animation.AnimatableManager;
|
import software.bernie.geckolib.core.animation.AnimatableManager;
|
||||||
|
@ -119,12 +117,12 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SoundEvent getHurtSound(DamageSource ds) {
|
public SoundEvent getHurtSound(DamageSource ds) {
|
||||||
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("superbwarfare:hit"));
|
return ModSounds.HIT.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SoundEvent getDeathSound() {
|
public SoundEvent getDeathSound() {
|
||||||
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("superbwarfare:hit"));
|
return ModSounds.HIT.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
@ -38,7 +37,6 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
import net.minecraftforge.network.PlayMessages;
|
import net.minecraftforge.network.PlayMessages;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
||||||
import software.bernie.geckolib.core.animation.AnimatableManager;
|
import software.bernie.geckolib.core.animation.AnimatableManager;
|
||||||
|
@ -108,12 +106,12 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SoundEvent getHurtSound(DamageSource ds) {
|
public SoundEvent getHurtSound(DamageSource ds) {
|
||||||
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("superbwarfare:hit"));
|
return ModSounds.HIT.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SoundEvent getDeathSound() {
|
public SoundEvent getDeathSound() {
|
||||||
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("superbwarfare:hit"));
|
return ModSounds.HIT.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -232,13 +230,22 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
||||||
stack.shrink(salvoShoot ? 2 : 1);
|
stack.shrink(salvoShoot ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 将炮弹生成在正确的位置(现在均在中心)
|
// TODO 将炮弹生成在正确的位置(现在偏差值很大)
|
||||||
|
// 中心点距离发射位置(炮口)的距离
|
||||||
|
final float radius = 1.5f;
|
||||||
|
// 两个炮管之间的距离
|
||||||
|
final float length = 0.15f;
|
||||||
|
// 可能用的偏差值
|
||||||
|
final float offset = 0.0f;
|
||||||
|
float yRot = this.getYRot();
|
||||||
|
|
||||||
//左炮管
|
//左炮管
|
||||||
CannonShellEntity entityToSpawnLeft = new CannonShellEntity(ModEntities.CANNON_SHELL.get(),
|
CannonShellEntity entityToSpawnLeft = new CannonShellEntity(ModEntities.CANNON_SHELL.get(),
|
||||||
player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime).durability(durability);
|
player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime).durability(durability);
|
||||||
|
|
||||||
entityToSpawnLeft.setPos(this.getX(), this.getEyeY(), this.getZ());
|
entityToSpawnLeft.setPos(this.getX() + this.getBbWidth() / 2 + (radius - length) * Mth.cos(yRot) - offset,
|
||||||
|
this.getEyeY(),
|
||||||
|
this.getZ() + this.getBbWidth() / 2 + (radius + length) * Mth.sin(yRot));
|
||||||
entityToSpawnLeft.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 18, 0.1f);
|
entityToSpawnLeft.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 18, 0.1f);
|
||||||
level.addFreshEntity(entityToSpawnLeft);
|
level.addFreshEntity(entityToSpawnLeft);
|
||||||
|
|
||||||
|
@ -247,24 +254,20 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
||||||
CannonShellEntity entityToSpawnRight = new CannonShellEntity(ModEntities.CANNON_SHELL.get(),
|
CannonShellEntity entityToSpawnRight = new CannonShellEntity(ModEntities.CANNON_SHELL.get(),
|
||||||
player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime).durability(durability);
|
player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime).durability(durability);
|
||||||
|
|
||||||
entityToSpawnRight.setPos(this.getX(), this.getEyeY(), this.getZ());
|
entityToSpawnRight.setPos(this.getX() + this.getBbWidth() / 2 + (radius + length) * Mth.cos(yRot) + offset,
|
||||||
|
this.getEyeY(),
|
||||||
|
this.getZ() + this.getBbWidth() / 2 + (radius - length) * Mth.sin(yRot));
|
||||||
entityToSpawnRight.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 18, 0.1f);
|
entityToSpawnRight.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 18, 0.1f);
|
||||||
level.addFreshEntity(entityToSpawnRight);
|
level.addFreshEntity(entityToSpawnRight);
|
||||||
|
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> capability.recoilHorizon = 1);
|
||||||
capability.recoilHorizon = 1;
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> capability.recoilHorizon = -1);
|
||||||
capability.recoilHorizon = -1;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
if (player instanceof ServerPlayer serverPlayer) {
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.MK_42_FIRE_1P.get(), 2, 1);
|
SoundTool.playLocalSound(serverPlayer, ModSounds.MK_42_FIRE_1P.get(), 2, 1);
|
||||||
ModUtils.queueServerWork(44, () -> {
|
ModUtils.queueServerWork(44, () -> SoundTool.playLocalSound(serverPlayer, ModSounds.MK_42_RELOAD.get(), 2, 1));
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.MK_42_RELOAD.get(), 2, 1);
|
|
||||||
});
|
|
||||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_FIRE_3P.get(), SoundSource.PLAYERS, 6, 1);
|
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_FIRE_3P.get(), SoundSource.PLAYERS, 6, 1);
|
||||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_FAR.get(), SoundSource.PLAYERS, 16, 1);
|
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_FAR.get(), SoundSource.PLAYERS, 16, 1);
|
||||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_VERYFAR.get(), SoundSource.PLAYERS, 32, 1);
|
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_VERYFAR.get(), SoundSource.PLAYERS, 32, 1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue