Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixin Changes #433

Merged
merged 4 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(PlayerControllerMP.class)
public class MixinPlayerController {
public class MixinPlayerControllerMP {

@Inject(method = "onPlayerDestroyBlock", at = @At("HEAD"))
private void onPlayerDestroyBlock(BlockPos pos, EnumFacing side, CallbackInfoReturnable<Boolean> cir) {
PlayerBreakBlockEvent.Companion.onPlayerBreakBlock$Partly_Sane_Skies(pos, side, cir);
PlayerBreakBlockEvent.Companion.onPlayerBreakBlock$Partly_Sane_Skies(pos, side);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// See LICENSE for copyright and license notices.
//

package me.partlysanestudios.partlysaneskies.mixin.minecraft;
package me.partlysanestudios.partlysaneskies.mixin.minecraft.accessors;

import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.inventory.IInventory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(GuiChest.class)
public interface MixinGuiChest {
public interface GuiChestAccessor {

@Accessor("upperChestInventory")
IInventory partlysaneskies$getUpperChestInventory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
//


package me.partlysanestudios.partlysaneskies.mixin.minecraft;
package me.partlysanestudios.partlysaneskies.mixin.minecraft.accessors;

import net.minecraft.client.gui.inventory.GuiContainer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(GuiContainer.class)
public interface MixinGuiContainer {
public interface GuiContainerAccessor {

@Accessor("xSize")
int partlysaneskies$getXSize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// See LICENSE for copyright and license notices.
//

package me.partlysanestudios.partlysaneskies.mixin.minecraft;
package me.partlysanestudios.partlysaneskies.mixin.minecraft.accessors;

import net.minecraft.client.gui.GuiPlayerTabOverlay;
import net.minecraft.util.IChatComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(GuiPlayerTabOverlay.class)
public interface MixinGuiPlayerTabOverlay {
public interface GuiPlayerTabOverlayAccessor {
@Accessor("footer")
IChatComponent partlySaneSkies$getFooter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
public class MixinDungeonGuideCollectDiagnostics {
@Inject(method = "sendLogActually*", at = @At("HEAD"), cancellable = true)
public void onSendLogActuallyHead(CallbackInfo ci) {
if (PartlySaneSkies.Companion.getConfig() == null) {
return;
}
if (PartlySaneSkies.Companion.getConfig() == null) return;
if (PrivacyMode.INSTANCE.shouldBlockTelemetry()) {
ci.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,12 @@
@Pseudo
@Mixin(targets = "gg.essential.network.connectionmanager.telemetry.TelemetryManager", remap = false)
public class MixinEssentialsTelemetryManager {
@Inject(method = "sendHardwareAndOSTelemetry*", at = @At("HEAD"), cancellable = true)
public void onSendHardwareAndOSTelemetryHead(CallbackInfo ci) {
if (PartlySaneSkies.Companion.getConfig() == null) {
return;
}
if (PrivacyMode.INSTANCE.shouldBlockTelemetry()) {
ci.cancel();
}
}

@Inject(method = "enqueue*", at = @At("HEAD"), cancellable = true)
public void onEnqueueHead(CallbackInfo ci) {
if (PartlySaneSkies.Companion.getConfig() == null) {
return;
}
@Inject(method = {"sendHardwareAndOSTelemetry*", "enqueue*"}, at = @At("HEAD"), cancellable = true)
public void onTelemetry(CallbackInfo ci) {
if (PartlySaneSkies.Companion.getConfig() == null) return;
if (PrivacyMode.INSTANCE.shouldBlockTelemetry()) {
ci.cancel();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@ import me.partlysanestudios.partlysaneskies.features.chat.ChatAlertsManager
import me.partlysanestudios.partlysaneskies.features.chat.ChatManager
import me.partlysanestudios.partlysaneskies.features.chat.ChatTransformer
import me.partlysanestudios.partlysaneskies.features.chat.WordEditor
import me.partlysanestudios.partlysaneskies.features.commands.*
import me.partlysanestudios.partlysaneskies.features.commands.Crepes
import me.partlysanestudios.partlysaneskies.features.commands.HelpCommand
import me.partlysanestudios.partlysaneskies.features.commands.PSSDiscord
import me.partlysanestudios.partlysaneskies.features.commands.SanityCheck
import me.partlysanestudios.partlysaneskies.features.commands.Version
import me.partlysanestudios.partlysaneskies.features.debug.DebugKey
import me.partlysanestudios.partlysaneskies.features.debug.ExampleHud
import me.partlysanestudios.partlysaneskies.features.debug.ExampleWebhook
import me.partlysanestudios.partlysaneskies.features.discord.DiscordRPC
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.WebhookMenu
import me.partlysanestudios.partlysaneskies.features.dungeons.*
import me.partlysanestudios.partlysaneskies.features.dungeons.AutoGG
import me.partlysanestudios.partlysaneskies.features.dungeons.HealthAlert
import me.partlysanestudios.partlysaneskies.features.dungeons.ItemRefill
import me.partlysanestudios.partlysaneskies.features.dungeons.PlayerRating
import me.partlysanestudios.partlysaneskies.features.dungeons.RequiredSecretsFound
import me.partlysanestudios.partlysaneskies.features.dungeons.TerminalWaypoints
import me.partlysanestudios.partlysaneskies.features.dungeons.WatcherReady
import me.partlysanestudios.partlysaneskies.features.dungeons.party.PartyFriendManager
import me.partlysanestudios.partlysaneskies.features.dungeons.party.partymanager.PartyManager
import me.partlysanestudios.partlysaneskies.features.dungeons.party.permpartyselector.PermPartyManager
Expand All @@ -59,7 +69,11 @@ import me.partlysanestudios.partlysaneskies.features.farming.MathematicalHoeRigh
import me.partlysanestudios.partlysaneskies.features.farming.WrongToolCropWarning
import me.partlysanestudios.partlysaneskies.features.farming.endoffarmnotifer.EndOfFarmNotifier
import me.partlysanestudios.partlysaneskies.features.farming.endoffarmnotifer.RangeHighlight
import me.partlysanestudios.partlysaneskies.features.farming.garden.*
import me.partlysanestudios.partlysaneskies.features.farming.garden.CompostValue
import me.partlysanestudios.partlysaneskies.features.farming.garden.CropMilestoneWebhook
import me.partlysanestudios.partlysaneskies.features.farming.garden.SkymartValue
import me.partlysanestudios.partlysaneskies.features.farming.garden.VisitorLogbookStats
import me.partlysanestudios.partlysaneskies.features.farming.garden.VisitorTradeValue
import me.partlysanestudios.partlysaneskies.features.foraging.TreecapitatorCooldown
import me.partlysanestudios.partlysaneskies.features.gui.RefreshKeybinds
import me.partlysanestudios.partlysaneskies.features.gui.hud.CooldownHud
Expand All @@ -75,8 +89,8 @@ import me.partlysanestudios.partlysaneskies.features.mining.crystalhollows.gemst
import me.partlysanestudios.partlysaneskies.features.mining.crystalhollows.gemstonewaypoints.GemstoneWaypointRender
import me.partlysanestudios.partlysaneskies.features.security.PrivacyMode
import me.partlysanestudios.partlysaneskies.features.security.modschecker.ModChecker
import me.partlysanestudios.partlysaneskies.features.skills.BestiaryMilestoneWebhook
import me.partlysanestudios.partlysaneskies.features.skills.BestiaryLevelUpWebhook
import me.partlysanestudios.partlysaneskies.features.skills.BestiaryMilestoneWebhook
import me.partlysanestudios.partlysaneskies.features.skills.PetAlert
import me.partlysanestudios.partlysaneskies.features.skills.PetLevelUpWebhook
import me.partlysanestudios.partlysaneskies.features.skills.SkillUpgradeRecommendation
Expand Down Expand Up @@ -106,7 +120,12 @@ import java.io.File
import java.io.IOException
import java.net.MalformedURLException

@Mod(modid = PartlySaneSkies.MODID, version = PartlySaneSkies.VERSION, name = PartlySaneSkies.NAME)
@Mod(
modid = PartlySaneSkies.MODID,
version = PartlySaneSkies.VERSION,
name = PartlySaneSkies.NAME,
clientSideOnly = true,
)
class PartlySaneSkies {
companion object {
@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import me.partlysanestudios.partlysaneskies.utils.geometry.vectors.Point3d
import me.partlysanestudios.partlysaneskies.utils.geometry.vectors.Point3d.Companion.toPoint3d
import net.minecraft.util.BlockPos
import net.minecraft.util.EnumFacing
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable

class PlayerBreakBlockEvent(val point: Point3d, val side: EnumFacing) {
companion object {
Expand All @@ -26,8 +25,9 @@ class PlayerBreakBlockEvent(val point: Point3d, val side: EnumFacing) {
}

// Called from the mixin because writing this code in java is about 50 times harder
internal fun onPlayerBreakBlock(blockPos: BlockPos, side: EnumFacing, cir: CallbackInfoReturnable<Boolean>) {
callEvent(EventManager.registeredFunctions[PlayerBreakBlockEvent::class] ?: ArrayList(), blockPos, side)
// that's called a hook
internal fun onPlayerBreakBlock(blockPos: BlockPos, side: EnumFacing) {
callEvent(EventManager.registeredFunctions[PlayerBreakBlockEvent::class] ?: return, blockPos, side)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import com.google.common.collect.ComparisonChain
import com.google.common.collect.Ordering
import me.partlysanestudios.partlysaneskies.PartlySaneSkies
import me.partlysanestudios.partlysaneskies.data.cache.PetData
import me.partlysanestudios.partlysaneskies.mixin.minecraft.MixinGuiChest
import me.partlysanestudios.partlysaneskies.mixin.minecraft.MixinGuiContainer
import me.partlysanestudios.partlysaneskies.mixin.minecraft.MixinGuiPlayerTabOverlay
import me.partlysanestudios.partlysaneskies.mixin.minecraft.accessors.GuiChestAccessor
import me.partlysanestudios.partlysaneskies.mixin.minecraft.accessors.GuiContainerAccessor
import me.partlysanestudios.partlysaneskies.mixin.minecraft.accessors.GuiPlayerTabOverlayAccessor
import me.partlysanestudios.partlysaneskies.utils.HypixelUtils.getItemId
import me.partlysanestudios.partlysaneskies.utils.StringUtils.removeColorCodes
import net.minecraft.client.gui.GuiPlayerTabOverlay
Expand Down Expand Up @@ -138,38 +138,28 @@ object MinecraftUtils {
* @return The inventory of the player at the bottom of the gui. ([GuiChest.upperChestInventory] field)
*/
val GuiChest.playerInventory: IInventory
get() {
return (this as MixinGuiChest).`partlysaneskies$getUpperChestInventory`()
}
get() = (this as GuiChestAccessor).`partlysaneskies$getUpperChestInventory`()

/**
* @return The inventory of any container at the top of the gui. ([GuiChest.lowerChestInventory] field)
*/
val GuiChest.containerInventory: IInventory
get() {
return (this as MixinGuiChest).`partlysaneskies$getLowerChestInventory`()
}
get() = (this as GuiChestAccessor).`partlysaneskies$getLowerChestInventory`()

/**
* @return the [GuiChest.xSize] field that is protected in the GuiContainer class
*/
val GuiContainer.xSize: Int
get() {
return (this as MixinGuiContainer).`partlysaneskies$getXSize`()
}
get() = (this as GuiContainerAccessor).`partlysaneskies$getXSize`()

/**
* @return the [GuiChest.ySize] field that is protected in the GuiContainer class
*/
val GuiContainer.ySize: Int
get() {
return (this as MixinGuiContainer).`partlysaneskies$getYSize`()
}
get() = (this as GuiContainerAccessor).`partlysaneskies$getYSize`()

val GuiPlayerTabOverlay.footer: IChatComponent
get() {
return (this as MixinGuiPlayerTabOverlay).`partlySaneSkies$getFooter`()
}
get() = (this as GuiPlayerTabOverlayAccessor).`partlySaneSkies$getFooter`()

fun ItemStack.getLore(): java.util.ArrayList<String> {
if (!this.hasTagCompound() || !this.tagCompound.hasKey("display") || !this.tagCompound.getCompoundTag(
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/mixins.pss.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"mods.MixinEssentialsTelemetryManager"
],
"client": [
"minecraft.MixinGuiChest",
"minecraft.MixinGuiContainer",
"minecraft.MixinGuiPlayerTabOverlay",
"minecraft.MixinPlayerController"
"minecraft.accessors.GuiChestAccessor",
"minecraft.accessors.GuiContainerAccessor",
"minecraft.accessors.GuiPlayerTabOverlayAccessor",
"minecraft.MixinPlayerControllerMP"
]
}
}
Loading