优化载具

This commit is contained in:
Atsuihsio 2024-12-28 03:11:37 +08:00
parent 5baedcae43
commit 2db63de858
9 changed files with 109 additions and 193 deletions

View file

@ -3,8 +3,10 @@ package com.atsuishio.superbwarfare.entity;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.CannonConfig;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModParticleTypes;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
import com.atsuishio.superbwarfare.tools.*;
import net.minecraft.core.BlockPos;
@ -22,8 +24,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
@ -31,7 +31,6 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.ProjectileUtil;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
@ -141,30 +140,6 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
return true;
}
@Override
public InteractionResult interact(Player player, InteractionHand hand) {
if (player.isShiftKeyDown()) {
if (player.getMainHandItem().is(ModItems.CROWBAR.get()) && this.getFirstPassenger() == null) {
ItemStack stack = ContainerBlockItem.createInstance(this);
if (!player.addItem(stack)) {
player.drop(stack, false);
}
this.discard();
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
return InteractionResult.PASS;
} else {
if (this.getFirstPassenger() == null) {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
player.startRiding(this);
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
}
return InteractionResult.PASS;
}
@Override
public Vec3 getDeltaMovement() {
return new Vec3(0, Math.min(super.getDeltaMovement().y, 0), 0);

View file

@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.config.server.CannonConfig;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem;
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
@ -24,8 +23,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.player.Player;
@ -120,31 +117,6 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit
return true;
}
@Override
public InteractionResult interact(Player player, InteractionHand hand) {
if (player.isShiftKeyDown()) {
if (player.getMainHandItem().is(ModItems.CROWBAR.get()) && this.getFirstPassenger() == null) {
ItemStack stack = ContainerBlockItem.createInstance(this);
if (!player.addItem(stack)) {
player.drop(stack, false);
}
this.discard();
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
return InteractionResult.PASS;
} else {
if (this.getFirstPassenger() == null) {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
player.startRiding(this);
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
}
return InteractionResult.PASS;
}
@Override
public Vec3 getDeltaMovement() {
return new Vec3(0, Math.min(super.getDeltaMovement().y, 0), 0);

View file

@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.config.server.CannonConfig;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem;
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
@ -24,8 +23,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.player.Player;
@ -135,31 +132,6 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEn
return true;
}
@Override
public InteractionResult interact(Player player, InteractionHand hand) {
if (player.isShiftKeyDown()) {
if (player.getMainHandItem().is(ModItems.CROWBAR.get()) && this.getFirstPassenger() == null) {
ItemStack stack = ContainerBlockItem.createInstance(this);
if (!player.addItem(stack)) {
player.drop(stack, false);
}
this.discard();
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
return InteractionResult.PASS;
} else {
if (this.getFirstPassenger() == null) {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
player.startRiding(this);
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
}
return InteractionResult.PASS;
}
@Override
public Vec3 getDeltaMovement() {
return new Vec3(0, Math.min(super.getDeltaMovement().y, 0), 0);

View file

@ -4,6 +4,7 @@ import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModSounds;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
@ -30,7 +31,9 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
@Override
public void baseTick() {
super.baseTick();
if (this.level() instanceof ServerLevel) {
crushEntities(this.getDeltaMovement());
}
this.refreshDimensions();
}
@ -40,23 +43,27 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
*/
public void crushEntities(Vec3 velocity) {
var frontBox = getBoundingBox().move(velocity.scale(0.5));
var velAdd = velocity.add(0, 0, 0).scale(1.5);
var velAdd = velocity.add(0, 0, 0).scale(1.3);
for (var entity : level().getEntities(EntityTypeTest.forClass(Entity.class), frontBox, entity -> entity != this && entity != getFirstPassenger() && entity.getVehicle() == null)) {
double entitySize = entity.getBbWidth() * entity.getBbHeight();
double thisSize = this.getBbWidth() * this.getBbHeight();
double f = Math.min(entitySize / thisSize, 2);
double f1 = Math.min(thisSize / entitySize, 4);
if (!(entity instanceof TargetEntity)) {
this.push(-f * velAdd.x, -f * velAdd.y, -f * velAdd.z);
}
if (velocity.length() > 0.25 && entity.isAlive() && !(entity instanceof ItemEntity || entity instanceof Projectile || entity instanceof ProjectileEntity)) {
if (entity.isAlive() && !(entity instanceof ItemEntity || entity instanceof Projectile || entity instanceof ProjectileEntity)) {
if (velocity.horizontalDistance() > 0.5) {
if (!this.level().isClientSide) {
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
}
if (!(entity instanceof TargetEntity)) {
this.push(-f * velAdd.x, -f * velAdd.y, -f * velAdd.z);
}
entity.push(f1 * velAdd.x, f1 * velAdd.y, f1 * velAdd.z);
entity.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (20 * velocity.length()));
entity.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (thisSize * 60 * (velocity.horizontalDistance() - 0.5)));
} else {
entity.push(0.2 * f1 * velAdd.x, 0.2 * f1 * velAdd.y, 0.2 * f1 * velAdd.z);
}
}
}
}

View file

@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.config.server.CannonConfig;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
import com.atsuishio.superbwarfare.item.PerkItem;
import com.atsuishio.superbwarfare.menu.VehicleMenu;
import com.atsuishio.superbwarfare.network.ModVariables;
@ -30,13 +29,10 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.ContainerHelper;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
@ -50,7 +46,6 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.ContainerEntity;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
@ -183,41 +178,6 @@ public class SpeedboatEntity extends MobileVehicleEntity implements GeoEntity, I
return true;
}
@Override
public InteractionResult interact(Player player, InteractionHand hand) {
if (player.getVehicle() == this) return InteractionResult.PASS;
if (player.isShiftKeyDown()) {
if (player.getMainHandItem().is(ModItems.CROWBAR.get()) && this.getFirstPassenger() == null) {
ItemStack stack = ContainerBlockItem.createInstance(this);
if (!player.addItem(stack)) {
player.drop(stack, false);
}
this.remove(RemovalReason.DISCARDED);
this.discard();
return InteractionResult.sidedSuccess(this.level().isClientSide());
} else {
player.openMenu(this);
return !player.level().isClientSide ? InteractionResult.CONSUME : InteractionResult.SUCCESS;
}
} else {
if (player.getMainHandItem().is(Items.IRON_INGOT)) {
if (this.getHealth() < this.getMaxHealth()) {
this.heal(Math.min(0.1f * this.getMaxHealth(), this.getMaxHealth()));
player.getMainHandItem().shrink(1);
if (!this.level().isClientSide) {
this.level().playSound(null, this, SoundEvents.IRON_GOLEM_REPAIR, this.getSoundSource(), 1, 1);
}
} else {
player.startRiding(this);
}
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
player.startRiding(this);
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
}
public double getSubmergedHeight(Entity entity) {
for (FluidType fluidType : ForgeRegistries.FLUID_TYPES.get().getValues()) {
if (entity.level().getFluidState(entity.blockPosition()).getFluidType() == fluidType)

View file

@ -1,16 +1,24 @@
package com.atsuishio.superbwarfare.entity;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.AreaEffectCloud;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Math;
@ -50,6 +58,40 @@ public class VehicleEntity extends Entity {
compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID));
}
@Override
public InteractionResult interact(Player player, InteractionHand hand) {
if (player.getVehicle() == this) return InteractionResult.PASS;
if (player.isShiftKeyDown() && player.getMainHandItem().is(ModItems.CROWBAR.get())) {
ItemStack stack = ContainerBlockItem.createInstance(this);
if (!player.addItem(stack)) {
player.drop(stack, false);
}
this.remove(RemovalReason.DISCARDED);
this.discard();
} else if (player.getMainHandItem().is(Items.IRON_INGOT)) {
if (this.getHealth() < this.getMaxHealth()) {
this.heal(Math.min(50, this.getMaxHealth()));
player.getMainHandItem().shrink(1);
if (!this.level().isClientSide) {
this.level().playSound(null, this, SoundEvents.IRON_GOLEM_REPAIR, this.getSoundSource(), 0.5f, 1);
}
} else if (!this.level().isClientSide) {
if (this.getFirstPassenger() == null) {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
}
}
} else if (!this.level().isClientSide) {
if (this.getFirstPassenger() == null) {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
}
}
return InteractionResult.PASS;
}
@Override
public boolean hurt(DamageSource source, float amount) {
if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud)
@ -70,6 +112,10 @@ public class VehicleEntity extends Entity {
return false;
if (source.is(DamageTypes.WITHER_SKULL))
return false;
if (source.is(DamageTypes.ON_FIRE))
return false;
if (source.is(DamageTypes.IN_FIRE))
return false;
if (source.getEntity() != null) {
this.entityData.set(LAST_ATTACKER_UUID, source.getEntity().getStringUUID());
}

View file

@ -3,9 +3,7 @@ package com.atsuishio.superbwarfare.entity;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
import com.atsuishio.superbwarfare.tools.ParticleTool;
@ -18,13 +16,9 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkHooks;
@ -43,6 +37,8 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity,
public float rightWheelRot;
public float leftWheelRotO;
public float rightWheelRotO;
public int jumpCoolDown;
public int handBusyTime;
public WheelChairEntity(PlayMessages.SpawnEntity packet, Level world) {
this(ModEntities.WHEEL_CHAIR.get(), world);
@ -91,63 +87,37 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity,
return true;
}
@Override
public InteractionResult interact(Player player, InteractionHand hand) {
if (player.getVehicle() == this) return InteractionResult.PASS;
if (player.isShiftKeyDown() && player.getMainHandItem().is(ModItems.CROWBAR.get())) {
ItemStack stack = ContainerBlockItem.createInstance(this);
if (!player.addItem(stack)) {
player.drop(stack, false);
}
this.remove(RemovalReason.DISCARDED);
this.discard();
} else {
if (player.getMainHandItem().is(Items.IRON_INGOT)) {
if (this.getHealth() < this.getMaxHealth()) {
this.heal(Math.min(0.5f * this.getMaxHealth(), this.getMaxHealth()));
player.getMainHandItem().shrink(1);
if (!this.level().isClientSide) {
this.level().playSound(null, this, SoundEvents.IRON_GOLEM_REPAIR, this.getSoundSource(), 1, 1);
}
} else {
player.startRiding(this);
}
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
player.startRiding(this);
}
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
@Override
public void baseTick() {
super.baseTick();
if (jumpCoolDown > 0 && onGround()) {
jumpCoolDown--;
}
if (handBusyTime > 0) {
handBusyTime--;
}
leftWheelRotO = this.getLeftWheelRot();
rightWheelRotO = this.getRightWheelRot();
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.078, 0.0));
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.048, 0.0));
if (this.onGround()) {
float f = 0.7f + 0.2f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90;
this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.99, f));
this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.95, f));
} else {
this.setDeltaMovement(this.getDeltaMovement().multiply(0.99, 0.99, 0.99));
this.setDeltaMovement(this.getDeltaMovement().multiply(0.99, 0.95, 0.99));
}
this.move(MoverType.SELF, this.getDeltaMovement());
if (this.getHealth() <= 0) {
this.ejectPassengers();
destroy();
}
if (level().isClientSide && this.getEnergy() > 0) {
level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), ModSounds.WHEEL_CHAIR_ENGINE.get(), this.getSoundSource(), (float) (0.2 * this.getDeltaMovement().length()), (random.nextFloat() * 0.1f + 0.7f), false);
}
this.setSprinting(this.getDeltaMovement().length() > 0.15);
this.setSprinting(this.getDeltaMovement().horizontalDistance() > 0.15);
travel();
this.refreshDimensions();
}
@ -181,27 +151,35 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity,
}
}
if (this.upInputDown && this.onGround() && this.getEnergy() > 400) {
if (this.upInputDown && this.onGround() && this.getEnergy() > 400 && jumpCoolDown == 0) {
if (passenger instanceof ServerPlayer serverPlayer) {
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.WHEEL_CHAIR_JUMP.get(), SoundSource.PLAYERS, 1, 1);
}
this.extraEnergy(400);
this.setDeltaMovement(this.getDeltaMovement().add(0, 0.58, 0));
this.setDeltaMovement(this.getDeltaMovement().add(0, 0.48, 0));
jumpCoolDown = 5;
}
if (this.forwardInputDown || this.backInputDown) {
this.extraEnergy(1);
}
if (passenger instanceof Player player && handBusyTime > 0) {
var localPlayer = Minecraft.getInstance().player;
if (localPlayer != null && player.getUUID().equals(localPlayer.getUUID())) {
localPlayer.handsBusy = true;
}
}
power *= 0.87f;
float angle = (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1));
double s0;
if (Mth.abs(angle) < 90) {
s0 = this.getDeltaMovement().length();
s0 = this.getDeltaMovement().horizontalDistance();
} else {
s0 = -this.getDeltaMovement().length();
s0 = -this.getDeltaMovement().horizontalDistance();
}
this.setLeftWheelRot((float) (this.getLeftWheelRot() - 1 * s0) - 0.015f * Mth.clamp(0.4f * diffY, -5f, 5f));
@ -211,9 +189,8 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity,
// player.displayClientMessage(Component.literal("Angle:" + new java.text.DecimalFormat("##.##").format(this.getRightWheelRot())), true);
// }
if (this.onGround()) {
this.setDeltaMovement(this.getDeltaMovement().add(Mth.sin(-this.getYRot() * 0.017453292F) * power, 0.0, Mth.cos(this.getYRot() * 0.017453292F) * power));
}
this.setDeltaMovement(this.getDeltaMovement().add(Mth.sin(-this.getYRot() * 0.017453292F) * (this.onGround() ? 1 : 0.1) * power, 0.0, Mth.cos(this.getYRot() * 0.017453292F) * (this.onGround() ? 1 : 0.1) * power));
}
public void moveWithOutPower(Player player, boolean forward) {
@ -223,11 +200,7 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity,
}
player.causeFoodExhaustion(0.03F);
var localPlayer = Minecraft.getInstance().player;
if (localPlayer != null && player.getUUID().equals(localPlayer.getUUID())) {
localPlayer.handsBusy = true;
}
handBusyTime = 4;
this.forwardInputDown = false;
this.backInputDown = false;
}

