mirror of
https://github.com/GTNewHorizons/ThaumicTinkerer.git
synced 2026-11-28 16:06:07 +00:00
Changed some items into baubles
This commit is contained in:
1 parent
7a93ae33f0
commit
3efdf93073
8 files changed
+266
-88
No files matched your search
@@ -14,11 +14,13 @@
|
||||
*/
|
||||
package vazkii.tinkerer.common.item.kami;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -39,7 +41,7 @@ import vazkii.tinkerer.common.item.ItemMod;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBlockTalisman extends ItemMod {
|
||||
public class ItemBlockTalisman extends ItemMod implements IBauble{
|
||||
@Deprecated
|
||||
private static final String TAG_BLOCK_ID = "blockID";
|
||||
private static final String TAG_BLOCK_NAME = "blockName";
|
||||
@@ -115,62 +117,6 @@ public class ItemBlockTalisman extends ItemMod {
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
|
||||
Block block=getBlock(par1ItemStack);
|
||||
if(!par2World.isRemote && par1ItemStack.getItemDamage() == 1 && block!=Blocks.air && par3Entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) par3Entity;
|
||||
int meta = getBlockMeta(par1ItemStack);
|
||||
|
||||
int highest = -1;
|
||||
boolean hasFreeSlot = false;
|
||||
int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.length];
|
||||
Arrays.fill(counts, 0);
|
||||
|
||||
for(int i = 0; i < counts.length; i++) {
|
||||
ItemStack stack = player.inventory.getStackInSlot(i);
|
||||
if(stack == null) {
|
||||
hasFreeSlot = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(Item.getItemFromBlock(block) == stack.getItem() && stack.getItemDamage() == meta) {
|
||||
counts[i] = stack.stackSize;
|
||||
if(highest == -1)
|
||||
highest = i;
|
||||
else highest = counts[i] > counts[highest] && highest > 8 ? i : highest;
|
||||
}
|
||||
}
|
||||
|
||||
if(highest == -1) {
|
||||
ItemStack heldItem = player.inventory.getItemStack();
|
||||
if(hasFreeSlot && (heldItem == null || Item.getItemFromBlock(block) == heldItem.getItem() || heldItem.getItemDamage() != meta)) {
|
||||
ItemStack stack = new ItemStack(block, remove(par1ItemStack, 64), meta);
|
||||
if(stack.stackSize != 0)
|
||||
player.inventory.addItemStackToInventory(stack);
|
||||
}
|
||||
} else {
|
||||
for(int i = 0; i < counts.length; i++) {
|
||||
int count = counts[i];
|
||||
|
||||
if(i == highest || count == 0)
|
||||
continue;
|
||||
|
||||
add(par1ItemStack, count);
|
||||
player.inventory.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
int countInHighest = counts[highest];
|
||||
int maxSize = new ItemStack(block, 1, meta).getMaxStackSize();
|
||||
if(countInHighest < maxSize) {
|
||||
int missing = maxSize - countInHighest;
|
||||
ItemStack stackInHighest = player.inventory.getStackInSlot(highest);
|
||||
stackInHighest.stackSize += remove(par1ItemStack, missing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean setBlock(ItemStack stack, Block block, int meta) {
|
||||
if(getBlock(stack) == Blocks.air || getBlockCount(stack) == 0) {
|
||||
ItemNBTHelper.setString(stack, TAG_BLOCK_NAME,Block.blockRegistry.getNameForObject(block));
|
||||
@@ -253,4 +199,84 @@ public class ItemBlockTalisman extends ItemMod {
|
||||
return TTClientProxy.kamiRarity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack itemstack) {
|
||||
return BaubleType.RING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemstack, EntityLivingBase entity) {
|
||||
Block block=getBlock(itemstack);
|
||||
if(!entity.worldObj.isRemote && itemstack.getItemDamage() == 1 && block!=Blocks.air && entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
int meta = getBlockMeta(itemstack);
|
||||
|
||||
int highest = -1;
|
||||
boolean hasFreeSlot = false;
|
||||
int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.length];
|
||||
Arrays.fill(counts, 0);
|
||||
|
||||
for(int i = 0; i < counts.length; i++) {
|
||||
ItemStack stack = player.inventory.getStackInSlot(i);
|
||||
if(stack == null) {
|
||||
hasFreeSlot = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(Item.getItemFromBlock(block) == stack.getItem() && stack.getItemDamage() == meta) {
|
||||
counts[i] = stack.stackSize;
|
||||
if(highest == -1)
|
||||
highest = i;
|
||||
else highest = counts[i] > counts[highest] && highest > 8 ? i : highest;
|
||||
}
|
||||
}
|
||||
|
||||
if(highest == -1) {
|
||||
ItemStack heldItem = player.inventory.getItemStack();
|
||||
if(hasFreeSlot && (heldItem == null || Item.getItemFromBlock(block) == heldItem.getItem() || heldItem.getItemDamage() != meta)) {
|
||||
ItemStack stack = new ItemStack(block, remove(itemstack, 64), meta);
|
||||
if(stack.stackSize != 0)
|
||||
player.inventory.addItemStackToInventory(stack);
|
||||
}
|
||||
} else {
|
||||
for(int i = 0; i < counts.length; i++) {
|
||||
int count = counts[i];
|
||||
|
||||
if(i == highest || count == 0)
|
||||
continue;
|
||||
|
||||
add(itemstack, count);
|
||||
player.inventory.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
int countInHighest = counts[highest];
|
||||
int maxSize = new ItemStack(block, 1, meta).getMaxStackSize();
|
||||
if(countInHighest < maxSize) {
|
||||
int missing = maxSize - countInHighest;
|
||||
ItemStack stackInHighest = player.inventory.getStackInSlot(highest);
|
||||
stackInHighest.stackSize += remove(itemstack, missing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,11 @@
|
||||
*/
|
||||
package vazkii.tinkerer.common.item.kami;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIAvoidEntity;
|
||||
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
|
||||
import net.minecraft.entity.ai.EntityAITasks;
|
||||
@@ -33,7 +36,7 @@ import vazkii.tinkerer.common.item.ItemMod;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemCatAmulet extends ItemMod {
|
||||
public class ItemCatAmulet extends ItemMod implements IBauble {
|
||||
|
||||
public ItemCatAmulet() {
|
||||
super();
|
||||
@@ -42,28 +45,7 @@ public class ItemCatAmulet extends ItemMod {
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity e, int par4, boolean par5) {
|
||||
int range = 10;
|
||||
int rangeY = 4;
|
||||
List<EntityLiving> entities = par2World.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(e.posX - range, e.posY - rangeY, e.posZ - range, e.posX + range, e.posY + rangeY, e.posZ + range));
|
||||
|
||||
for(EntityLiving entity : entities) {
|
||||
List<EntityAITasks.EntityAITaskEntry> entries = new ArrayList(entity.tasks.taskEntries);
|
||||
entries.addAll(new ArrayList(entity.targetTasks.taskEntries));
|
||||
|
||||
boolean avoidsOcelots = false;
|
||||
for(EntityAITasks.EntityAITaskEntry entry : entries) {
|
||||
if(entry.action instanceof EntityAIAvoidEntity)
|
||||
avoidsOcelots = messWithRunAwayAI((EntityAIAvoidEntity) entry.action) || avoidsOcelots;
|
||||
|
||||
if(entry.action instanceof EntityAINearestAttackableTarget)
|
||||
messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action);
|
||||
}
|
||||
|
||||
if(entity instanceof EntityCreeper) {
|
||||
((EntityCreeper)entity).timeSinceIgnited=2;
|
||||
entity.setAttackTarget(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,4 +65,55 @@ public class ItemCatAmulet extends ItemMod {
|
||||
if( aiEntry.targetClass== EntityPlayer.class)
|
||||
aiEntry.targetClass=EntityEnderCrystal.class; // Something random that won't be around
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack itemstack) {
|
||||
return BaubleType.AMULET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
|
||||
int range = 10;
|
||||
int rangeY = 4;
|
||||
List<EntityLiving> entities = player.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - rangeY, player.posZ - range, player.posX + range, player.posY + rangeY, player.posZ + range));
|
||||
|
||||
for(EntityLiving entity : entities) {
|
||||
List<EntityAITasks.EntityAITaskEntry> entries = new ArrayList(entity.tasks.taskEntries);
|
||||
entries.addAll(new ArrayList(entity.targetTasks.taskEntries));
|
||||
|
||||
boolean avoidsOcelots = false;
|
||||
for(EntityAITasks.EntityAITaskEntry entry : entries) {
|
||||
if(entry.action instanceof EntityAIAvoidEntity)
|
||||
avoidsOcelots = messWithRunAwayAI((EntityAIAvoidEntity) entry.action) || avoidsOcelots;
|
||||
|
||||
if(entry.action instanceof EntityAINearestAttackableTarget)
|
||||
messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action);
|
||||
}
|
||||
|
||||
if(entity instanceof EntityCreeper) {
|
||||
((EntityCreeper)entity).timeSinceIgnited=2;
|
||||
entity.setAttackTarget(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,12 @@
|
||||
*/
|
||||
package vazkii.tinkerer.common.item.kami;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -32,7 +35,7 @@ import vazkii.tinkerer.common.ThaumicTinkerer;
|
||||
import vazkii.tinkerer.common.core.handler.ModCreativeTab;
|
||||
import vazkii.tinkerer.common.lib.LibGuiIDs;
|
||||
|
||||
public class ItemIchorPouch extends ItemFocusPouch {
|
||||
public class ItemIchorPouch extends ItemFocusPouch implements IBauble {
|
||||
|
||||
public ItemIchorPouch() {
|
||||
super();
|
||||
@@ -77,4 +80,33 @@ public class ItemIchorPouch extends ItemFocusPouch {
|
||||
return stackList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack itemstack) {
|
||||
return BaubleType.BELT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class ItemGemHelm extends ItemIchorclothArmorAdv implements IGoggles, IRe
|
||||
|
||||
if(effect != null && effect.duration <= 202)
|
||||
effect.duration=202;
|
||||
else player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 202, 0));
|
||||
else player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 202, 0,true));
|
||||
}
|
||||
if(player.isInsideOfMaterial(Material.lava) && ThaumicTinkerer.proxy.armorStatus(player) && armor.getItemDamage()==0) {
|
||||
player.setAir(300);
|
||||
@@ -62,7 +62,7 @@ public class ItemGemHelm extends ItemIchorclothArmorAdv implements IGoggles, IRe
|
||||
|
||||
if(effect != null && effect.duration <= 202)
|
||||
effect.duration=202;
|
||||
else player.addPotionEffect(new PotionEffect(Potion.blindness.id, 202, 0));
|
||||
else player.addPotionEffect(new PotionEffect(Potion.blindness.id, 202, 0,true));
|
||||
}
|
||||
int food = player.getFoodStats().getFoodLevel();
|
||||
if(food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0)
|
||||
|
||||
Reference in new issue
Block a user