-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
145 additions
and
4 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
28 changes: 28 additions & 0 deletions
28
src/main/java/io/github/rainyaphthyl/potteckit/config/option/EnumRealmStatus.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,28 @@ | ||
package io.github.rainyaphthyl.potteckit.config.option; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import fi.dy.masa.malilib.config.value.OptionListConfigValue; | ||
|
||
public enum EnumRealmStatus implements OptionListConfigValue { | ||
VANILLA("vanilla", "Vanilla"), | ||
DISABLED("disabled", "Disabled"), | ||
INVISIBLE("invisible", "Invisible"); | ||
public static final ImmutableList<EnumRealmStatus> list = ImmutableList.copyOf(values()); | ||
public final String name; | ||
public final String description; | ||
|
||
EnumRealmStatus(String name, String description) { | ||
this.name = name; | ||
this.description = description; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return description; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/io/github/rainyaphthyl/potteckit/mixin/core/MixinGuiMainMenu.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,29 @@ | ||
package io.github.rainyaphthyl.potteckit.mixin.core; | ||
|
||
import io.github.rainyaphthyl.potteckit.config.Configs; | ||
import io.github.rainyaphthyl.potteckit.config.option.EnumRealmStatus; | ||
import net.minecraft.client.gui.GuiButton; | ||
import net.minecraft.client.gui.GuiMainMenu; | ||
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.CallbackInfo; | ||
|
||
@Mixin(GuiMainMenu.class) | ||
public abstract class MixinGuiMainMenu { | ||
@Shadow | ||
private GuiButton realmsButton; | ||
|
||
@Inject(method = "addSingleplayerMultiplayerButtons", at = @At(value = "RETURN")) | ||
public void yeetRealmButton(int y1, int y2, CallbackInfo ci) { | ||
EnumRealmStatus value = Configs.enablePotteckit.getValue() ? Configs.yeetRealmPage.getValue() : EnumRealmStatus.VANILLA; | ||
switch (value) { | ||
case INVISIBLE: | ||
realmsButton.visible = false; | ||
case DISABLED: | ||
realmsButton.enabled = false; | ||
break; | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/io/github/rainyaphthyl/potteckit/mixin/core/MixinMinecraft.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 @@ | ||
package io.github.rainyaphthyl.potteckit.mixin.core; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import com.mojang.authlib.minecraft.MinecraftSessionService; | ||
import com.mojang.authlib.properties.PropertyMap; | ||
import io.github.rainyaphthyl.potteckit.config.Configs; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.server.integrated.IntegratedServer; | ||
import net.minecraft.util.Session; | ||
import org.spongepowered.asm.mixin.Final; | ||
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.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
@Mixin(Minecraft.class) | ||
public abstract class MixinMinecraft { | ||
@Shadow | ||
@Final | ||
private Session session; | ||
@Shadow | ||
@Final | ||
private PropertyMap profileProperties; | ||
|
||
@Shadow | ||
public abstract MinecraftSessionService getSessionService(); | ||
|
||
@Redirect(method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/integrated/IntegratedServer;initiateShutdown()V")) | ||
public void skipDuplicateShutdown(@Nonnull IntegratedServer serverIn) { | ||
boolean flag = Configs.fixLanQuittingFreeze.getBooleanValue() && Configs.enablePotteckit.getBooleanValue(); | ||
if (!flag) { | ||
serverIn.initiateShutdown(); | ||
} | ||
} | ||
|
||
@Inject(method = "getProfileProperties", at = @At(value = "HEAD")) | ||
public void addSignature(CallbackInfoReturnable<PropertyMap> cir) { | ||
boolean flag = Configs.fixLanSkinAbsence.getBooleanValue() && Configs.enablePotteckit.getBooleanValue(); | ||
if (flag) { | ||
if (profileProperties.isEmpty()) { | ||
GameProfile profile = getSessionService().fillProfileProperties(session.getProfile(), true); | ||
profileProperties.putAll(profile.getProperties()); | ||
} | ||
} | ||
} | ||
} |
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