Skip to content

Commit

Permalink
1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mdashlw committed Apr 21, 2021
1 parent f7ac376 commit 47acfce
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'

group 'ru.mdashlw.hypixel.pit.stats'
version '1.4.0'
version '1.5.0'
archivesBaseName = 'The Hypixel Pit - Epic Stats'

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import ru.mdashlw.hypixel.pit.stats.config.Settings;
import ru.mdashlw.hypixel.pit.stats.listeners.ChatListener;

@Mod(modid = "pitstats", name = "Hypixel Pit Stats", version = "1.4.0", clientSideOnly = true)
@Mod(modid = "pitstats", name = "Hypixel Pit Stats", version = "1.5.0", clientSideOnly = true)
public final class HypixelPitStats {

@Mod.Instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import org.spongepowered.asm.lib.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -29,9 +31,11 @@ public final class MixinItemStack {
method = "getTooltip",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/item/ItemStack;getAttributeModifiers()Lcom/google/common/collect/Multimap;"
target = "Lnet/minecraft/item/ItemStack;getAttributeModifiers()Lcom/google/common/collect/Multimap;",
ordinal = 0,
opcode = Opcodes.INVOKEVIRTUAL
),
locals = LocalCapture.CAPTURE_FAILSOFT
locals = LocalCapture.CAPTURE_FAILHARD
)
public void getTooltip(final EntityPlayer player, final boolean advanced,
final CallbackInfoReturnable<List<String>> cir,
Expand Down Expand Up @@ -75,4 +79,38 @@ public void getTooltip(final EntityPlayer player, final boolean advanced,
}
}
}

@Inject(
method = "isItemEnchanted",
at = @At("RETURN"),
cancellable = true
)
public void isItemEnchanted(final CallbackInfoReturnable<Boolean> cir) {
final HypixelPitStats mod = HypixelPitStats.getInstance();

if (mod == null) {
return;
}

if (!mod.getSettings().isBetterGlint()) {
return;
}

final Item item = this.item;

if (item != null && (item == Items.leather_leggings || item == Items.golden_sword || item == Items.bow)) {
final NBTTagCompound nbt = this.stackTagCompound;

if (nbt != null && nbt.hasKey("ExtraAttributes", 10)) {
final NBTTagCompound extraAttributes = (NBTTagCompound) nbt.getTag("ExtraAttributes");
final int nonce = extraAttributes.getInteger("Nonce");

if (nonce != 0) {
final NBTTagList customEnchants = extraAttributes.getTagList("CustomEnchants", 10);

cir.setReturnValue(customEnchants.tagCount() != 0);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,25 @@ public void processCommand(final ICommandSender sender, final String[] args) {
return;
}

if (playerName.equalsIgnoreCase("config") || playerName.equalsIgnoreCase("cfg")) {
if (playerName.equalsIgnoreCase("config") ||
playerName.equalsIgnoreCase("cfg") ||
playerName.equalsIgnoreCase("settings")) {
final Settings settings = mod.getSettings();

if (args.length == 1) {
sender.addChatMessage(new ChatComponentText("§9[§6PIT§9] §7Mod Configuration (click to toggle on/off)\n")
.appendSibling(new ChatComponentText("§8> §fDisplay required pants for mystic items §8- " +
(settings.isDisplayRequiredPants() ? "§aON" : "§cOFF"))
.appendSibling(new ChatComponentText(" §8- §fDisplay required pants for mystic items: " +
(settings.isDisplayRequiredPants() ? "§aON" : "§cOFF") + "\n")
.setChatStyle(new ChatStyle()
.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new ChatComponentText("§7Click to toggle this setting on/off")))
.setChatClickEvent(new ClickEvent(Action.RUN_COMMAND, "/pit config pants")))));
.setChatClickEvent(new ClickEvent(Action.RUN_COMMAND, "/pit config pants"))))
.appendSibling(new ChatComponentText(" §8- §fAdd enchant glint for pit items: " +
(settings.isBetterGlint() ? "§aON" : "§cOFF"))
.setChatStyle(new ChatStyle()
.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new ChatComponentText("§7Click to toggle this setting on/off")))
.setChatClickEvent(new ClickEvent(Action.RUN_COMMAND, "/pit config glint")))));
return;
}

Expand All @@ -78,6 +86,11 @@ public void processCommand(final ICommandSender sender, final String[] args) {
settings.save();
sender.addChatMessage(new ChatComponentText("§9[§6PIT§9] §7Display required pants for mystic items is now " +
(settings.isDisplayRequiredPants() ? "§aenabled" : "§cdisabled") + "§7."));
} else if (option.equalsIgnoreCase("glint")) {
settings.setBetterGlint(!settings.isBetterGlint());
sender.addChatMessage(new ChatComponentText("§9[§6PIT§9] §7Add enchant glint for pit items now " +
(settings.isBetterGlint() ? "§aenabled" : "§cdisabled") + "§7."));
settings.save();
} else {
sender.addChatMessage(new ChatComponentText("§9[§6PIT§9] §7Invalid config option."));
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/ru/mdashlw/hypixel/pit/stats/config/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public final class Settings {
private final Configuration configuration;
private String apiKey;
private boolean displayRequiredPants;
private boolean betterGlint;

public Settings(final Configuration configuration) {
this.configuration = configuration;
Expand Down Expand Up @@ -40,6 +41,14 @@ public void update(final boolean load) {
} else {
property.set(this.displayRequiredPants);
}

property = this.configuration.get("general", "better_glint", true);

if (load) {
this.betterGlint = property.getBoolean();
} else {
property.set(this.betterGlint);
}
}

public String getApiKey() {
Expand All @@ -57,4 +66,12 @@ public boolean isDisplayRequiredPants() {
public void setDisplayRequiredPants(final boolean displayRequiredPants) {
this.displayRequiredPants = displayRequiredPants;
}

public boolean isBetterGlint() {
return this.betterGlint;
}

public void setBetterGlint(final boolean betterGlint) {
this.betterGlint = betterGlint;
}
}

0 comments on commit 47acfce

Please sign in to comment.