-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/stats' into dev
- Loading branch information
Showing
23 changed files
with
404 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mixins/early/forge/MixinASMDataTable.java → ...e/mixins/early/fml/MixinASMDataTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ns/early/forge/MixinFMLClientHandler.java → ...xins/early/fml/MixinFMLClientHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...xins/early/forge/MixinFMLProxyPacket.java → ...mixins/early/fml/MixinFMLProxyPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/com/mitchej123/hodgepodge/mixins/early/fml/MixinGameRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.mitchej123.hodgepodge.mixins.early.fml; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemBlock; | ||
import net.minecraft.stats.StatCrafting; | ||
import net.minecraft.stats.StatList; | ||
import net.minecraft.util.ChatComponentTranslation; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.mitchej123.hodgepodge.Common; | ||
|
||
import cpw.mods.fml.common.registry.GameRegistry; | ||
|
||
@Mixin(GameRegistry.class) | ||
public class MixinGameRegistry { | ||
|
||
@ModifyExpressionValue( | ||
at = @At( | ||
target = "Lcpw/mods/fml/common/registry/GameData;registerItem(Lnet/minecraft/item/Item;Ljava/lang/String;)I", | ||
value = "INVOKE"), | ||
method = "registerBlock(Lnet/minecraft/block/Block;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/block/Block;", | ||
remap = false) | ||
private static int hodgepodge$registerBlockStats(int itemId, Block block, Class<? extends ItemBlock> itemclass, | ||
String name, Object[] itemCtorArgs, @Local ItemBlock i) { | ||
if (block.getEnableStats()) { | ||
StatCrafting statMine = hodgepodge$createAndRegisterStat("stat.mineBlock", i); | ||
StatList.mineBlockStatArray[itemId] = statMine; | ||
StatList.objectMineStats.add(statMine); | ||
} | ||
StatList.objectUseStats[itemId] = hodgepodge$createAndRegisterStat("stat.useItem", i); | ||
StatList.objectCraftStats[itemId] = hodgepodge$createAndRegisterStat("stat.craftItem", i); | ||
return itemId; | ||
} | ||
|
||
@ModifyExpressionValue( | ||
at = @At( | ||
target = "Lcpw/mods/fml/common/registry/GameData;registerItem(Lnet/minecraft/item/Item;Ljava/lang/String;)I", | ||
value = "INVOKE"), | ||
method = "registerItem(Lnet/minecraft/item/Item;Ljava/lang/String;Ljava/lang/String;)Lnet/minecraft/item/Item;", | ||
remap = false) | ||
private static int hodgepodge$registerItemStats(int itemId, Item item, String name, String modId) { | ||
if (item.isDamageable()) { | ||
StatList.objectBreakStats[itemId] = hodgepodge$createAndRegisterStat("stat.breakItem", item); | ||
} | ||
StatCrafting statCraft = hodgepodge$createAndRegisterStat("stat.useItem", item); | ||
StatList.objectUseStats[itemId] = statCraft; | ||
if (!(item instanceof ItemBlock)) { | ||
StatList.itemStats.add(statCraft); | ||
} | ||
StatList.objectCraftStats[itemId] = hodgepodge$createAndRegisterStat("stat.craftItem", item); | ||
return itemId; | ||
} | ||
|
||
@Unique | ||
private static StatCrafting hodgepodge$createAndRegisterStat(String key, Item item) { | ||
String unlocalizedName; | ||
try { | ||
unlocalizedName = item.getUnlocalizedName(); | ||
} catch (Exception e) { | ||
String registryName = item.delegate.name(); | ||
unlocalizedName = "item." + registryName + ".name"; | ||
Common.log.warn( | ||
"An Exception occured while invoking Item.getUnlocalizedName() after registering the item {} ({})! Using fallback unlocalized name.", | ||
registryName, | ||
item.getClass().getName()); | ||
} | ||
StatCrafting stat = new StatCrafting( | ||
key + ".autogen." + item.delegate.name(), | ||
new ChatComponentTranslation(key, new ChatComponentTranslation(unlocalizedName)), | ||
item); | ||
stat.registerStat(); | ||
return stat; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ns/early/forge/MixinLanguageRegistry.java → ...xins/early/fml/MixinLanguageRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/early/forge/MixinNetworkDispatcher.java → ...ins/early/fml/MixinNetworkDispatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinStatList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.mitchej123.hodgepodge.mixins.early.minecraft; | ||
|
||
import net.minecraft.entity.EntityList.EntityEggInfo; | ||
import net.minecraft.stats.StatList; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.mitchej123.hodgepodge.util.StatHandler; | ||
import com.mitchej123.hodgepodge.util.StatHandler.EntityInfo; | ||
|
||
@Mixin(StatList.class) | ||
public class MixinStatList { | ||
|
||
@ModifyExpressionValue( | ||
at = @At( | ||
target = "Lnet/minecraft/entity/EntityList;getStringFromID(I)Ljava/lang/String;", | ||
value = "INVOKE"), | ||
method = { "func_151182_a", "func_151176_b" }) // these methods create and register the stats for | ||
// killing/being killed by the specified entity | ||
private static String hodgepodge$getEntityName(String original, EntityEggInfo info) { | ||
if (info instanceof EntityInfo) { | ||
return StatHandler.currentEntityName; | ||
} | ||
return original; | ||
} | ||
|
||
} |
Oops, something went wrong.