重写火炮/爆炸视角抖动,将饰品模组作为必需前置
This commit is contained in:
parent
54a93d1604
commit
4722ecc924
14 changed files with 184 additions and 99 deletions
|
@ -148,6 +148,7 @@ public class ModUtils {
|
||||||
addNetworkMessage(ShootMessage.class, ShootMessage::encode, ShootMessage::decode, ShootMessage::handler);
|
addNetworkMessage(ShootMessage.class, ShootMessage::encode, ShootMessage::decode, ShootMessage::handler);
|
||||||
addNetworkMessage(LaserShootMessage.class, LaserShootMessage::encode, LaserShootMessage::decode, LaserShootMessage::handler);
|
addNetworkMessage(LaserShootMessage.class, LaserShootMessage::encode, LaserShootMessage::decode, LaserShootMessage::handler);
|
||||||
addNetworkMessage(ShootClientMessage.class, ShootClientMessage::encode, ShootClientMessage::decode, ShootClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
addNetworkMessage(ShootClientMessage.class, ShootClientMessage::encode, ShootClientMessage::decode, ShootClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
|
addNetworkMessage(ShakeClientMessage.class, ShakeClientMessage::encode, ShakeClientMessage::decode, ShakeClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
addNetworkMessage(DrawClientMessage.class, DrawClientMessage::encode, DrawClientMessage::decode, DrawClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
addNetworkMessage(DrawClientMessage.class, DrawClientMessage::encode, DrawClientMessage::decode, DrawClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
addNetworkMessage(EditModeMessage.class, EditModeMessage::encode, EditModeMessage::decode, EditModeMessage::handler);
|
addNetworkMessage(EditModeMessage.class, EditModeMessage::encode, EditModeMessage::decode, EditModeMessage::handler);
|
||||||
addNetworkMessage(EditMessage.class, EditMessage::encode, EditMessage::decode, EditMessage::handler);
|
addNetworkMessage(EditMessage.class, EditMessage::encode, EditMessage::decode, EditMessage::handler);
|
||||||
|
|
|
@ -24,10 +24,16 @@ public class ModDamageTypeTagProvider extends DamageTypeTagsProvider {
|
||||||
this.tag(ModTags.DamageTypes.PROJECTILE).add(ModDamageTypes.GUN_FIRE, ModDamageTypes.GUN_FIRE_HEADSHOT,
|
this.tag(ModTags.DamageTypes.PROJECTILE).add(ModDamageTypes.GUN_FIRE, ModDamageTypes.GUN_FIRE_HEADSHOT,
|
||||||
DamageTypes.ARROW, DamageTypes.TRIDENT, DamageTypes.THROWN)
|
DamageTypes.ARROW, DamageTypes.TRIDENT, DamageTypes.THROWN)
|
||||||
.addOptional(new ResourceLocation("tacz", "bullet"))
|
.addOptional(new ResourceLocation("tacz", "bullet"))
|
||||||
.addOptional(new ResourceLocation("tacz", "bullet_void"));
|
.addOptional(new ResourceLocation("tacz", "bullet_void"))
|
||||||
|
.addOptional(new ResourceLocation("virtuarealcraft", "rain_crystal"))
|
||||||
|
.addOptional(new ResourceLocation("virtuarealcraft", "rain_shower_butterfly"))
|
||||||
|
.addOptional(new ResourceLocation("virtuarealcraft", "sparkle_butterfly"))
|
||||||
|
.addOptional(new ResourceLocation("dreamaticvoyage", "blood_crystal"))
|
||||||
|
.addOptional(new ResourceLocation("dreamaticvoyage", "leviy_beam"));
|
||||||
this.tag(ModTags.DamageTypes.PROJECTILE_ABSOLUTE).add(ModDamageTypes.GUN_FIRE_ABSOLUTE, ModDamageTypes.GUN_FIRE_HEADSHOT_ABSOLUTE)
|
this.tag(ModTags.DamageTypes.PROJECTILE_ABSOLUTE).add(ModDamageTypes.GUN_FIRE_ABSOLUTE, ModDamageTypes.GUN_FIRE_HEADSHOT_ABSOLUTE)
|
||||||
.addOptional(new ResourceLocation("tacz", "bullet_ignore_armor"))
|
.addOptional(new ResourceLocation("tacz", "bullet_ignore_armor"))
|
||||||
.addOptional(new ResourceLocation("tacz", "bullet_void_ignore_armor"));
|
.addOptional(new ResourceLocation("tacz", "bullet_void_ignore_armor"))
|
||||||
|
.addOptional(new ResourceLocation("dreamaticvoyage", "leviy_beam_absolute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package com.atsuishio.superbwarfare.entity;
|
package com.atsuishio.superbwarfare.entity;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
||||||
import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem;
|
import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem;
|
||||||
|
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
||||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
|
@ -32,6 +34,7 @@ import net.minecraft.world.level.Explosion;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.minecraftforge.network.PlayMessages;
|
import net.minecraftforge.network.PlayMessages;
|
||||||
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;
|
||||||
|
@ -68,7 +71,7 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
compound.putInt("CoolDown", this.entityData.get(COOL_DOWN));
|
compound.putInt("oolDown", this.entityData.get(COOL_DOWN));
|
||||||
compound.putFloat("Health", this.entityData.get(HEALTH));
|
compound.putFloat("Health", this.entityData.get(HEALTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +107,7 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPassengersRidingOffset() {
|
public double getPassengersRidingOffset() {
|
||||||
return super.getPassengersRidingOffset() - 1.25;
|
return super.getPassengersRidingOffset() - 0.25;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -324,7 +327,6 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
double z = this.getZ() + 9 * this.getLookAngle().z;
|
double z = this.getZ() + 9 * this.getLookAngle().z;
|
||||||
|
|
||||||
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, x, y, z, 10, 0.4, 0.4, 0.4, 0.0075);
|
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, x, y, z, 10, 0.4, 0.4, 0.4, 0.0075);
|
||||||
|
|
||||||
server.sendParticles(ParticleTypes.CLOUD, x, y, z, 10, 0.4, 0.4, 0.4, 0.0075);
|
server.sendParticles(ParticleTypes.CLOUD, x, y, z, 10, 0.4, 0.4, 0.4, 0.0075);
|
||||||
|
|
||||||
int count = 6;
|
int count = 6;
|
||||||
|
@ -336,6 +338,10 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
this.getZ() + i * this.getLookAngle().z,
|
this.getZ() + i * this.getLookAngle().z,
|
||||||
Mth.clamp(count--, 1, 5), 0.15, 0.15, 0.15, 0.0025);
|
Mth.clamp(count--, 1, 5), 0.15, 0.15, 0.15, 0.0025);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
|
||||||
|
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(15,15,45, this.getX(), this.getY(), this.getZ()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,13 +386,6 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
float f1 = Mth.clamp(f, -85.0F, 16.3F);
|
float f1 = Mth.clamp(f, -85.0F, 16.3F);
|
||||||
entity.xRotO += f1 - f;
|
entity.xRotO += f1 - f;
|
||||||
entity.setXRot(entity.getXRot() + f1 - f);
|
entity.setXRot(entity.getXRot() + f1 - f);
|
||||||
|
|
||||||
// entity.setYBodyRot(this.getYRot());
|
|
||||||
// float f2 = Mth.wrapDegrees(entity.getYRot() - this.getYRot());
|
|
||||||
// float f3 = Mth.clamp(f2, -60.0F, 60.0F);
|
|
||||||
// entity.yRotO += f3 - f2;
|
|
||||||
// entity.setYRot(entity.getYRot() + f3 - f2);
|
|
||||||
// entity.setYHeadRot(entity.getYRot());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -398,7 +397,6 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
if (this.entityData.get(COOL_DOWN) > 10) {
|
if (this.entityData.get(COOL_DOWN) > 10) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mk42.idle"));
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mk42.idle"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
||||||
import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem;
|
import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem;
|
||||||
|
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
||||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
|
@ -33,6 +34,7 @@ import net.minecraft.world.level.Explosion;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.minecraftforge.network.PlayMessages;
|
import net.minecraftforge.network.PlayMessages;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
|
@ -112,7 +114,7 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPassengersRidingOffset() {
|
public double getPassengersRidingOffset() {
|
||||||
return super.getPassengersRidingOffset() - 1.075;
|
return super.getPassengersRidingOffset() - 0.075;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -422,6 +424,10 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
this.getY(),
|
this.getY(),
|
||||||
this.getZ() + 5 * this.getLookAngle().z,
|
this.getZ() + 5 * this.getLookAngle().z,
|
||||||
100, 7, 0.02, 7, 0.005);
|
100, 7, 0.02, 7, 0.005);
|
||||||
|
|
||||||
|
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
|
||||||
|
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(17,20,50, this.getX(), this.getY(), this.getZ()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +440,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
|
|
||||||
public void travel() {
|
public void travel() {
|
||||||
Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
||||||
|
|
||||||
if (!(passenger instanceof LivingEntity entity)) return;
|
if (!(passenger instanceof LivingEntity entity)) return;
|
||||||
|
|
||||||
float passengerY = entity.getYHeadRot();
|
float passengerY = entity.getYHeadRot();
|
||||||
|
@ -472,6 +477,8 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
this.clampRotation(entity);
|
this.clampRotation(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private PlayState movementPredicate(AnimationState<Mle1934Entity> event) {
|
private PlayState movementPredicate(AnimationState<Mle1934Entity> event) {
|
||||||
if (this.entityData.get(COOL_DOWN) > 64) {
|
if (this.entityData.get(COOL_DOWN) > 64) {
|
||||||
if (this.entityData.get(TYPE) == 1) {
|
if (this.entityData.get(TYPE) == 1) {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package com.atsuishio.superbwarfare.entity.model;
|
package com.atsuishio.superbwarfare.entity.model;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.Mk42Entity;
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.entity.Mk42Entity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -49,10 +48,5 @@ public class Mk42Model extends GeoModel<Mk42Entity> {
|
||||||
CoreGeoBone bone = getAnimationProcessor().getBone("maingun");
|
CoreGeoBone bone = getAnimationProcessor().getBone("maingun");
|
||||||
EntityModelData entityData = animationState.getData(DataTickets.ENTITY_MODEL_DATA);
|
EntityModelData entityData = animationState.getData(DataTickets.ENTITY_MODEL_DATA);
|
||||||
bone.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
|
bone.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
|
||||||
|
|
||||||
CoreGeoBone camera = getAnimationProcessor().getBone("camera");
|
|
||||||
|
|
||||||
if (animatable.getFirstPassenger() == null) return;
|
|
||||||
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(), Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package com.atsuishio.superbwarfare.entity.model;
|
package com.atsuishio.superbwarfare.entity.model;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.Mle1934Entity;
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.entity.Mle1934Entity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -48,10 +47,5 @@ public class Mle1934Model extends GeoModel<Mle1934Entity> {
|
||||||
CoreGeoBone barrle = getAnimationProcessor().getBone("barrel");
|
CoreGeoBone barrle = getAnimationProcessor().getBone("barrel");
|
||||||
EntityModelData entityData = (EntityModelData) animationState.getData(DataTickets.ENTITY_MODEL_DATA);
|
EntityModelData entityData = (EntityModelData) animationState.getData(DataTickets.ENTITY_MODEL_DATA);
|
||||||
barrle.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
|
barrle.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
|
||||||
|
|
||||||
CoreGeoBone camera = getAnimationProcessor().getBone("camera");
|
|
||||||
|
|
||||||
if (animatable.getFirstPassenger() == null) return;
|
|
||||||
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.atsuishio.superbwarfare.entity.projectile;
|
package com.atsuishio.superbwarfare.entity.projectile;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.init.ModEntities;
|
import com.atsuishio.superbwarfare.init.ModEntities;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.ProjectileTool;
|
import com.atsuishio.superbwarfare.tools.ProjectileTool;
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
|
@ -16,7 +16,6 @@ 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;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
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;
|
||||||
|
@ -28,7 +27,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.minecraftforge.network.PlayMessages;
|
import net.minecraftforge.network.PlayMessages;
|
||||||
|
@ -139,15 +137,6 @@ public class HandGrenadeEntity extends ThrowableItemProjectile {
|
||||||
1, 0, 0, 0, 0.01, true);
|
1, 0, 0, 0, 0.01, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void shootFromRotation(Entity pShooter, float pX, float pY, float pZ, float pVelocity, float pInaccuracy) {
|
|
||||||
float f = -Mth.sin(pY * 0.017453292F) * Mth.cos(pX * 0.017453292F);
|
|
||||||
float f1 = -Mth.sin((pX + pZ) * 0.017453292F);
|
|
||||||
float f2 = Mth.cos(pY * 0.017453292F) * Mth.cos(pX * 0.017453292F);
|
|
||||||
this.shoot((double)f, (double)f1, (double)f2, pVelocity, pInaccuracy);
|
|
||||||
Vec3 vec3 = pShooter.getDeltaMovement();
|
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(vec3.x, pShooter.onGround() ? 0.0 : -vec3.y, vec3.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getGravity() {
|
protected float getGravity() {
|
||||||
|
|
|
@ -78,9 +78,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
if (state.getBlock() instanceof BellBlock bell) {
|
if (state.getBlock() instanceof BellBlock bell) {
|
||||||
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
|
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
|
||||||
}
|
}
|
||||||
if (this.tickCount > 2) {
|
|
||||||
ProjectileTool.causeCustomExplode(this, 100f, 4f, 1.2f);
|
ProjectileTool.causeCustomExplode(this, 100f, 4f, 1.2f);
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ENTITY:
|
case ENTITY:
|
||||||
|
@ -93,7 +91,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.tickCount > 2 && !(entity instanceof DroneEntity)) {
|
if (entity instanceof DroneEntity) {
|
||||||
ProjectileTool.causeCustomExplode(this, 100f, 4f, 1.2f);
|
ProjectileTool.causeCustomExplode(this, 100f, 4f, 1.2f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -114,13 +112,11 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.tickCount > 2) {
|
|
||||||
if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) {
|
if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) {
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.SMOKE, this.xo, this.yo, this.zo,
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.SMOKE, this.xo, this.yo, this.zo,
|
||||||
1, 0, 0, 0, 0.01, true);
|
1, 0, 0, 0, 0.01, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getGravity() {
|
protected float getGravity() {
|
||||||
|
@ -146,13 +142,4 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
this.xRotO = this.getXRot();
|
this.xRotO = this.getXRot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void shootFromRotation(Entity pShooter, float pX, float pY, float pZ, float pVelocity, float pInaccuracy) {
|
|
||||||
float f = -Mth.sin(pY * 0.017453292F) * Mth.cos(pX * 0.017453292F);
|
|
||||||
float f1 = -Mth.sin((pX + pZ) * 0.017453292F);
|
|
||||||
float f2 = Mth.cos(pY * 0.017453292F) * Mth.cos(pX * 0.017453292F);
|
|
||||||
this.shoot((double)f, (double)f1, (double)f2, pVelocity, pInaccuracy);
|
|
||||||
Vec3 vec3 = pShooter.getDeltaMovement();
|
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(vec3.x, pShooter.onGround() ? 0.0 : -vec3.y, vec3.z));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.DroneEntity;
|
import com.atsuishio.superbwarfare.entity.DroneEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem;
|
|
||||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
import com.atsuishio.superbwarfare.network.message.LaserShootMessage;
|
import com.atsuishio.superbwarfare.network.message.LaserShootMessage;
|
||||||
import com.atsuishio.superbwarfare.network.message.ShootMessage;
|
import com.atsuishio.superbwarfare.network.message.ShootMessage;
|
||||||
|
@ -20,6 +19,7 @@ import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -35,6 +35,7 @@ import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
|
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
|
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||||
import net.minecraftforge.client.event.ViewportEvent;
|
import net.minecraftforge.client.event.ViewportEvent;
|
||||||
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
|
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
|
@ -123,9 +124,13 @@ public class ClientEventHandler {
|
||||||
public static int miniGunRot = 0;
|
public static int miniGunRot = 0;
|
||||||
|
|
||||||
public static double revolverPreTime = 0;
|
public static double revolverPreTime = 0;
|
||||||
|
|
||||||
public static double revolverWheelPreTime = 0;
|
public static double revolverWheelPreTime = 0;
|
||||||
|
|
||||||
|
public static double shakeTime = 0;
|
||||||
|
public static double shakeRadius = 0;
|
||||||
|
public static double shakeAmplitude = 0;
|
||||||
|
public static double[] shakePos = {0, 0, 0};
|
||||||
|
public static double shakeType = 0;
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void handleWeaponTurn(RenderHandEvent event) {
|
public static void handleWeaponTurn(RenderHandEvent event) {
|
||||||
|
@ -201,6 +206,7 @@ public class ClientEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
beamShoot(player, stack);
|
beamShoot(player, stack);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -439,7 +445,9 @@ public class ClientEventHandler {
|
||||||
public static void handleClientShoot() {
|
public static void handleClientShoot() {
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
CompoundTag tag = player.getMainHandItem().getOrCreateTag();
|
CompoundTag tag = player.getMainHandItem().getOrCreateTag();
|
||||||
|
|
||||||
if (!player.getMainHandItem().is(ModTags.Items.GUN)) return;
|
if (!player.getMainHandItem().is(ModTags.Items.GUN)) return;
|
||||||
|
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new ShootMessage(gunSpread));
|
ModUtils.PACKET_HANDLER.sendToServer(new ShootMessage(gunSpread));
|
||||||
|
@ -459,6 +467,20 @@ public class ClientEventHandler {
|
||||||
randomShell[2] = (0.7 + (Math.random() - 0.5));
|
randomShell[2] = (0.7 + (Math.random() - 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void handleShakeClient(double time, double radius, double amplitude, double x, double y,double z, Supplier<NetworkEvent.Context> ctx) {
|
||||||
|
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||||
|
Player player = Minecraft.getInstance().player;
|
||||||
|
if (player == null) return;
|
||||||
|
shakeTime = time;
|
||||||
|
shakeRadius = radius;
|
||||||
|
shakeAmplitude = amplitude * Mth.DEG_TO_RAD;
|
||||||
|
shakePos[0] = x;
|
||||||
|
shakePos[1] = y;
|
||||||
|
shakePos[2] = z;
|
||||||
|
shakeType = 2 * (Math.random() - 0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void playGunClientSounds(Player player) {
|
public static void playGunClientSounds(Player player) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) {
|
if (!stack.is(ModTags.Items.GUN)) {
|
||||||
|
@ -561,6 +583,7 @@ public class ClientEventHandler {
|
||||||
ClientLevel level = Minecraft.getInstance().level;
|
ClientLevel level = Minecraft.getInstance().level;
|
||||||
Entity entity = event.getCamera().getEntity();
|
Entity entity = event.getCamera().getEntity();
|
||||||
handlePlayerCamera(event);
|
handlePlayerCamera(event);
|
||||||
|
|
||||||
if (level != null && entity instanceof LivingEntity living
|
if (level != null && entity instanceof LivingEntity living
|
||||||
&& living.getMainHandItem().is(ModItems.MONITOR.get())
|
&& living.getMainHandItem().is(ModItems.MONITOR.get())
|
||||||
&& living.getMainHandItem().getOrCreateTag().getBoolean("Using")
|
&& living.getMainHandItem().getOrCreateTag().getBoolean("Using")
|
||||||
|
@ -572,6 +595,7 @@ public class ClientEventHandler {
|
||||||
Minecraft.getInstance().gameRenderer.shutdownEffect();
|
Minecraft.getInstance().gameRenderer.shutdownEffect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level != null && entity instanceof LivingEntity living && living.getMainHandItem().is(ModTags.Items.GUN)) {
|
if (level != null && entity instanceof LivingEntity living && living.getMainHandItem().is(ModTags.Items.GUN)) {
|
||||||
handleWeaponSway(living);
|
handleWeaponSway(living);
|
||||||
handleWeaponMove(living);
|
handleWeaponMove(living);
|
||||||
|
@ -584,6 +608,33 @@ public class ClientEventHandler {
|
||||||
handleBowPullAnimation(living);
|
handleBowPullAnimation(living);
|
||||||
handleWeaponDraw(living);
|
handleWeaponDraw(living);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float times = Minecraft.getInstance().getDeltaFrameTime();
|
||||||
|
LocalPlayer player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
|
float yaw = event.getYaw();
|
||||||
|
float pitch = event.getPitch();
|
||||||
|
float roll = event.getRoll();
|
||||||
|
float shakeRadiusAmplitude;
|
||||||
|
|
||||||
|
shakeTime = Mth.lerp(0.25 * times, shakeTime, 0);
|
||||||
|
|
||||||
|
if (player != null && shakeTime > 0) {
|
||||||
|
shakeRadiusAmplitude = (float) (1 - player.position().distanceTo(new Vec3(shakePos[0], shakePos[1], shakePos[2])) / shakeRadius);
|
||||||
|
|
||||||
|
player.displayClientMessage(Component.literal(new java.text.DecimalFormat("##.##").format(shakeRadiusAmplitude)), true);
|
||||||
|
|
||||||
|
if (shakeType > 0) {
|
||||||
|
event.setYaw((float) (yaw + (shakeTime * Math.sin(0.5 *Math.PI * shakeTime) * shakeAmplitude * shakeRadiusAmplitude * 0.75 * shakeType)));
|
||||||
|
event.setPitch((float) (pitch - (shakeTime * Math.sin(0.5 *Math.PI * shakeTime) * shakeAmplitude * shakeRadiusAmplitude * shakeType)));
|
||||||
|
event.setRoll((float) (roll - (shakeTime * Math.sin(0.5 *Math.PI * shakeTime) * shakeAmplitude * shakeRadiusAmplitude)));
|
||||||
|
} else {
|
||||||
|
event.setYaw((float) (yaw - (shakeTime * Math.sin(0.5 *Math.PI * shakeTime) * shakeAmplitude * shakeRadiusAmplitude * 0.75 * shakeType)));
|
||||||
|
event.setPitch((float) (pitch + (shakeTime * Math.sin(0.5 *Math.PI * shakeTime) * shakeAmplitude * shakeRadiusAmplitude * shakeType)));
|
||||||
|
event.setRoll((float) (roll + (shakeTime * Math.sin(0.5 *Math.PI * shakeTime) * shakeAmplitude * shakeRadiusAmplitude)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void droneBodyAngle(float RotX, float RotZ) {
|
public static void droneBodyAngle(float RotX, float RotZ) {
|
||||||
|
@ -998,7 +1049,7 @@ public class ClientEventHandler {
|
||||||
angle = Math.atan(Mth.abs((float) cameraLocation) / (lookDistance + 2.9)) * Mth.RAD_TO_DEG;
|
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 && player.getMainHandItem().getItem() instanceof CannonShellItem)) {
|
if (player.getMainHandItem().is(ModTags.Items.GUN)) {
|
||||||
event.setPitch((float) (pitch + cameraRot[0] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.2 : 0) * turnRot[0] + 3 * velocityY));
|
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) {
|
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));
|
event.setYaw((float) (yaw + cameraRot[1] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.8 : 0) * turnRot[1] - (cameraLocation > 0 ? 1 : -1) * angle * zoomPos));
|
||||||
|
@ -1091,6 +1142,15 @@ public class ClientEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void setPlayerInvisible(RenderPlayerEvent.Pre event) {
|
||||||
|
var otherPlayer = event.getEntity();
|
||||||
|
|
||||||
|
if (otherPlayer.getVehicle() instanceof ICannonEntity) {
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void handleRenderCrossHair(RenderGuiOverlayEvent.Pre event) {
|
public static void handleRenderCrossHair(RenderGuiOverlayEvent.Pre event) {
|
||||||
if (event.getOverlay() != VanillaGuiOverlay.CROSSHAIR.type()) {
|
if (event.getOverlay() != VanillaGuiOverlay.CROSSHAIR.type()) {
|
||||||
|
|
|
@ -120,14 +120,6 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
//计算防弹插板减伤
|
//计算防弹插板减伤
|
||||||
if (source.is(ModTags.DamageTypes.PROJECTILE) || source.is(ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
|
|
||||||
|| source.is(ModDamageTypes.PROJECTILE_BOOM)
|
|
||||||
|| source.is(ModDamageTypes.MINE)
|
|
||||||
|| source.is(ModDamageTypes.CANNON_FIRE)
|
|
||||||
|| source.is(ModDamageTypes.CUSTOM_EXPLOSION)
|
|
||||||
|| source.is(DamageTypes.EXPLOSION)
|
|
||||||
|| source.is(DamageTypes.PLAYER_EXPLOSION)
|
|
||||||
|| source.is(DamageTypes.MOB_PROJECTILE)) {
|
|
||||||
ItemStack armor = entity.getItemBySlot(EquipmentSlot.CHEST);
|
ItemStack armor = entity.getItemBySlot(EquipmentSlot.CHEST);
|
||||||
|
|
||||||
if (armor != ItemStack.EMPTY && armor.getTag() != null && armor.getTag().contains("ArmorPlate")) {
|
if (armor != ItemStack.EMPTY && armor.getTag() != null && armor.getTag().contains("ArmorPlate")) {
|
||||||
|
@ -150,7 +142,6 @@ public class LivingEventHandler {
|
||||||
|| source.is(DamageTypes.EXPLOSION) || source.is(DamageTypes.PLAYER_EXPLOSION)) {
|
|| source.is(DamageTypes.EXPLOSION) || source.is(DamageTypes.PLAYER_EXPLOSION)) {
|
||||||
damage *= 1 - 0.3 * Mth.clamp(entity.getAttributeValue(ModAttributes.BULLET_RESISTANCE.get()), 0, 1);
|
damage *= 1 - 0.3 * Mth.clamp(entity.getAttributeValue(ModAttributes.BULLET_RESISTANCE.get()), 0, 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
event.setAmount((float) damage);
|
event.setAmount((float) damage);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.mixins;
|
package com.atsuishio.superbwarfare.mixins;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.DroneEntity;
|
import com.atsuishio.superbwarfare.entity.DroneEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.Mk42Entity;
|
import com.atsuishio.superbwarfare.entity.Mk42Entity;
|
||||||
import com.atsuishio.superbwarfare.entity.Mle1934Entity;
|
import com.atsuishio.superbwarfare.entity.Mle1934Entity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
|
@ -42,11 +41,7 @@ public abstract class CameraMixin {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (player.getVehicle() != null && mc.player.getVehicle() instanceof ICannonEntity && Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
|
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
||||||
setRotation(player.getViewYRot(partialTicks), player.getViewXRot(partialTicks));
|
|
||||||
setPosition(player.getX(), player.getEyeY() + 1, player.getZ());
|
|
||||||
info.cancel();
|
|
||||||
} else if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
|
||||||
DroneEntity drone = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone"));
|
DroneEntity drone = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone"));
|
||||||
|
|
||||||
if (drone != null) {
|
if (drone != null) {
|
||||||
|
@ -69,11 +64,11 @@ public abstract class CameraMixin {
|
||||||
@Inject(method = "setup", at = @At("TAIL"))
|
@Inject(method = "setup", at = @At("TAIL"))
|
||||||
public void ia$setup(BlockGetter area, Entity entity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
|
public void ia$setup(BlockGetter area, Entity entity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
|
||||||
if (thirdPerson && entity.getVehicle() instanceof Mk42Entity) {
|
if (thirdPerson && entity.getVehicle() instanceof Mk42Entity) {
|
||||||
move(-getMaxZoom(8), 2, 0.0);
|
move(-getMaxZoom(8), 1, 0.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (thirdPerson && entity.getVehicle() instanceof Mle1934Entity) {
|
if (thirdPerson && entity.getVehicle() instanceof Mle1934Entity) {
|
||||||
move(-getMaxZoom(10), 2.3, 0.0);
|
move(-getMaxZoom(10), 1.3, 0.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && entity instanceof Player player && player.getMainHandItem().is(ModTags.Items.GUN)) {
|
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && entity instanceof Player player && player.getMainHandItem().is(ModTags.Items.GUN)) {
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.atsuishio.superbwarfare.network.message;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class ShakeClientMessage {
|
||||||
|
public double time;
|
||||||
|
public double radius;
|
||||||
|
public double amplitude;
|
||||||
|
|
||||||
|
public double x;
|
||||||
|
|
||||||
|
public double y;
|
||||||
|
|
||||||
|
public double z;
|
||||||
|
|
||||||
|
public ShakeClientMessage(double time, double radius, double amplitude, double x, double y, double z) {
|
||||||
|
this.time = time;
|
||||||
|
this.radius = radius;
|
||||||
|
this.amplitude = amplitude;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encode(ShakeClientMessage message, FriendlyByteBuf buffer) {
|
||||||
|
buffer.writeDouble(message.time);
|
||||||
|
buffer.writeDouble(message.radius);
|
||||||
|
buffer.writeDouble(message.amplitude);
|
||||||
|
buffer.writeDouble(message.x);
|
||||||
|
buffer.writeDouble(message.y);
|
||||||
|
buffer.writeDouble(message.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShakeClientMessage decode(FriendlyByteBuf buffer) {
|
||||||
|
return new ShakeClientMessage(buffer.readDouble(), buffer.readDouble(), buffer.readDouble(), buffer.readDouble(), buffer.readDouble(), buffer.readDouble());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handle(ShakeClientMessage message, Supplier<NetworkEvent.Context> context) {
|
||||||
|
context.get().enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT,
|
||||||
|
() -> () -> ClientEventHandler.handleShakeClient(message.time, message.radius, message.amplitude, message.x, message.y, message.z, context)));
|
||||||
|
context.get().setPacketHandled(true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
package com.atsuishio.superbwarfare.tools;
|
package com.atsuishio.superbwarfare.tools;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
|
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -18,8 +21,10 @@ import net.minecraft.world.level.gameevent.GameEvent;
|
||||||
import net.minecraft.world.level.material.FluidState;
|
import net.minecraft.world.level.material.FluidState;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -59,6 +64,15 @@ public class CustomExplosion extends Explosion {
|
||||||
|
|
||||||
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction) {
|
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction) {
|
||||||
this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction);
|
this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction);
|
||||||
|
|
||||||
|
final Vec3 center = new Vec3(pToBlowX, pToBlowY, pToBlowZ);
|
||||||
|
|
||||||
|
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4 * radius), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||||
|
|
||||||
|
if (target instanceof ServerPlayer serverPlayer) {
|
||||||
|
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(20 + 0.02 * damage,3 * pRadius,60 + 0.05 * damage, pToBlowX, pToBlowY, pToBlowZ));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomExplosion setFireTime(int fireTime) {
|
public CustomExplosion setFireTime(int fireTime) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.superbwarfare]]
|
[[dependencies.superbwarfare]]
|
||||||
modId = "curios"
|
modId = "curios"
|
||||||
mandatory = false
|
mandatory = true
|
||||||
versionRange = "[5.4.0,)"
|
versionRange = "[5.4.0,)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
Loading…
Add table
Reference in a new issue