Knapsack/extended slots tick updates

- Fixed a null pointer exception
- Clean up imports in GlassBlock(accidental)
- Made the extended armor slots tick and armor tick items
- Made the knapsack tick items
This commit is contained in:
Arthur Uzulin committed 2013-12-14 14:11:41 +11:00
1 parent 22c99c80dd
commit f8450e4a31
4 files changed
+47 -4

No files matched your search

+1
View File
@@ -89,6 +89,7 @@ public class TConstruct
basinCasting = new LiquidCasting();
chiselDetailing = new Detailing();
recipes = new TRecipes();
content = new TContent();
MinecraftForge.EVENT_BUS.register(new TEventHandlerAchievement());
@@ -1,13 +1,11 @@
package tconstruct.blocks;
import cpw.mods.fml.relauncher.*;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.world.*;
public class GlassBlock extends TConstructBlock
{
@@ -1,5 +1,11 @@
package tconstruct.items.armor;
import tconstruct.TConstruct;
import tconstruct.util.player.*;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import java.util.List;
import tconstruct.items.CraftingItem;
@@ -29,5 +35,20 @@ public class Knapsack extends CraftingItem
break;
}
}
@Override
public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack)
{
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
KnapsackInventory inv = stats.knapsack;
if (stats != null && inv != null) {
for(int i = 0; i < inv.getSizeInventory(); i++){
if(inv.getStackInSlot(i) != null){
inv.getStackInSlot(i).getItem().onUpdate(inv.getStackInSlot(i), player.worldObj, player, i, false);
}
}
}
}
}
@@ -1,5 +1,9 @@
package tconstruct.util;
import tconstruct.util.player.ArmorExtended;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import java.util.Random;
import net.minecraft.block.Block;
@@ -620,6 +624,25 @@ public class TEventHandler
}
}
@ForgeSubscribe
public void livingUpdate (LivingUpdateEvent event)
{
if(event.entityLiving instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer) event.entityLiving;
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(player.username);
if(stats != null){
ArmorExtended armor = stats.armor;
for(int i = 0; i < armor.getSizeInventory(); i++){
if(armor.getStackInSlot(i) != null){
armor.getStackInSlot(i).getItem().onUpdate(armor.getStackInSlot(i), player.worldObj, player, i, false);
armor.getStackInSlot(i).getItem().onArmorTickUpdate(player.worldObj, player, armor.getStackInSlot(i));
}
}
}
}
}
//Player interact event - prevent breaking of tank air blocks in creative
@ForgeSubscribe
public void playerInteract (PlayerInteractEvent event)