added tool deconstruct and repair, made tool modifiers actually work
This commit is contained in:
@@ -8,8 +8,8 @@ To-Dos
|
|||||||
- [ ] Add Iron Ring Recipe
|
- [ ] Add Iron Ring Recipe
|
||||||
- [ ] Add chainmail recipe
|
- [ ] Add chainmail recipe
|
||||||
- [ ] Add Iron Shield Recipe
|
- [ ] Add Iron Shield Recipe
|
||||||
- [ ] Tool Disassembly
|
- [x] Tool Disassembly
|
||||||
- [ ] Tool Repair
|
- [x] Tool Repair
|
||||||
- [ ] Gold Smelting
|
- [ ] Gold Smelting
|
||||||
- [ ] Custom Tool Material
|
- [ ] Custom Tool Material
|
||||||
- [ ] Add Iron to to Empty Crucible via right click
|
- [ ] Add Iron to to Empty Crucible via right click
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx3G
|
|||||||
|
|
||||||
mod_group=nmd.primal.forgecraft
|
mod_group=nmd.primal.forgecraft
|
||||||
mod_name=ForgeCraft
|
mod_name=ForgeCraft
|
||||||
mod_version=1.2.03
|
mod_version=1.2.05
|
||||||
forge_version=13.20.0.2226
|
forge_version=13.20.0.2226
|
||||||
mcp_mappings=snapshot_20161220
|
mcp_mappings=snapshot_20161220
|
||||||
mc_version=1.11.2
|
mc_version=1.11.2
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||||
import nmd.primal.forgecraft.init.ModItems;
|
import nmd.primal.forgecraft.init.ModItems;
|
||||||
import nmd.primal.forgecraft.items.parts.ToolPart;
|
import nmd.primal.forgecraft.items.parts.ToolPart;
|
||||||
import nmd.primal.forgecraft.items.tools.CustomAxe;
|
import nmd.primal.forgecraft.items.tools.*;
|
||||||
import nmd.primal.forgecraft.items.tools.CustomHoe;
|
|
||||||
import nmd.primal.forgecraft.items.tools.CustomPickaxe;
|
|
||||||
import nmd.primal.forgecraft.items.tools.CustomShovel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mminaie on 3/15/17.
|
* Created by mminaie on 3/15/17.
|
||||||
@@ -34,9 +31,6 @@ public class CommonEvents implements ToolNBT{
|
|||||||
event.crafting.getTagCompound().setTag("tags", tempTag);
|
event.crafting.getTagCompound().setTag("tags", tempTag);
|
||||||
event.crafting.getItem().updateItemStackNBT(event.crafting.getTagCompound());
|
event.crafting.getItem().updateItemStackNBT(event.crafting.getTagCompound());
|
||||||
event.crafting.setItemDamage(event.craftMatrix.getStackInSlot(i).getItemDamage());
|
event.crafting.setItemDamage(event.craftMatrix.getStackInSlot(i).getItemDamage());
|
||||||
//if( getDiamondLevel(event.crafting) > 0 ){
|
|
||||||
// event.crafting.getItem().setHarvestLevel("pickaxe", 3);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class ModInfo {
|
|||||||
public static final String MOD_NAME = "Kitsu's ForgeCraft";
|
public static final String MOD_NAME = "Kitsu's ForgeCraft";
|
||||||
//public static final String MOD_PREFIX = MOD_ID + ":";
|
//public static final String MOD_PREFIX = MOD_ID + ":";
|
||||||
public static final String MOD_CHANNEL = MOD_ID;
|
public static final String MOD_CHANNEL = MOD_ID;
|
||||||
public static final String MOD_VERSION = "1.2.03";
|
public static final String MOD_VERSION = "1.2.05";
|
||||||
public static final String MC_VERSIONS = "[1.11.0, 1.12.0)";
|
public static final String MC_VERSIONS = "[1.11.0, 1.12.0)";
|
||||||
public static final String DEPENDENCIES = "required-after:forge@[13.20.0.2226,);"
|
public static final String DEPENDENCIES = "required-after:forge@[13.20.0.2226,);"
|
||||||
+ "after:primal;";
|
+ "after:primal;";
|
||||||
|
|||||||
@@ -8,35 +8,6 @@ import nmd.primal.forgecraft.util.IMetaLookup;
|
|||||||
*/
|
*/
|
||||||
public class EnumHandler {
|
public class EnumHandler {
|
||||||
|
|
||||||
public static enum TongTypes implements IStringSerializable {
|
|
||||||
DEFAULT("default", 0),
|
|
||||||
EMPTYHOT("emptyhot", 1);
|
|
||||||
|
|
||||||
private int ID;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
private TongTypes(String name, int ID) {
|
|
||||||
this.ID = ID;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getID() {
|
|
||||||
return ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public enum IngotTypes implements IMetaLookup<IngotTypes> {
|
public enum IngotTypes implements IMetaLookup<IngotTypes> {
|
||||||
IRONCOOL, /*0*/
|
IRONCOOL, /*0*/
|
||||||
IRONHOT; /*1*/
|
IRONHOT; /*1*/
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import nmd.primal.forgecraft.ModInfo;
|
import nmd.primal.forgecraft.ModInfo;
|
||||||
import nmd.primal.forgecraft.blocks.IngotBall;
|
import nmd.primal.forgecraft.blocks.IngotBall;
|
||||||
|
import nmd.primal.forgecraft.enumhandler.EnumHandler;
|
||||||
import nmd.primal.forgecraft.items.*;
|
import nmd.primal.forgecraft.items.*;
|
||||||
import nmd.primal.forgecraft.items.parts.ToolPart;
|
import nmd.primal.forgecraft.items.parts.ToolPart;
|
||||||
import nmd.primal.forgecraft.items.tools.CustomAxe;
|
import nmd.primal.forgecraft.items.tools.*;
|
||||||
import nmd.primal.forgecraft.items.tools.CustomHoe;
|
|
||||||
import nmd.primal.forgecraft.items.tools.CustomPickaxe;
|
|
||||||
import nmd.primal.forgecraft.items.tools.CustomShovel;
|
|
||||||
import nmd.primal.forgecraft.items.weapons.CustomSword;
|
import nmd.primal.forgecraft.items.weapons.CustomSword;
|
||||||
|
import nmd.primal.forgecraft.util.ToolMaterials;
|
||||||
|
import nmd.primal.forgecraft.items.tools.BaseTool.ForgeToolMaterial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by kitsu on 11/26/2016.
|
* Created by kitsu on 11/26/2016.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import nmd.primal.forgecraft.enumhandler.EnumHandler;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static nmd.primal.forgecraft.enumhandler.EnumHandler.IngotTypes.*;
|
//import static nmd.primal.forgecraft.enumhandler.EnumHandler.IngotTypes.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mminaie on 2/12/17.
|
* Created by mminaie on 2/12/17.
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import nmd.primal.forgecraft.ModInfo;
|
import nmd.primal.forgecraft.ModInfo;
|
||||||
import nmd.primal.forgecraft.ToolNBT;
|
import nmd.primal.forgecraft.ToolNBT;
|
||||||
|
import nmd.primal.forgecraft.enumhandler.EnumHandler;
|
||||||
|
import nmd.primal.forgecraft.items.tools.BaseTool;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package nmd.primal.forgecraft.items.tools;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemTool;
|
||||||
|
import nmd.primal.forgecraft.enumhandler.EnumHandler;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mminaie on 3/29/17.
|
||||||
|
*/
|
||||||
|
public abstract class BasePickaxe extends BaseTool
|
||||||
|
{
|
||||||
|
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE});
|
||||||
|
|
||||||
|
protected BasePickaxe(ForgeToolMaterial material)
|
||||||
|
{
|
||||||
|
super(1.0F, -2.8F, material, EFFECTIVE_ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether this Item can harvest the given Block
|
||||||
|
*/
|
||||||
|
public boolean canHarvestBlock(IBlockState blockIn)
|
||||||
|
{
|
||||||
|
Block block = blockIn.getBlock();
|
||||||
|
|
||||||
|
if (block == Blocks.OBSIDIAN)
|
||||||
|
{
|
||||||
|
return this.toolMaterial.getHarvestLevel() == 3;
|
||||||
|
}
|
||||||
|
else if (block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE)
|
||||||
|
{
|
||||||
|
if (block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK)
|
||||||
|
{
|
||||||
|
if (block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE)
|
||||||
|
{
|
||||||
|
if (block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE)
|
||||||
|
{
|
||||||
|
if (block != Blocks.LAPIS_BLOCK && block != Blocks.LAPIS_ORE)
|
||||||
|
{
|
||||||
|
if (block != Blocks.REDSTONE_ORE && block != Blocks.LIT_REDSTONE_ORE)
|
||||||
|
{
|
||||||
|
Material material = blockIn.getMaterial();
|
||||||
|
return material == Material.ROCK ? true : (material == Material.IRON ? true : material == Material.ANVIL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.toolMaterial.getHarvestLevel() >= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.toolMaterial.getHarvestLevel() >= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.toolMaterial.getHarvestLevel() >= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.toolMaterial.getHarvestLevel() >= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.toolMaterial.getHarvestLevel() >= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.toolMaterial.getHarvestLevel() >= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||||
|
{
|
||||||
|
Material material = state.getMaterial();
|
||||||
|
return material != Material.IRON && material != Material.ANVIL && material != Material.ROCK ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,263 @@
|
|||||||
|
package nmd.primal.forgecraft.items.tools;
|
||||||
|
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||||
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import nmd.primal.forgecraft.enumhandler.EnumHandler;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mminaie on 3/29/17.
|
||||||
|
*/
|
||||||
|
public abstract class BaseTool extends Item {
|
||||||
|
|
||||||
|
private final Set<Block> effectiveBlocks;
|
||||||
|
protected float efficiencyOnProperMaterial;
|
||||||
|
/** Damage versus entities. */
|
||||||
|
protected float damageVsEntity;
|
||||||
|
protected float attackSpeed;
|
||||||
|
/** The material this tool is made from. */
|
||||||
|
protected ForgeToolMaterial toolMaterial;
|
||||||
|
|
||||||
|
protected BaseTool(float attackDamageIn, float attackSpeedIn, ForgeToolMaterial materialIn, Set<Block> effectiveBlocksIn)
|
||||||
|
{
|
||||||
|
this.efficiencyOnProperMaterial = 4.0F;
|
||||||
|
this.toolMaterial = materialIn;
|
||||||
|
this.effectiveBlocks = effectiveBlocksIn;
|
||||||
|
this.maxStackSize = 1;
|
||||||
|
this.setMaxDamage(materialIn.getMaxUses());
|
||||||
|
this.efficiencyOnProperMaterial = materialIn.getEfficiencyOnProperMaterial();
|
||||||
|
this.damageVsEntity = attackDamageIn + materialIn.getDamageVsEntity();
|
||||||
|
this.attackSpeed = attackSpeedIn;
|
||||||
|
this.setCreativeTab(CreativeTabs.TOOLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BaseTool(ForgeToolMaterial materialIn, Set<Block> effectiveBlocksIn)
|
||||||
|
{
|
||||||
|
this(0.0F, 0.0F, materialIn, effectiveBlocksIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||||
|
{
|
||||||
|
for (String type : getToolClasses(stack))
|
||||||
|
{
|
||||||
|
if (state.getBlock().isToolEffective(type, state))
|
||||||
|
return efficiencyOnProperMaterial;
|
||||||
|
}
|
||||||
|
return this.effectiveBlocks.contains(state.getBlock()) ? this.efficiencyOnProperMaterial : 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static enum ForgeToolMaterial {
|
||||||
|
IRON(2, 250, 6.0F, 2.0F, 14);
|
||||||
|
//DIAMOND(3, 1561, 8.0F, 3.0F, 10),
|
||||||
|
//GOLD(0, 32, 12.0F, 0.0F, 22);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = WOOD/GOLD)
|
||||||
|
*/
|
||||||
|
private int harvestLevel;
|
||||||
|
/**
|
||||||
|
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
|
||||||
|
*/
|
||||||
|
private int maxUses;
|
||||||
|
/**
|
||||||
|
* The strength of this tool material against blocks which it is effective against.
|
||||||
|
*/
|
||||||
|
private float efficiencyOnProperMaterial;
|
||||||
|
/**
|
||||||
|
* Damage versus entities.
|
||||||
|
*/
|
||||||
|
private float damageVsEntity;
|
||||||
|
/**
|
||||||
|
* Defines the natural enchantability factor of the material.
|
||||||
|
*/
|
||||||
|
private int enchantability;
|
||||||
|
//Added by forge for custom Tool materials.
|
||||||
|
|
||||||
|
ForgeToolMaterial(int harvestLevel, int maxUses, float efficiency, float damageVsEntity, int enchantability) {
|
||||||
|
this.harvestLevel = harvestLevel;
|
||||||
|
this.maxUses = maxUses;
|
||||||
|
this.efficiencyOnProperMaterial = efficiency;
|
||||||
|
this.damageVsEntity = damageVsEntity;
|
||||||
|
this.enchantability = enchantability;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
|
||||||
|
*/
|
||||||
|
public int getMaxUses() {
|
||||||
|
return this.maxUses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxUses(int maxUses) {
|
||||||
|
this.maxUses = maxUses;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The strength of this tool material against blocks which it is effective against.
|
||||||
|
*/
|
||||||
|
public float getEfficiencyOnProperMaterial() {
|
||||||
|
return this.efficiencyOnProperMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEfficiencyOnProperMaterial(float efficiencyOnProperMaterial) {
|
||||||
|
this.efficiencyOnProperMaterial = efficiencyOnProperMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the damage against a given entity.
|
||||||
|
*/
|
||||||
|
public float getDamageVsEntity() {
|
||||||
|
return this.damageVsEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDamageVsEntity(float damageVsEntity) {
|
||||||
|
this.damageVsEntity = damageVsEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD)
|
||||||
|
*/
|
||||||
|
public int getHarvestLevel() {
|
||||||
|
return this.harvestLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHarvestLevel(int harvestLevel) {
|
||||||
|
this.harvestLevel = harvestLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the natural enchantability factor of the material.
|
||||||
|
*/
|
||||||
|
public int getEnchantability() {
|
||||||
|
return this.enchantability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnchantability(int enchantability) {
|
||||||
|
this.enchantability = enchantability;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
|
||||||
|
* the damage on the stack.
|
||||||
|
*/
|
||||||
|
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||||
|
{
|
||||||
|
stack.damageItem(2, attacker);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a Block is destroyed using this Item. Return true to trigger the "Use Item" statistic.
|
||||||
|
*/
|
||||||
|
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving)
|
||||||
|
{
|
||||||
|
if (!worldIn.isRemote && (double)state.getBlockHardness(worldIn, pos) != 0.0D)
|
||||||
|
{
|
||||||
|
stack.damageItem(1, entityLiving);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns True is the item is renderer in full 3D when hold.
|
||||||
|
*/
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public boolean isFull3D()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForgeToolMaterial getToolMaterial()
|
||||||
|
{
|
||||||
|
return this.toolMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the enchantability factor of the item, most of the time is based on material.
|
||||||
|
*/
|
||||||
|
public int getItemEnchantability()
|
||||||
|
{
|
||||||
|
return this.toolMaterial.getEnchantability();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name for this tool's material.
|
||||||
|
*/
|
||||||
|
public String getToolMaterialName()
|
||||||
|
{
|
||||||
|
return this.toolMaterial.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether this item is repairable in an anvil.
|
||||||
|
*/
|
||||||
|
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
|
||||||
|
{
|
||||||
|
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
|
||||||
|
|
||||||
|
if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
|
||||||
|
{
|
||||||
|
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", (double)this.damageVsEntity, 0));
|
||||||
|
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", (double)this.attackSpeed, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return multimap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*===================================== FORGE START =================================*/
|
||||||
|
@javax.annotation.Nullable
|
||||||
|
private String toolClass;
|
||||||
|
@Override
|
||||||
|
public int getHarvestLevel(ItemStack stack, String toolClass, @javax.annotation.Nullable net.minecraft.entity.player.EntityPlayer player, @javax.annotation.Nullable IBlockState blockState)
|
||||||
|
{
|
||||||
|
int level = super.getHarvestLevel(stack, toolClass, player, blockState);
|
||||||
|
if (level == -1 && toolClass.equals(this.toolClass))
|
||||||
|
{
|
||||||
|
return this.toolMaterial.getHarvestLevel();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getToolClasses(ItemStack stack)
|
||||||
|
{
|
||||||
|
return toolClass != null ? com.google.common.collect.ImmutableSet.of(toolClass) : super.getToolClasses(stack);
|
||||||
|
}
|
||||||
|
/*===================================== FORGE END =================================*/
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package nmd.primal.forgecraft.items.tools;
|
package nmd.primal.forgecraft.items.tools;
|
||||||
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@@ -21,6 +22,7 @@ import nmd.primal.forgecraft.ToolNBT;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mminaie on 3/20/17.
|
* Created by mminaie on 3/20/17.
|
||||||
@@ -289,6 +291,7 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
|
|||||||
if (getLapisLevel(item) > 0) {
|
if (getLapisLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
||||||
}
|
}
|
||||||
|
tooltip.add(ChatFormatting.LIGHT_PURPLE + "Damage: " + item.getItemDamage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,17 +303,18 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
|
|||||||
if(!player.world.isRemote){
|
if(!player.world.isRemote){
|
||||||
World world = player.getEntityWorld();
|
World world = player.getEntityWorld();
|
||||||
//System.out.println(world.getBlockState(pos).getBlock());
|
//System.out.println(world.getBlockState(pos).getBlock());
|
||||||
if(itemstack.getItem() instanceof CustomPickaxe){
|
if(itemstack.getItem() instanceof CustomAxe){
|
||||||
if( getEmerald(itemstack)){
|
if( getEmerald(itemstack)){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
||||||
}
|
}
|
||||||
if( getDiamondLevel(itemstack) > 0 ){
|
/*if( getDiamondLevel(itemstack) > 0 ){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(34), getDiamondLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(34), getDiamondLevel(itemstack));
|
||||||
itemstack.getItem().setHarvestLevel("axe", 3);
|
itemstack.getItem().setHarvestLevel("pickaxe", 3);
|
||||||
}
|
}*/
|
||||||
if( getRedstoneLevel(itemstack) > 0 ){
|
/*if( getRedstoneLevel(itemstack) > 0 ){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(32), getRedstoneLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(32), getRedstoneLevel(itemstack));
|
||||||
}
|
//System.out.println(itemstack.getEnchantmentTagList());
|
||||||
|
}*/
|
||||||
if ( getLapisLevel(itemstack) > 0) {
|
if ( getLapisLevel(itemstack) > 0) {
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(35), getLapisLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(35), getLapisLevel(itemstack));
|
||||||
}
|
}
|
||||||
@@ -328,13 +332,32 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
|
|||||||
|
|
||||||
stack.getTagCompound().removeTag("ench");
|
stack.getTagCompound().removeTag("ench");
|
||||||
//System.out.println(stack.getTagCompound());
|
//System.out.println(stack.getTagCompound());
|
||||||
|
if(getDiamondLevel(stack) > 0) {
|
||||||
|
if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) {
|
||||||
stack.damageItem(1, entityLiving);
|
stack.damageItem(1, entityLiving);
|
||||||
}
|
}
|
||||||
|
} else stack.damageItem(1, entityLiving);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||||
|
{
|
||||||
|
Material material = state.getMaterial();
|
||||||
|
//return material != Material.IRON && material != Material.ANVIL && material != Material.ROCK ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial;
|
||||||
|
|
||||||
|
if(material != Material.IRON && material != Material.ANVIL && material != Material.ROCK){
|
||||||
|
return super.getStrVsBlock(stack, state);
|
||||||
|
} else if (this.getRedstoneLevel(stack) > 0) {
|
||||||
|
return this.efficiencyOnProperMaterial * ((this.getRedstoneLevel(stack) / 2) * this.getRedstoneLevel(stack) );
|
||||||
|
} else {
|
||||||
|
return this.efficiencyOnProperMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public boolean hasEffect(ItemStack stack)
|
public boolean hasEffect(ItemStack stack)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nmd.primal.forgecraft.items.tools;
|
package nmd.primal.forgecraft.items.tools;
|
||||||
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@@ -21,6 +22,7 @@ import nmd.primal.forgecraft.ToolNBT;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mminaie on 3/21/17.
|
* Created by mminaie on 3/21/17.
|
||||||
@@ -285,6 +287,7 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
|
|||||||
if (getLapisLevel(item) > 0) {
|
if (getLapisLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
||||||
}
|
}
|
||||||
|
tooltip.add(ChatFormatting.LIGHT_PURPLE + "Damage: " + item.getItemDamage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,17 +300,18 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
|
|||||||
if(!player.world.isRemote){
|
if(!player.world.isRemote){
|
||||||
World world = player.getEntityWorld();
|
World world = player.getEntityWorld();
|
||||||
System.out.println(world.getBlockState(pos).getBlock());
|
System.out.println(world.getBlockState(pos).getBlock());
|
||||||
if(itemstack.getItem() instanceof CustomPickaxe){
|
if(itemstack.getItem() instanceof CustomHoe){
|
||||||
if( getEmerald(itemstack)){
|
if( getEmerald(itemstack)){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
||||||
}
|
}
|
||||||
if( getDiamondLevel(itemstack) > 0 ){
|
/*if( getDiamondLevel(itemstack) > 0 ){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(34), getDiamondLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(34), getDiamondLevel(itemstack));
|
||||||
itemstack.getItem().setHarvestLevel("hoe", 3);
|
itemstack.getItem().setHarvestLevel("pickaxe", 3);
|
||||||
}
|
}*/
|
||||||
if( getRedstoneLevel(itemstack) > 0 ){
|
/*if( getRedstoneLevel(itemstack) > 0 ){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(32), getRedstoneLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(32), getRedstoneLevel(itemstack));
|
||||||
}
|
//System.out.println(itemstack.getEnchantmentTagList());
|
||||||
|
}*/
|
||||||
if ( getLapisLevel(itemstack) > 0) {
|
if ( getLapisLevel(itemstack) > 0) {
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(35), getLapisLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(35), getLapisLevel(itemstack));
|
||||||
}
|
}
|
||||||
@@ -325,9 +329,12 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
|
|||||||
|
|
||||||
stack.getTagCompound().removeTag("ench");
|
stack.getTagCompound().removeTag("ench");
|
||||||
//System.out.println(stack.getTagCompound());
|
//System.out.println(stack.getTagCompound());
|
||||||
|
if(getDiamondLevel(stack) > 0) {
|
||||||
|
if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) {
|
||||||
stack.damageItem(1, entityLiving);
|
stack.damageItem(1, entityLiving);
|
||||||
}
|
}
|
||||||
|
} else stack.damageItem(1, entityLiving);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import net.minecraft.item.ItemPickaxe;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -25,9 +26,11 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import nmd.primal.forgecraft.ModInfo;
|
import nmd.primal.forgecraft.ModInfo;
|
||||||
import nmd.primal.forgecraft.ToolNBT;
|
import nmd.primal.forgecraft.ToolNBT;
|
||||||
|
import nmd.primal.forgecraft.enumhandler.EnumHandler;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mminaie on 3/14/17.
|
* Created by mminaie on 3/14/17.
|
||||||
@@ -42,6 +45,8 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
|
|||||||
this.setMaxStackSize(1);
|
this.setMaxStackSize(1);
|
||||||
this.setNoRepair();
|
this.setNoRepair();
|
||||||
|
|
||||||
|
//this.toolClass = "pickaxe";
|
||||||
|
|
||||||
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
|
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@@ -267,6 +272,9 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*if(){
|
||||||
|
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//public void onItemTooltip(ItemTooltipEvent event){
|
//public void onItemTooltip(ItemTooltipEvent event){
|
||||||
@@ -276,7 +284,7 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
|
|||||||
public void addInformation(ItemStack item, EntityPlayer player, List<String> tooltip, boolean advanced)
|
public void addInformation(ItemStack item, EntityPlayer player, List<String> tooltip, boolean advanced)
|
||||||
{
|
{
|
||||||
if(player.getEntityWorld().isRemote) {
|
if(player.getEntityWorld().isRemote) {
|
||||||
|
//tooltip.add(ChatFormatting.GRAY + "Damage: " + item.getItemDamage() );
|
||||||
if(item.hasTagCompound()) {
|
if(item.hasTagCompound()) {
|
||||||
|
|
||||||
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
||||||
@@ -292,6 +300,7 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
|
|||||||
if (getLapisLevel(item) > 0) {
|
if (getLapisLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
||||||
}
|
}
|
||||||
|
tooltip.add(ChatFormatting.LIGHT_PURPLE + "Damage: " + item.getItemDamage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,14 +317,14 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
|
|||||||
if( getEmerald(itemstack)){
|
if( getEmerald(itemstack)){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
||||||
}
|
}
|
||||||
if( getDiamondLevel(itemstack) > 0 ){
|
/*if( getDiamondLevel(itemstack) > 0 ){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(34), getDiamondLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(34), getDiamondLevel(itemstack));
|
||||||
itemstack.getItem().setHarvestLevel("pickaxe", 3);
|
itemstack.getItem().setHarvestLevel("pickaxe", 3);
|
||||||
}
|
}*/
|
||||||
if( getRedstoneLevel(itemstack) > 0 ){
|
/*if( getRedstoneLevel(itemstack) > 0 ){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(32), getRedstoneLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(32), getRedstoneLevel(itemstack));
|
||||||
System.out.println(itemstack.getEnchantmentTagList());
|
//System.out.println(itemstack.getEnchantmentTagList());
|
||||||
}
|
}*/
|
||||||
if ( getLapisLevel(itemstack) > 0) {
|
if ( getLapisLevel(itemstack) > 0) {
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(35), getLapisLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(35), getLapisLevel(itemstack));
|
||||||
}
|
}
|
||||||
@@ -333,9 +342,12 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
|
|||||||
|
|
||||||
stack.getTagCompound().removeTag("ench");
|
stack.getTagCompound().removeTag("ench");
|
||||||
//System.out.println(stack.getTagCompound());
|
//System.out.println(stack.getTagCompound());
|
||||||
|
if(getDiamondLevel(stack) > 0) {
|
||||||
|
if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) {
|
||||||
stack.damageItem(1, entityLiving);
|
stack.damageItem(1, entityLiving);
|
||||||
}
|
}
|
||||||
|
} else stack.damageItem(1, entityLiving);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -358,4 +370,20 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||||
|
{
|
||||||
|
Material material = state.getMaterial();
|
||||||
|
//return material != Material.IRON && material != Material.ANVIL && material != Material.ROCK ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial;
|
||||||
|
|
||||||
|
if(material != Material.IRON && material != Material.ANVIL && material != Material.ROCK){
|
||||||
|
return super.getStrVsBlock(stack, state);
|
||||||
|
} else if (this.getRedstoneLevel(stack) > 0) {
|
||||||
|
return this.efficiencyOnProperMaterial * ((this.getRedstoneLevel(stack) / 2) * this.getRedstoneLevel(stack) );
|
||||||
|
} else {
|
||||||
|
return this.efficiencyOnProperMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nmd.primal.forgecraft.items.tools;
|
package nmd.primal.forgecraft.items.tools;
|
||||||
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@@ -21,6 +22,7 @@ import nmd.primal.forgecraft.ToolNBT;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mminaie on 3/21/17.
|
* Created by mminaie on 3/21/17.
|
||||||
@@ -285,6 +287,7 @@ public class CustomShovel extends ItemSpade implements ToolNBT {
|
|||||||
if (getLapisLevel(item) > 0) {
|
if (getLapisLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
||||||
}
|
}
|
||||||
|
tooltip.add(ChatFormatting.LIGHT_PURPLE + "Damage: " + item.getItemDamage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,13 +304,14 @@ public class CustomShovel extends ItemSpade implements ToolNBT {
|
|||||||
if( getEmerald(itemstack)){
|
if( getEmerald(itemstack)){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
||||||
}
|
}
|
||||||
if( getDiamondLevel(itemstack) > 0 ){
|
/*if( getDiamondLevel(itemstack) > 0 ){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(34), getDiamondLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(34), getDiamondLevel(itemstack));
|
||||||
itemstack.getItem().setHarvestLevel("shovel", 3);
|
itemstack.getItem().setHarvestLevel("pickaxe", 3);
|
||||||
}
|
}*/
|
||||||
if( getRedstoneLevel(itemstack) > 0 ){
|
/*if( getRedstoneLevel(itemstack) > 0 ){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(32), getRedstoneLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(32), getRedstoneLevel(itemstack));
|
||||||
}
|
//System.out.println(itemstack.getEnchantmentTagList());
|
||||||
|
}*/
|
||||||
if ( getLapisLevel(itemstack) > 0) {
|
if ( getLapisLevel(itemstack) > 0) {
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(35), getLapisLevel(itemstack));
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(35), getLapisLevel(itemstack));
|
||||||
}
|
}
|
||||||
@@ -325,13 +329,32 @@ public class CustomShovel extends ItemSpade implements ToolNBT {
|
|||||||
|
|
||||||
stack.getTagCompound().removeTag("ench");
|
stack.getTagCompound().removeTag("ench");
|
||||||
//System.out.println(stack.getTagCompound());
|
//System.out.println(stack.getTagCompound());
|
||||||
|
if(getDiamondLevel(stack) > 0) {
|
||||||
|
if(ThreadLocalRandom.current().nextInt(0, getDiamondLevel(stack)) == 0) {
|
||||||
stack.damageItem(1, entityLiving);
|
stack.damageItem(1, entityLiving);
|
||||||
}
|
}
|
||||||
|
} else stack.damageItem(1, entityLiving);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||||
|
{
|
||||||
|
Material material = state.getMaterial();
|
||||||
|
//return material != Material.IRON && material != Material.ANVIL && material != Material.ROCK ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial;
|
||||||
|
|
||||||
|
if(material != Material.IRON && material != Material.ANVIL && material != Material.ROCK){
|
||||||
|
return super.getStrVsBlock(stack, state);
|
||||||
|
} else if (this.getRedstoneLevel(stack) > 0) {
|
||||||
|
return this.efficiencyOnProperMaterial * ((this.getRedstoneLevel(stack) / 2) * this.getRedstoneLevel(stack) );
|
||||||
|
} else {
|
||||||
|
return this.efficiencyOnProperMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public boolean hasEffect(ItemStack stack)
|
public boolean hasEffect(ItemStack stack)
|
||||||
|
|||||||
@@ -1,303 +0,0 @@
|
|||||||
package nmd.primal.forgecraft.items.tools;
|
|
||||||
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
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.util.ResourceLocation;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
import nmd.primal.forgecraft.ModInfo;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mminaie on 3/9/17.
|
|
||||||
*/
|
|
||||||
public abstract class CustomTool extends ItemTool {
|
|
||||||
|
|
||||||
public Item.ToolMaterial material;
|
|
||||||
private String toolClass;
|
|
||||||
private final float attackDamage;
|
|
||||||
|
|
||||||
public CustomTool(String name, Item.ToolMaterial material, float attack_damage, float attack_speed, Set<Block> effective_on) {
|
|
||||||
|
|
||||||
super(attack_damage, attack_speed, material, effective_on);
|
|
||||||
|
|
||||||
this.attackDamage = 2.0F + material.getDamageVsEntity();
|
|
||||||
this.material = material;
|
|
||||||
this.setUnlocalizedName(name);
|
|
||||||
this.setRegistryName(name);
|
|
||||||
this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
|
|
||||||
this.setMaxStackSize(1);
|
|
||||||
this.setNoRepair();
|
|
||||||
|
|
||||||
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter()
|
|
||||||
{
|
|
||||||
|
|
||||||
/***
|
|
||||||
|
|
||||||
hot . emerald . diamond . redstone . lapis
|
|
||||||
0 . 0 . 0 . 0 . 0
|
|
||||||
|
|
||||||
***/
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public float apply(ItemStack item, @Nullable World worldIn, @Nullable EntityLivingBase entityIn)
|
|
||||||
{
|
|
||||||
if (item.hasTagCompound()) {
|
|
||||||
|
|
||||||
|
|
||||||
if (item.getSubCompound("tags").getBoolean("hot") == false) {
|
|
||||||
if (item.getSubCompound("tags").getInteger("modifiers") != 0) {
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == true) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.1F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == true) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.11F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == true) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 2) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.12F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == true) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.111F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == true) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 2) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.102F;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.01F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 2) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.02F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 3) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.03F;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.001F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 2) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.002F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 3) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.003F;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=========
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 1)) {
|
|
||||||
return 0.0001F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 2)) {
|
|
||||||
return 0.0002F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 3)) {
|
|
||||||
return 0.0003F;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 1)) {
|
|
||||||
return 0.0111F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 2) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.021F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 2) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 0)) {
|
|
||||||
return 0.012F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 2)) {
|
|
||||||
return 0.0012F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 2) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 1)) {
|
|
||||||
return 0.0021F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((item.getSubCompound("tags").getBoolean("emerald") == false) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("diamond") == 1) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("redstone") == 0) &&
|
|
||||||
(item.getSubCompound("tags").getInteger("lapis") == 2)) {
|
|
||||||
return 0.0102F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.getSubCompound("tags").getBoolean("hot") == true) {
|
|
||||||
return 1.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.getSubCompound("tags").getBoolean("hot") == false) {
|
|
||||||
if (item.getSubCompound("tags").getInteger("modifiers") == 0) {
|
|
||||||
return 0.0F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0.0F;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isHidden()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreated(ItemStack item, World worldIn, EntityPlayer playerIn) {
|
|
||||||
|
|
||||||
if (!item.hasTagCompound()) {
|
|
||||||
item.setTagCompound(new NBTTagCompound());
|
|
||||||
NBTTagCompound tags = new NBTTagCompound();
|
|
||||||
|
|
||||||
item.getTagCompound().setTag("tags", tags);
|
|
||||||
|
|
||||||
item.getSubCompound("tags").setBoolean("hot", false);
|
|
||||||
|
|
||||||
item.getSubCompound("tags").setBoolean("emerald", false);
|
|
||||||
item.getSubCompound("tags").setInteger("diamond", 0);
|
|
||||||
item.getSubCompound("tags").setInteger("redstone", 0);
|
|
||||||
item.getSubCompound("tags").setInteger("lapis", 0);
|
|
||||||
|
|
||||||
item.getSubCompound("tags").setInteger("modifiers", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate(ItemStack item, World world, Entity player, int itemSlot, boolean isSelected) {
|
|
||||||
if (!item.hasTagCompound()) {
|
|
||||||
item.setTagCompound(new NBTTagCompound());
|
|
||||||
NBTTagCompound tags = new NBTTagCompound();
|
|
||||||
|
|
||||||
item.getTagCompound().setTag("tags", tags);
|
|
||||||
|
|
||||||
item.getSubCompound("tags").setBoolean("hot", false);
|
|
||||||
|
|
||||||
item.getSubCompound("tags").setBoolean("emerald", false);
|
|
||||||
item.getSubCompound("tags").setInteger("diamond", 0);
|
|
||||||
item.getSubCompound("tags").setInteger("redstone", 0);
|
|
||||||
item.getSubCompound("tags").setInteger("lapis", 0);
|
|
||||||
|
|
||||||
item.getSubCompound("tags").setInteger("modifiers", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void addInformation(ItemStack item, EntityPlayer player, List<String> tooltip, boolean advanced)
|
|
||||||
{
|
|
||||||
if(player.getEntityWorld().isRemote) {
|
|
||||||
tooltip.add(ChatFormatting.GRAY + "Upgrades");
|
|
||||||
if (item.getSubCompound("tags").getBoolean("emerald") == true) {
|
|
||||||
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
|
|
||||||
}
|
|
||||||
if (item.getSubCompound("tags").getInteger("diamond") > 0) {
|
|
||||||
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + item.getSubCompound("tags").getInteger("diamond"));
|
|
||||||
}
|
|
||||||
if (item.getSubCompound("tags").getInteger("redstone") > 0) {
|
|
||||||
tooltip.add(ChatFormatting.RED + "Redstone Level: " + item.getSubCompound("tags").getInteger("redstone"));
|
|
||||||
}
|
|
||||||
if (item.getSubCompound("tags").getInteger("lapis") > 0) {
|
|
||||||
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + item.getSubCompound("tags").getInteger("lapis"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRepairable()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemEnchantability(ItemStack stack)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package nmd.primal.forgecraft.util;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mminaie on 3/29/17.
|
||||||
|
*/
|
||||||
|
public interface ToolMaterials {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"modid": "forgecraft",
|
"modid": "forgecraft",
|
||||||
"name": "Kitsu's Forgecraft",
|
"name": "Kitsu's Forgecraft",
|
||||||
"description": "Forged with sweat and blood",
|
"description": "Forged with sweat and blood",
|
||||||
"version": "1.2.03",
|
"version": "1.2.05",
|
||||||
"mcversion": "1.11.2",
|
"mcversion": "1.11.2",
|
||||||
"url": "",
|
"url": "",
|
||||||
"updateUrl": "",
|
"updateUrl": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user