Restore intro screen and visible crater test behavior
All checks were successful
Build / build (push) Successful in 9m37s

This commit is contained in:
MrSphay
2026-05-07 22:29:22 +02:00
parent eebf126bac
commit 73f0fac8eb
3 changed files with 59 additions and 1 deletions

View File

@@ -1,14 +1,44 @@
package com.vinlanx.explosionoverhaul;
import com.vinlanx.explosionoverhaul.api.IExplosionPower;
import com.vinlanx.explosionoverhaul.mixinhelper.ExplosionAccessor;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
public class ServerExplosionHandler {
public static void handleExplosion(ServerLevel level, Explosion explosion, List<BlockPos> affectedBlocks) {
if (!((Boolean)Config.COMMON.enableCraterDestruction.get()).booleanValue()) {
affectedBlocks.clear();
return;
}
float power = 4.0f;
if (explosion instanceof IExplosionPower explosionPower) {
power = Math.max(1.0f, explosionPower.getPower());
}
Vec3 center = explosion instanceof ExplosionAccessor accessor ? accessor.explosionoverhaul$getCenter() : Vec3.ZERO;
int radius = Math.max(5, Math.min(18, Math.round(power * 2.0f * ((Double)Config.COMMON.craterSizeMultiplier.get()).floatValue())));
Set<BlockPos> existing = new HashSet<>(affectedBlocks);
BlockPos origin = BlockPos.containing(center);
double radiusSq = radius * radius;
for (BlockPos pos : BlockPos.betweenClosed(origin.offset(-radius, -radius, -radius), origin.offset(radius, radius, radius))) {
double distanceSq = pos.distToCenterSqr(center);
if (distanceSq > radiusSq) {
continue;
}
BlockState state = level.getBlockState(pos);
if (state.isAir() || state.getDestroySpeed(level, pos) < 0.0f) {
continue;
}
BlockPos immutable = pos.immutable();
if (existing.add(immutable)) {
affectedBlocks.add(immutable);
}
}
}

View File

@@ -22,6 +22,18 @@ public class FirstTimeSetupHandler {
@SubscribeEvent
public static void onClientTick(ClientTickEvent.Post event) {
Minecraft mc = Minecraft.getInstance();
if (!hasChecked && mc.screen instanceof TitleScreen) {
hasChecked = true;
if (Config.isFirstLaunch()) {
pendingShowIntro = true;
}
}
if (pendingShowIntro && mc.screen instanceof TitleScreen) {
pendingShowIntro = false;
mc.setScreen(new IntroSplashScreen());
Config.markFirstLaunchComplete();
}
}
static {

View File

@@ -6,11 +6,27 @@ import net.minecraft.network.chat.Component;
public class IntroSplashScreen extends Screen {
public IntroSplashScreen() {
super(Component.empty());
super(Component.literal("Explosion Overhaul"));
}
@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
this.renderBackground(graphics, mouseX, mouseY, partialTick);
graphics.drawCenteredString(this.font, Component.literal("Explosion Overhaul"), this.width / 2, this.height / 2 - 32, 0xFFFFFF);
graphics.drawCenteredString(this.font, Component.literal("NeoForge 1.21.1 private test port"), this.width / 2, this.height / 2 - 10, 0xD0D0D0);
graphics.drawCenteredString(this.font, Component.literal("Click or press any key to continue"), this.width / 2, this.height / 2 + 16, 0xA0A0A0);
super.render(graphics, mouseX, mouseY, partialTick);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
this.onClose();
return true;
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
this.onClose();
return true;
}
}