View file

@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.event;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.common.GameplayConfig;
import com.atsuishio.superbwarfare.entity.VehicleEntity;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
@ -20,11 +21,13 @@ import net.minecraft.util.Mth;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@ -388,4 +391,12 @@ public class PlayerEventHandler {
event.setMaterialCost(1);
}
}
@SubscribeEvent
public static void onEntityFall(LivingFallEvent event) {
LivingEntity living = event.getEntity();
if (living.getVehicle() instanceof VehicleEntity) {
event.setCanceled(true);
}
}
}

View file

@ -26,10 +26,10 @@ public class ModEntities {
public static final RegistryObject<EntityType<MortarEntity>> MORTAR = register("mortar",
EntityType.Builder.<MortarEntity>of(MortarEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(MortarEntity::new).fireImmune().sized(0.8f, 1.4f));
public static final RegistryObject<EntityType<SenpaiEntity>> SENPAI = register("senpai",
EntityType.Builder.<SenpaiEntity>of(SenpaiEntity::new, MobCategory.MONSTER).setShouldReceiveVelocityUpdates(true).setTrackingRange(1024).setUpdateInterval(3).setCustomClientFactory(SenpaiEntity::new)
EntityType.Builder.<SenpaiEntity>of(SenpaiEntity::new, MobCategory.MONSTER).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(SenpaiEntity::new)
.sized(0.6f, 2f));
public static final RegistryObject<EntityType<ClaymoreEntity>> CLAYMORE = register("claymore",
EntityType.Builder.<ClaymoreEntity>of(ClaymoreEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(1).sized(0.5f, 0.5f));
EntityType.Builder.<ClaymoreEntity>of(ClaymoreEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(1).sized(0.5f, 0.5f));
public static final RegistryObject<EntityType<Mk42Entity>> MK_42 = register("mk_42",
EntityType.Builder.<Mk42Entity>of(Mk42Entity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(Mk42Entity::new).fireImmune().sized(3.4f, 3.5f));
public static final RegistryObject<EntityType<Mle1934Entity>> MLE_1934 = register("mle_1934",