Skip to content

Commit

Permalink
Merge pull request #3 from Mithion/master
Browse files Browse the repository at this point in the history
Synchronising with the main AM2 code
  • Loading branch information
DoomFruit committed Sep 12, 2015
2 parents ad17f64 + 2cfc581 commit e9c2cce
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 31 deletions.
18 changes: 10 additions & 8 deletions src/main/java/am2/AMEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import net.minecraft.item.ItemPotion;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.stats.AchievementList;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
Expand All @@ -56,6 +57,7 @@
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.player.AchievementEvent;
import net.minecraftforge.event.entity.player.EntityInteractEvent;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.event.entity.player.FillBucketEvent;
Expand Down Expand Up @@ -179,6 +181,14 @@ public void onEntityDeath(LivingDeathEvent event){
}
}

@SubscribeEvent
public void onPlayerGetAchievement(AchievementEvent event){
if (!event.entityPlayer.worldObj.isRemote && event.achievement == AchievementList.theEnd2){
AMCore.instance.proxy.playerTracker.storeExtendedPropertiesForRespawn(event.entityPlayer);
// AMCore.instance.proxy.playerTracker.storeSoulboundItemsForRespawn(event.entityPlayer);
}
}

@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event){
if (EntityUtilities.isSummon(event.entityLiving) && !(event.entityLiving instanceof EntityHorse)){
Expand Down Expand Up @@ -316,14 +326,6 @@ public void onEntityLiving(LivingUpdateEvent event){

EntityLivingBase ent = event.entityLiving;

if (ent.isDead){
if (ent instanceof EntityPlayer && ent.dimension == 1){
AMCore.instance.proxy.playerTracker.storeExtendedPropertiesForRespawn((EntityPlayer)ent);
AMCore.instance.proxy.playerTracker.storeSoulboundItemsForRespawn((EntityPlayer)ent);
}
return;
}

World world = ent.worldObj;

boolean isRemote = world.isRemote;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/am2/blocks/BlockKeystoneDoor.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package am2.blocks;

import java.util.Random;
import am2.AMCore;
import am2.api.blocks.IKeystoneLockable;
import am2.blocks.tileentities.TileEntityKeystoneDoor;
import am2.guis.ArsMagicaGuiIdList;
import am2.items.ItemsCommonProxy;
import am2.lore.CompendiumUnlockHandler;
import am2.texture.ResourceManager;
import am2.utility.KeystoneUtilities;
Expand All @@ -16,6 +18,7 @@
import net.minecraft.client.renderer.IconFlipped;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
Expand Down Expand Up @@ -172,6 +175,13 @@ public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityP
return;
super.onBlockHarvested(world, x, y, z, meta, player);
}

@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return ItemsCommonProxy.itemKeystoneDoor;
}


@Override
public TileEntity createNewTileEntity(World world, int i){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ public void updateEntity(){
}
}else{
if (current_deconstruction_time++ >= DECONSTRUCTION_TIME){
for (ItemStack stack : deconstructionRecipe){
transferOrEjectItem(stack);
if(getDeconstructionRecipe() == true){
for (ItemStack stack : deconstructionRecipe){
transferOrEjectItem(stack);
}
}
deconstructionRecipe = null;
decrStackSize(0, 1);
Expand Down Expand Up @@ -200,7 +202,7 @@ private boolean getDeconstructionRecipe(){

for (Object o : recipeParts){
ItemStack stack = objectToItemStack(o);
if (stack != null){
if (stack != null && !stack.getItem().hasContainerItem(stack)){
stack.stackSize = 1;
recipeItems.add(stack.copy());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,13 @@ private void doStandardDecrement(IInventory inventory, ItemStack itemstack1, int
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
itemstack2 = null;
}

if (itemstack2 != null && (itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1))){
if (inventory.getStackInSlot(i) == null){
inventory.setInventorySlotContents(i, itemstack2);
}else{
if (itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1)){
if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2))
this.thePlayer.dropItem(itemstack2.getItem(), itemstack2.getItemDamage());
}
}

if (itemstack2 != null){
inventory.setInventorySlotContents(i, itemstack2);
}else{
inventory.decrStackSize(i, 1);
}

}else{
inventory.decrStackSize(i, 1);
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/am2/items/ItemCandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int
if (!world.isRemote){

if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("search_block")){
player.addChatMessage(new ChatComponentText("am2.tooltip.candlecantplace"));
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.candlecantplace")));
return false;
}

Expand Down Expand Up @@ -171,7 +171,13 @@ public String getItemStackDisplayName(ItemStack stack){
String name = StatCollector.translateToLocal("item.arsmagica2:warding_candle.name");
if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("search_block")){
ItemStack blockStack = new ItemStack(Block.getBlockById(stack.stackTagCompound.getInteger("search_block")), 1, stack.stackTagCompound.getInteger("search_meta"));
name += " (" + blockStack.getDisplayName() + ")";
Item tempItem = blockStack.getItem();
if(tempItem == null){
name += " (" + stack.stackTagCompound.getInteger("search_block") + ":" + stack.stackTagCompound.getInteger("search_meta") + ")";
}
else{
name += " (" + blockStack.getDisplayName() + ")";
}
}else{
name += " (" + StatCollector.translateToLocal("am2.tooltip.unattuned") + ")";
}
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/am2/items/ItemEssenceBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ public void addInformation(ItemStack par1ItemStack,

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entityplayer){
if (entityplayer.isSneaking()){
FMLNetworkHandler.openGui(entityplayer, AMCore.instance, ArsMagicaGuiIdList.GUI_ESSENCE_BAG, world, (int)entityplayer.posX, (int)entityplayer.posY, (int)entityplayer.posZ);
}
FMLNetworkHandler.openGui(entityplayer, AMCore.instance, ArsMagicaGuiIdList.GUI_ESSENCE_BAG, world, (int)entityplayer.posX, (int)entityplayer.posY, (int)entityplayer.posZ);
return stack;
}

Expand All @@ -57,8 +55,7 @@ public void UpdateStackTagCompound(ItemStack itemStack, ItemStack[] values){
continue;
}else{
itemStack.stackTagCompound.setInteger("essencebagstacksize" + i, stack.stackSize);
if (stack.getItemDamage() != 0)
itemStack.stackTagCompound.setInteger("essencebagmeta" + i, stack.getItemDamage());
itemStack.stackTagCompound.setInteger("essencebagmeta" + i, stack.getItemDamage());
}
}
}
Expand All @@ -73,8 +70,7 @@ public void UpdateStackTagCompound(ItemStack itemStack, InventoryEssenceBag inve
continue;
}else{
itemStack.stackTagCompound.setInteger("essencebagstacksize" + i, stack.stackSize);
if (stack.getItemDamage() != 0)
itemStack.stackTagCompound.setInteger("essencebagmeta" + i, stack.getItemDamage());
itemStack.stackTagCompound.setInteger("essencebagmeta" + i, stack.getItemDamage());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/arsmagica2/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,4 @@ achievement.componentUnlock=Discovered Spell Part

Legendary Mana Restoration.postfix=Legendary Mana Potion
Epic Mana Restoration.postfix=Epic Mana Potion
Greater Mana Restoration.postfix=Greater Mana Potion
Greater Mana Restoration.postfix=Greater Mana Potion

0 comments on commit e9c2cce

Please sign in to comment.