调整载具碰撞方块

This commit is contained in:
Atsuishio 2025-04-18 15:01:53 +08:00 committed by Light_Quanta
parent ad2db9c888
commit 79743d316c
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
4 changed files with 9 additions and 31 deletions

View file

@ -1,7 +1,7 @@
// 1.21.1 2025-04-07T06:12:27.7140791 Tags for minecraft:block mod id superbwarfare
// 1.21.1 2025-04-18T21:42:41.5729186 Tags for minecraft:block mod id superbwarfare
0acfd31854bf15f2c108138b3df7206bd2593e6b data/minecraft/tags/block/mineable/axe.json
8965b7e0b3f7494b78b596ed00b9721b483b0796 data/minecraft/tags/block/mineable/pickaxe.json
3da7f021790388a122717f16f51c7ec5232eebcb data/minecraft/tags/block/mineable/shovel.json
f42a8c01336e64b74da966f03d45ee0d60ac5d6b data/minecraft/tags/block/needs_iron_tool.json
32d65f7120acb277f54e1a7d4f6163456b9d1030 data/superbwarfare/tags/block/hard_collision.json
72e1c9e318d4c8df58bc2b667c48ddb3c1e2d747 data/superbwarfare/tags/block/soft_collision.json
68e02f66c2338932da61ce57dde5221401b9340c data/superbwarfare/tags/block/soft_collision.json

View file

@ -1,6 +1,5 @@
{
"values": [
"#minecraft:leaves",
"#minecraft:fences",
"#minecraft:fence_gates",
"#minecraft:doors",
@ -10,7 +9,6 @@
"#minecraft:stairs",
"#minecraft:slabs",
"#c:glass_panes",
"minecraft:cactus",
"minecraft:bamboo",
"minecraft:melon",
"minecraft:pumpkin",
@ -18,7 +16,6 @@
"minecraft:bell",
"minecraft:chain",
"minecraft:snow_block",
"minecraft:cobweb",
"minecraft:mushroom_stem",
"minecraft:brown_mushroom_block",
"minecraft:red_mushroom_block"

View file

@ -38,10 +38,10 @@ public class ModBlockTagProvider extends BlockTagsProvider {
this.tag(BlockTags.MINEABLE_WITH_SHOVEL).add(ModBlocks.SANDBAG.get());
this.tag(ModTags.Blocks.SOFT_COLLISION)
.addTags(BlockTags.LEAVES, BlockTags.FENCES, BlockTags.FENCE_GATES, BlockTags.DOORS, BlockTags.TRAPDOORS, BlockTags.WALLS, BlockTags.WOOL,
.addTags(BlockTags.FENCES, BlockTags.FENCE_GATES, BlockTags.DOORS, BlockTags.TRAPDOORS, BlockTags.WALLS, BlockTags.WOOL,
BlockTags.STAIRS, BlockTags.SLABS, Tags.Blocks.GLASS_PANES)
.add(Blocks.CACTUS, Blocks.BAMBOO, Blocks.MELON, Blocks.PUMPKIN, Blocks.HAY_BLOCK, Blocks.BELL, Blocks.CHAIN, Blocks.SNOW_BLOCK,
Blocks.COBWEB, Blocks.MUSHROOM_STEM, Blocks.BROWN_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM_BLOCK);
.add(Blocks.BAMBOO, Blocks.MELON, Blocks.PUMPKIN, Blocks.HAY_BLOCK, Blocks.BELL, Blocks.CHAIN, Blocks.SNOW_BLOCK,
Blocks.MUSHROOM_STEM, Blocks.BROWN_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM_BLOCK);
this.tag(ModTags.Blocks.HARD_COLLISION)
.addTags(BlockTags.LOGS, BlockTags.PLANKS, Tags.Blocks.GLASS_BLOCKS)

View file

@ -21,6 +21,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
@ -224,7 +225,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
}
this.move(MoverType.SELF, this.getDeltaMovement());
collideLilyPadBlock();
baseCollideBlock();
this.refreshDimensions();
}
@ -232,7 +233,6 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
public void releaseSmokeDecoy() {
if (decoyInputDown) {
if (this.entityData.get(DECOY_COUNT) > 0 && this.level() instanceof ServerLevel) {
Entity passenger = getFirstPassenger();
for (int i = 0; i < 16; i++) {
SmokeDecoyEntity smokeDecoyEntity = new SmokeDecoyEntity(this.level());
smokeDecoyEntity.setPos(this.getX(), this.getY() + 2, this.getZ());
@ -256,7 +256,6 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
public void releaseDecoy() {
if (decoyInputDown) {
if (this.entityData.get(DECOY_COUNT) > 0 && this.level() instanceof ServerLevel) {
Entity passenger = getFirstPassenger();
for (int i = 0; i < 4; i++) {
FlareDecoyEntity flareDecoyEntity = new FlareDecoyEntity(this.level());
flareDecoyEntity.setPos(this.getX() + this.getDeltaMovement().x, this.getY() + 0.5 + this.getDeltaMovement().y, this.getZ() + this.getDeltaMovement().z);
@ -292,14 +291,6 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
Matrix4f transform = this.getWheelsTransform(1);
// 点位
//
Vector4f positionF = transformPosition(transform, 0, 0, l / 2);
//
Vector4f positionB = transformPosition(transform, 0, 0, -l / 2);
//
Vector4f positionL = transformPosition(transform, -w / 2, 0, 0);
//
Vector4f positionR = transformPosition(transform, w / 2, 0, 0);
// 左前
Vector4f positionLF = transformPosition(transform, w / 2, 0, l / 2);
// 右前
@ -314,22 +305,12 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
Vec3 p3 = new Vec3(positionLB.x, positionLB.y, positionLB.z);
Vec3 p4 = new Vec3(positionRB.x, positionRB.y, positionRB.z);
Vec3 p5 = new Vec3(positionF.x, positionF.y, positionF.z);
Vec3 p6 = new Vec3(positionB.x, positionB.y, positionB.z);
Vec3 p7 = new Vec3(positionL.x, positionL.y, positionL.z);
Vec3 p8 = new Vec3(positionR.x, positionR.y, positionR.z);
// 确定点位是否在墙里来调整点位高度
float p1y = (float) this.traceBlockY(p1, l);
float p2y = (float) this.traceBlockY(p2, l);
float p3y = (float) this.traceBlockY(p3, l);
float p4y = (float) this.traceBlockY(p4, l);
float p5y = (float) Mth.clamp(this.traceBlockY(p5, l), -l, l);
float p6y = (float) Mth.clamp(this.traceBlockY(p6, l), -l, l);
float p7y = (float) Mth.clamp(this.traceBlockY(p7, l), -l, l);
float p8y = (float) Mth.clamp(this.traceBlockY(p8, l), -l, l);
p1 = new Vec3(positionLF.x, p1y, positionLF.z);
p2 = new Vec3(positionRF.x, p2y, positionRF.z);
p3 = new Vec3(positionLB.x, p3y, positionLB.z);
@ -399,12 +380,12 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
return pos.y + 0.5f * diffY;
}
public void collideLilyPadBlock() {
public void baseCollideBlock() {
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)) {
if (blockstate.is(Blocks.LILY_PAD) || blockstate.is(BlockTags.LEAVES) || blockstate.is(Blocks.COBWEB) || blockstate.is(Blocks.CACTUS)) {
this.level().destroyBlock(pos, true);
}
});