Skip to content

Commit 02b3f35

Browse files
committed
fix: tighten portal handling and rebalance recipes
1 parent 5c0c3b2 commit 02b3f35

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/main/java/fr/geomtech/universegate/PortalConnectionManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,7 @@ private static BlockPos findActiveCoreNear(ServerLevel level, BlockPos center, i
451451
// Champ portal (à brancher ensuite)
452452
// ----------------------------
453453
private static boolean placeField(ServerLevel level, PortalFrameDetector.FrameMatch match, boolean unstable) {
454-
var axis = match.right() == net.minecraft.core.Direction.EAST
455-
? net.minecraft.core.Direction.Axis.X
456-
: net.minecraft.core.Direction.Axis.Z;
454+
var axis = axisFromMatch(match);
457455
var baseFieldState = ModBlocks.PORTAL_FIELD.defaultBlockState()
458456
.setValue(PortalFieldBlock.AXIS, axis)
459457
.setValue(PortalFieldBlock.UNSTABLE, unstable);
@@ -470,9 +468,7 @@ private static void removeField(ServerLevel level, PortalFrameDetector.FrameMatc
470468
if (state.is(ModBlocks.PORTAL_FIELD)) {
471469
var axis = state.hasProperty(PortalFieldBlock.AXIS)
472470
? state.getValue(PortalFieldBlock.AXIS)
473-
: (match.right() == net.minecraft.core.Direction.EAST
474-
? net.minecraft.core.Direction.Axis.X
475-
: net.minecraft.core.Direction.Axis.Z);
471+
: axisFromMatch(match);
476472
boolean unstable = state.hasProperty(PortalFieldBlock.UNSTABLE)
477473
&& state.getValue(PortalFieldBlock.UNSTABLE);
478474
spawnFieldCollapseParticles(level, p, axis, unstable);
@@ -488,6 +484,10 @@ private static void removeField(ServerLevel level, PortalFrameDetector.FrameMatc
488484
}
489485
}
490486

487+
private static Direction.Axis axisFromMatch(PortalFrameDetector.FrameMatch match) {
488+
return match.right() == Direction.EAST ? Direction.Axis.X : Direction.Axis.Z;
489+
}
490+
491491
private static void setFieldInstability(ServerLevel level, PortalFrameDetector.FrameMatch match, boolean unstable) {
492492
for (BlockPos p : match.interior()) {
493493
var state = level.getBlockState(p);

src/main/java/fr/geomtech/universegate/PortalCoreBlockEntity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public void onBroken() {
9494
// ---------- Ticking ----------
9595
public void serverTick() {
9696
if (!(level instanceof ServerLevel sl)) return;
97+
long now = sl.getGameTime();
9798
if (restorePending) {
9899
restorePending = false;
99100
if (active && !restoreActiveState(sl)) return;
@@ -103,14 +104,14 @@ public void serverTick() {
103104
return;
104105
}
105106
if (openingCompleteGameTime <= 0L) {
106-
openingStartedGameTime = sl.getGameTime();
107+
openingStartedGameTime = now;
107108
openingCompleteGameTime = openingStartedGameTime + OPENING_DURATION_FALLBACK_TICKS;
108109
setChanged();
109110
}
110111
PortalConnectionManager.setNearbyKeyboardsLit(sl, worldPosition, true);
111112
}
112113
}
113-
if (sl.getGameTime() % 10L == 0L) {
114+
if (now % 10L == 0L) {
114115
PortalRiftHelper.findNearestChargedRod(sl, worldPosition, ChargedLightningRodBlock.PORTAL_RADIUS)
115116
.ifPresent((rod) -> spawnRiftParticles(sl));
116117
}
@@ -120,7 +121,6 @@ public void serverTick() {
120121
}
121122
if (!active) return;
122123

123-
long now = sl.getGameTime();
124124
if (activeStartedGameTime <= 0L || activeStartedGameTime > now) {
125125
activeStartedGameTime = now;
126126
setChanged();

src/main/java/fr/geomtech/universegate/PortalTeleportHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.minecraft.world.entity.LivingEntity;
1515
import net.minecraft.world.entity.RelativeMovement;
1616
import net.minecraft.world.entity.projectile.AbstractArrow;
17+
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
1718
import net.minecraft.world.entity.vehicle.AbstractMinecart;
1819
import net.minecraft.world.phys.Vec3;
1920

@@ -297,7 +298,8 @@ private static PortalKeyboardBlockEntity findKeyboardNear(ServerLevel level, Blo
297298
for (int dx = -r; dx <= r; dx++) {
298299
for (int dz = -r; dz <= r; dz++) {
299300
BlockPos p = corePos.offset(dx, dy, dz);
300-
if (!level.getBlockState(p).is(ModBlocks.PORTAL_KEYBOARD)) continue;
301+
var state = level.getBlockState(p);
302+
if (!state.is(ModBlocks.PORTAL_KEYBOARD) && !state.is(ModBlocks.PORTAL_NATURAL_KEYBOARD)) continue;
301303
if (level.getBlockEntity(p) instanceof PortalKeyboardBlockEntity kb) return kb;
302304
}
303305
}
@@ -383,7 +385,9 @@ private static float pitchFromVelocity(Vec3 velocity, float fallbackPitch) {
383385
}
384386

385387
private static boolean shouldPreserveProjectileMomentum(Entity entity) {
386-
return entity instanceof AbstractArrow || entity instanceof AbstractMinecart;
388+
return entity instanceof AbstractArrow
389+
|| entity instanceof AbstractMinecart
390+
|| entity instanceof ThrownEnderpearl;
387391
}
388392

389393
}

src/main/resources/data/universegate/loot_table/blocks/kelo_log.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
"conditions": [
88
{
99
"condition": "minecraft:survives_explosion"
10-
},
11-
{
12-
"condition": "minecraft:random_chance",
13-
"chance": 0.4
1410
}
1511
],
1612
"entries": [

src/main/resources/data/universegate/recipe/rift_refiner.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"key": {
99
"W": {
10-
"item": "universegate:white_purpur_block"
10+
"item": "minecraft:iron_ingot"
1111
},
1212
"P": {
1313
"item": "minecraft:piston"

0 commit comments

Comments
 (0)