-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- portal tick moved from entity to portal manager
- Loading branch information
1 parent
e89d6c2
commit 16e1c58
Showing
3 changed files
with
53 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
.../org/spongepowered/common/mixin/realtime/world/dimension/PortalManagerMixin_RealTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* OKTW Galaxy Project | ||
* Copyright (C) 2018-2024 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.spongepowered.common.mixin.realtime.world.dimension; | ||
|
||
import net.minecraft.block.Portal; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.world.dimension.PortalManager; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.common.bridge.RealTimeTrackingBridge; | ||
|
||
@Mixin(PortalManager.class) | ||
public abstract class PortalManagerMixin_RealTime { | ||
@Shadow | ||
private Portal portal; | ||
@Shadow | ||
private int ticksInPortal; | ||
@Shadow | ||
private boolean inPortal; | ||
|
||
@Inject(method = "tick", at = @At("RETURN"), cancellable = true) | ||
private void realTimeImpl$adjustForRealTimePortalCounter(ServerWorld world, Entity entity, boolean canUsePortals, CallbackInfoReturnable<Boolean> cir) { | ||
if (this.inPortal) { | ||
final int ticks = (int) ((RealTimeTrackingBridge) world).realTimeBridge$getRealTimeTicks(); | ||
this.ticksInPortal += ticks; | ||
// FIXME: Does this still need to this.ticksInPortal++ ? | ||
cir.setReturnValue(canUsePortals && this.ticksInPortal >= this.portal.getPortalDelay(world, entity)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters