Browse Source

Autocollecting Tools now actually throw Item Collection Events Fixes #35

Gregorius Techneticies 2 months ago
parent
commit
6534d4fd6f
Signed by: Gregorius Techneticies <gregoriustech@gmail.com> GPG Key ID: 1B693EA14F2FD70F
2 changed files with 22 additions and 10 deletions
  1. 1
    0
      CHANGELOG.md
  2. 21
    10
      src/main/java/gregapi/GT_API_Proxy.java

+ 1
- 0
CHANGELOG.md View File

@@ -11,6 +11,7 @@ Nothing (I tend to only add finished Stuff to the Changelog).
11 11
 
12 12
 6.14.09: (Not released yet, released whenever it needs to be)
13 13
 [COMPAT] Aroma1997's Mining Dimension is now Compatible with my Worldgen.
14
+[FIXED] Forestry Backpacks didn't work with Autocollecting Tools, because the Magnetic Autocollect did not throw an Item Collect Event.
14 15
 [FIXED] Chainsaws used WAY too much durability for Treecapitation!
15 16
 [FIXED] Worldgeneration in different Dimensions had the same RNG as on the Overworld. Now the Seed is being XOR-ed with the Dimension ID to prevent that. This has the convenient Side Effect of the Overworld staying the same as before, because it's ID is Zero.
16 17
 [CHANGED] Blue Steel is Red Steel now and vice versa. This should fix my ages old fuckup of the Recipes. Everything should still be the same as before when it comes to Stats, just the Color of the Material changed. If you used Matter Fabricators to make Red/Blue Steel for some reason, you may need to check the USB Stick with the Recipe.

+ 21
- 10
src/main/java/gregapi/GT_API_Proxy.java View File

@@ -146,6 +146,7 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
146 146
 import net.minecraftforge.event.entity.living.LivingSpawnEvent;
147 147
 import net.minecraftforge.event.entity.player.ArrowLooseEvent;
148 148
 import net.minecraftforge.event.entity.player.ArrowNockEvent;
149
+import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
149 150
 import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
150 151
 import net.minecraftforge.event.entity.player.PlayerEvent;
151 152
 import net.minecraftforge.event.entity.player.PlayerInteractEvent;
@@ -634,8 +635,9 @@ public abstract class GT_API_Proxy extends Abstract_Proxy implements IGuiHandler
634 635
 									aEvent.player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, Math.max(140, ((tEffect = aEvent.player.getActivePotionEffect(Potion.moveSlowdown))==null?0:tEffect.getDuration())), 3));
635 636
 								}
636 637
 								if (tCrazyJ1984 && !tStack.hasTagCompound() && tData.hasValidPrefixData() && tData.mPrefix.mNameInternal.startsWith("gem")) {
637
-									if (tData.mMaterial.mMaterial == MT.Diamond  ) ST.name_(tStack, tData.mPrefix.mMaterialPre + MT.Craponite.mNameLocal + tData.mPrefix.mMaterialPost);
638
-									if (tData.mMaterial.mMaterial == MT.Craponite) ST.name_(tStack, tData.mPrefix.mMaterialPre + MT.Diamond  .mNameLocal + tData.mPrefix.mMaterialPost);
638
+									if (tData.mMaterial.mMaterial == MT.Diamond    ) ST.name_(tStack, tData.mPrefix.mMaterialPre + MT.Craponite.mNameLocal + tData.mPrefix.mMaterialPost);
639
+									if (tData.mMaterial.mMaterial == MT.DiamondPink) ST.name_(tStack, tData.mPrefix.mMaterialPre + MT.Craponite.mNameLocal + tData.mPrefix.mMaterialPost);
640
+									if (tData.mMaterial.mMaterial == MT.Craponite  ) ST.name_(tStack, tData.mPrefix.mMaterialPre + MT.Diamond  .mNameLocal + tData.mPrefix.mMaterialPost);
639 641
 								}
640 642
 							}
641 643
 							if (tHungerEffect) tCount+=(tStack.stackSize * 64) / Math.max(1, tStack.getMaxStackSize());
@@ -1014,9 +1016,9 @@ public abstract class GT_API_Proxy extends Abstract_Proxy implements IGuiHandler
1014 1016
 	public void onBlockHarvestingEvent(BlockEvent.HarvestDropsEvent aEvent) {
1015 1017
 		Iterator<ItemStack> aDrops = aEvent.drops.iterator();
1016 1018
 		while (aDrops.hasNext()) {
1017
-			ItemStack tDrop = aDrops.next();
1018
-			if (ST.invalid(tDrop) || ItemsGT.ILLEGAL_DROPS.contains(tDrop, T)) {aDrops.remove(); continue;}
1019
-			if (ST.item_(tDrop) == Items.gold_nugget) ST.meta_(tDrop, 0);
1019
+			ItemStack aDrop = aDrops.next();
1020
+			if (ST.invalid(aDrop) || ItemsGT.ILLEGAL_DROPS.contains(aDrop, T)) {aDrops.remove(); continue;}
1021
+			if (ST.item_(aDrop) == Items.gold_nugget) ST.meta_(aDrop, 0);
1020 1022
 		}
1021 1023
 		
1022 1024
 		if (aEvent.block == Blocks.dirt && aEvent.blockMetadata == 1) for (int i = 0, j = aEvent.drops.size(); i < j; i++) if (ST.block(aEvent.drops.get(0)) == Blocks.dirt) {
@@ -1095,11 +1097,20 @@ public abstract class GT_API_Proxy extends Abstract_Proxy implements IGuiHandler
1095 1097
 				if (tCanCollect && !aEvent.drops.isEmpty()) {
1096 1098
 					boolean aCollectSound = T;
1097 1099
 					aDrops = aEvent.drops.iterator();
1098
-					while (aDrops.hasNext()) if (UT.Inventories.addStackToPlayerInventory(aEvent.harvester, ST.update(aDrops.next(), aEvent.world, aEvent.x, aEvent.y, aEvent.z))) {
1099
-						aDrops.remove();
1100
-						if (aCollectSound) {
1101
-							UT.Sounds.send(SFX.MC_COLLECT, 0.2F, ((RNGSUS.nextFloat()-RNGSUS.nextFloat())*0.7F+1.0F)*2.0F, aEvent.harvester);
1102
-							aCollectSound = F;
1100
+					while (aDrops.hasNext()) {
1101
+						ItemStack aDrop = ST.update(aDrops.next(), aEvent.world, aEvent.x, aEvent.y, aEvent.z);
1102
+						
1103
+						EntityItem tEntity = ST.entity(aEvent.harvester, aDrop);
1104
+						EntityItemPickupEvent tEvent = new EntityItemPickupEvent(aEvent.harvester, tEntity);
1105
+						ST.set(aDrop, tEvent.item.getEntityItem(), T, T);
1106
+						if (MinecraftForge.EVENT_BUS.post(tEvent)) continue;
1107
+						
1108
+						if (tEvent.getResult() == Result.ALLOW || aDrop.stackSize <= 0 || UT.Inventories.addStackToPlayerInventory(aEvent.harvester, aDrop)) {
1109
+							aDrops.remove();
1110
+							if (aCollectSound) {
1111
+								UT.Sounds.send(SFX.MC_COLLECT, 0.2F, ((RNGSUS.nextFloat()-RNGSUS.nextFloat())*0.7F+1.0F)*2.0F, aEvent.harvester);
1112
+								aCollectSound = F;
1113
+							}
1103 1114
 						}
1104 1115
 					}
1105 1116
 				}

Loading…
Cancel
Save