添加更多能撞掉的方块
This commit is contained in:
parent
f1a1c728e6
commit
e2f28c7787
5 changed files with 105 additions and 82 deletions
|
@ -101,7 +101,7 @@ public class ModItemTagProvider extends ItemTagsProvider {
|
||||||
this.tag(ModTags.Items.MILITARY_ARMOR).add(ModItems.RU_CHEST_6B43.get(), ModItems.US_CHEST_IOTV.get());
|
this.tag(ModTags.Items.MILITARY_ARMOR).add(ModItems.RU_CHEST_6B43.get(), ModItems.US_CHEST_IOTV.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TagKey<Item> forgeTag(String name) {
|
public static TagKey<Item> forgeTag(String name) {
|
||||||
return ItemTags.create(new ResourceLocation("forge", name));
|
return ItemTags.create(new ResourceLocation("forge", name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,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.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;
|
||||||
|
@ -348,6 +347,10 @@ public class Bmp2Entity extends ContainerMobileEntity implements GeoEntity, ICha
|
||||||
}
|
}
|
||||||
|
|
||||||
collideBlock();
|
collideBlock();
|
||||||
|
if (this.getDeltaMovement().length() > 0.15) {
|
||||||
|
collideHardBlock();
|
||||||
|
}
|
||||||
|
|
||||||
gunnerAngle();
|
gunnerAngle();
|
||||||
lowHealthWarning();
|
lowHealthWarning();
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
|
@ -487,20 +490,6 @@ public class Bmp2Entity extends ContainerMobileEntity implements GeoEntity, ICha
|
||||||
return -Mth.lerp(pPartialTick, turretYRotO - this.yRotO, getTurretYRot() - this.getYRot());
|
return -Mth.lerp(pPartialTick, turretYRotO - this.yRotO, getTurretYRot() - this.getYRot());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撞掉莲叶和冰块
|
|
||||||
*/
|
|
||||||
public void collideBlock() {
|
|
||||||
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
|
||||||
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
|
||||||
BlockState blockstate = this.level().getBlockState(pos);
|
|
||||||
if (blockstate.is(Blocks.LILY_PAD) || blockstate.is(Blocks.CACTUS)) {
|
|
||||||
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);
|
||||||
|
|
|
@ -36,7 +36,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.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;
|
||||||
|
@ -308,6 +307,11 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC
|
||||||
}
|
}
|
||||||
|
|
||||||
collideBlock();
|
collideBlock();
|
||||||
|
if (this.getDeltaMovement().length() > 0.2) {
|
||||||
|
collideHardBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gunnerAngle();
|
gunnerAngle();
|
||||||
lowHealthWarning();
|
lowHealthWarning();
|
||||||
|
|
||||||
|
@ -460,20 +464,6 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC
|
||||||
return -Mth.lerp(pPartialTick, turretYRotO - this.yRotO, getTurretYRot() - this.getYRot());
|
return -Mth.lerp(pPartialTick, turretYRotO - this.yRotO, getTurretYRot() - this.getYRot());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撞掉莲叶和冰块
|
|
||||||
*/
|
|
||||||
public void collideBlock() {
|
|
||||||
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
|
||||||
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
|
||||||
BlockState blockstate = this.level().getBlockState(pos);
|
|
||||||
if (blockstate.is(Blocks.LILY_PAD) || blockstate.is(Blocks.CACTUS)) {
|
|
||||||
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);
|
||||||
|
|
|
@ -7,13 +7,16 @@ import com.atsuishio.superbwarfare.entity.projectile.LaserEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
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.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
import net.minecraft.world.entity.AreaEffectCloud;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -23,8 +26,12 @@ import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.projectile.Projectile;
|
import net.minecraft.world.entity.projectile.Projectile;
|
||||||
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.level.entity.EntityTypeTest;
|
import net.minecraft.world.level.entity.EntityTypeTest;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraftforge.common.Tags;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
@ -79,9 +86,43 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void collideBlock() {
|
||||||
|
if (level() instanceof ServerLevel) {
|
||||||
|
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
||||||
|
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
||||||
|
BlockState blockstate = this.level().getBlockState(pos);
|
||||||
|
if (blockstate.is(Blocks.LILY_PAD) || blockstate.is(Blocks.CACTUS)
|
||||||
|
|| blockstate.is(BlockTags.LEAVES) || blockstate.is(BlockTags.FENCES)
|
||||||
|
|| blockstate.is(BlockTags.FENCE_GATES) || blockstate.is(BlockTags.DOORS)
|
||||||
|
|| blockstate.is(BlockTags.TRAPDOORS) || blockstate.is(Blocks.BAMBOO)
|
||||||
|
|| blockstate.is(Tags.Blocks.GLASS) || blockstate.is(Tags.Blocks.GLASS_PANES)
|
||||||
|
|| blockstate.is(Blocks.MELON) || blockstate.is(Blocks.PUMPKIN)
|
||||||
|
|| blockstate.is(Blocks.HAY_BLOCK) || blockstate.is(Blocks.BELL)
|
||||||
|
|| blockstate.is(BlockTags.WALLS) || blockstate.is(Blocks.CHAIN)) {
|
||||||
|
this.level().destroyBlock(pos, true);
|
||||||
|
this.setDeltaMovement(this.getDeltaMovement().scale(0.96));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void collideHardBlock() {
|
||||||
|
if (level() instanceof ServerLevel) {
|
||||||
|
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
||||||
|
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
||||||
|
BlockState blockstate = this.level().getBlockState(pos);
|
||||||
|
if (blockstate.is(BlockTags.LOGS) || blockstate.is(BlockTags.PLANKS)) {
|
||||||
|
this.level().destroyBlock(pos, true);
|
||||||
|
this.setDeltaMovement(this.getDeltaMovement().scale(0.6));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void move(@NotNull MoverType movementType, @NotNull Vec3 movement) {
|
public void move(@NotNull MoverType movementType, @NotNull Vec3 movement) {
|
||||||
super.move(movementType, movement);
|
super.move(movementType, movement);
|
||||||
|
if (level() instanceof ServerLevel) {
|
||||||
if (lastTickSpeed < 0.3 || collisionCoolDown > 0) return;
|
if (lastTickSpeed < 0.3 || collisionCoolDown > 0) return;
|
||||||
|
|
||||||
if ((verticalCollision)) {
|
if ((verticalCollision)) {
|
||||||
|
@ -108,6 +149,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
this.entityData.set(POWER, 0.4f * entityData.get(POWER));
|
this.entityData.set(POWER, 0.4f * entityData.get(POWER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void bounceHorizontal(Direction direction) {
|
public void bounceHorizontal(Direction direction) {
|
||||||
switch (direction.getAxis()) {
|
switch (direction.getAxis()) {
|
||||||
|
@ -160,6 +202,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
* @param velocity 动量
|
* @param velocity 动量
|
||||||
*/
|
*/
|
||||||
public void crushEntities(Vec3 velocity) {
|
public void crushEntities(Vec3 velocity) {
|
||||||
|
if (level() instanceof ServerLevel) {
|
||||||
if (!this.canCrushEntities()) return;
|
if (!this.canCrushEntities()) return;
|
||||||
if (velocity.horizontalDistance() < 0.25) return;
|
if (velocity.horizontalDistance() < 0.25) return;
|
||||||
if (isRemoved()) return;
|
if (isRemoved()) return;
|
||||||
|
@ -197,6 +240,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3f getForwardDirection() {
|
public Vector3f getForwardDirection() {
|
||||||
return new Vector3f(
|
return new Vector3f(
|
||||||
|
|
|
@ -244,7 +244,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
collideBlock();
|
collideBoatBlock();
|
||||||
gunnerAngle();
|
gunnerAngle();
|
||||||
lowHealthWarning();
|
lowHealthWarning();
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity,
|
||||||
/**
|
/**
|
||||||
* 撞掉莲叶和冰块
|
* 撞掉莲叶和冰块
|
||||||
*/
|
*/
|
||||||
public void collideBlock() {
|
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);
|
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) -> {
|
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
||||||
BlockState blockstate = this.level().getBlockState(pos);
|
BlockState blockstate = this.level().getBlockState(pos);
|
||||||
|
|
Loading…
Add table
Reference in a new issue