generated from babric/babric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix portal not transferring to the right dimension when using StAPI
- Loading branch information
1 parent
1e36afa
commit d721e9b
Showing
6 changed files
with
41 additions
and
64 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
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
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
48 changes: 10 additions & 38 deletions
48
apron/src/main/java/io/github/betterthanupdates/shockahpi/mixin/client/WorldMixin.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 |
---|---|---|
@@ -1,71 +1,43 @@ | ||
package io.github.betterthanupdates.shockahpi.mixin.client; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
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.ModifyArg; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import shockahpi.DimensionBase; | ||
import shockahpi.Loc; | ||
import shockahpi.SAPI; | ||
|
||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.WorldProperties; | ||
import net.minecraft.world.dimension.Dimension; | ||
|
||
@Mixin(World.class) | ||
public abstract class WorldMixin implements BlockView { | ||
@Shadow | ||
public WorldProperties properties; | ||
|
||
@Redirect(method = "<init>(Lnet/minecraft/world/dimension/DimensionData;Ljava/lang/String;JLnet/minecraft/world/dimension/Dimension;)V", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/dimension/Dimension;getByID(I)Lnet/minecraft/world/dimension/Dimension;", ordinal = 0)) | ||
private Dimension sapi$ctr1(int i) { | ||
DimensionBase localDimensionBase = DimensionBase.getDimByNumber(i); | ||
return localDimensionBase.getWorldProvider(); | ||
} | ||
|
||
@Redirect(method = "<init>(Lnet/minecraft/world/dimension/DimensionData;Ljava/lang/String;JLnet/minecraft/world/dimension/Dimension;)V", | ||
@ModifyArg(method = "<init>(Lnet/minecraft/world/dimension/DimensionData;Ljava/lang/String;JLnet/minecraft/world/dimension/Dimension;)V", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/dimension/Dimension;getByID(I)Lnet/minecraft/world/dimension/Dimension;", ordinal = 1)) | ||
private Dimension sapi$ctr2(int i) { | ||
private int sapi$fixDimensionId(int i) { | ||
if (this.properties != null) { | ||
i = this.properties.getDimensionId(); | ||
} | ||
|
||
DimensionBase localDimensionBase = DimensionBase.getDimByNumber(i); | ||
return localDimensionBase.getWorldProvider(); | ||
} | ||
|
||
int cachedI, cachedJ, cachedK; | ||
|
||
@Inject(method = "setBlockWithMetadata", at = @At("HEAD")) | ||
private void sapi$setBlockWithMetadata(int i, int j, int k, int l, int i1, CallbackInfoReturnable<Boolean> cir) { | ||
this.cachedI = i; | ||
this.cachedJ = j; | ||
this.cachedK = k; | ||
return i; | ||
} | ||
|
||
@ModifyArg(method = "setBlockWithMetadata", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setBlockWithMetadata(IIIII)Z"), index = 3) | ||
private int sapi$setBlockWithMetadata$1(int i) { | ||
return SAPI.interceptBlockSet((World) (Object) this, new Loc(this.cachedI, this.cachedJ, this.cachedK), i); | ||
} | ||
|
||
int cachedI2, cachedJ2, cachedK2; | ||
|
||
@Inject(method = "setBlockInChunk", at = @At("HEAD")) | ||
private void sapi$setBlockInChunk(int i, int j, int k, int l, CallbackInfoReturnable<Boolean> cir) { | ||
this.cachedI2 = i; | ||
this.cachedJ2 = j; | ||
this.cachedK2 = k; | ||
private int sapi$setBlockWithMetadata$1(int i, @Local(ordinal = 0, argsOnly = true) int x, @Local(ordinal = 1, argsOnly = true) int y, | ||
@Local(ordinal = 2, argsOnly = true) int z) { | ||
return SAPI.interceptBlockSet((World) (Object) this, new Loc(x, y, z), i); | ||
} | ||
|
||
@ModifyArg(method = "setBlockInChunk", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;method_860(IIII)Z"), index = 3) | ||
private int sapi$setBlockInChunk$1(int i) { | ||
return SAPI.interceptBlockSet((World) (Object) this, new Loc(this.cachedI2, this.cachedJ2, this.cachedK2), i); | ||
private int sapi$setBlockInChunk$1(int i, @Local(ordinal = 0, argsOnly = true) int x, @Local(ordinal = 1, argsOnly = true) int y, | ||
@Local(ordinal = 2, argsOnly = true) int z) { | ||
return SAPI.interceptBlockSet((World) (Object) this, new Loc(x, y, z), i); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...n/java/io/github/betterthanupdates/shockahpi/mixin/client/nostation/PortalBlockMixin.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,25 @@ | ||
package io.github.betterthanupdates.shockahpi.mixin.client.nostation; | ||
|
||
import io.github.betterthanupdates.shockahpi.block.ShockAhPIPortalBlock; | ||
import net.minecraft.block.PortalBlock; | ||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import playerapi.PlayerAPI; | ||
import shockahpi.PlayerBaseSAPI; | ||
|
||
@Mixin(PortalBlock.class) | ||
public abstract class PortalBlockMixin implements ShockAhPIPortalBlock { | ||
|
||
@Inject(method = "onEntityCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;method_1388()V", shift = At.Shift.BEFORE)) | ||
public void onEntityCollision(World world, int i, int j, int k, Entity entity, CallbackInfo ci) { | ||
if (entity instanceof AbstractClientPlayerEntity) { | ||
AbstractClientPlayerEntity entityplayersp = (AbstractClientPlayerEntity) entity; | ||
PlayerAPI.getPlayerBase(entityplayersp, PlayerBaseSAPI.class).portal = this.getDimNumber(); | ||
} | ||
} | ||
} |
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