mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-10-26 14:33:50 +00:00
Merge pull request #21 from Sirse/master
Fixed a lot of NPE's and few duplication glitches
This commit is contained in:
16 files changed
+396
-245
No files matched your search
@@ -1,14 +1,8 @@
|
||||
package tconstruct.armor;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -18,6 +12,9 @@ import tconstruct.armor.items.TravelGear;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.util.network.HealthUpdatePacket;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
|
||||
public class ArmorAbilities
|
||||
{
|
||||
@@ -45,7 +42,7 @@ public class ArmorAbilities
|
||||
|
||||
//Feet changes
|
||||
ItemStack feet = player.getCurrentArmor(0);
|
||||
if (feet != null)
|
||||
if (feet != null && feet.hasTagCompound())
|
||||
{
|
||||
if (feet.getItem() instanceof IModifyable && !player.isSneaking())
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package tconstruct.armor.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -10,6 +9,8 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.armor.ArmorPart;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TravelWings extends TravelGear
|
||||
{
|
||||
@@ -38,22 +39,25 @@ public class TravelWings extends TravelGear
|
||||
public void onArmorTick (World world, EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
super.onArmorTick(world, player, itemStack);
|
||||
NBTTagCompound tag = itemStack.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
int feather = tag.getInteger("Feather Fall");
|
||||
if (feather > 0)
|
||||
if (itemStack.hasTagCompound())
|
||||
{
|
||||
if (player.fallDistance > 2.5)
|
||||
player.fallDistance = 2.5f;
|
||||
float terminalVelocity = -0.4f + (feather * 0.08f);
|
||||
if (terminalVelocity > -0.05f)
|
||||
terminalVelocity = -0.05f;
|
||||
if (player.isSneaking() && terminalVelocity > -0.8f)
|
||||
terminalVelocity = -0.8F;
|
||||
boolean flying = false;
|
||||
flying = player.capabilities.isFlying;
|
||||
if (!flying && player.motionY < terminalVelocity)
|
||||
NBTTagCompound tag = itemStack.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
int feather = tag.getInteger("Feather Fall");
|
||||
if (feather > 0)
|
||||
{
|
||||
player.motionY = terminalVelocity;
|
||||
if (player.fallDistance > 2.5)
|
||||
player.fallDistance = 2.5f;
|
||||
float terminalVelocity = -0.4f + (feather * 0.08f);
|
||||
if (terminalVelocity > -0.05f)
|
||||
terminalVelocity = -0.05f;
|
||||
if (player.isSneaking() && terminalVelocity > -0.8f)
|
||||
terminalVelocity = -0.8F;
|
||||
boolean flying = false;
|
||||
flying = player.capabilities.isFlying;
|
||||
if (!flying && player.motionY < terminalVelocity)
|
||||
{
|
||||
player.motionY = terminalVelocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
package tconstruct.armor.player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.UUID;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.*;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.accessory.IHealthAccessory;
|
||||
|
||||
public class ArmorExtended implements IInventory
|
||||
@@ -278,13 +279,15 @@ public class ArmorExtended implements IInventory
|
||||
public void dropItems ()
|
||||
{
|
||||
EntityPlayer player = parent.get();
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
if (player != null)
|
||||
{
|
||||
if (this.inventory[i] != null && !isSoulBounded(this.inventory[i]))
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
player.func_146097_a(this.inventory[i], true, false);
|
||||
this.inventory[i] = null;
|
||||
if (this.inventory[i] != null && !isSoulBounded(this.inventory[i]))
|
||||
{
|
||||
player.func_146097_a(this.inventory[i], true, false);
|
||||
this.inventory[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package tconstruct.armor.player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class KnapsackInventory implements IInventory
|
||||
{
|
||||
@@ -166,12 +167,15 @@ public class KnapsackInventory implements IInventory
|
||||
{
|
||||
EntityPlayer player = parent.get();
|
||||
|
||||
for (int i = 0; i < inventory.length; ++i)
|
||||
if (player != null)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
for (int i = 0; i < inventory.length; ++i)
|
||||
{
|
||||
player.func_146097_a(this.inventory[i], true, false);
|
||||
this.inventory[i] = null;
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
player.func_146097_a(this.inventory[i], true, false);
|
||||
this.inventory[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,12 +183,16 @@ public class KnapsackInventory implements IInventory
|
||||
public void unequipItems ()
|
||||
{
|
||||
EntityPlayer player = parent.get();
|
||||
for (int i = 0; i < inventory.length; ++i)
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
for (int i = 0; i < inventory.length; ++i)
|
||||
{
|
||||
dropItemEntity(player, inventory[i]);
|
||||
this.inventory[i] = null;
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
dropItemEntity(player, inventory[i]);
|
||||
this.inventory[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.armor.player;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -73,15 +74,17 @@ public class TPlayerStats implements IExtendedEntityProperties, IPlayerExtendedI
|
||||
public void loadNBTData (NBTTagCompound compound)
|
||||
{
|
||||
NBTTagCompound properties = (NBTTagCompound) compound.getTag(PROP_NAME);
|
||||
|
||||
this.armor.readFromNBT(properties);
|
||||
this.knapsack.readFromNBT(properties);
|
||||
this.beginnerManual = properties.getBoolean("beginnerManual");
|
||||
this.materialManual = properties.getBoolean("materialManual");
|
||||
this.smelteryManual = properties.getBoolean("smelteryManual");
|
||||
this.weaponryManual = properties.getBoolean("weaponryManual");
|
||||
this.battlesignBonus = properties.getBoolean("battlesignBonus");
|
||||
this.derpLevel = properties.getInteger("derpLevel");
|
||||
if (properties != null)
|
||||
{
|
||||
this.armor.readFromNBT(properties);
|
||||
this.knapsack.readFromNBT(properties);
|
||||
this.beginnerManual = properties.getBoolean("beginnerManual");
|
||||
this.materialManual = properties.getBoolean("materialManual");
|
||||
this.smelteryManual = properties.getBoolean("smelteryManual");
|
||||
this.weaponryManual = properties.getBoolean("weaponryManual");
|
||||
this.battlesignBonus = properties.getBoolean("battlesignBonus");
|
||||
this.derpLevel = properties.getInteger("derpLevel");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,34 +1,35 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import mantle.world.WorldHelper;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.*;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import tconstruct.library.*;
|
||||
import tconstruct.library.tools.*;
|
||||
import tconstruct.library.tools.AOEHarvestTool;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon"),
|
||||
@Optional.Interface(modid = "ZeldaItemAPI", iface = "zeldaswordskills.api.item.ISword")
|
||||
})
|
||||
@Optional.InterfaceList({ @Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon"),
|
||||
@Optional.Interface(modid = "ZeldaItemAPI", iface = "zeldaswordskills.api.item.ISword") })
|
||||
public class Battleaxe extends AOEHarvestTool implements IBattlegearWeapon
|
||||
{
|
||||
public Battleaxe()
|
||||
{
|
||||
super(4, 1,1);
|
||||
super(4, 1, 1);
|
||||
this.setUnlocalizedName("InfiTool.Battleaxe");
|
||||
}
|
||||
|
||||
@@ -181,10 +182,14 @@ public class Battleaxe extends AOEHarvestTool implements IBattlegearWeapon
|
||||
int boost = time / 100;
|
||||
if (boost > 2)
|
||||
boost = 2;
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, time * 4, boost));
|
||||
player.addPotionEffect(new PotionEffect(Potion.jump.id, time * 4, boost));
|
||||
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, time * 4, 0));
|
||||
player.addPotionEffect(new PotionEffect(Potion.hunger.id, time * 2, 0));
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, time * 4, boost));
|
||||
player.addPotionEffect(new PotionEffect(Potion.jump.id, time * 4, boost));
|
||||
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, time * 4, 0));
|
||||
player.addPotionEffect(new PotionEffect(Potion.hunger.id, time * 2, 0));
|
||||
}
|
||||
if (time > 5 && player.onGround)
|
||||
{
|
||||
player.addExhaustion(0.2F);
|
||||
@@ -239,45 +244,51 @@ public class Battleaxe extends AOEHarvestTool implements IBattlegearWeapon
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean sheatheOnBack(ItemStack item)
|
||||
public boolean sheatheOnBack (ItemStack item)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean isOffhandHandDual(ItemStack off) {
|
||||
public boolean isOffhandHandDual (ItemStack off)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
public boolean offhandAttackEntity (PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
public boolean offhandClickAir (PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
public boolean offhandClickBlock (PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem) {
|
||||
public void performPassiveEffects (Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem)
|
||||
{
|
||||
// unused
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "battlegear2")
|
||||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
||||
if(offhand == null)
|
||||
public boolean allowOffhand (ItemStack mainhand, ItemStack offhand)
|
||||
{
|
||||
if (offhand == null)
|
||||
return true;
|
||||
|
||||
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver && mainhand.getItem() != TinkerTools.battleaxe)
|
||||
|
||||
@@ -1,29 +1,37 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import java.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.*;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.entity.player.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.stats.*;
|
||||
import net.minecraft.stats.AchievementList;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.entity.player.UseHoeEvent;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.*;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.PiercingEntityDamage;
|
||||
|
||||
public class AbilityHelper
|
||||
@@ -58,7 +66,7 @@ public class AbilityHelper
|
||||
|
||||
public static boolean onLeftClickEntity (ItemStack stack, EntityLivingBase player, Entity entity, ToolCore tool, int baseDamage)
|
||||
{
|
||||
if (entity.canAttackWithItem() && stack.hasTagCompound())
|
||||
if (entity != null && player != null && entity.canAttackWithItem() && stack.hasTagCompound())
|
||||
{
|
||||
if (!entity.hitByEntity(player)) // can't attack this entity
|
||||
{
|
||||
|
||||
@@ -1,39 +1,36 @@
|
||||
package tconstruct.library.weaponry;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.ammo.ArrowAmmo;
|
||||
import tconstruct.weaponry.ammo.BoltAmmo;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.entity.ArrowEntity;
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mods.battlegear2.api.PlayerEventChild;
|
||||
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.weaponry.TinkerWeaponry;
|
||||
import tconstruct.weaponry.client.CrosshairType;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon")
|
||||
})
|
||||
@@ -132,8 +129,12 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
|
||||
public float getProjectileSpeed(ItemStack itemStack)
|
||||
{
|
||||
NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
return toolTag.getFloat("FlightSpeed");
|
||||
if (itemStack != null && itemStack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
return toolTag.getFloat("FlightSpeed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Bow usage */
|
||||
@@ -166,6 +167,11 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
@Override
|
||||
public void onPlayerStoppedUsing (ItemStack weapon, World world, EntityPlayer player, int useRemaining)
|
||||
{
|
||||
if (!weapon.hasTagCompound())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int time = this.getMaxItemUseDuration(weapon) - useRemaining;
|
||||
|
||||
// we abuse the arrowLooseEvent for all projectiles
|
||||
@@ -244,7 +250,10 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
NBTTagCompound tags = null;
|
||||
|
||||
if(stack.hasTagCompound())
|
||||
tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
if(tags == null || renderPass > 10)
|
||||
return super.getIcon(stack, renderPass, player, usingItem, useRemaining);
|
||||
|
||||
@@ -1,31 +1,45 @@
|
||||
package tconstruct.mechworks.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import java.util.*;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mantle.blocks.BlockUtils;
|
||||
import mantle.world.WorldHelper;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.BlockPressurePlate.Sensitivity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.item.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.*;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.mechworks.MechworksProxyCommon;
|
||||
import tconstruct.mechworks.landmine.Helper;
|
||||
import tconstruct.mechworks.logic.*;
|
||||
import tconstruct.mechworks.logic.LandmineExplodeLogic;
|
||||
import tconstruct.mechworks.logic.TileEntityLandmine;
|
||||
import tconstruct.world.model.RenderLandmine;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
@@ -442,16 +456,17 @@ public class BlockLandmine extends BlockContainer
|
||||
|
||||
protected int getMineState (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
Sensitivity triggerType;
|
||||
|
||||
TileEntity tileEntity = par1World.getTileEntity(par2, par3, par4);
|
||||
// Change to return 1 if you want the landmine to blow up when the block
|
||||
// holding it is broken
|
||||
if (te == null)
|
||||
if (!(tileEntity instanceof TileEntityLandmine))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
TileEntityLandmine te = (TileEntityLandmine)tileEntity;
|
||||
Sensitivity triggerType;
|
||||
|
||||
switch (te.triggerType)
|
||||
{
|
||||
case 0:
|
||||
|
||||
@@ -1,30 +1,47 @@
|
||||
package tconstruct.smeltery.logic;
|
||||
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import java.util.*;
|
||||
import mantle.blocks.abstracts.*;
|
||||
import mantle.blocks.iface.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import mantle.blocks.abstracts.MultiServantLogic;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
import mantle.world.CoordTuple;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.*;
|
||||
import net.minecraft.entity.passive.*;
|
||||
import net.minecraft.entity.player.*;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.monster.EntityIronGolem;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.network.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
import tconstruct.smeltery.*;
|
||||
import tconstruct.smeltery.SmelteryDamageSource;
|
||||
import tconstruct.smeltery.TinkerSmeltery;
|
||||
import tconstruct.smeltery.inventory.SmelteryContainer;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
@@ -328,67 +345,74 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
|
||||
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(minPos.x, minPos.y, minPos.z, maxPos.x + 1, minPos.y + layers, maxPos.z + 1);
|
||||
|
||||
List list = worldObj.getEntitiesWithinAABB(Entity.class, box);
|
||||
for (Object o : list)
|
||||
List<Entity> list = worldObj.getEntitiesWithinAABB(Entity.class, box);
|
||||
for (Entity o : list)
|
||||
{
|
||||
if (o.isDead)
|
||||
return;
|
||||
|
||||
if (moltenMetal.size() >= 1)
|
||||
{
|
||||
Fluid fluid = null;
|
||||
int amount = 0;
|
||||
float damage = 5;
|
||||
|
||||
if (o instanceof EntityVillager && PHConstruct.meltableVillagers)
|
||||
{
|
||||
EntityVillager villager = (EntityVillager) o;
|
||||
if (villager.attackEntityFrom(new SmelteryDamageSource(), 5))
|
||||
{
|
||||
if (currentLiquid + 40 < maxLiquid)
|
||||
{
|
||||
int amount = villager.isChild() ? 5 : 40;
|
||||
this.fill(new FluidStack(TinkerSmeltery.moltenEmeraldFluid, amount), true);
|
||||
}
|
||||
}
|
||||
fluid = TinkerSmeltery.moltenEmeraldFluid;
|
||||
amount = villager.isChild() ? 5 : 40;
|
||||
}
|
||||
else if (o instanceof EntityEnderman)
|
||||
{
|
||||
EntityEnderman villager = (EntityEnderman) o;
|
||||
if (villager.attackEntityFrom(new SmelteryDamageSource(), 5))
|
||||
{
|
||||
if (currentLiquid + 125 < maxLiquid)
|
||||
{
|
||||
this.fill(new FluidStack(TinkerSmeltery.moltenEnderFluid, 125), true);
|
||||
}
|
||||
}
|
||||
fluid = TinkerSmeltery.moltenEnderFluid;
|
||||
amount = 125;
|
||||
}
|
||||
else if (o instanceof EntityIronGolem)
|
||||
{
|
||||
EntityIronGolem golem = (EntityIronGolem) o;
|
||||
if (golem.attackEntityFrom(new SmelteryDamageSource(), 5))
|
||||
{
|
||||
if (currentLiquid + 40 < maxLiquid)
|
||||
{
|
||||
this.fill(new FluidStack(TinkerSmeltery.moltenIronFluid, 40), true);
|
||||
}
|
||||
}
|
||||
fluid = TinkerSmeltery.moltenIronFluid;
|
||||
amount = 40;
|
||||
}
|
||||
else if (o instanceof EntityHorse && PHConstruct.meltableHorses)
|
||||
{
|
||||
EntityHorse horse = (EntityHorse) o;
|
||||
if (horse.attackEntityFrom(new SmelteryDamageSource(), 5))
|
||||
{
|
||||
if (currentLiquid + 108 < maxLiquid)
|
||||
{
|
||||
this.fill(new FluidStack(TinkerSmeltery.glueFluid, 108), true);
|
||||
}
|
||||
}
|
||||
fluid = TinkerSmeltery.glueFluid;
|
||||
amount = 108;
|
||||
}
|
||||
else if (o instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase living = (EntityLivingBase) o;
|
||||
if (!living.isDead && living.attackEntityFrom(new SmelteryDamageSource(), 5))
|
||||
fluid = TinkerSmeltery.bloodFluid;
|
||||
amount = living.isChild() || living instanceof EntityPlayer ? 5 : 40;
|
||||
}
|
||||
|
||||
if (fluid != null && amount > 0 && damage > 0)
|
||||
{
|
||||
boolean canFill = false;
|
||||
|
||||
if (o instanceof EntityLivingBase)
|
||||
{
|
||||
if (currentLiquid + 40 < maxLiquid)
|
||||
int freeLiquid = Math.max(0, this.maxLiquid - this.currentLiquid - 1);
|
||||
if (freeLiquid > 0)
|
||||
{
|
||||
int amount = (living.isChild() || living instanceof EntityPlayer) ? 5 : 40;
|
||||
this.fill(new FluidStack(TinkerSmeltery.bloodFluid, amount), true);
|
||||
int freeQuants = MathHelper.floor_float((float) freeLiquid / amount);
|
||||
if (freeQuants > 0)
|
||||
{
|
||||
float health = ((EntityLivingBase) o).getHealth();
|
||||
int quantsAmount = MathHelper.ceiling_float_int(health / damage);
|
||||
if (quantsAmount > 0)
|
||||
{
|
||||
int quantsToBeAdded = Math.min(freeQuants, quantsAmount);
|
||||
amount = quantsToBeAdded * amount;
|
||||
canFill = o.attackEntityFrom(DamageSource.outOfWorld, 9999);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
canFill = o.attackEntityFrom(new SmelteryDamageSource(), damage);
|
||||
|
||||
if (canFill && amount > 0)
|
||||
this.fill(new FluidStack(fluid, amount), true);
|
||||
}
|
||||
}
|
||||
else if (PHConstruct.throwableSmeltery && o instanceof EntityItem)
|
||||
@@ -753,9 +777,9 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
int xd1 = 1, xd2 = 1; // x-difference
|
||||
for (int i = 1; i < MAX_SMELTERY_SIZE; i++) // don't check farther than needed
|
||||
{
|
||||
if (worldObj.getBlock(x - xd1, y, z) == null || worldObj.isAirBlock(x - xd1, y, z))
|
||||
if (this.worldObj.isAirBlock(x - xd1, y, z))
|
||||
xd1++;
|
||||
else if (worldObj.getBlock(x + xd2, y, z) == null || worldObj.isAirBlock(x + xd2, y, z))
|
||||
else if (this.worldObj.isAirBlock(x + xd2, y, z))
|
||||
xd2++;
|
||||
|
||||
// if one side hit a wall and the other didn't we might have to center our x-position again
|
||||
@@ -778,9 +802,9 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
int zd1 = 1, zd2 = 1;
|
||||
for (int i = 1; i < MAX_SMELTERY_SIZE; i++) // don't check farther than needed
|
||||
{
|
||||
if (worldObj.getBlock(x, y, z - zd1) == null || worldObj.isAirBlock(x, y, z - zd1))
|
||||
if (this.worldObj.isAirBlock(x, y, z - zd1))
|
||||
zd1++;
|
||||
else if (worldObj.getBlock(x, y, z + zd2) == null || worldObj.isAirBlock(x, y, z + zd2))
|
||||
else if (this.worldObj.isAirBlock(x, y, z + zd2))
|
||||
zd2++;
|
||||
|
||||
// if one side hit a wall and the other didn't we might have to center our x-position again
|
||||
@@ -885,9 +909,10 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
{
|
||||
for (int zPos = zMin + 1; zPos <= zMax - 1; zPos++)
|
||||
{
|
||||
block = worldObj.getBlock(xPos, y, zPos);
|
||||
if (block != null && !worldObj.isAirBlock(xPos, y, zPos))
|
||||
if (!this.worldObj.isAirBlock(xPos, y, zPos))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -940,7 +965,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
{
|
||||
// regular check failed, maybe it's the bottom?
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
if (block != null && !worldObj.isAirBlock(x, y, z))
|
||||
if (!block.isAir(this.worldObj, x, y, z))
|
||||
if (validBlockID(block))
|
||||
return validateBottom(x, y, z, sides, count);
|
||||
|
||||
@@ -960,21 +985,29 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
int zMax = z + sides[3] - 1;
|
||||
|
||||
// Check inside
|
||||
for (int xPos = xMin; xPos <= xMax; xPos++)
|
||||
{
|
||||
for (int zPos = zMin; zPos <= zMax; zPos++)
|
||||
if (y >= 0 && y < 256) {
|
||||
for (int xPos = xMin; xPos <= xMax; xPos++)
|
||||
{
|
||||
if (validBlockID(worldObj.getBlock(xPos, y, zPos)) && (worldObj.getBlockMetadata(xPos, y, zPos) >= 2)) {
|
||||
TileEntity te = worldObj.getTileEntity(xPos, y, zPos);
|
||||
for (int zPos = zMin; zPos <= zMax; zPos++)
|
||||
{
|
||||
Chunk chunk = this.worldObj.getChunkFromBlockCoords(xPos, zPos);
|
||||
if (chunk == null)
|
||||
continue;
|
||||
|
||||
if (te instanceof MultiServantLogic) {
|
||||
MultiServantLogic servant = (MultiServantLogic) te;
|
||||
if (servant.hasValidMaster()) {
|
||||
if (servant.verifyMaster(this, worldObj, this.xCoord, this.yCoord, this.zCoord))
|
||||
int xx = xPos & 15;
|
||||
int zz = zPos & 15;
|
||||
if (this.validBlockID(chunk.getBlock(xx, y, zz)) && chunk.getBlockMetadata(xx, y, zz) >= 2) {
|
||||
TileEntity te = worldObj.getTileEntity(xPos, y, zPos);
|
||||
|
||||
if (te instanceof MultiServantLogic) {
|
||||
MultiServantLogic servant = (MultiServantLogic) te;
|
||||
if (servant.hasValidMaster()) {
|
||||
if (servant.verifyMaster(this, worldObj, this.xCoord, this.yCoord, this.zCoord))
|
||||
bottomBricks++;
|
||||
} else {
|
||||
servant.overrideMaster(this.xCoord, this.yCoord, this.zCoord);
|
||||
bottomBricks++;
|
||||
} else {
|
||||
servant.overrideMaster(this.xCoord, this.yCoord, this.zCoord);
|
||||
bottomBricks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,36 @@
|
||||
package tconstruct.tools;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import cpw.mods.fml.common.eventhandler.*;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.*;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.*;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.S14PacketEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraftforge.event.entity.living.*;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
import net.minecraftforge.oredict.*;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.library.event.*;
|
||||
import tconstruct.library.event.PartBuilderEvent;
|
||||
import tconstruct.library.event.ToolBuildEvent;
|
||||
import tconstruct.library.event.ToolCraftEvent;
|
||||
import tconstruct.library.tools.*;
|
||||
import tconstruct.util.ItemHelper;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
@@ -35,6 +41,9 @@ public class TinkerToolEvents
|
||||
@SubscribeEvent
|
||||
public void onCrafting (ItemCraftedEvent event)
|
||||
{
|
||||
if (event.crafting == null || event.player == null || event.player.worldObj == null || event.craftMatrix == null)
|
||||
return;
|
||||
|
||||
Item item = event.crafting.getItem();
|
||||
if (!event.player.worldObj.isRemote)
|
||||
{
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.*;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.event.ToolCraftedEvent;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.CraftingStationLogic;
|
||||
|
||||
@@ -26,6 +29,7 @@ public class CraftingStationContainer extends Container
|
||||
private int posX;
|
||||
private int posY;
|
||||
private int posZ;
|
||||
private WeakReference[] inventories;
|
||||
|
||||
public CraftingStationContainer(InventoryPlayer inventorplayer, CraftingStationLogic logic, int x, int y, int z)
|
||||
{
|
||||
@@ -37,6 +41,7 @@ public class CraftingStationContainer extends Container
|
||||
this.logic = logic;
|
||||
craftMatrix = new InventoryCraftingStation(this, 3, 3, logic);
|
||||
craftResult = new InventoryCraftingStationResult(logic);
|
||||
this.inventories = logic.getInventories();
|
||||
|
||||
int row;
|
||||
int column;
|
||||
@@ -162,6 +167,10 @@ public class CraftingStationContainer extends Container
|
||||
Block block = worldObj.getBlock(this.posX, this.posY, this.posZ);
|
||||
if (block != TinkerTools.craftingStationWood && block != TinkerTools.craftingSlabWood)
|
||||
return false;
|
||||
|
||||
if (!this.logic.isUseableByPlayer(player) || !CraftingStationLogic.isUseableByPlayer(player, this.inventories))
|
||||
return false;
|
||||
|
||||
return player.getDistanceSq((double) this.posX + 0.5D, (double) this.posY + 0.5D, (double) this.posZ + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.armor.inventory.SlotOnlyTake;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.smeltery.inventory.ActiveContainer;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.*;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
|
||||
public class PartCrafterChestContainer extends ActiveContainer
|
||||
{
|
||||
@@ -74,9 +76,10 @@ public class PartCrafterChestContainer extends ActiveContainer
|
||||
ItemStack slotStack = slot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if (slotID < logic.getSizeInventory())
|
||||
int inventorySize = this.inventory.length + this.patternLogic.getSizeInventory();
|
||||
if (slotID < inventorySize)
|
||||
{
|
||||
if (!this.mergeItemStack(slotStack, logic.getSizeInventory() + patternLogic.getSizeInventory(), this.inventorySlots.size(), true))
|
||||
if (!this.mergeItemStack(slotStack, inventorySize, this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -94,7 +97,7 @@ public class PartCrafterChestContainer extends ActiveContainer
|
||||
|
||||
if (slotStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
slot.putStack(null);
|
||||
logic.tryBuildPart(slotID);
|
||||
}
|
||||
slot.onSlotChanged();
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.tools.inventory.CraftingStationContainer;
|
||||
|
||||
@@ -93,6 +99,26 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
return new int[] {};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return isUseableByPlayer(player, this.getInventories()) && super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
public static boolean isUseableByPlayer(EntityPlayer player, WeakReference[] inventories) {
|
||||
for (WeakReference<IInventory> ref : inventories)
|
||||
{
|
||||
if (ref != null)
|
||||
{
|
||||
IInventory inv = ref.get();
|
||||
if (inv != null && !inv.isUseableByPlayer(player))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
@@ -142,6 +168,11 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
|
||||
}
|
||||
|
||||
public WeakReference[] getInventories()
|
||||
{
|
||||
return new WeakReference[] { this.chest, this.doubleChest, this.patternChest, this.furnace };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,8 @@ package tconstruct.tools.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
@@ -55,13 +56,20 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if (slot == 0) {
|
||||
if(itemstack != null && StencilBuilder.isBlank(itemstack)) {
|
||||
if (itemstack != null && StencilBuilder.isBlank(itemstack))
|
||||
{
|
||||
super.setInventorySlotContents(1, selectedStack);
|
||||
} else if(itemstack!=null) {
|
||||
}
|
||||
else if (itemstack!=null)
|
||||
{
|
||||
ItemStack cpy=itemstack.copy();
|
||||
cpy.stackSize=1;
|
||||
super.setInventorySlotContents(1, cpy);
|
||||
}else super.setInventorySlotContents(1,null);
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setInventorySlotContents(1,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ package tconstruct.tools.logic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.crafting.*;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.inventory.ToolStationContainer;
|
||||
|
||||
/* Simple class for storing items in the block
|
||||
@@ -193,7 +193,7 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return null;
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user