调整载具在不开启破坏方块下也能撞掉莲叶,将冰添加到“坚硬方块”中
This commit is contained in:
parent
ef45e840b4
commit
996cae06f3
3 changed files with 26 additions and 24 deletions
|
@ -85,23 +85,37 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
crushEntities(this.getDeltaMovement());
|
crushEntities(this.getDeltaMovement());
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.06, 0.0));
|
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.06, 0.0));
|
||||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||||
|
collideLilyPadBlock();
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void collideLilyPadBlock() {
|
||||||
|
if (level() instanceof ServerLevel) {
|
||||||
|
AABB aabb = getBoundingBox().inflate(0.05).move(this.getDeltaMovement().scale(0.6));
|
||||||
|
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
||||||
|
BlockState blockstate = this.level().getBlockState(pos);
|
||||||
|
if (blockstate.is(Blocks.LILY_PAD)) {
|
||||||
|
this.level().destroyBlock(pos, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void collideBlock() {
|
public void collideBlock() {
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
if (!VehicleConfig.COLLISION_DESTROY_BLOCKS.get()) return;
|
if (!VehicleConfig.COLLISION_DESTROY_BLOCKS.get()) return;
|
||||||
|
|
||||||
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
AABB aabb = getBoundingBox().move(this.getDeltaMovement().scale(0.6));
|
||||||
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
||||||
BlockState blockstate = this.level().getBlockState(pos);
|
BlockState blockstate = this.level().getBlockState(pos);
|
||||||
if (blockstate.is(Blocks.LILY_PAD) || blockstate.is(Blocks.CACTUS)
|
if (blockstate.is(Blocks.CACTUS)
|
||||||
|| blockstate.is(BlockTags.LEAVES) || blockstate.is(BlockTags.FENCES)
|
|| blockstate.is(BlockTags.LEAVES) || blockstate.is(BlockTags.FENCES)
|
||||||
|| blockstate.is(BlockTags.FENCE_GATES) || blockstate.is(BlockTags.DOORS)
|
|| blockstate.is(BlockTags.FENCE_GATES) || blockstate.is(BlockTags.DOORS)
|
||||||
|| blockstate.is(BlockTags.TRAPDOORS) || blockstate.is(Blocks.BAMBOO)
|
|| blockstate.is(BlockTags.TRAPDOORS) || blockstate.is(Blocks.BAMBOO)
|
||||||
|| blockstate.is(Blocks.MELON) || blockstate.is(Blocks.PUMPKIN)
|
|| blockstate.is(Blocks.MELON) || blockstate.is(Blocks.PUMPKIN)
|
||||||
|| blockstate.is(Blocks.HAY_BLOCK) || blockstate.is(Blocks.BELL)
|
|| blockstate.is(Blocks.HAY_BLOCK) || blockstate.is(Blocks.BELL)
|
||||||
|| blockstate.is(BlockTags.WALLS) || blockstate.is(Blocks.CHAIN)) {
|
|| blockstate.is(BlockTags.WALLS) || blockstate.is(Blocks.CHAIN)
|
||||||
|
|| blockstate.is(Blocks.SNOW_BLOCK)) {
|
||||||
this.level().destroyBlock(pos, true);
|
this.level().destroyBlock(pos, true);
|
||||||
this.setDeltaMovement(this.getDeltaMovement().scale(0.96));
|
this.setDeltaMovement(this.getDeltaMovement().scale(0.96));
|
||||||
}
|
}
|
||||||
|
@ -113,11 +127,13 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
if (!VehicleConfig.COLLISION_DESTROY_HARD_BLOCKS.get()) return;
|
if (!VehicleConfig.COLLISION_DESTROY_HARD_BLOCKS.get()) return;
|
||||||
|
|
||||||
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
AABB aabb = getBoundingBox().move(this.getDeltaMovement().scale(0.6));
|
||||||
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
||||||
BlockState blockstate = this.level().getBlockState(pos);
|
BlockState blockstate = this.level().getBlockState(pos);
|
||||||
if (blockstate.is(BlockTags.LOGS) || blockstate.is(BlockTags.PLANKS)
|
if (blockstate.is(BlockTags.LOGS) || blockstate.is(BlockTags.PLANKS)
|
||||||
|| blockstate.is(Tags.Blocks.GLASS) || blockstate.is(Tags.Blocks.GLASS_PANES)) {
|
|| blockstate.is(Tags.Blocks.GLASS) || blockstate.is(Tags.Blocks.GLASS_PANES)
|
||||||
|
|| blockstate.is(Blocks.ICE) || blockstate.is(Blocks.FROSTED_ICE)
|
||||||
|
|| blockstate.is(Blocks.PACKED_ICE) || blockstate.is(Blocks.BLUE_ICE)) {
|
||||||
this.level().destroyBlock(pos, true);
|
this.level().destroyBlock(pos, true);
|
||||||
this.setDeltaMovement(this.getDeltaMovement().scale(0.6));
|
this.setDeltaMovement(this.getDeltaMovement().scale(0.6));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
@ -35,8 +34,6 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Explosion;
|
import net.minecraft.world.level.Explosion;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
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.fluids.FluidType;
|
import net.minecraftforge.fluids.FluidType;
|
||||||
|
@ -245,9 +242,12 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity,
|
||||||
sendParticle(serverLevel, ParticleTypes.BUBBLE_COLUMN_UP, this.getX() - 4.5 * this.getLookAngle().x, this.getY() - 0.25, this.getZ() - 4.5 * this.getLookAngle().z, (int) (40 * Mth.abs(this.entityData.get(POWER))), 0.15, 0.15, 0.15, 0.02, true);
|
sendParticle(serverLevel, ParticleTypes.BUBBLE_COLUMN_UP, this.getX() - 4.5 * this.getLookAngle().x, this.getY() - 0.25, this.getZ() - 4.5 * this.getLookAngle().z, (int) (40 * Mth.abs(this.entityData.get(POWER))), 0.15, 0.15, 0.15, 0.02, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
collideBoatBlock();
|
|
||||||
gunnerAngle();
|
gunnerAngle();
|
||||||
lowHealthWarning();
|
lowHealthWarning();
|
||||||
|
collideBlock();
|
||||||
|
if (this.getDeltaMovement().length() > 0.15) {
|
||||||
|
collideHardBlock();
|
||||||
|
}
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
@ -304,20 +304,6 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity,
|
||||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撞掉莲叶和冰块
|
|
||||||
*/
|
|
||||||
public void collideBoatBlock() {
|
|
||||||
AABB aabb = AABB.ofSize(new Vec3(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ()), 3.6, 2.6, 3.6);
|
|
||||||
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
|
||||||
BlockState blockstate = this.level().getBlockState(pos);
|
|
||||||
if (blockstate.is(Blocks.LILY_PAD) || blockstate.is(Blocks.ICE) || blockstate.is(Blocks.FROSTED_ICE)) {
|
|
||||||
this.level().destroyBlock(pos, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void travel() {
|
public void travel() {
|
||||||
Entity passenger0 = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
Entity passenger0 = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class VehicleEntity extends Entity {
|
||||||
if (source.is(DamageTypes.WITHER_SKULL))
|
if (source.is(DamageTypes.WITHER_SKULL))
|
||||||
return false;
|
return false;
|
||||||
if (source.is(ModDamageTypes.VEHICLE_STRIKE)) {
|
if (source.is(ModDamageTypes.VEHICLE_STRIKE)) {
|
||||||
amount -= 20;
|
amount -= 8;
|
||||||
crash = true;
|
crash = true;
|
||||||
} else {
|
} else {
|
||||||
crash = false;
|
crash = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue