mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
i rember
This commit is contained in:
parent
9cc9c4d451
commit
b68f9395e8
@ -1,9 +1,88 @@
|
|||||||
package com.hbm.items.tool;
|
package com.hbm.items.tool;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.network.play.client.C07PacketPlayerDigging;
|
||||||
|
import net.minecraft.network.play.server.S23PacketBlockChange;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
|
|
||||||
public interface IItemAbility {
|
public interface IItemAbility {
|
||||||
|
|
||||||
public void breakExtraBlock(World world, int x, int y, int z, EntityPlayer player, int refX, int refY, int refZ);
|
public boolean canHarvestBlock(Block par1Block, ItemStack itemStack);
|
||||||
|
|
||||||
|
public default void breakExtraBlock(World world, int x, int y, int z, EntityPlayer playerEntity, int refX, int refY, int refZ) {
|
||||||
|
|
||||||
|
if(world.isAirBlock(x, y, z))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!(playerEntity instanceof EntityPlayerMP))
|
||||||
|
return;
|
||||||
|
|
||||||
|
EntityPlayerMP player = (EntityPlayerMP) playerEntity;
|
||||||
|
ItemStack stack = player.getHeldItem();
|
||||||
|
|
||||||
|
Block block = world.getBlock(x, y, z);
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
|
if(!canHarvestBlock(block, stack))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Block refBlock = world.getBlock(refX, refY, refZ);
|
||||||
|
float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ);
|
||||||
|
float strength = ForgeHooks.blockStrength(block, player, world, x, y, z);
|
||||||
|
|
||||||
|
if(!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength / strength > 10f || block.getBlockHardness(world, x, y, z) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
||||||
|
if(event.isCanceled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(player.capabilities.isCreativeMode) {
|
||||||
|
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||||
|
if(block.removedByPlayer(world, player, x, y, z, false))
|
||||||
|
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||||
|
|
||||||
|
if(!world.isRemote) {
|
||||||
|
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player);
|
||||||
|
|
||||||
|
if(!world.isRemote) {
|
||||||
|
|
||||||
|
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||||
|
|
||||||
|
if(block.removedByPlayer(world, player, x, y, z, true)) {
|
||||||
|
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||||
|
block.harvestBlock(world, player, x, y, z, meta);
|
||||||
|
block.dropXpOnBlockBreak(world, x, y, z, event.getExpToDrop());
|
||||||
|
}
|
||||||
|
|
||||||
|
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||||
|
if(block.removedByPlayer(world, player, x, y, z, true)) {
|
||||||
|
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||||
|
}
|
||||||
|
ItemStack itemstack = player.getCurrentEquippedItem();
|
||||||
|
if(itemstack != null) {
|
||||||
|
itemstack.func_150999_a(world, block, x, y, z, player);
|
||||||
|
|
||||||
|
if(itemstack.stackSize == 0) {
|
||||||
|
player.destroyCurrentEquippedItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,77 +83,6 @@ public class ItemSwordAbility extends ItemSword implements IItemAbility {
|
|||||||
return multimap;
|
return multimap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void breakExtraBlock(World world, int x, int y, int z, EntityPlayer playerEntity, int refX, int refY, int refZ) {
|
|
||||||
|
|
||||||
if(world.isAirBlock(x, y, z))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(!(playerEntity instanceof EntityPlayerMP))
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityPlayerMP player = (EntityPlayerMP) playerEntity;
|
|
||||||
ItemStack stack = player.getHeldItem();
|
|
||||||
|
|
||||||
Block block = world.getBlock(x, y, z);
|
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
|
||||||
|
|
||||||
if(!canHarvestBlock(block, stack))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Block refBlock = world.getBlock(refX, refY, refZ);
|
|
||||||
float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ);
|
|
||||||
float strength = ForgeHooks.blockStrength(block, player, world, x, y, z);
|
|
||||||
|
|
||||||
if(!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength / strength > 10f)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
|
||||||
if(event.isCanceled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(player.capabilities.isCreativeMode) {
|
|
||||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
|
||||||
if(block.removedByPlayer(world, player, x, y, z, false))
|
|
||||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
|
||||||
|
|
||||||
if(!world.isRemote) {
|
|
||||||
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player);
|
|
||||||
|
|
||||||
if(!world.isRemote) {
|
|
||||||
|
|
||||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
|
||||||
|
|
||||||
if(block.removedByPlayer(world, player, x, y, z, true)) {
|
|
||||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
|
||||||
block.harvestBlock(world, player, x, y, z, meta);
|
|
||||||
block.dropXpOnBlockBreak(world, x, y, z, event.getExpToDrop());
|
|
||||||
}
|
|
||||||
|
|
||||||
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
|
||||||
if(block.removedByPlayer(world, player, x, y, z, true)) {
|
|
||||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
|
||||||
}
|
|
||||||
ItemStack itemstack = player.getCurrentEquippedItem();
|
|
||||||
if(itemstack != null) {
|
|
||||||
itemstack.func_150999_a(world, block, x, y, z, player);
|
|
||||||
|
|
||||||
if(itemstack.stackSize == 0) {
|
|
||||||
player.destroyCurrentEquippedItem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||||
|
|
||||||
|
|||||||
@ -43,10 +43,10 @@ public class ItemToolAbility extends ItemTool implements IItemAbility, IDepthRoc
|
|||||||
private EnumToolType toolType;
|
private EnumToolType toolType;
|
||||||
private EnumRarity rarity = EnumRarity.common;
|
private EnumRarity rarity = EnumRarity.common;
|
||||||
//was there a reason for this to be private?
|
//was there a reason for this to be private?
|
||||||
protected float damage;
|
protected float damage;
|
||||||
protected double movement;
|
protected double movement;
|
||||||
private List<ToolAbility> breakAbility = new ArrayList() {{ add(null); }};
|
private List<ToolAbility> breakAbility = new ArrayList() {{ add(null); }};
|
||||||
private List<WeaponAbility> hitAbility = new ArrayList();
|
private List<WeaponAbility> hitAbility = new ArrayList();
|
||||||
|
|
||||||
public static enum EnumToolType {
|
public static enum EnumToolType {
|
||||||
|
|
||||||
@ -65,11 +65,11 @@ public class ItemToolAbility extends ItemTool implements IItemAbility, IDepthRoc
|
|||||||
MINER(
|
MINER(
|
||||||
Sets.newHashSet(new Material[] { Material.grass, Material.iron, Material.anvil, Material.rock, Material.clay, Material.sand, Material.ground, Material.snow, Material.craftedSnow })
|
Sets.newHashSet(new Material[] { Material.grass, Material.iron, Material.anvil, Material.rock, Material.clay, Material.sand, Material.ground, Material.snow, Material.craftedSnow })
|
||||||
);
|
);
|
||||||
|
|
||||||
private EnumToolType(Set<Material> materials) {
|
private EnumToolType(Set<Material> materials) {
|
||||||
this.materials = materials;
|
this.materials = materials;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EnumToolType(Set<Material> materials, Set<Block> blocks) {
|
private EnumToolType(Set<Material> materials, Set<Block> blocks) {
|
||||||
this.materials = materials;
|
this.materials = materials;
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
@ -86,168 +86,93 @@ public class ItemToolAbility extends ItemTool implements IItemAbility, IDepthRoc
|
|||||||
this.toolType = type;
|
this.toolType = type;
|
||||||
this.setHarvestLevel(type.toString().toLowerCase(), material.getHarvestLevel());
|
this.setHarvestLevel(type.toString().toLowerCase(), material.getHarvestLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemToolAbility addBreakAbility(ToolAbility breakAbility) {
|
public ItemToolAbility addBreakAbility(ToolAbility breakAbility) {
|
||||||
this.breakAbility.add(breakAbility);
|
this.breakAbility.add(breakAbility);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemToolAbility addHitAbility(WeaponAbility weaponAbility) {
|
public ItemToolAbility addHitAbility(WeaponAbility weaponAbility) {
|
||||||
this.hitAbility.add(weaponAbility);
|
this.hitAbility.add(weaponAbility);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//<insert obvious Rarity joke here>
|
// <insert obvious Rarity joke here>
|
||||||
public ItemToolAbility setRarity(EnumRarity rarity) {
|
public ItemToolAbility setRarity(EnumRarity rarity) {
|
||||||
this.rarity = rarity;
|
this.rarity = rarity;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return this.rarity != EnumRarity.common ? this.rarity : super.getRarity(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase attacker) {
|
|
||||||
|
|
||||||
if(!attacker.worldObj.isRemote && !this.hitAbility.isEmpty() && attacker instanceof EntityPlayer && canOperate(stack)) {
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
|
return this.rarity != EnumRarity.common ? this.rarity : super.getRarity(stack);
|
||||||
for(WeaponAbility ability : this.hitAbility) {
|
}
|
||||||
|
|
||||||
|
public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase attacker) {
|
||||||
|
|
||||||
|
if(!attacker.worldObj.isRemote && !this.hitAbility.isEmpty() && attacker instanceof EntityPlayer && canOperate(stack)) {
|
||||||
|
|
||||||
|
for(WeaponAbility ability : this.hitAbility) {
|
||||||
ability.onHit(attacker.worldObj, (EntityPlayer) attacker, victim, this);
|
ability.onHit(attacker.worldObj, (EntityPlayer) attacker, victim, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.damageItem(2, attacker);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
stack.damageItem(2, attacker);
|
||||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
|
||||||
|
|
||||||
World world = player.worldObj;
|
|
||||||
Block block = world.getBlock(x, y, z);
|
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
|
||||||
|
|
||||||
if(!world.isRemote && canHarvestBlock(block, stack) && this.getCurrentAbility(stack) != null && canOperate(stack))
|
|
||||||
this.getCurrentAbility(stack).onDig(world, x, y, z, player, block, meta, this);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return true;
|
||||||
public float getDigSpeed(ItemStack stack, Block block, int meta) {
|
}
|
||||||
|
|
||||||
if(!canOperate(stack))
|
@Override
|
||||||
return 1;
|
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||||
|
|
||||||
if(toolType == null)
|
World world = player.worldObj;
|
||||||
return super.getDigSpeed(stack, block, meta);
|
Block block = world.getBlock(x, y, z);
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
if(toolType.blocks.contains(block) || toolType.materials.contains(block.getMaterial()))
|
|
||||||
return this.efficiencyOnProperMaterial;
|
if(!world.isRemote && canHarvestBlock(block, stack) && this.getCurrentAbility(stack) != null && canOperate(stack))
|
||||||
|
this.getCurrentAbility(stack).onDig(world, x, y, z, player, block, meta, this);
|
||||||
return super.getDigSpeed(stack, block, meta);
|
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean canHarvestBlock(Block block, ItemStack stack) {
|
@Override
|
||||||
|
public float getDigSpeed(ItemStack stack, Block block, int meta) {
|
||||||
if(!canOperate(stack)) return false;
|
|
||||||
|
if(!canOperate(stack))
|
||||||
if(this.getCurrentAbility(stack) instanceof SilkAbility)
|
return 1;
|
||||||
return true;
|
|
||||||
|
if(toolType == null)
|
||||||
return getDigSpeed(stack, block, 0) > 1;
|
return super.getDigSpeed(stack, block, meta);
|
||||||
}
|
|
||||||
|
if(toolType.blocks.contains(block) || toolType.materials.contains(block.getMaterial()))
|
||||||
@Override
|
return this.efficiencyOnProperMaterial;
|
||||||
public Multimap getItemAttributeModifiers() {
|
|
||||||
|
return super.getDigSpeed(stack, block, meta);
|
||||||
Multimap multimap = HashMultimap.create();
|
}
|
||||||
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", (double)this.damage, 0));
|
|
||||||
|
@Override
|
||||||
|
public boolean canHarvestBlock(Block block, ItemStack stack) {
|
||||||
|
|
||||||
|
if(!canOperate(stack))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(this.getCurrentAbility(stack) instanceof SilkAbility)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return getDigSpeed(stack, block, 0) > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Multimap getItemAttributeModifiers() {
|
||||||
|
|
||||||
|
Multimap multimap = HashMultimap.create();
|
||||||
|
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", (double) this.damage, 0));
|
||||||
multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", movement, 1));
|
multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", movement, 1));
|
||||||
return multimap;
|
return multimap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void breakExtraBlock(World world, int x, int y, int z, EntityPlayer playerEntity, int refX, int refY, int refZ) {
|
|
||||||
|
|
||||||
if (world.isAirBlock(x, y, z))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(!(playerEntity instanceof EntityPlayerMP))
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityPlayerMP player = (EntityPlayerMP) playerEntity;
|
|
||||||
ItemStack stack = player.getHeldItem();
|
|
||||||
|
|
||||||
Block block = world.getBlock(x, y, z);
|
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
|
||||||
|
|
||||||
if(!canHarvestBlock(block, stack))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Block refBlock = world.getBlock(refX, refY, refZ);
|
|
||||||
float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ);
|
|
||||||
float strength = ForgeHooks.blockStrength(block, player, world, x,y,z);
|
|
||||||
|
|
||||||
if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x,y,z);
|
|
||||||
if(event.isCanceled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (player.capabilities.isCreativeMode) {
|
|
||||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
|
||||||
if (block.removedByPlayer(world, player, x, y, z, false))
|
|
||||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
|
||||||
|
|
||||||
if (!world.isRemote) {
|
|
||||||
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player);
|
|
||||||
|
|
||||||
if (!world.isRemote) {
|
|
||||||
|
|
||||||
block.onBlockHarvested(world, x,y,z, meta, player);
|
|
||||||
|
|
||||||
if(block.removedByPlayer(world, player, x,y,z, true))
|
|
||||||
{
|
|
||||||
block.onBlockDestroyedByPlayer( world, x,y,z, meta);
|
|
||||||
block.harvestBlock(world, player, x,y,z, meta);
|
|
||||||
block.dropXpOnBlockBreak(world, x,y,z, event.getExpToDrop());
|
|
||||||
}
|
|
||||||
|
|
||||||
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
|
||||||
if(block.removedByPlayer(world, player, x,y,z, true))
|
|
||||||
{
|
|
||||||
block.onBlockDestroyedByPlayer(world, x,y,z, meta);
|
|
||||||
}
|
|
||||||
ItemStack itemstack = player.getCurrentEquippedItem();
|
|
||||||
if (itemstack != null)
|
|
||||||
{
|
|
||||||
itemstack.func_150999_a(world, block, x, y, z, player);
|
|
||||||
|
|
||||||
if (itemstack.stackSize == 0)
|
|
||||||
{
|
|
||||||
player.destroyCurrentEquippedItem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public boolean hasEffect(ItemStack stack) {
|
public boolean hasEffect(ItemStack stack) {
|
||||||
|
return getCurrentAbility(stack) != null || stack.isItemEnchanted();
|
||||||
return getCurrentAbility(stack) != null ? true : super.hasEffect(stack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@ -285,62 +210,56 @@ public class ItemToolAbility extends ItemTool implements IItemAbility, IDepthRoc
|
|||||||
list.add(EnumChatFormatting.RED + "Can break depth rock!");
|
list.add(EnumChatFormatting.RED + "Can break depth rock!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
|
||||||
|
|
||||||
if(world.isRemote || this.breakAbility.size() < 2 || !canOperate(stack))
|
|
||||||
return super.onItemRightClick(stack, world, player);
|
|
||||||
|
|
||||||
int i = getAbility(stack);
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if(player.isSneaking())
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
setAbility(stack, i % this.breakAbility.size());
|
|
||||||
|
|
||||||
while(getCurrentAbility(stack) != null && !getCurrentAbility(stack).isAllowed()) {
|
|
||||||
|
|
||||||
player.addChatComponentMessage(
|
|
||||||
new ChatComponentText("[Ability ")
|
|
||||||
.appendSibling(new ChatComponentTranslation(getCurrentAbility(stack).getName(), new Object[0]))
|
|
||||||
.appendSibling(new ChatComponentText(getCurrentAbility(stack).getExtension() + " is blacklisted!]"))
|
|
||||||
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
|
||||||
|
|
||||||
i++;
|
|
||||||
setAbility(stack, i % this.breakAbility.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(getCurrentAbility(stack) != null) {
|
|
||||||
player.addChatComponentMessage(
|
|
||||||
new ChatComponentText("[Enabled ")
|
|
||||||
.appendSibling(new ChatComponentTranslation(getCurrentAbility(stack).getName(), new Object[0]))
|
|
||||||
.appendSibling(new ChatComponentText(getCurrentAbility(stack).getExtension() + "]"))
|
|
||||||
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
|
|
||||||
} else {
|
|
||||||
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "[Tool ability deactivated]"));
|
|
||||||
}
|
|
||||||
|
|
||||||
world.playSoundAtEntity(player, "random.orb", 0.25F, getCurrentAbility(stack) == null ? 0.75F : 1.25F);
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||||
|
|
||||||
return stack;
|
if(world.isRemote || this.breakAbility.size() < 2 || !canOperate(stack))
|
||||||
}
|
return super.onItemRightClick(stack, world, player);
|
||||||
|
|
||||||
private ToolAbility getCurrentAbility(ItemStack stack) {
|
int i = getAbility(stack);
|
||||||
|
i++;
|
||||||
int ability = getAbility(stack) % this.breakAbility.size();
|
|
||||||
|
if(player.isSneaking())
|
||||||
return this.breakAbility.get(ability);
|
i = 0;
|
||||||
}
|
|
||||||
|
setAbility(stack, i % this.breakAbility.size());
|
||||||
private int getAbility(ItemStack stack) {
|
|
||||||
|
while(getCurrentAbility(stack) != null && !getCurrentAbility(stack).isAllowed()) {
|
||||||
if(stack.hasTagCompound())
|
|
||||||
return stack.stackTagCompound.getInteger("ability");
|
player.addChatComponentMessage(new ChatComponentText("[Ability ").appendSibling(new ChatComponentTranslation(getCurrentAbility(stack).getName(), new Object[0]))
|
||||||
|
.appendSibling(new ChatComponentText(getCurrentAbility(stack).getExtension() + " is blacklisted!]")).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||||
return 0;
|
|
||||||
}
|
i++;
|
||||||
|
setAbility(stack, i % this.breakAbility.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(getCurrentAbility(stack) != null) {
|
||||||
|
player.addChatComponentMessage(new ChatComponentText("[Enabled ").appendSibling(new ChatComponentTranslation(getCurrentAbility(stack).getName(), new Object[0]))
|
||||||
|
.appendSibling(new ChatComponentText(getCurrentAbility(stack).getExtension() + "]")).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
|
||||||
|
} else {
|
||||||
|
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "[Tool ability deactivated]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
world.playSoundAtEntity(player, "random.orb", 0.25F, getCurrentAbility(stack) == null ? 0.75F : 1.25F);
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ToolAbility getCurrentAbility(ItemStack stack) {
|
||||||
|
|
||||||
|
int ability = getAbility(stack) % this.breakAbility.size();
|
||||||
|
|
||||||
|
return this.breakAbility.get(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getAbility(ItemStack stack) {
|
||||||
|
|
||||||
|
if(stack.hasTagCompound())
|
||||||
|
return stack.stackTagCompound.getInteger("ability");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void setAbility(ItemStack stack, int ability) {
|
private void setAbility(ItemStack stack, int ability) {
|
||||||
|
|
||||||
if(!stack.hasTagCompound())
|
if(!stack.hasTagCompound())
|
||||||
@ -357,7 +276,7 @@ public class ItemToolAbility extends ItemTool implements IItemAbility, IDepthRoc
|
|||||||
this.rockBreaker = true;
|
this.rockBreaker = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean rockBreaker = false;
|
private boolean rockBreaker = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user