Skip to content

Commit

Permalink
Merge pull request #1339 from YocyCraft/dev/tesla_hotfix
Browse files Browse the repository at this point in the history
[Hotfix] Tesla Tower crash the game and implement cross sliding rail [热修] 修复特斯拉塔使游戏崩溃的问题,实装十字形滑轨
  • Loading branch information
Gu-ZT authored Dec 17, 2024
2 parents a4b7054 + 578730b commit 0d02831
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"y": 90
},
"axis=y": {
"model": "anvilcraft:block/sliding_rail"
"model": "anvilcraft:block/sliding_rail_cross"
},
"axis=z": {
"model": "anvilcraft:block/sliding_rail"
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/dev/dubhe/anvilcraft/block/SlidingRailBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public class SlidingRailBlock extends Block implements IHammerChangeable, IHamme
Block.box(0, 12, 0, 5, 16, 16),
Block.box(11, 6, 0, 14, 12, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
public static final VoxelShape AABB_Y =
Stream.of(
Block.box(0, 0, 0, 16, 6, 16),
Block.box(11, 6, 11, 16, 16, 16),
Block.box(0, 6, 11, 5, 16, 16),
Block.box(0, 6, 0, 5, 16, 5),
Block.box(11, 6, 0, 16, 16, 5)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
public static final EnumProperty<Direction.Axis> AXIS = BlockStateProperties.AXIS;
public static final HashMap<BlockPos, PistonPushInfo> MOVING_PISTON_MAP = new HashMap<>();

Expand Down Expand Up @@ -99,8 +107,9 @@ public VoxelShape getShape(
case X:
yield AABB_X;
case Z:
default:
yield AABB_Z;
case Y:
yield AABB_Y;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,17 @@ public void emitLaser(Direction direction) {

if (!(level instanceof ServerLevel serverLevel)) return;
updateLaserLevel(calculateLaserLevel());
AABB trackBoundingBox = new AABB(
getBlockPos()
.relative(direction)
.getCenter()
.add(-0.0625, -0.0625, -0.0625),
irradiateBlockPos.relative(direction.getOpposite())
.getCenter()
.add(0.0625, 0.0625, 0.0625)
);
int hurt = Math.min(16, laserLevel - 4);
if (hurt > 0) {
AABB trackBoundingBox = new AABB(
getBlockPos()
.relative(direction)
.getCenter()
.add(-0.0625, -0.0625, -0.0625),
irradiateBlockPos.relative(direction.getOpposite())
.getCenter()
.add(0.0625, 0.0625, 0.0625)
);
level.getEntities(
EntityTypeTest.forClass(LivingEntity.class),
trackBoundingBox,
Expand All @@ -180,16 +180,16 @@ public void emitLaser(Direction direction) {
);
}
BlockState irradiateBlock = level.getBlockState(irradiateBlockPos);
List<ItemStack> drops = Block.getDrops(
irradiateBlock,
serverLevel,
irradiateBlockPos,
level.getBlockEntity(irradiateBlockPos)
);
int cooldown = COOLDOWNS[Math.clamp(laserLevel / 4, 0, 4)];
if (tickCount >= cooldown) {
tickCount = 0;
if (irradiateBlock.is(Tags.Blocks.ORES)) {
List<ItemStack> drops = Block.getDrops(
irradiateBlock,
serverLevel,
irradiateBlockPos,
level.getBlockEntity(irradiateBlockPos)
);
Vec3 blockPos = getBlockPos().relative(direction.getOpposite()).getCenter();
IItemHandler cap = getLevel()
.getCapability(
Expand All @@ -216,16 +216,12 @@ public void emitLaser(Direction direction) {
});
if (irradiateBlock.is(Blocks.ANCIENT_DEBRIS)) {
level.setBlockAndUpdate(irradiateBlockPos, Blocks.NETHERRACK.defaultBlockState());
} else if (irradiateBlock.is(Tags.Blocks.ORES_IN_GROUND_DEEPSLATE)) {
level.setBlockAndUpdate(irradiateBlockPos, Blocks.DEEPSLATE.defaultBlockState());
} else if (irradiateBlock.is(Tags.Blocks.ORES_IN_GROUND_NETHERRACK)) {
level.setBlockAndUpdate(irradiateBlockPos, Blocks.NETHERRACK.defaultBlockState());
} else {
if (irradiateBlock.is(Tags.Blocks.ORES_IN_GROUND_DEEPSLATE))
level.setBlockAndUpdate(irradiateBlockPos, Blocks.DEEPSLATE.defaultBlockState());
else {
if (irradiateBlock.is(Tags.Blocks.ORES_IN_GROUND_NETHERRACK)) {
level.setBlockAndUpdate(irradiateBlockPos, Blocks.NETHERRACK.defaultBlockState());
} else {
level.setBlockAndUpdate(irradiateBlockPos, Blocks.STONE.defaultBlockState());
}
}
level.setBlockAndUpdate(irradiateBlockPos, Blocks.STONE.defaultBlockState());
}
/* else {
if (level.getBlockState(irradiateBlockPos).getBlock().defaultDestroyTime() >= 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static TeslaTowerBlockEntity createBlockEntity(BlockEntityType<?> type, B
if (!this.getBlockState().is(ModBlocks.TESLA_TOWER.get())) return PowerComponentType.INVALID;
if (this.getBlockState().getValue(TeslaTowerBlock.HALF) != Vertical4PartHalf.BOTTOM)
return PowerComponentType.INVALID;
return PowerComponentType.TRANSMITTER;
return PowerComponentType.CONSUMER;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public static void init(RegistrateRecipeProvider provider) {
.input(Blocks.DIRT)
.result(Blocks.MYCELIUM)
.save(provider);
BlockCompressRecipe.builder()
.input(ModBlocks.VOID_MATTER_BLOCK.get())
.input(ModBlocks.SUPERCRITICAL_NESTING_SHULKER_BOX.get())
.result(ModBlocks.SPACE_OVERCOMPRESSOR.get())
.save(provider);
}

private static void blockCompress(RegistrateRecipeProvider provider, Block block1, Block block2, Block result) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,9 @@ public class ModBlocks {
.modelFile(DangerUtil.genModModelFile("block/sliding_rail").get())
.rotationY(90)
.buildLast()};
case Z, Y -> DangerUtil.genConfiguredModel("block/sliding_rail")
case Z -> DangerUtil.genConfiguredModel("block/sliding_rail")
.get();
case Y -> DangerUtil.genConfiguredModel("block/sliding_rail_cross")
.get();
});
})
Expand Down

0 comments on commit 0d02831

Please sign in to comment.