Skip to content
Draft
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
24 changes: 16 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
mavenCentral()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:3.+'
gradlePluginPortal()
}
}

apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
plugins {
id "java"
id "idea"
id "maven-publish"
id "net.minecraftforge.gradle" version "5.1.+"
id "com.github.johnrengelman.shadow" version "7.1.0"
}

version = '1.1.1'
version = '1.1.2'
group = 'net.mcplayhd.lootrunstatistics' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'lootrunstatistics'

Expand All @@ -37,6 +38,8 @@ minecraft {
client {
workingDirectory project.file('run')

property("devauth.configDir", project.file(".devauth").absolutePath)

// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

Expand All @@ -55,6 +58,11 @@ minecraft {
}
}

repositories {
maven { url = "https://maven.minecraftforge.net" }
maven { url = "https://files.minecraftforge.net/maven" }
}

dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
19 changes: 19 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven { url = "https://maven.minecraftforge.net/" }
maven { url = "https://files.minecraftforge.net/maven" }
}
resolutionStrategy {
eachPlugin {
switch (requested.id.id) {
case "net.minecraftforge.gradle":
useModule("net.minecraftforge.gradle:ForgeGradle:${requested.version}")
break
}
}
}
}

rootProject.name = "LootrunStatistics"
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class LootrunStatistics {
public static final String MODID = "lootrunstatistics";
public static final String NAME = "Lootrun Statistics";
// version needs to be updated here, in resources/version.txt and in build.gradle
public static final String VERSION = "1.1.1";
public static final String VERSION = "1.1.2";

private static Logger logger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerChest;
Expand All @@ -22,11 +24,14 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -51,7 +56,7 @@ private Loc getLastChestLocation() {
private EntityPlayerSP getPlayer() {
return Minecraft.getMinecraft().player;
}

/*
@SubscribeEvent(priority = EventPriority.LOWEST)
public void openChest(PlayerInteractEvent.RightClickBlock e) {
if (e.isCanceled()) return;
Expand All @@ -66,6 +71,31 @@ public void openChest(PlayerInteractEvent.RightClickBlock e) {
chestLocation = pos.toImmutable();
getLogger().info("Clicked chest at " + chestLocation.getX() + "," + chestLocation.getY() + "," + chestLocation.getZ() + ".");
}
*/

@SubscribeEvent
public void onRightClick(PlayerInteractEvent.EntityInteract event) {
Entity entity = event.getTarget();
if (entity instanceof EntitySlime) {
BlockPos pos = entity.getPosition();
chestConsidered = false;
foundItemsUntilSlot = -1;
lastItemArrived = -1;
chestLocation = pos.toImmutable();
}
}

@SubscribeEvent
public void onLeftClick(AttackEntityEvent event) {
Entity entity = event.getTarget();
if (entity instanceof EntitySlime) {
BlockPos pos = entity.getPosition();
chestConsidered = false;
foundItemsUntilSlot = -1;
lastItemArrived = -1;
chestLocation = pos.toImmutable();
}
}

/*
Credits to https://github.com/albarv340/chestcountmod for using the InitGuiEvent to change the title of the chest
Expand All @@ -81,7 +111,8 @@ public void onGuiOpen(GuiScreenEvent.InitGuiEvent event) {
if (!(openContainer instanceof ContainerChest)) return;
InventoryBasic lowerInventory = (InventoryBasic) ((ContainerChest) openContainer).getLowerChestInventory();
String containerName = Objects.requireNonNull(TextFormatting.getTextWithoutFormattingCodes(lowerInventory.getName()));
if (containerName.startsWith("Loot Chest") && !containerName.contains("\u00a77\u00a7r") && !chestConsidered) {

if ((containerName.startsWith("Loot Chest") || containerName.startsWith("Objective Rewards") || containerName.startsWith("Challenge Rewards")) && !containerName.contains("§7§r") && !chestConsidered) {
// this is a loot chest, and we did not yet change its name.
getChestCountData().addChest();
int totalChests = getChestCountData().getTotalChests();
Expand All @@ -90,9 +121,9 @@ public void onGuiOpen(GuiScreenEvent.InitGuiEvent event) {
// "\u00a77\u00a7r" is our identifier.
// It won't show because it just sets the color and resets it immediately.
if (getConfiguration().displayTotalChestCountInChest()) {
lowerInventory.setCustomName(lowerInventory.getName() + "\u00a77\u00a7r" + " #" + getFormatted(totalChests));
lowerInventory.setCustomName(lowerInventory.getName() + "§7§r" + " #" + getFormatted(totalChests));
} else {
lowerInventory.setCustomName(lowerInventory.getName() + "\u00a77\u00a7r");
lowerInventory.setCustomName(lowerInventory.getName() + "§7§r");
}
}
} catch (Throwable throwable) {
Expand All @@ -110,7 +141,7 @@ public void guiDraw(GuiScreenEvent.DrawScreenEvent.Pre event) {
if (!(openContainer instanceof ContainerChest)) return;
InventoryBasic lowerInventory = (InventoryBasic) ((ContainerChest) openContainer).getLowerChestInventory();
String containerName = Objects.requireNonNull(TextFormatting.getTextWithoutFormattingCodes(lowerInventory.getName()));
if (!containerName.startsWith("Loot Chest")) return;
if (!containerName.startsWith("Loot Chest") && !containerName.startsWith("Objective Rewards") && !containerName.startsWith("Challenge Rewards")) return;
if (getConfiguration().displayDryCountInChest()) {
// Credits to https://github.com/albarv340/chestcountmod
GlStateManager.pushMatrix();
Expand Down Expand Up @@ -150,15 +181,29 @@ public void guiDraw(GuiScreenEvent.DrawScreenEvent.Pre event) {
if (foundItemsUntilSlot == -1) {
// this is the first time we saw an item in this chest
getChests().registerOpened(loc);
containerName = containerName.substring("Loot Chest ".length());
String[] sp = containerName.split(" ");
String roman = sp[0];
int tier = FormatterHelper.convertRomanToArabic(roman);
getChests().setTier(loc, tier);
if (containerName.startsWith("Loot Chest")) {
String[] sp = lowerInventory.getName().substring("Loot Chest ".length()).split(" ");
String roman = sp[0];
int tier = 1;
switch (roman) {
case "§7[§f✫§8✫✫✫§7]§7§r":
tier = 1;
break;
case "§e[§6✫✫§8✫✫§e]§7§r":
tier = 2;
break;
case "§5[§d✫✫✫§8✫§5]§7§r":
tier = 3;
break;
case "§3[§b✫✫✫✫§3]§7§r":
tier = 4;
break;
}
getChests().setTier(loc, tier);
}
}
boolean dryDataUpdated = false;
// we can now check every slot up until the slot we found the last item in
getLogger().info("Checking from slot " + (foundItemsUntilSlot + 1) + " up to and including slot " + (newFoundItemsUntilSlot));
for (int slot = foundItemsUntilSlot + 1; slot <= newFoundItemsUntilSlot; slot++) {
try { // I intentionally cause exceptions because it's more convenient to develop
ItemStack itemStack = lowerInventory.getStackInSlot(slot);
Expand Down Expand Up @@ -233,6 +278,11 @@ public void guiDraw(GuiScreenEvent.DrawScreenEvent.Pre event) {
getChests().addEmeralds(loc, emeralds);
getDryData().addEmeralds(emeralds);
dryDataUpdated = true;
} else if (displayName.equals("Emerald Block")) {
int emeralds = itemStack.getCount() * 64;
getChests().addEmeralds(loc, emeralds);
getDryData().addEmeralds(emeralds);
dryDataUpdated = true;
} else if (displayName.contains("Earth Powder")
|| displayName.contains("Thunder Powder")
|| displayName.contains("Fire Powder")
Expand Down