Skip to content

Commit

Permalink
might fix achievements from items gotten through inventories instead …
Browse files Browse the repository at this point in the history
…of drops
  • Loading branch information
GregoriusT committed Sep 10, 2023
1 parent 71967db commit 535d0dd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
5 changes: 0 additions & 5 deletions src/main/java/gregapi/GT_API_Proxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -932,11 +932,6 @@ public void onPlayerInteraction(PlayerInteractEvent aEvent) {
Block aBlock = WD.block(aEvent.world, aEvent.x, aEvent.y, aEvent.z);
TileEntity aTileEntity = aEvent.world.getTileEntity(aEvent.x, aEvent.y, aEvent.z);

// You cant detect properly when you pick things up out of a Chest.
if (IL.TF_Trophy_Urghast.equal(aStack, T, T)) {
UT.Inventories.checkAchievements(aEvent.entityPlayer, aStack);
}

if (aEvent.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
// Fixing a Vanilla Dupe Bug with stacked Music Discs and the Jukebox.
if (aTileEntity instanceof TileEntityJukebox) {
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/gregapi/gui/ContainerCommon.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020 GregTech-6 Team
* Copyright (c) 2023 GregTech-6 Team
*
* This file is part of GregTech.
*
Expand All @@ -19,10 +19,6 @@

package gregapi.gui;

import static gregapi.data.CS.*;

import java.util.List;

import gregapi.tileentity.ITileEntityInventoryGUI;
import gregapi.util.ST;
import gregapi.util.UT;
Expand All @@ -34,6 +30,10 @@
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

import java.util.List;

import static gregapi.data.CS.*;

/**
* @author Gregorius Techneticies
*/
Expand Down Expand Up @@ -489,6 +489,8 @@ public ItemStack slotClick(int aIndex, int aMouse, int aShift, EntityPlayer aPla
aPlayerInventory.setItemStack(tTempStack);
}
}

UT.Inventories.checkAchievements(aPlayer, aPlayerInventory.getItemStack());
detectAndSendChanges();
return rStack;
}
Expand All @@ -503,6 +505,7 @@ public ItemStack transferStackInSlot(EntityPlayer aPlayer, int aIndex) {
// null checks and checks if the item can be stacked (maxStackSize > 1)
if (getSlotCount() > 0 && tSlot != null && tSlot.getHasStack() && !(tSlot instanceof Slot_Holo)) {
ItemStack tStack = tSlot.getStack();
UT.Inventories.checkAchievements(aPlayer, tStack);
rStack = ST.copy(tStack);

// TileEntity -> Player
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gregapi/util/UT.java
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ public static boolean unlockAchievement(EntityPlayer aPlayer, Achievement aAchie
}

public static boolean checkAchievements(EntityPlayer aPlayer, ItemStack aStack) {
if (aPlayer == null) return F;
if (aPlayer == null || aPlayer.worldObj == null || aPlayer.worldObj.isRemote) return F;

if (aPlayer.worldObj.provider.dimensionId == DIM_NETHER) {
unlockAchievement(aPlayer, AchievementList.portal);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/gregtech/loaders/b/Loader_Books.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public void run() {
, "Once you are inside of the Twilight Forest you can gather up Materials from the ground as usual. A good recommendation would be to find a Firefly Forest and grab a bunch of the Firefly Jars there, because they are blocklike Torches."
, "The Obsidian Pillars you see spread all over the place have a Block of Lapis Lazuli at their Top, it is sometimes easier to get that then to go mining. These Pillars also have Ravens around them, if you need a Feather for a Magic Map Focus."
, "Lakes are just boring Bodies of Water, not even Squids spawn inside of them, due to the Twilight Forest being of a too low Y Level to do so. I guess the Lake is a good place to go fishing or build some IC2 Water Power Generator."
, "The Mushroom Fortress is currently not in use. No Loot or anything in there, not even Staircases or Ladders, you could make a Base inside of it though."
, "The Questing Ram is an Animal you can find in the middle of a Biome full of Rainbow Trees. If you click it with one of each type of Wool it will reward you with the Crumble Horn, a somewhat useful Mining Tool, and some Blocks of Resources."
, "In general all Loot Chests in Twilight Forest can be picked up wholesale as long as you have never opened them before. That way you can bring them home without cluttering your Inventory and then open them there safely."
, "If you find small ruined Buildings, it is well advised to break their wooden Floor and dig a three block deep hole to see if there is a hidden Chest in the Basement. It is a 50:50 chance for it to exist."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ protected ItemStack[] generateChestContent(Random aRandom, IInventory aInventory
aWorld.setBlock(aX, aY, aZ, NB, 0, 1);
// Place the better Loot Chest.
tRegistry.mBlock.placeBlock(aWorld, aX, aY, aZ, SIDE_UNKNOWN, mChestID, UT.NBT.make(NBT_FACING, tFacing, NBT_TRAPPED, T, "gt.dungeonloot", mCategory), F, T);
// TODO REMOVE DEBUG LINE
if (ChestGenHooks.DUNGEON_CHEST.equals(mCategory)) {
DEB.println(aX + " ; " + aY + " ; " + aZ);
new Exception().printStackTrace(DEB);
}
// Loot wont need to be generated anymore in that case.
return ZL_IS;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/gregtech/worldgen/TwilightTreasureReplacer.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ public TwilightTreasureReplacer(TFTreasure aTreasure, int aIndex, String aCatego
useless .add(Items.feather, 8);
useless .add(FL.Potion_NightVision_1L.fill(IL.Porcelain_Cup.get(1)));
useless .add(IL.Food_Pickle.get(8));
// A Guide to the Twilight Forest.
rare .add(ST.book("Manual_Portal_TF"));
// Add a Death Compass to the Ultra Rares, even though it is super easy to get.
ultrarare.add(IL.Compass_Death.get(1));
// A Guide to the Twilight Forest.
ultrarare.add(ST.book("Manual_Portal_TF"));
}

// Labyrinth Vault
Expand Down Expand Up @@ -217,7 +217,7 @@ public TwilightTreasureReplacer(TFTreasure aTreasure, int aIndex, String aCatego

@Override public boolean generate(World aWorld, Random aRandom, int aX, int aY, int aZ) {return generate(aWorld, aRandom, aX, aY, aZ, Blocks.chest);}
@Override public boolean generate(World aWorld, Random aRandom, int aX, int aY, int aZ, Block aChest) {
if (mTreasureID == 3 && RNGSUS.nextBoolean()) return HILLS_2.generate(aWorld, aRandom, aX, aY, aZ, aChest);
if (mTreasureID == 3 && RNGSUS.nextInt(3) == 0) return HILLS_2.generate(aWorld, aRandom, aX, aY, aZ, aChest);
MultiTileEntityRegistry tRegistry = MultiTileEntityRegistry.getRegistry("gt.multitileentity");
if (tRegistry == null) return super.generate(aWorld, aRandom, aX, aY, aZ, aChest);
// Narrow down facing direction of the Chest if it is a double chest.
Expand Down

0 comments on commit 535d0dd

Please sign in to comment.