Skip to content

Commit

Permalink
New achievement
Browse files Browse the repository at this point in the history
- Added two new events related to smeltery
- Added a new secret achievement labelled "Doing it Wrong"
  • Loading branch information
fuj1n committed Dec 14, 2013
1 parent 049f8f4 commit 5694517
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 13 deletions.
2 changes: 2 additions & 0 deletions resources/assets/tinker/lang/en_US.lang
Expand Up @@ -598,6 +598,7 @@ achievement.tconstruct.smelteryMaker=Smeltery Creator
achievement.tconstruct.preparedFight=Prepared to Fight
achievement.tconstruct.enemySlayer=Enemy Slayer
achievement.tconstruct.dualConvenience=Dual Convenience
achievement.tconstruct.doingItWrong=Doing it wrong

achievement.tconstruct.beginner.desc=Open the "Materials and You" manual
achievement.tconstruct.pattern.desc=Craft your first blank pattern
Expand All @@ -607,6 +608,7 @@ achievement.tconstruct.smelteryMaker.desc=Craft a smeltery component
achievement.tconstruct.preparedFight.desc=Create your first weapon
achievement.tconstruct.enemySlayer.desc=Slay a mob
achievement.tconstruct.dualConvenience.desc=Kill a mob with a frying pan, and then cook their meat in it
achievement.tconstruct.doingItWrong.desc=You are doing it wrong!

knapsack.tooltip=A Knapsack to hold your things.
strangefood1.tooltip=It smells terrible, but if you
Expand Down
28 changes: 15 additions & 13 deletions src/main/java/tconstruct/blocks/SearedBlock.java
@@ -1,25 +1,21 @@
package tconstruct.blocks;

import java.util.List;

import tconstruct.TConstruct;
import tconstruct.blocks.logic.CastingBasinLogic;
import tconstruct.blocks.logic.CastingTableLogic;
import tconstruct.blocks.logic.FaucetLogic;
import tconstruct.client.block.SearedRender;
import tconstruct.library.TConstructRegistry;
import mantle.blocks.abstracts.InventoryBlock;
import tconstruct.library.tools.AbilityHelper;

import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.util.*;
import net.minecraft.world.*;
import net.minecraftforge.common.MinecraftForge;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.*;
import tconstruct.client.block.SearedRender;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.event.SmelteryEvent;
import tconstruct.library.tools.AbilityHelper;

public class SearedBlock extends InventoryBlock
{
Expand Down Expand Up @@ -112,17 +108,20 @@ boolean activateCastingTable (World world, int x, int y, int z, EntityPlayer pla
ItemStack stack = player.getCurrentEquippedItem();
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
logic.setInventorySlotContents(0, stack);
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemInsertedIntoCasting(logic, x, y, z, stack, player));
}
else
{
if (logic.isStackInSlot(1))
{
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemRemovedFromCasting(logic, x, y, z, logic.getStackInSlot(1), player));
ItemStack stack = logic.decrStackSize(1, 1);
if (stack != null)
addItemToInventory(player, world, x, y, z, stack);
}
else if (logic.isStackInSlot(0))
{
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemRemovedFromCasting(logic, x, y, z, logic.getStackInSlot(0), player));
ItemStack stack = logic.decrStackSize(0, 1);
if (stack != null)
addItemToInventory(player, world, x, y, z, stack);
Expand All @@ -147,17 +146,20 @@ boolean activateCastingBasin (World world, int x, int y, int z, EntityPlayer pla
ItemStack stack = player.getCurrentEquippedItem();
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
logic.setInventorySlotContents(0, stack);
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemInsertedIntoCasting(logic, x, y, z, stack, player));
}
else
{
if (logic.isStackInSlot(1))
{
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemRemovedFromCasting(logic, x, y, z, logic.getStackInSlot(1), player));
ItemStack stack = logic.decrStackSize(1, 1);
if (stack != null)
addItemToInventory(player, world, x, y, z, stack);
}
else if (logic.isStackInSlot(0))
{
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemRemovedFromCasting(logic, x, y, z, logic.getStackInSlot(0), player));
ItemStack stack = logic.decrStackSize(0, 1);
if (stack != null)
addItemToInventory(player, world, x, y, z, stack);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/tconstruct/common/TContent.java
Expand Up @@ -841,5 +841,6 @@ public void addAchievements ()
new Achievement(2747, "tconstruct.enemySlayer", 0, 5, new ItemStack(TRepo.titleIcon, 1, 4099), achievements.get("tconstruct.preparedFight")).registerAchievement());
achievements.put("tconstruct.dualConvenience", new Achievement(2748, "tconstruct.dualConvenience", 0, 7, new ItemStack(TRepo.titleIcon, 1, 4100), achievements.get("tconstruct.enemySlayer"))
.setSpecial().registerAchievement());
achievements.put("tconstruct.doingItWrong", new Achievement(2749, "tconstruct.doingItWrong", -2, -3, new ItemStack(TRepo.manualBook, 1, 2), achievements.get("tconstruct.smelteryMaker")).registerAchievement());
}
}
42 changes: 42 additions & 0 deletions src/main/java/tconstruct/library/event/SmelteryEvent.java
@@ -0,0 +1,42 @@
package tconstruct.library.event;

import mantle.blocks.abstracts.InventoryLogic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.Event;

public class SmelteryEvent extends Event {

public InventoryLogic component;
public int x, y, z;

public SmelteryEvent(InventoryLogic component, int x, int y, int z){
this.component = component;
this.x = x;
this.y = y;
this.z = z;
}

public static class ItemInsertedIntoCasting extends SmelteryEvent {
public ItemStack item;
public EntityPlayer player;

public ItemInsertedIntoCasting(InventoryLogic component, int x, int y, int z, ItemStack item, EntityPlayer player) {
super(component, x, y, z);
this.item = item;
this.player = player;
}
}

public static class ItemRemovedFromCasting extends SmelteryEvent {
public ItemStack item;
public EntityPlayer player;

public ItemRemovedFromCasting(InventoryLogic component, int x, int y, int z, ItemStack item, EntityPlayer player) {
super(component, x, y, z);
this.item = item;
this.player = player;
}
}

}
11 changes: 11 additions & 0 deletions src/main/java/tconstruct/util/TEventHandlerAchievement.java
@@ -1,5 +1,7 @@
package tconstruct.util;

import tconstruct.library.event.SmelteryEvent;

import net.minecraftforge.common.FakePlayer;
import net.minecraftforge.event.ForgeSubscribe;
import tconstruct.achievements.TAchievements;
Expand All @@ -24,4 +26,13 @@ public void onToolCrafted(ToolCraftedEvent event){
}
}

@ForgeSubscribe
public void onItemPlacedIntoCasting(SmelteryEvent.ItemInsertedIntoCasting event){
if(event.player != null && event.item != null){
if(event.item.getItem() instanceof ToolCore){
event.player.addStat(TAchievements.achievements.get("tconstruct.doingItWrong"), 1);
}
}
}

}

0 comments on commit 5694517

Please sign in to comment.