Conflicts:
	src/main/java/techreborn/Core.java
This commit is contained in:
Modmuss50 2015-04-17 17:43:44 +01:00
commit 8f33305025
14 changed files with 130 additions and 0 deletions

View file

@ -5,7 +5,11 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
<<<<<<< HEAD
import net.minecraftforge.common.MinecraftForge;
=======
import techreborn.achievement.TRAchievements;
>>>>>>> d5628ff93a9b7d42a02be9eb21b95d57313cd15e
import techreborn.client.GuiHandler;
import techreborn.compat.CompatManager;
import techreborn.config.ConfigTechReborn;
@ -55,6 +59,8 @@ public class Core {
PacketHandler.setChannels(NetworkRegistry.INSTANCE.newChannel(ModInfo.MOD_ID + "_packets", new PacketHandler()));
//Events
MinecraftForge.EVENT_BUS.register(new MultiblockEvent());
//Achievements
TRAchievements.init();
LogHelper.info("Initialization Compleate");
}

View file

@ -0,0 +1,32 @@
package techreborn.achievement;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
public class AchievementMod extends Achievement{
public static List<Achievement> achievements = new ArrayList();
public AchievementMod(String name, int x, int y, ItemStack icon, Achievement parent)
{
super("achievement.techreborn:" + name, "TechReborn:" + name, x, y, icon, parent);
achievements.add(this);
registerStat();
}
public AchievementMod(String name, int x, int y, Item icon, Achievement parent)
{
this(name, x, y, new ItemStack(icon), parent);
}
public AchievementMod(String name, int x, int y, Block icon, Achievement parent)
{
this(name, x, y, new ItemStack(icon), parent);
}
}

View file

@ -0,0 +1,30 @@
package techreborn.achievement;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
public class AchievementTriggerer {
@SubscribeEvent
public void onItemPickedUp(ItemPickupEvent event) {
ItemStack stack = event.pickedUp.getEntityItem();
if(stack != null && stack.getItem() instanceof IPickupAchievement) {
Achievement achievement = ((IPickupAchievement) stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp);
if(achievement != null)
event.player.addStat(achievement, 1);
}
}
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event) {
if(event.crafting != null && event.crafting.getItem() instanceof ICraftAchievement) {
Achievement achievement = ((ICraftAchievement) event.crafting.getItem()).getAchievementOnCraft(event.crafting, event.player, event.craftMatrix);
if(achievement != null)
event.player.addStat(achievement, 1);
}
}
}

View file

@ -0,0 +1,12 @@
package techreborn.achievement;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
public interface ICraftAchievement {
public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix);
}

View file

@ -0,0 +1,12 @@
package techreborn.achievement;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
public interface IPickupAchievement {
public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item);
}

View file

@ -0,0 +1,30 @@
package techreborn.achievement;
import cpw.mods.fml.common.FMLCommonHandler;
import techreborn.init.ModBlocks;
import techreborn.lib.AchievementNames;
import techreborn.lib.ModInfo;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraftforge.common.AchievementPage;
public class TRAchievements {
public static AchievementPage techrebornPage;
public static int pageIndex;
public static Achievement orePickUp;
public static void init()
{
orePickUp = new AchievementMod(AchievementNames.ORE_PICKUP, 0, 0, new ItemStack(ModBlocks.ore,1, 0), null);
pageIndex = AchievementPage.getAchievementPages().size();
techrebornPage = new AchievementPage(ModInfo.MOD_NAME, AchievementMod.achievements.toArray(new Achievement[AchievementMod.achievements.size()]));
AchievementPage.registerAchievementPage(techrebornPage);
FMLCommonHandler.instance().bus().register(new AchievementTriggerer());
}
}

View file

@ -0,0 +1,7 @@
package techreborn.lib;
public class AchievementNames
{
public static final String ORE_PICKUP = "orePickup";
}

View file

@ -9,6 +9,7 @@ tile.techreborn.rollingmachine.name=Rolling machine
tile.techreborn.machineCasing.Standard.name=Standard Casing
tile.techreborn.machineCasing.Reinforced.name=Reinforced Casing
tile.techreborn.machineCasing.Advanced.name=Advanced Casing
tile.techreborn.blastfurnace.name=Blast Furnace
#Ores
tile.techreborn.ore.Galena.name=Galena Ore

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB