mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 06:42:56 +00:00
Cleanup Tools Module code (#5578)
* Make most mekanism tools extend the vanilla tool class * Move things around slightly * ATs and work on making the paxel's behaviour be identical to the axe, pickaxe, or shovel it represents * Keep track of normal tools via the Paxel * Set the Material's Repair Stack * Cleanup material repair stack registry * Small spacing changes * Replace ToolsItems with ToolsItem * Cleanup adding smelting recipes * Move the various materials into an enum * Ensure the Materials doesn't read the config values before the config is loaded if somewhere it is referenced ends up being called * Minor cleanup/add some comments * Show repair recipes in JEI, and fix it so that you can smelt any damage into a nugget like vanilla * Minor code cleanup to entity equipment spawning * Make sure the paxel canHarvestBlock uses the correct mining level * Switch back to if statements for setting entity equipment * Remove unneeded code that gets handled by ForgeHooks anyways * Make sure to refresh the Item references
This commit is contained in:
1 parent
0f5ef4e11e
commit
034340eed1
17 files changed
+479
-887
No files matched your search
@@ -3,94 +3,14 @@ package mekanism.tools.client;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.tools.common.MekanismTools;
|
||||
import mekanism.tools.common.ToolsCommonProxy;
|
||||
import mekanism.tools.common.ToolsItems;
|
||||
import net.minecraft.item.Item;
|
||||
import mekanism.tools.common.ToolsItem;
|
||||
|
||||
public class ToolsClientProxy extends ToolsCommonProxy {
|
||||
|
||||
@Override
|
||||
public void registerItemRenders() {
|
||||
//Vanilla Material Paxels
|
||||
registerItemRender(ToolsItems.WoodPaxel);
|
||||
registerItemRender(ToolsItems.StonePaxel);
|
||||
registerItemRender(ToolsItems.IronPaxel);
|
||||
registerItemRender(ToolsItems.DiamondPaxel);
|
||||
registerItemRender(ToolsItems.GoldPaxel);
|
||||
|
||||
//Glowstone Items
|
||||
registerItemRender(ToolsItems.GlowstonePaxel);
|
||||
registerItemRender(ToolsItems.GlowstonePickaxe);
|
||||
registerItemRender(ToolsItems.GlowstoneAxe);
|
||||
registerItemRender(ToolsItems.GlowstoneShovel);
|
||||
registerItemRender(ToolsItems.GlowstoneHoe);
|
||||
registerItemRender(ToolsItems.GlowstoneSword);
|
||||
registerItemRender(ToolsItems.GlowstoneHelmet);
|
||||
registerItemRender(ToolsItems.GlowstoneChestplate);
|
||||
registerItemRender(ToolsItems.GlowstoneLeggings);
|
||||
registerItemRender(ToolsItems.GlowstoneBoots);
|
||||
|
||||
//Bronze Items
|
||||
registerItemRender(ToolsItems.BronzePaxel);
|
||||
registerItemRender(ToolsItems.BronzePickaxe);
|
||||
registerItemRender(ToolsItems.BronzeAxe);
|
||||
registerItemRender(ToolsItems.BronzeShovel);
|
||||
registerItemRender(ToolsItems.BronzeHoe);
|
||||
registerItemRender(ToolsItems.BronzeSword);
|
||||
registerItemRender(ToolsItems.BronzeHelmet);
|
||||
registerItemRender(ToolsItems.BronzeChestplate);
|
||||
registerItemRender(ToolsItems.BronzeLeggings);
|
||||
registerItemRender(ToolsItems.BronzeBoots);
|
||||
|
||||
//Osmium Items
|
||||
registerItemRender(ToolsItems.OsmiumPaxel);
|
||||
registerItemRender(ToolsItems.OsmiumPickaxe);
|
||||
registerItemRender(ToolsItems.OsmiumAxe);
|
||||
registerItemRender(ToolsItems.OsmiumShovel);
|
||||
registerItemRender(ToolsItems.OsmiumHoe);
|
||||
registerItemRender(ToolsItems.OsmiumSword);
|
||||
registerItemRender(ToolsItems.OsmiumHelmet);
|
||||
registerItemRender(ToolsItems.OsmiumChestplate);
|
||||
registerItemRender(ToolsItems.OsmiumLeggings);
|
||||
registerItemRender(ToolsItems.OsmiumBoots);
|
||||
|
||||
//Obsidian Items
|
||||
registerItemRender(ToolsItems.ObsidianPaxel);
|
||||
registerItemRender(ToolsItems.ObsidianPickaxe);
|
||||
registerItemRender(ToolsItems.ObsidianAxe);
|
||||
registerItemRender(ToolsItems.ObsidianShovel);
|
||||
registerItemRender(ToolsItems.ObsidianHoe);
|
||||
registerItemRender(ToolsItems.ObsidianSword);
|
||||
registerItemRender(ToolsItems.ObsidianHelmet);
|
||||
registerItemRender(ToolsItems.ObsidianChestplate);
|
||||
registerItemRender(ToolsItems.ObsidianLeggings);
|
||||
registerItemRender(ToolsItems.ObsidianBoots);
|
||||
|
||||
//Lazuli Items
|
||||
registerItemRender(ToolsItems.LazuliPaxel);
|
||||
registerItemRender(ToolsItems.LazuliPickaxe);
|
||||
registerItemRender(ToolsItems.LazuliAxe);
|
||||
registerItemRender(ToolsItems.LazuliShovel);
|
||||
registerItemRender(ToolsItems.LazuliHoe);
|
||||
registerItemRender(ToolsItems.LazuliSword);
|
||||
registerItemRender(ToolsItems.LazuliHelmet);
|
||||
registerItemRender(ToolsItems.LazuliChestplate);
|
||||
registerItemRender(ToolsItems.LazuliLeggings);
|
||||
registerItemRender(ToolsItems.LazuliBoots);
|
||||
|
||||
//Steel Items
|
||||
registerItemRender(ToolsItems.SteelPaxel);
|
||||
registerItemRender(ToolsItems.SteelPickaxe);
|
||||
registerItemRender(ToolsItems.SteelAxe);
|
||||
registerItemRender(ToolsItems.SteelShovel);
|
||||
registerItemRender(ToolsItems.SteelHoe);
|
||||
registerItemRender(ToolsItems.SteelSword);
|
||||
registerItemRender(ToolsItems.SteelHelmet);
|
||||
registerItemRender(ToolsItems.SteelChestplate);
|
||||
registerItemRender(ToolsItems.SteelLeggings);
|
||||
registerItemRender(ToolsItems.SteelBoots);
|
||||
}
|
||||
|
||||
public void registerItemRender(Item item) {
|
||||
MekanismRenderer.registerItemRender(MekanismTools.MODID, item);
|
||||
for (ToolsItem toolsItem : ToolsItem.values()) {
|
||||
MekanismRenderer.registerItemRender(MekanismTools.MODID, toolsItem.getItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package mekanism.tools.client.jei;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.Collections;
|
||||
import mekanism.tools.common.ToolsItem;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.recipe.IVanillaRecipeFactory;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@JEIPlugin
|
||||
public class ToolsJEI implements IModPlugin {
|
||||
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
IVanillaRecipeFactory factory = registry.getJeiHelpers().getVanillaRecipeFactory();
|
||||
//Add the Anvil repair recipes to JEI for all the different tools and armors in Mekanism Tools
|
||||
for (ToolsItem toolsItem : ToolsItem.values()) {
|
||||
//Based off of how JEI adds for Vanilla items: https://github.com/mezz/JustEnoughItems/blob/1.12/src/main/java/mezz/jei/plugins/vanilla/anvil/AnvilRecipeMaker.java#L180
|
||||
ItemStack damaged2 = toolsItem.getItemStack();
|
||||
damaged2.setItemDamage(damaged2.getMaxDamage() * 3 / 4);
|
||||
ItemStack damaged3 = toolsItem.getItemStack();
|
||||
damaged3.setItemDamage(damaged3.getMaxDamage() * 2 / 4);
|
||||
|
||||
//Two damaged items combine to undamaged
|
||||
registry.addRecipes(ImmutableList.of(factory.createAnvilRecipe(damaged2, Collections.singletonList(damaged2), Collections.singletonList(damaged3))), VanillaRecipeCategoryUid.ANVIL);
|
||||
|
||||
ItemStack repairMaterial = toolsItem.getRepairStack();
|
||||
//Damaged item + the repair material
|
||||
if (!repairMaterial.isEmpty()) {
|
||||
//While this is damaged1 it is down here as we don't need to bother creating the reference if we don't have a repair material
|
||||
ItemStack damaged1 = toolsItem.getItemStack();
|
||||
damaged1.setItemDamage(damaged1.getMaxDamage());
|
||||
registry.addRecipes(ImmutableList.of(factory.createAnvilRecipe(damaged1, Collections.singletonList(repairMaterial), Collections.singletonList(damaged2))), VanillaRecipeCategoryUid.ANVIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package mekanism.tools.common;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IHasRepairType {
|
||||
|
||||
/**
|
||||
* Gets the stack that can be used to repair this item. This is used to simplify getting repair type dynamically for adding to JEI's Anvil recipe category.
|
||||
*/
|
||||
ItemStack getRepairStack();
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package mekanism.tools.common;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
import mekanism.common.config.ToolsConfig;
|
||||
import mekanism.common.config.ToolsConfig.ArmorBalance;
|
||||
import mekanism.common.config.ToolsConfig.ToolBalance;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.Item.ToolMaterial;
|
||||
import net.minecraft.item.ItemArmor.ArmorMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
|
||||
public enum Materials {
|
||||
OBSIDIAN("OBSIDIAN", cfg -> cfg.toolOBSIDIAN, cfg -> cfg.toolOBSIDIAN2, cfg -> cfg.armorOBSIDIAN, () -> new ItemStack(MekanismItems.Ingot)),
|
||||
LAZULI("LAZULI", cfg -> cfg.toolLAZULI, cfg -> cfg.toolLAZULI2, cfg -> cfg.armorLAZULI, () -> new ItemStack(Items.DYE, 1, 4), SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND),
|
||||
OSMIUM("OSMIUM", cfg -> cfg.toolOSMIUM, cfg -> cfg.toolOSMIUM2, cfg -> cfg.armorOSMIUM, () -> new ItemStack(MekanismItems.Ingot, 1, 1)),
|
||||
BRONZE("BRONZE", cfg -> cfg.toolBRONZE, cfg -> cfg.toolBRONZE2, cfg -> cfg.armorBRONZE, () -> new ItemStack(MekanismItems.Ingot, 1, 2)),
|
||||
GLOWSTONE("GLOWSTONE", tools -> tools.toolGLOWSTONE, tools -> tools.toolGLOWSTONE2, cfg -> cfg.armorGLOWSTONE, () -> new ItemStack(MekanismItems.Ingot, 1, 3)),
|
||||
STEEL("STEEL", cfg -> cfg.toolSTEEL, cfg -> cfg.toolSTEEL2, cfg -> cfg.armorSTEEL, () -> new ItemStack(MekanismItems.Ingot, 1, 4));
|
||||
|
||||
private final Function<ToolsConfig, ToolBalance> materialFunction;
|
||||
private final Function<ToolsConfig, ToolBalance> paxelMaterialFunction;
|
||||
private final Function<ToolsConfig, ArmorBalance> armorMaterialFunction;
|
||||
private final Supplier<ItemStack> repairStackSupplier;
|
||||
private final SoundEvent equipSound;
|
||||
private final String materialName;
|
||||
private ToolMaterial material;
|
||||
private ToolMaterial paxelMaterial;
|
||||
private ArmorMaterial armorMaterial;
|
||||
private boolean initialized;
|
||||
private float axeDamage;
|
||||
private float axeSpeed;
|
||||
|
||||
Materials(@Nonnull String name, @Nonnull Function<ToolsConfig, ToolBalance> material, @Nonnull Function<ToolsConfig, ToolBalance> paxelMaterial,
|
||||
@Nonnull Function<ToolsConfig, ArmorBalance> armorMaterial, @Nonnull Supplier<ItemStack> repairStack) {
|
||||
this(name, material, paxelMaterial, armorMaterial, repairStack, SoundEvents.ITEM_ARMOR_EQUIP_IRON);
|
||||
}
|
||||
|
||||
Materials(@Nonnull String name, @Nonnull Function<ToolsConfig, ToolBalance> material, @Nonnull Function<ToolsConfig, ToolBalance> paxelMaterial,
|
||||
@Nonnull Function<ToolsConfig, ArmorBalance> armorMaterial, @Nonnull Supplier<ItemStack> repairStack, @Nonnull SoundEvent equipSound) {
|
||||
this.materialName = name;
|
||||
this.materialFunction = material;
|
||||
this.paxelMaterialFunction = paxelMaterial;
|
||||
this.armorMaterialFunction = armorMaterial;
|
||||
this.repairStackSupplier = repairStack;
|
||||
this.equipSound = equipSound;
|
||||
}
|
||||
|
||||
private static ToolMaterial getToolMaterial(@Nonnull String enumName, @Nonnull ToolBalance config) {
|
||||
return EnumHelper.addToolMaterial(enumName, config.harvestLevel.val(), config.maxUses.val(), config.efficiency.val(), config.damage.val(), config.enchantability.val());
|
||||
}
|
||||
|
||||
private static ArmorMaterial getArmorMaterial(@Nonnull String enumName, @Nonnull ArmorBalance config, @Nonnull SoundEvent equipSound) {
|
||||
return EnumHelper.addArmorMaterial(enumName, "TODO", config.durability.val(), new int[]{
|
||||
config.feetProtection.val(), config.legsProtection.val(), config.chestProtection.val(), config.headProtection.val(),
|
||||
}, config.enchantability.val(), equipSound, config.toughness.val());
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
for (Materials material : values()) {
|
||||
material.init();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
ToolBalance materialBalance = materialFunction.apply(MekanismConfig.current().tools);
|
||||
ToolBalance paxelMaterialBalance = paxelMaterialFunction.apply(MekanismConfig.current().tools);
|
||||
ArmorBalance armorBalance = armorMaterialFunction.apply(MekanismConfig.current().tools);
|
||||
|
||||
this.material = getToolMaterial(materialName, materialBalance);
|
||||
this.paxelMaterial = getToolMaterial(materialName + "2", paxelMaterialBalance);
|
||||
this.armorMaterial = getArmorMaterial(materialName, armorBalance, equipSound);
|
||||
this.axeDamage = materialBalance.axeAttackDamage.val();
|
||||
this.axeSpeed = materialBalance.axeAttackSpeed.val();
|
||||
//Set repair stack of the material
|
||||
ItemStack repairStack = repairStackSupplier.get();
|
||||
material.setRepairItem(repairStack);
|
||||
paxelMaterial.setRepairItem(repairStack);
|
||||
armorMaterial.setRepairItem(repairStack);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
//The below getters should **NOT** be used before the Materials are initialized. Storing the Materials object for reference
|
||||
// before any of the getters is fine as the Fucntions/Suppliers mean nothing is prematurely initialized (before the config gets red for example)
|
||||
public ToolMaterial getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public ToolMaterial getPaxelMaterial() {
|
||||
return paxelMaterial;
|
||||
}
|
||||
|
||||
public ArmorMaterial getArmorMaterial() {
|
||||
return armorMaterial;
|
||||
}
|
||||
|
||||
public float getAxeDamage() {
|
||||
return axeDamage;
|
||||
}
|
||||
|
||||
public float getAxeSpeed() {
|
||||
return axeSpeed;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,23 @@
|
||||
package mekanism.tools.common;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.Version;
|
||||
import mekanism.common.base.IModule;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
import mekanism.common.config.ToolsConfig;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Item.ToolMaterial;
|
||||
import net.minecraft.item.ItemArmor.ArmorMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
|
||||
@@ -33,6 +26,7 @@ import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.Mod.Instance;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLModIdMappingEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
@@ -54,36 +48,9 @@ public class MekanismTools implements IModule {
|
||||
*/
|
||||
public static Version versionNumber = new Version(999, 999, 999);
|
||||
|
||||
//Enums: Tools
|
||||
public static ToolMaterial toolOBSIDIAN;
|
||||
public static ToolMaterial toolOBSIDIAN2;
|
||||
public static ToolMaterial toolLAZULI;
|
||||
public static ToolMaterial toolLAZULI2;
|
||||
public static ToolMaterial toolOSMIUM;
|
||||
public static ToolMaterial toolOSMIUM2;
|
||||
public static ToolMaterial toolBRONZE;
|
||||
public static ToolMaterial toolBRONZE2;
|
||||
public static ToolMaterial toolGLOWSTONE;
|
||||
public static ToolMaterial toolGLOWSTONE2;
|
||||
public static ToolMaterial toolSTEEL;
|
||||
public static ToolMaterial toolSTEEL2;
|
||||
|
||||
//Enums: Armor
|
||||
public static ArmorMaterial armorOBSIDIAN;
|
||||
public static ArmorMaterial armorLAZULI;
|
||||
public static ArmorMaterial armorOSMIUM;
|
||||
public static ArmorMaterial armorBRONZE;
|
||||
public static ArmorMaterial armorGLOWSTONE;
|
||||
public static ArmorMaterial armorSTEEL;
|
||||
|
||||
//Can't use EnumMap as the custom ToolMaterial's do not exist yet
|
||||
public static Map<ToolMaterial, Float> AXE_DAMAGE = new HashMap<>();
|
||||
public static Map<ToolMaterial, Float> AXE_SPEED = new HashMap<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||
// Register items and itemBlocks
|
||||
ToolsItems.registerItems(event.getRegistry());
|
||||
ToolsItem.registerItems(event.getRegistry());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -96,7 +63,7 @@ public class MekanismTools implements IModule {
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
//Load the config
|
||||
proxy.loadConfiguration();
|
||||
addItems();
|
||||
Materials.load();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -111,120 +78,29 @@ public class MekanismTools implements IModule {
|
||||
Mekanism.logger.info("Loaded 'Mekanism: Tools' module.");
|
||||
}
|
||||
|
||||
public void addItems() {
|
||||
//Tools
|
||||
toolOBSIDIAN = getToolMaterial("OBSIDIAN", MekanismConfig.current().tools.toolOBSIDIAN);
|
||||
toolOBSIDIAN2 = getToolMaterial("OBSIDIAN2", MekanismConfig.current().tools.toolOBSIDIAN2);
|
||||
toolLAZULI = getToolMaterial("LAZULI", MekanismConfig.current().tools.toolLAZULI);
|
||||
toolLAZULI2 = getToolMaterial("LAZULI2", MekanismConfig.current().tools.toolLAZULI2);
|
||||
toolOSMIUM = getToolMaterial("OSMIUM", MekanismConfig.current().tools.toolOSMIUM);
|
||||
toolOSMIUM2 = getToolMaterial("OSMIUM2", MekanismConfig.current().tools.toolOSMIUM2);
|
||||
toolBRONZE = getToolMaterial("BRONZE", MekanismConfig.current().tools.toolBRONZE);
|
||||
toolBRONZE2 = getToolMaterial("BRONZE2", MekanismConfig.current().tools.toolBRONZE2);
|
||||
toolGLOWSTONE = getToolMaterial("GLOWSTONE", MekanismConfig.current().tools.toolGLOWSTONE);
|
||||
toolGLOWSTONE2 = getToolMaterial("GLOWSTONE2", MekanismConfig.current().tools.toolGLOWSTONE2);
|
||||
toolSTEEL = getToolMaterial("STEEL", MekanismConfig.current().tools.toolSTEEL);
|
||||
toolSTEEL2 = getToolMaterial("STEEL2", MekanismConfig.current().tools.toolSTEEL2);
|
||||
|
||||
setAxeSpeedDamage(toolOBSIDIAN, MekanismConfig.current().tools.toolOBSIDIAN);
|
||||
setAxeSpeedDamage(toolLAZULI, MekanismConfig.current().tools.toolLAZULI);
|
||||
setAxeSpeedDamage(toolOSMIUM, MekanismConfig.current().tools.toolOSMIUM);
|
||||
setAxeSpeedDamage(toolBRONZE, MekanismConfig.current().tools.toolBRONZE);
|
||||
setAxeSpeedDamage(toolGLOWSTONE, MekanismConfig.current().tools.toolGLOWSTONE);
|
||||
setAxeSpeedDamage(toolSTEEL, MekanismConfig.current().tools.toolSTEEL);
|
||||
|
||||
//Armors
|
||||
armorOBSIDIAN = getArmorMaterial("OBSIDIAN", MekanismConfig.current().tools.armorOBSIDIAN, SoundEvents.ITEM_ARMOR_EQUIP_IRON);
|
||||
armorLAZULI = getArmorMaterial("LAZULI", MekanismConfig.current().tools.armorLAZULI, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND);
|
||||
armorOSMIUM = getArmorMaterial("OSMIUM", MekanismConfig.current().tools.armorOSMIUM, SoundEvents.ITEM_ARMOR_EQUIP_IRON);
|
||||
armorBRONZE = getArmorMaterial("BRONZE", MekanismConfig.current().tools.armorBRONZE, SoundEvents.ITEM_ARMOR_EQUIP_IRON);
|
||||
armorGLOWSTONE = getArmorMaterial("GLOWSTONE", MekanismConfig.current().tools.armorGLOWSTONE, SoundEvents.ITEM_ARMOR_EQUIP_IRON);
|
||||
armorSTEEL = getArmorMaterial("STEEL", MekanismConfig.current().tools.armorSTEEL, SoundEvents.ITEM_ARMOR_EQUIP_IRON);
|
||||
|
||||
ToolsItems.initializeItems();
|
||||
ToolsItems.setHarvestLevels();
|
||||
}
|
||||
|
||||
private void setAxeSpeedDamage(ToolMaterial toolOBSIDIAN, ToolsConfig.ToolBalance toolOBSIDIAN2) {
|
||||
AXE_DAMAGE.put(toolOBSIDIAN, toolOBSIDIAN2.axeAttackDamage.val());
|
||||
AXE_SPEED.put(toolOBSIDIAN, toolOBSIDIAN2.axeAttackSpeed.val());
|
||||
}
|
||||
|
||||
private ToolMaterial getToolMaterial(String enumName, ToolsConfig.ToolBalance toolConfig) {
|
||||
return EnumHelper.addToolMaterial(enumName, toolConfig.harvestLevel.val(), toolConfig.maxUses.val(),
|
||||
toolConfig.efficiency.val(), toolConfig.damage.val(), toolConfig.enchantability.val());
|
||||
}
|
||||
|
||||
private ArmorMaterial getArmorMaterial(String enumName, ToolsConfig.ArmorBalance settings,
|
||||
SoundEvent equipSoundEvent) {
|
||||
return EnumHelper.addArmorMaterial(enumName, "TODO", settings.durability.val(), new int[]{
|
||||
settings.feetProtection.val(),
|
||||
settings.legsProtection.val(),
|
||||
settings.chestProtection.val(),
|
||||
settings.headProtection.val(),
|
||||
}, settings.enchantability.val(), equipSoundEvent, settings.toughness.val());
|
||||
@EventHandler
|
||||
public void modRemapping(FMLModIdMappingEvent event) {
|
||||
ToolsItem.remapItems();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
|
||||
//Furnace Recipes
|
||||
GameRegistry.addSmelting(ToolsItems.IronPaxel, new ItemStack(Items.IRON_NUGGET), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GoldPaxel, new ItemStack(Items.GOLD_NUGGET), 0.1F);
|
||||
addSmeltingRecipe(ToolsItem.IRON_PAXEL, new ItemStack(Items.IRON_NUGGET));
|
||||
addSmeltingRecipe(ToolsItem.GOLD_PAXEL, new ItemStack(Items.GOLD_NUGGET));
|
||||
addSmeltingRecipe(ToolsItem.OBSIDIAN_SET, new ItemStack(MekanismItems.Nugget));
|
||||
addSmeltingRecipe(ToolsItem.OSMIUM_SET, new ItemStack(MekanismItems.Nugget, 1, 1));
|
||||
addSmeltingRecipe(ToolsItem.BRONZE_SET, new ItemStack(MekanismItems.Nugget, 1, 2));
|
||||
addSmeltingRecipe(ToolsItem.GLOWSTONE_SET, new ItemStack(MekanismItems.Nugget, 1, 3));
|
||||
addSmeltingRecipe(ToolsItem.STEEL_SET, new ItemStack(MekanismItems.Nugget, 1, 4));
|
||||
}
|
||||
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstonePaxel, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstonePickaxe, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstoneAxe, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstoneShovel, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstoneHoe, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstoneSword, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstoneHelmet, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstoneChestplate, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstoneLeggings, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.GlowstoneBoots, new ItemStack(MekanismItems.Nugget, 1, 3), 0.1F);
|
||||
private static void addSmeltingRecipe(List<ToolsItem> itemSet, ItemStack nugget) {
|
||||
itemSet.forEach(toolsItem -> addSmeltingRecipe(toolsItem, nugget));
|
||||
}
|
||||
|
||||
GameRegistry.addSmelting(ToolsItems.BronzePaxel, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.BronzePickaxe, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.BronzeAxe, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.BronzeShovel, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.BronzeHoe, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.BronzeSword, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.BronzeHelmet, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.BronzeChestplate, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.BronzeLeggings, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.BronzeBoots, new ItemStack(MekanismItems.Nugget, 1, 2), 0.1F);
|
||||
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumPaxel, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumPickaxe, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumAxe, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumShovel, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumHoe, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumSword, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumHelmet, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumChestplate, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumLeggings, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.OsmiumBoots, new ItemStack(MekanismItems.Nugget, 1, 1), 0.1F);
|
||||
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianPaxel, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianPickaxe, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianAxe, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianShovel, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianHoe, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianSword, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianHelmet, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianChestplate, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianLeggings, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.ObsidianBoots, new ItemStack(MekanismItems.Nugget, 1, 0), 0.1F);
|
||||
|
||||
GameRegistry.addSmelting(ToolsItems.SteelPaxel, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.SteelPickaxe, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.SteelAxe, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.SteelShovel, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.SteelHoe, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.SteelSword, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.SteelHelmet, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.SteelChestplate, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.SteelLeggings, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
GameRegistry.addSmelting(ToolsItems.SteelBoots, new ItemStack(MekanismItems.Nugget, 1, 4), 0.1F);
|
||||
private static void addSmeltingRecipe(ToolsItem toolsItem, ItemStack nugget) {
|
||||
GameRegistry.addSmelting(toolsItem.getItemStackAnyDamage(), nugget, 0.1F);
|
||||
}
|
||||
|
||||
private void setStackIfEmpty(EntityLivingBase entity, EntityEquipmentSlot slot, ItemStack item) {
|
||||
@@ -233,50 +109,48 @@ public class MekanismTools implements IModule {
|
||||
}
|
||||
}
|
||||
|
||||
private void setEntityArmorWithChance(Random random, EntityLivingBase entity, Item sword, Item helmet, Item chestplate, Item leggings, Item boots) {
|
||||
private void setEntityArmorWithChance(Random random, EntityLivingBase entity, ToolsItem sword, ToolsItem helmet, ToolsItem chestplate, ToolsItem leggings, ToolsItem boots) {
|
||||
if (entity instanceof EntityZombie && random.nextInt(100) < 50) {
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.MAINHAND, new ItemStack(sword));
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.MAINHAND, sword.getItemStack());
|
||||
}
|
||||
if (random.nextInt(100) < 50) {
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.HEAD, new ItemStack(helmet));
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.HEAD, helmet.getItemStack());
|
||||
}
|
||||
if (random.nextInt(100) < 50) {
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.CHEST, new ItemStack(chestplate));
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.CHEST, chestplate.getItemStack());
|
||||
}
|
||||
if (random.nextInt(100) < 50) {
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.LEGS, new ItemStack(leggings));
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.LEGS, leggings.getItemStack());
|
||||
}
|
||||
if (random.nextInt(100) < 50) {
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.FEET, new ItemStack(boots));
|
||||
setStackIfEmpty(entity, EntityEquipmentSlot.FEET, boots.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingSpecialSpawn(LivingSpawnEvent.SpecialSpawn event) {
|
||||
Random random = event.getWorld().rand;
|
||||
double chance = random.nextDouble();
|
||||
|
||||
if (chance < MekanismConfig.current().tools.armorSpawnRate.val()) {
|
||||
int armorType = random.nextInt(4);
|
||||
|
||||
EntityLivingBase entity = event.getEntityLiving();
|
||||
|
||||
if (entity instanceof EntityZombie || entity instanceof EntitySkeleton) {
|
||||
EntityLivingBase entity = event.getEntityLiving();
|
||||
if (entity instanceof EntityZombie || entity instanceof EntitySkeleton) {
|
||||
//Don't bother calculating random numbers unless the instanceof checks pass
|
||||
Random random = event.getWorld().rand;
|
||||
double chance = random.nextDouble();
|
||||
if (chance < MekanismConfig.current().tools.armorSpawnRate.val()) {
|
||||
int armorType = random.nextInt(4);
|
||||
if (armorType == 0) {
|
||||
setEntityArmorWithChance(random, entity, ToolsItems.GlowstoneSword, ToolsItems.GlowstoneHelmet, ToolsItems.GlowstoneChestplate,
|
||||
ToolsItems.GlowstoneLeggings, ToolsItems.GlowstoneBoots);
|
||||
setEntityArmorWithChance(random, entity, ToolsItem.GLOWSTONE_SWORD, ToolsItem.GLOWSTONE_HELMET, ToolsItem.GLOWSTONE_CHESTPLATE,
|
||||
ToolsItem.GLOWSTONE_LEGGINGS, ToolsItem.GLOWSTONE_BOOTS);
|
||||
} else if (armorType == 1) {
|
||||
setEntityArmorWithChance(random, entity, ToolsItems.LazuliSword, ToolsItems.LazuliHelmet, ToolsItems.LazuliChestplate,
|
||||
ToolsItems.LazuliLeggings, ToolsItems.LazuliBoots);
|
||||
setEntityArmorWithChance(random, entity, ToolsItem.LAPIS_LAZULI_SWORD, ToolsItem.LAPIS_LAZULI_HELMET, ToolsItem.LAPIS_LAZULI_CHESTPLATE,
|
||||
ToolsItem.LAPIS_LAZULI_LEGGINGS, ToolsItem.LAPIS_LAZULI_BOOTS);
|
||||
} else if (armorType == 2) {
|
||||
setEntityArmorWithChance(random, entity, ToolsItems.OsmiumSword, ToolsItems.OsmiumHelmet, ToolsItems.OsmiumChestplate,
|
||||
ToolsItems.OsmiumLeggings, ToolsItems.OsmiumBoots);
|
||||
setEntityArmorWithChance(random, entity, ToolsItem.OBSIDIAN_SWORD, ToolsItem.OBSIDIAN_HELMET, ToolsItem.OBSIDIAN_CHESTPLATE,
|
||||
ToolsItem.OBSIDIAN_LEGGINGS, ToolsItem.OBSIDIAN_BOOTS);
|
||||
} else if (armorType == 3) {
|
||||
setEntityArmorWithChance(random, entity, ToolsItems.SteelSword, ToolsItems.SteelHelmet, ToolsItems.SteelChestplate,
|
||||
ToolsItems.SteelLeggings, ToolsItems.SteelBoots);
|
||||
setEntityArmorWithChance(random, entity, ToolsItem.STEEL_SWORD, ToolsItem.STEEL_HELMET, ToolsItem.STEEL_CHESTPLATE,
|
||||
ToolsItem.STEEL_LEGGINGS, ToolsItem.STEEL_BOOTS);
|
||||
} else if (armorType == 4) {
|
||||
setEntityArmorWithChance(random, entity, ToolsItems.BronzeSword, ToolsItems.BronzeHelmet, ToolsItems.BronzeChestplate,
|
||||
ToolsItems.BronzeLeggings, ToolsItems.BronzeBoots);
|
||||
setEntityArmorWithChance(random, entity, ToolsItem.BRONZE_SWORD, ToolsItem.BRONZE_HELMET, ToolsItem.BRONZE_CHESTPLATE,
|
||||
ToolsItem.BRONZE_LEGGINGS, ToolsItem.BRONZE_BOOTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package mekanism.tools.common;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
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.ToolMaterial;
|
||||
|
||||
public class ToolUtils {
|
||||
|
||||
public static boolean canPickaxeHarvest(@Nonnull IBlockState state, ToolMaterial toolMaterial) {
|
||||
Block block = state.getBlock();
|
||||
if (block == Blocks.OBSIDIAN) {
|
||||
return toolMaterial.getHarvestLevel() == 3;
|
||||
}
|
||||
if (block == Blocks.DIAMOND_BLOCK || block == Blocks.DIAMOND_ORE) {
|
||||
return toolMaterial.getHarvestLevel() >= 2;
|
||||
}
|
||||
if (block == Blocks.GOLD_BLOCK || block == Blocks.GOLD_ORE) {
|
||||
return toolMaterial.getHarvestLevel() >= 2;
|
||||
}
|
||||
if (block == Blocks.IRON_BLOCK || block == Blocks.IRON_ORE) {
|
||||
return toolMaterial.getHarvestLevel() >= 1;
|
||||
}
|
||||
if (block == Blocks.LAPIS_BLOCK || block == Blocks.LAPIS_ORE) {
|
||||
return toolMaterial.getHarvestLevel() >= 1;
|
||||
}
|
||||
if (block == Blocks.REDSTONE_ORE || block == Blocks.LIT_REDSTONE_ORE) {
|
||||
return toolMaterial.getHarvestLevel() >= 2;
|
||||
}
|
||||
if (block == Blocks.ANVIL) {
|
||||
return toolMaterial.getHarvestLevel() >= 0;
|
||||
}
|
||||
if (state.getMaterial() == Material.ROCK) {
|
||||
return true;
|
||||
}
|
||||
return state.getMaterial() == Material.IRON;
|
||||
}
|
||||
|
||||
public static boolean canShovelHarvest(Block block) {
|
||||
return block == Blocks.SNOW_LAYER || block == Blocks.SNOW;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package mekanism.tools.common;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.tools.item.ItemMekanismArmor;
|
||||
import mekanism.tools.item.ItemMekanismAxe;
|
||||
import mekanism.tools.item.ItemMekanismHoe;
|
||||
import mekanism.tools.item.ItemMekanismPaxel;
|
||||
import mekanism.tools.item.ItemMekanismPickaxe;
|
||||
import mekanism.tools.item.ItemMekanismShovel;
|
||||
import mekanism.tools.item.ItemMekanismSword;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Item.ToolMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
public enum ToolsItem {
|
||||
WOOD_PAXEL("WoodPaxel", new ItemMekanismPaxel(ToolMaterial.WOOD)),
|
||||
STONE_PAXEL("StonePaxel", new ItemMekanismPaxel(ToolMaterial.STONE)),
|
||||
IRON_PAXEL("IronPaxel", new ItemMekanismPaxel(ToolMaterial.IRON)),
|
||||
DIAMOND_PAXEL("DiamondPaxel", new ItemMekanismPaxel(ToolMaterial.DIAMOND)),
|
||||
GOLD_PAXEL("GoldPaxel", new ItemMekanismPaxel(ToolMaterial.GOLD)),
|
||||
|
||||
GLOWSTONE_PICKAXE("GlowstonePickaxe", new ItemMekanismPickaxe(Materials.GLOWSTONE)),
|
||||
GLOWSTONE_AXE("GlowstoneAxe", new ItemMekanismAxe(Materials.GLOWSTONE)),
|
||||
GLOWSTONE_SHOVEL("GlowstoneShovel", new ItemMekanismShovel(Materials.GLOWSTONE)),
|
||||
GLOWSTONE_HOE("GlowstoneHoe", new ItemMekanismHoe(Materials.GLOWSTONE)),
|
||||
GLOWSTONE_SWORD("GlowstoneSword", new ItemMekanismSword(Materials.GLOWSTONE)),
|
||||
GLOWSTONE_PAXEL("GlowstonePaxel", new ItemMekanismPaxel(Materials.GLOWSTONE)),
|
||||
GLOWSTONE_HELMET("GlowstoneHelmet", new ItemMekanismArmor(Materials.GLOWSTONE, 0, EntityEquipmentSlot.HEAD)),
|
||||
GLOWSTONE_CHESTPLATE("GlowstoneChestplate", new ItemMekanismArmor(Materials.GLOWSTONE, 1, EntityEquipmentSlot.CHEST)),
|
||||
GLOWSTONE_LEGGINGS("GlowstoneLeggings", new ItemMekanismArmor(Materials.GLOWSTONE, 2, EntityEquipmentSlot.LEGS)),
|
||||
GLOWSTONE_BOOTS("GlowstoneBoots", new ItemMekanismArmor(Materials.GLOWSTONE, 3, EntityEquipmentSlot.FEET)),
|
||||
|
||||
BRONZE_PICKAXE("BronzePickaxe", new ItemMekanismPickaxe(Materials.BRONZE)),
|
||||
BRONZE_AXE("BronzeAxe", new ItemMekanismAxe(Materials.BRONZE)),
|
||||
BRONZE_SHOVEL("BronzeShovel", new ItemMekanismShovel(Materials.BRONZE)),
|
||||
BRONZE_HOE("BronzeHoe", new ItemMekanismHoe(Materials.BRONZE)),
|
||||
BRONZE_SWORD("BronzeSword", new ItemMekanismSword(Materials.BRONZE)),
|
||||
BRONZE_PAXEL("BronzePaxel", new ItemMekanismPaxel(Materials.BRONZE)),
|
||||
BRONZE_HELMET("BronzeHelmet", new ItemMekanismArmor(Materials.BRONZE, 0, EntityEquipmentSlot.HEAD)),
|
||||
BRONZE_CHESTPLATE("BronzeChestplate", new ItemMekanismArmor(Materials.BRONZE, 1, EntityEquipmentSlot.CHEST)),
|
||||
BRONZE_LEGGINGS("BronzeLeggings", new ItemMekanismArmor(Materials.BRONZE, 2, EntityEquipmentSlot.LEGS)),
|
||||
BRONZE_BOOTS("BronzeBoots", new ItemMekanismArmor(Materials.BRONZE, 3, EntityEquipmentSlot.FEET)),
|
||||
|
||||
OSMIUM_PICKAXE("OsmiumPickaxe", new ItemMekanismPickaxe(Materials.OSMIUM)),
|
||||
OSMIUM_AXE("OsmiumAxe", new ItemMekanismAxe(Materials.OSMIUM)),
|
||||
OSMIUM_SHOVEL("OsmiumShovel", new ItemMekanismShovel(Materials.OSMIUM)),
|
||||
OSMIUM_HOE("OsmiumHoe", new ItemMekanismHoe(Materials.OSMIUM)),
|
||||
OSMIUM_SWORD("OsmiumSword", new ItemMekanismSword(Materials.OSMIUM)),
|
||||
OSMIUM_PAXEL("OsmiumPaxel", new ItemMekanismPaxel(Materials.OSMIUM)),
|
||||
OSMIUM_HELMET("OsmiumHelmet", new ItemMekanismArmor(Materials.OSMIUM, 0, EntityEquipmentSlot.HEAD)),
|
||||
OSMIUM_CHESTPLATE("OsmiumChestplate", new ItemMekanismArmor(Materials.OSMIUM, 1, EntityEquipmentSlot.CHEST)),
|
||||
OSMIUM_LEGGINGS("OsmiumLeggings", new ItemMekanismArmor(Materials.OSMIUM, 2, EntityEquipmentSlot.LEGS)),
|
||||
OSMIUM_BOOTS("OsmiumBoots", new ItemMekanismArmor(Materials.OSMIUM, 3, EntityEquipmentSlot.FEET)),
|
||||
|
||||
OBSIDIAN_PICKAXE("ObsidianPickaxe", new ItemMekanismPickaxe(Materials.OBSIDIAN)),
|
||||
OBSIDIAN_AXE("ObsidianAxe", new ItemMekanismAxe(Materials.OBSIDIAN)),
|
||||
OBSIDIAN_SHOVEL("ObsidianShovel", new ItemMekanismShovel(Materials.OBSIDIAN)),
|
||||
OBSIDIAN_HOE("ObsidianHoe", new ItemMekanismHoe(Materials.OBSIDIAN)),
|
||||
OBSIDIAN_SWORD("ObsidianSword", new ItemMekanismSword(Materials.OBSIDIAN)),
|
||||
OBSIDIAN_PAXEL("ObsidianPaxel", new ItemMekanismPaxel(Materials.OBSIDIAN)),
|
||||
OBSIDIAN_HELMET("ObsidianHelmet", new ItemMekanismArmor(Materials.OBSIDIAN, 0, EntityEquipmentSlot.HEAD)),
|
||||
OBSIDIAN_CHESTPLATE("ObsidianChestplate", new ItemMekanismArmor(Materials.OBSIDIAN, 1, EntityEquipmentSlot.CHEST)),
|
||||
OBSIDIAN_LEGGINGS("ObsidianLeggings", new ItemMekanismArmor(Materials.OBSIDIAN, 2, EntityEquipmentSlot.LEGS)),
|
||||
OBSIDIAN_BOOTS("ObsidianBoots", new ItemMekanismArmor(Materials.OBSIDIAN, 3, EntityEquipmentSlot.FEET)),
|
||||
|
||||
LAPIS_LAZULI_PICKAXE("LapisLazuliPickaxe", new ItemMekanismPickaxe(Materials.LAZULI)),
|
||||
LAPIS_LAZULI_AXE("LapisLazuliAxe", new ItemMekanismAxe(Materials.LAZULI)),
|
||||
LAPIS_LAZULI_SHOVEL("LapisLazuliShovel", new ItemMekanismShovel(Materials.LAZULI)),
|
||||
LAPIS_LAZULI_HOE("LapisLazuliHoe", new ItemMekanismHoe(Materials.LAZULI)),
|
||||
LAPIS_LAZULI_SWORD("LapisLazuliSword", new ItemMekanismSword(Materials.LAZULI)),
|
||||
LAPIS_LAZULI_PAXEL("LapisLazuliPaxel", new ItemMekanismPaxel(Materials.LAZULI)),
|
||||
LAPIS_LAZULI_HELMET("LapisLazuliHelmet", new ItemMekanismArmor(Materials.LAZULI, 0, EntityEquipmentSlot.HEAD)),
|
||||
LAPIS_LAZULI_CHESTPLATE("LapisLazuliChestplate", new ItemMekanismArmor(Materials.LAZULI, 1, EntityEquipmentSlot.CHEST)),
|
||||
LAPIS_LAZULI_LEGGINGS("LapisLazuliLeggings", new ItemMekanismArmor(Materials.LAZULI, 2, EntityEquipmentSlot.LEGS)),
|
||||
LAPIS_LAZULI_BOOTS("LapisLazuliBoots", new ItemMekanismArmor(Materials.LAZULI, 3, EntityEquipmentSlot.FEET)),
|
||||
|
||||
STEEL_PICKAXE("SteelPickaxe", new ItemMekanismPickaxe(Materials.STEEL)),
|
||||
STEEL_AXE("SteelAxe", new ItemMekanismAxe(Materials.STEEL)),
|
||||
STEEL_SHOVEL("SteelShovel", new ItemMekanismShovel(Materials.STEEL)),
|
||||
STEEL_HOE("SteelHoe", new ItemMekanismHoe(Materials.STEEL)),
|
||||
STEEL_SWORD("SteelSword", new ItemMekanismSword(Materials.STEEL)),
|
||||
STEEL_PAXEL("SteelPaxel", new ItemMekanismPaxel(Materials.STEEL)),
|
||||
STEEL_HELMET("SteelHelmet", new ItemMekanismArmor(Materials.STEEL, 0, EntityEquipmentSlot.HEAD)),
|
||||
STEEL_CHESTPLATE("SteelChestplate", new ItemMekanismArmor(Materials.STEEL, 1, EntityEquipmentSlot.CHEST)),
|
||||
STEEL_LEGGINGS("SteelLeggings", new ItemMekanismArmor(Materials.STEEL, 2, EntityEquipmentSlot.LEGS)),
|
||||
STEEL_BOOTS("SteelBoots", new ItemMekanismArmor(Materials.STEEL, 3, EntityEquipmentSlot.FEET));
|
||||
|
||||
public static final List<ToolsItem> BRONZE_SET = Arrays.asList(BRONZE_PICKAXE, BRONZE_AXE, BRONZE_SHOVEL, BRONZE_HOE, BRONZE_SWORD, BRONZE_PAXEL, BRONZE_HELMET,
|
||||
BRONZE_CHESTPLATE, BRONZE_LEGGINGS, BRONZE_BOOTS);
|
||||
public static final List<ToolsItem> OSMIUM_SET = Arrays.asList(OSMIUM_PICKAXE, OSMIUM_AXE, OSMIUM_SHOVEL, OSMIUM_HOE, OSMIUM_SWORD, OSMIUM_PAXEL, OSMIUM_HELMET,
|
||||
OSMIUM_CHESTPLATE, OSMIUM_LEGGINGS, OSMIUM_BOOTS);
|
||||
public static final List<ToolsItem> OBSIDIAN_SET = Arrays.asList(OBSIDIAN_PICKAXE, OBSIDIAN_AXE, OBSIDIAN_SHOVEL, OBSIDIAN_HOE, OBSIDIAN_SWORD, OBSIDIAN_PAXEL,
|
||||
OBSIDIAN_HELMET, OBSIDIAN_CHESTPLATE, OBSIDIAN_LEGGINGS, OBSIDIAN_BOOTS);
|
||||
public static final List<ToolsItem> GLOWSTONE_SET = Arrays.asList(GLOWSTONE_PICKAXE, GLOWSTONE_AXE, GLOWSTONE_SHOVEL, GLOWSTONE_HOE, GLOWSTONE_SWORD, GLOWSTONE_PAXEL,
|
||||
GLOWSTONE_HELMET, GLOWSTONE_CHESTPLATE, GLOWSTONE_LEGGINGS, GLOWSTONE_BOOTS);
|
||||
public static final List<ToolsItem> STEEL_SET = Arrays.asList(STEEL_PICKAXE, STEEL_AXE, STEEL_SHOVEL, STEEL_HOE, STEEL_SWORD, STEEL_PAXEL, STEEL_HELMET,
|
||||
STEEL_CHESTPLATE, STEEL_LEGGINGS, STEEL_BOOTS);
|
||||
//Unused but for consistency if something needs it
|
||||
public static final List<ToolsItem> LAPIS_LAZULI_SET = Arrays.asList(LAPIS_LAZULI_PICKAXE, LAPIS_LAZULI_AXE, LAPIS_LAZULI_SHOVEL, LAPIS_LAZULI_HOE, LAPIS_LAZULI_SWORD,
|
||||
LAPIS_LAZULI_PAXEL, LAPIS_LAZULI_HELMET, LAPIS_LAZULI_CHESTPLATE, LAPIS_LAZULI_LEGGINGS, LAPIS_LAZULI_BOOTS);
|
||||
|
||||
@Nonnull
|
||||
private Item item;
|
||||
|
||||
<ITEM extends Item & IHasRepairType> ToolsItem(@Nonnull String name, @Nonnull ITEM item) {
|
||||
//TODO: Make name be part of item instead of added on this extra layer.
|
||||
// Also make them have underscores rather than "fake" capitalization that is just to make it easier to read in the enum
|
||||
// This note is for 1.14 when we are going to be mass changing ids anyways to flatten things
|
||||
this.item = item.setTranslationKey(name).setRegistryName(new ResourceLocation(MekanismTools.MODID, name)).setCreativeTab(Mekanism.tabMekanism);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
private void updateItem(Item item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getRepairStack() {
|
||||
//All cases currently implement IHasRepairType but just in case we decide to add some eventually that doesn't
|
||||
return item instanceof IHasRepairType ? ((IHasRepairType) item).getRepairStack() : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getItemStack() {
|
||||
return getItemStack(1);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getItemStack(int size) {
|
||||
return new ItemStack(getItem(), size);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getItemStackAnyDamage() {
|
||||
return getItemStackAnyDamage(1);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getItemStackAnyDamage(int size) {
|
||||
return new ItemStack(getItem(), size, OreDictionary.WILDCARD_VALUE);
|
||||
}
|
||||
|
||||
public static void registerItems(IForgeRegistry<Item> registry) {
|
||||
for (ToolsItem toolsItem : values()) {
|
||||
registry.register(toolsItem.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
public static void remapItems() {
|
||||
for (ToolsItem toolsItem : values()) {
|
||||
ResourceLocation registryName = toolsItem.getItem().getRegistryName();
|
||||
toolsItem.updateItem(ForgeRegistries.ITEMS.getValue(registryName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,295 +0,0 @@
|
||||
package mekanism.tools.common;
|
||||
|
||||
import mekanism.tools.item.ItemMekanismArmor;
|
||||
import mekanism.tools.item.ItemMekanismAxe;
|
||||
import mekanism.tools.item.ItemMekanismHoe;
|
||||
import mekanism.tools.item.ItemMekanismPaxel;
|
||||
import mekanism.tools.item.ItemMekanismPickaxe;
|
||||
import mekanism.tools.item.ItemMekanismShovel;
|
||||
import mekanism.tools.item.ItemMekanismSword;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Item.ToolMaterial;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
@ObjectHolder(MekanismTools.MODID)
|
||||
public class ToolsItems {
|
||||
|
||||
//Vanilla Material Paxels
|
||||
public static Item WoodPaxel;
|
||||
public static Item StonePaxel;
|
||||
public static Item IronPaxel;
|
||||
public static Item DiamondPaxel;
|
||||
public static Item GoldPaxel;
|
||||
|
||||
//Glowstone Items
|
||||
public static Item GlowstonePaxel;
|
||||
public static Item GlowstonePickaxe;
|
||||
public static Item GlowstoneAxe;
|
||||
public static Item GlowstoneShovel;
|
||||
public static Item GlowstoneHoe;
|
||||
public static Item GlowstoneSword;
|
||||
public static Item GlowstoneHelmet;
|
||||
public static Item GlowstoneChestplate;
|
||||
public static Item GlowstoneLeggings;
|
||||
public static Item GlowstoneBoots;
|
||||
|
||||
//Bronze Items
|
||||
public static Item BronzePaxel;
|
||||
public static Item BronzePickaxe;
|
||||
public static Item BronzeAxe;
|
||||
public static Item BronzeShovel;
|
||||
public static Item BronzeHoe;
|
||||
public static Item BronzeSword;
|
||||
public static Item BronzeHelmet;
|
||||
public static Item BronzeChestplate;
|
||||
public static Item BronzeLeggings;
|
||||
public static Item BronzeBoots;
|
||||
|
||||
//Osmium Items
|
||||
public static Item OsmiumPaxel;
|
||||
public static Item OsmiumPickaxe;
|
||||
public static Item OsmiumAxe;
|
||||
public static Item OsmiumShovel;
|
||||
public static Item OsmiumHoe;
|
||||
public static Item OsmiumSword;
|
||||
public static Item OsmiumHelmet;
|
||||
public static Item OsmiumChestplate;
|
||||
public static Item OsmiumLeggings;
|
||||
public static Item OsmiumBoots;
|
||||
|
||||
//Obsidian Items
|
||||
public static Item ObsidianPaxel;
|
||||
public static Item ObsidianPickaxe;
|
||||
public static Item ObsidianAxe;
|
||||
public static Item ObsidianShovel;
|
||||
public static Item ObsidianHoe;
|
||||
public static Item ObsidianSword;
|
||||
public static Item ObsidianHelmet;
|
||||
public static Item ObsidianChestplate;
|
||||
public static Item ObsidianLeggings;
|
||||
public static Item ObsidianBoots;
|
||||
|
||||
//Lazuli Items
|
||||
public static Item LazuliPaxel;
|
||||
public static Item LazuliPickaxe;
|
||||
public static Item LazuliAxe;
|
||||
public static Item LazuliShovel;
|
||||
public static Item LazuliHoe;
|
||||
public static Item LazuliSword;
|
||||
public static Item LazuliHelmet;
|
||||
public static Item LazuliChestplate;
|
||||
public static Item LazuliLeggings;
|
||||
public static Item LazuliBoots;
|
||||
|
||||
//Steel Items
|
||||
public static Item SteelPaxel;
|
||||
public static Item SteelPickaxe;
|
||||
public static Item SteelAxe;
|
||||
public static Item SteelShovel;
|
||||
public static Item SteelHoe;
|
||||
public static Item SteelSword;
|
||||
public static Item SteelHelmet;
|
||||
public static Item SteelChestplate;
|
||||
public static Item SteelLeggings;
|
||||
public static Item SteelBoots;
|
||||
|
||||
public static void initializeItems() {
|
||||
WoodPaxel = init(new ItemMekanismPaxel(ToolMaterial.WOOD), "WoodPaxel");
|
||||
StonePaxel = init(new ItemMekanismPaxel(ToolMaterial.STONE), "StonePaxel");
|
||||
IronPaxel = init(new ItemMekanismPaxel(ToolMaterial.IRON), "IronPaxel");
|
||||
DiamondPaxel = init(new ItemMekanismPaxel(ToolMaterial.DIAMOND), "DiamondPaxel");
|
||||
GoldPaxel = init(new ItemMekanismPaxel(ToolMaterial.GOLD), "GoldPaxel");
|
||||
GlowstonePaxel = init(new ItemMekanismPaxel(MekanismTools.toolGLOWSTONE2), "GlowstonePaxel");
|
||||
GlowstonePickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolGLOWSTONE), "GlowstonePickaxe");
|
||||
GlowstoneAxe = init(new ItemMekanismAxe(MekanismTools.toolGLOWSTONE), "GlowstoneAxe");
|
||||
GlowstoneShovel = init(new ItemMekanismShovel(MekanismTools.toolGLOWSTONE), "GlowstoneShovel");
|
||||
GlowstoneHoe = init(new ItemMekanismHoe(MekanismTools.toolGLOWSTONE), "GlowstoneHoe");
|
||||
GlowstoneSword = init(new ItemMekanismSword(MekanismTools.toolGLOWSTONE), "GlowstoneSword");
|
||||
GlowstoneHelmet = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 0, EntityEquipmentSlot.HEAD), "GlowstoneHelmet");
|
||||
GlowstoneChestplate = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 1, EntityEquipmentSlot.CHEST), "GlowstoneChestplate");
|
||||
GlowstoneLeggings = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 2, EntityEquipmentSlot.LEGS), "GlowstoneLeggings");
|
||||
GlowstoneBoots = init(new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, 3, EntityEquipmentSlot.FEET), "GlowstoneBoots");
|
||||
BronzePaxel = init(new ItemMekanismPaxel(MekanismTools.toolBRONZE2), "BronzePaxel");
|
||||
BronzePickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolBRONZE), "BronzePickaxe");
|
||||
BronzeAxe = init(new ItemMekanismAxe(MekanismTools.toolBRONZE), "BronzeAxe");
|
||||
BronzeShovel = init(new ItemMekanismShovel(MekanismTools.toolBRONZE), "BronzeShovel");
|
||||
BronzeHoe = init(new ItemMekanismHoe(MekanismTools.toolBRONZE), "BronzeHoe");
|
||||
BronzeSword = init(new ItemMekanismSword(MekanismTools.toolBRONZE), "BronzeSword");
|
||||
BronzeHelmet = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 0, EntityEquipmentSlot.HEAD), "BronzeHelmet");
|
||||
BronzeChestplate = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 1, EntityEquipmentSlot.CHEST), "BronzeChestplate");
|
||||
BronzeLeggings = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 2, EntityEquipmentSlot.LEGS), "BronzeLeggings");
|
||||
BronzeBoots = init(new ItemMekanismArmor(MekanismTools.armorBRONZE, 3, EntityEquipmentSlot.FEET), "BronzeBoots");
|
||||
OsmiumPaxel = init(new ItemMekanismPaxel(MekanismTools.toolOSMIUM2), "OsmiumPaxel");
|
||||
OsmiumPickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolOSMIUM), "OsmiumPickaxe");
|
||||
OsmiumAxe = init(new ItemMekanismAxe(MekanismTools.toolOSMIUM), "OsmiumAxe");
|
||||
OsmiumShovel = init(new ItemMekanismShovel(MekanismTools.toolOSMIUM), "OsmiumShovel");
|
||||
OsmiumHoe = init(new ItemMekanismHoe(MekanismTools.toolOSMIUM), "OsmiumHoe");
|
||||
OsmiumSword = init(new ItemMekanismSword(MekanismTools.toolOSMIUM), "OsmiumSword");
|
||||
OsmiumHelmet = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 0, EntityEquipmentSlot.HEAD), "OsmiumHelmet");
|
||||
OsmiumChestplate = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 1, EntityEquipmentSlot.CHEST), "OsmiumChestplate");
|
||||
OsmiumLeggings = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 2, EntityEquipmentSlot.LEGS), "OsmiumLeggings");
|
||||
OsmiumBoots = init(new ItemMekanismArmor(MekanismTools.armorOSMIUM, 3, EntityEquipmentSlot.FEET), "OsmiumBoots");
|
||||
ObsidianPaxel = init(new ItemMekanismPaxel(MekanismTools.toolOBSIDIAN2), "ObsidianPaxel");
|
||||
ObsidianPickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolOBSIDIAN), "ObsidianPickaxe");
|
||||
ObsidianAxe = init(new ItemMekanismAxe(MekanismTools.toolOBSIDIAN), "ObsidianAxe");
|
||||
ObsidianShovel = init(new ItemMekanismShovel(MekanismTools.toolOBSIDIAN), "ObsidianShovel");
|
||||
ObsidianHoe = init(new ItemMekanismHoe(MekanismTools.toolOBSIDIAN), "ObsidianHoe");
|
||||
ObsidianSword = init(new ItemMekanismSword(MekanismTools.toolOBSIDIAN), "ObsidianSword");
|
||||
ObsidianHelmet = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 0, EntityEquipmentSlot.HEAD), "ObsidianHelmet");
|
||||
ObsidianChestplate = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 1, EntityEquipmentSlot.CHEST), "ObsidianChestplate");
|
||||
ObsidianLeggings = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 2, EntityEquipmentSlot.LEGS), "ObsidianLeggings");
|
||||
ObsidianBoots = init(new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, 3, EntityEquipmentSlot.FEET), "ObsidianBoots");
|
||||
LazuliPaxel = init(new ItemMekanismPaxel(MekanismTools.toolLAZULI2), "LapisLazuliPaxel");
|
||||
LazuliPickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolLAZULI), "LapisLazuliPickaxe");
|
||||
LazuliAxe = init(new ItemMekanismAxe(MekanismTools.toolLAZULI), "LapisLazuliAxe");
|
||||
LazuliShovel = init(new ItemMekanismShovel(MekanismTools.toolLAZULI), "LapisLazuliShovel");
|
||||
LazuliHoe = init(new ItemMekanismHoe(MekanismTools.toolLAZULI), "LapisLazuliHoe");
|
||||
LazuliSword = init(new ItemMekanismSword(MekanismTools.toolLAZULI), "LapisLazuliSword");
|
||||
LazuliHelmet = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 0, EntityEquipmentSlot.HEAD), "LapisLazuliHelmet");
|
||||
LazuliChestplate = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 1, EntityEquipmentSlot.CHEST), "LapisLazuliChestplate");
|
||||
LazuliLeggings = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 2, EntityEquipmentSlot.LEGS), "LapisLazuliLeggings");
|
||||
LazuliBoots = init(new ItemMekanismArmor(MekanismTools.armorLAZULI, 3, EntityEquipmentSlot.FEET), "LapisLazuliBoots");
|
||||
SteelPaxel = init(new ItemMekanismPaxel(MekanismTools.toolSTEEL2), "SteelPaxel");
|
||||
SteelPickaxe = init(new ItemMekanismPickaxe(MekanismTools.toolSTEEL), "SteelPickaxe");
|
||||
SteelAxe = init(new ItemMekanismAxe(MekanismTools.toolSTEEL), "SteelAxe");
|
||||
SteelShovel = init(new ItemMekanismShovel(MekanismTools.toolSTEEL), "SteelShovel");
|
||||
SteelHoe = init(new ItemMekanismHoe(MekanismTools.toolSTEEL), "SteelHoe");
|
||||
SteelSword = init(new ItemMekanismSword(MekanismTools.toolSTEEL), "SteelSword");
|
||||
SteelHelmet = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 0, EntityEquipmentSlot.HEAD), "SteelHelmet");
|
||||
SteelChestplate = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 1, EntityEquipmentSlot.CHEST), "SteelChestplate");
|
||||
SteelLeggings = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 2, EntityEquipmentSlot.LEGS), "SteelLeggings");
|
||||
SteelBoots = init(new ItemMekanismArmor(MekanismTools.armorSTEEL, 3, EntityEquipmentSlot.FEET), "SteelBoots");
|
||||
}
|
||||
|
||||
public static void setHarvestLevels() {
|
||||
setPaxelHarvest(BronzePaxel, MekanismTools.toolBRONZE2);
|
||||
BronzePickaxe.setHarvestLevel("pickaxe", MekanismTools.toolBRONZE.getHarvestLevel());
|
||||
BronzeAxe.setHarvestLevel("axe", MekanismTools.toolBRONZE.getHarvestLevel());
|
||||
BronzeShovel.setHarvestLevel("shovel", MekanismTools.toolBRONZE.getHarvestLevel());
|
||||
|
||||
setPaxelHarvest(OsmiumPaxel, MekanismTools.toolOSMIUM2);
|
||||
OsmiumPickaxe.setHarvestLevel("pickaxe", MekanismTools.toolOSMIUM.getHarvestLevel());
|
||||
OsmiumAxe.setHarvestLevel("axe", MekanismTools.toolOSMIUM.getHarvestLevel());
|
||||
OsmiumShovel.setHarvestLevel("shovel", MekanismTools.toolOSMIUM.getHarvestLevel());
|
||||
|
||||
setPaxelHarvest(ObsidianPaxel, MekanismTools.toolOBSIDIAN2);
|
||||
ObsidianPickaxe.setHarvestLevel("pickaxe", MekanismTools.toolOBSIDIAN.getHarvestLevel());
|
||||
ObsidianAxe.setHarvestLevel("axe", MekanismTools.toolOBSIDIAN.getHarvestLevel());
|
||||
ObsidianShovel.setHarvestLevel("shovel", MekanismTools.toolOBSIDIAN.getHarvestLevel());
|
||||
|
||||
setPaxelHarvest(LazuliPaxel, MekanismTools.toolLAZULI2);
|
||||
LazuliPickaxe.setHarvestLevel("pickaxe", MekanismTools.toolLAZULI.getHarvestLevel());
|
||||
LazuliAxe.setHarvestLevel("axe", MekanismTools.toolLAZULI.getHarvestLevel());
|
||||
LazuliShovel.setHarvestLevel("shovel", MekanismTools.toolLAZULI.getHarvestLevel());
|
||||
|
||||
setPaxelHarvest(GlowstonePaxel, MekanismTools.toolGLOWSTONE2);
|
||||
GlowstonePickaxe.setHarvestLevel("pickaxe", MekanismTools.toolGLOWSTONE.getHarvestLevel());
|
||||
GlowstoneAxe.setHarvestLevel("axe", MekanismTools.toolGLOWSTONE.getHarvestLevel());
|
||||
GlowstoneShovel.setHarvestLevel("shovel", MekanismTools.toolGLOWSTONE.getHarvestLevel());
|
||||
|
||||
setPaxelHarvest(SteelPaxel, MekanismTools.toolSTEEL2);
|
||||
SteelPickaxe.setHarvestLevel("pickaxe", MekanismTools.toolSTEEL.getHarvestLevel());
|
||||
SteelAxe.setHarvestLevel("axe", MekanismTools.toolSTEEL.getHarvestLevel());
|
||||
SteelShovel.setHarvestLevel("shovel", MekanismTools.toolSTEEL.getHarvestLevel());
|
||||
|
||||
setPaxelHarvest(WoodPaxel, ToolMaterial.WOOD);
|
||||
setPaxelHarvest(StonePaxel, ToolMaterial.STONE);
|
||||
setPaxelHarvest(IronPaxel, ToolMaterial.IRON);
|
||||
setPaxelHarvest(DiamondPaxel, ToolMaterial.DIAMOND);
|
||||
setPaxelHarvest(GoldPaxel, ToolMaterial.GOLD);
|
||||
}
|
||||
|
||||
private static void setPaxelHarvest(Item item, ToolMaterial material) {
|
||||
item.setHarvestLevel("pickaxe", material.getHarvestLevel());
|
||||
item.setHarvestLevel("axe", material.getHarvestLevel());
|
||||
item.setHarvestLevel("shovel", material.getHarvestLevel());
|
||||
}
|
||||
|
||||
public static void registerItems(IForgeRegistry<Item> registry) {
|
||||
//Base
|
||||
registry.register(WoodPaxel);
|
||||
registry.register(StonePaxel);
|
||||
registry.register(IronPaxel);
|
||||
registry.register(DiamondPaxel);
|
||||
registry.register(GoldPaxel);
|
||||
|
||||
//Obsidian
|
||||
registry.register(ObsidianHelmet);
|
||||
registry.register(ObsidianChestplate);
|
||||
registry.register(ObsidianLeggings);
|
||||
registry.register(ObsidianBoots);
|
||||
registry.register(ObsidianPaxel);
|
||||
registry.register(ObsidianPickaxe);
|
||||
registry.register(ObsidianAxe);
|
||||
registry.register(ObsidianShovel);
|
||||
registry.register(ObsidianHoe);
|
||||
registry.register(ObsidianSword);
|
||||
|
||||
//Lazuli
|
||||
registry.register(LazuliHelmet);
|
||||
registry.register(LazuliChestplate);
|
||||
registry.register(LazuliLeggings);
|
||||
registry.register(LazuliBoots);
|
||||
registry.register(LazuliPaxel);
|
||||
registry.register(LazuliPickaxe);
|
||||
registry.register(LazuliAxe);
|
||||
registry.register(LazuliShovel);
|
||||
registry.register(LazuliHoe);
|
||||
registry.register(LazuliSword);
|
||||
|
||||
//Osmium
|
||||
registry.register(OsmiumHelmet);
|
||||
registry.register(OsmiumChestplate);
|
||||
registry.register(OsmiumLeggings);
|
||||
registry.register(OsmiumBoots);
|
||||
registry.register(OsmiumPaxel);
|
||||
registry.register(OsmiumPickaxe);
|
||||
registry.register(OsmiumAxe);
|
||||
registry.register(OsmiumShovel);
|
||||
registry.register(OsmiumHoe);
|
||||
registry.register(OsmiumSword);
|
||||
|
||||
//Bronze
|
||||
registry.register(BronzeHelmet);
|
||||
registry.register(BronzeChestplate);
|
||||
registry.register(BronzeLeggings);
|
||||
registry.register(BronzeBoots);
|
||||
registry.register(BronzePaxel);
|
||||
registry.register(BronzePickaxe);
|
||||
registry.register(BronzeAxe);
|
||||
registry.register(BronzeShovel);
|
||||
registry.register(BronzeHoe);
|
||||
registry.register(BronzeSword);
|
||||
|
||||
//Glowstone
|
||||
registry.register(GlowstonePaxel);
|
||||
registry.register(GlowstonePickaxe);
|
||||
registry.register(GlowstoneAxe);
|
||||
registry.register(GlowstoneShovel);
|
||||
registry.register(GlowstoneHoe);
|
||||
registry.register(GlowstoneSword);
|
||||
registry.register(GlowstoneHelmet);
|
||||
registry.register(GlowstoneChestplate);
|
||||
registry.register(GlowstoneLeggings);
|
||||
registry.register(GlowstoneBoots);
|
||||
|
||||
//Steel
|
||||
registry.register(SteelPaxel);
|
||||
registry.register(SteelPickaxe);
|
||||
registry.register(SteelAxe);
|
||||
registry.register(SteelShovel);
|
||||
registry.register(SteelHoe);
|
||||
registry.register(SteelSword);
|
||||
registry.register(SteelHelmet);
|
||||
registry.register(SteelChestplate);
|
||||
registry.register(SteelLeggings);
|
||||
registry.register(SteelBoots);
|
||||
}
|
||||
|
||||
public static Item init(Item item, String name) {
|
||||
return item.setTranslationKey(name).setRegistryName(new ResourceLocation(MekanismTools.MODID, name));
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,15 @@ package mekanism.tools.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.client.render.ModelCustomArmor;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import mekanism.tools.common.MekanismTools;
|
||||
import mekanism.tools.common.ToolsItems;
|
||||
import mekanism.tools.common.IHasRepairType;
|
||||
import mekanism.tools.common.Materials;
|
||||
import mekanism.tools.common.ToolsItem;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,11 +18,10 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMekanismArmor extends ItemArmor {
|
||||
public class ItemMekanismArmor extends ItemArmor implements IHasRepairType {
|
||||
|
||||
public ItemMekanismArmor(ArmorMaterial enumarmormaterial, int renderIndex, EntityEquipmentSlot slot) {
|
||||
super(enumarmormaterial, renderIndex, slot);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
public ItemMekanismArmor(Materials material, int renderIndex, EntityEquipmentSlot slot) {
|
||||
super(material.getArmorMaterial(), renderIndex, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,40 +32,22 @@ public class ItemMekanismArmor extends ItemArmor {
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
|
||||
int layer = (slot == EntityEquipmentSlot.LEGS) ? 2 : 1;
|
||||
int layer = slot == EntityEquipmentSlot.LEGS ? 2 : 1;
|
||||
return "mekanism:armor/" + getArmorMaterial().name().toLowerCase(Locale.ROOT) + "_" + layer + ".png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack stack1, @Nonnull ItemStack stack2) {
|
||||
return StackUtils.equalsWildcard(getRepairStack(), stack2) || super.getIsRepairable(stack1, stack2);
|
||||
}
|
||||
|
||||
private ItemStack getRepairStack() {
|
||||
if (getArmorMaterial() == MekanismTools.armorOBSIDIAN) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 0);
|
||||
} else if (getArmorMaterial() == MekanismTools.armorLAZULI) {
|
||||
return new ItemStack(Items.DYE, 1, 4);
|
||||
} else if (getArmorMaterial() == MekanismTools.armorOSMIUM) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 1);
|
||||
} else if (getArmorMaterial() == MekanismTools.armorBRONZE) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 2);
|
||||
} else if (getArmorMaterial() == MekanismTools.armorGLOWSTONE) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 3);
|
||||
} else if (getArmorMaterial() == MekanismTools.armorSTEEL) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 4);
|
||||
}
|
||||
return new ItemStack(getArmorMaterial().getRepairItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot,
|
||||
ModelBiped _default) {
|
||||
if (itemStack.getItem() == ToolsItems.GlowstoneHelmet || itemStack.getItem() == ToolsItems.GlowstoneChestplate
|
||||
|| itemStack.getItem() == ToolsItems.GlowstoneLeggings || itemStack.getItem() == ToolsItems.GlowstoneBoots) {
|
||||
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) {
|
||||
if (itemStack.getItem() == ToolsItem.GLOWSTONE_HELMET.getItem() || itemStack.getItem() == ToolsItem.GLOWSTONE_CHESTPLATE.getItem()
|
||||
|| itemStack.getItem() == ToolsItem.GLOWSTONE_LEGGINGS.getItem() || itemStack.getItem() == ToolsItem.GLOWSTONE_BOOTS.getItem()) {
|
||||
return ModelCustomArmor.getGlow(armorSlot);
|
||||
}
|
||||
return super.getArmorModel(entityLiving, itemStack, armorSlot, _default);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRepairStack() {
|
||||
return getArmorMaterial().getRepairItemStack();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package mekanism.tools.item;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import mekanism.tools.common.MekanismTools;
|
||||
import mekanism.tools.common.IHasRepairType;
|
||||
import mekanism.tools.common.Materials;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -13,11 +11,11 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMekanismAxe extends ItemAxe {
|
||||
public class ItemMekanismAxe extends ItemAxe implements IHasRepairType {
|
||||
|
||||
public ItemMekanismAxe(ToolMaterial tool) {
|
||||
super(tool, MekanismTools.AXE_DAMAGE.get(tool), MekanismTools.AXE_SPEED.get(tool));
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
public ItemMekanismAxe(Materials material) {
|
||||
super(material.getMaterial(), material.getAxeDamage(), material.getAxeSpeed());
|
||||
setHarvestLevel("axe", material.getMaterial().getHarvestLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,7 +25,7 @@ public class ItemMekanismAxe extends ItemAxe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack toRepair, @Nonnull ItemStack repair) {
|
||||
return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), repair) || super.getIsRepairable(toRepair, repair);
|
||||
public ItemStack getRepairStack() {
|
||||
return toolMaterial.getRepairItemStack();
|
||||
}
|
||||
}
|
||||
@@ -1,112 +1,20 @@
|
||||
package mekanism.tools.item;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.common.item.ItemMekanism;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDirt;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import mekanism.tools.common.IHasRepairType;
|
||||
import mekanism.tools.common.Materials;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
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.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMekanismHoe extends ItemMekanism {
|
||||
public class ItemMekanismHoe extends ItemHoe implements IHasRepairType {
|
||||
|
||||
private final float speed;
|
||||
protected ToolMaterial toolMaterial;
|
||||
|
||||
public ItemMekanismHoe(ToolMaterial enumtoolmaterial) {
|
||||
super();
|
||||
toolMaterial = enumtoolmaterial;
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(enumtoolmaterial.getMaxUses());
|
||||
setCreativeTab(CreativeTabs.TOOLS);
|
||||
speed = enumtoolmaterial.getAttackDamage() + 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) {
|
||||
return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), stack2) || super.getIsRepairable(stack1, stack2);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = playerIn.getHeldItem(hand);
|
||||
|
||||
if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
||||
return EnumActionResult.FAIL;
|
||||
} else {
|
||||
int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos);
|
||||
if (hook != 0) {
|
||||
return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if (facing != EnumFacing.DOWN && worldIn.isAirBlock(pos.up())) {
|
||||
if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) {
|
||||
setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState());
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
if (block == Blocks.DIRT) {
|
||||
switch (iblockstate.getValue(BlockDirt.VARIANT)) {
|
||||
case DIRT:
|
||||
setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState());
|
||||
return EnumActionResult.SUCCESS;
|
||||
case COARSE_DIRT:
|
||||
setBlock(stack, playerIn, worldIn, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) {
|
||||
worldIn.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
if (!worldIn.isRemote) {
|
||||
worldIn.setBlockState(pos, state, 11);
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(@Nonnull EntityEquipmentSlot equipmentSlot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(equipmentSlot, stack);
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 0.0D, 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.speed - 4.0F, 0));
|
||||
}
|
||||
return multimap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
stack.damageItem(1, attacker);
|
||||
return true;
|
||||
public ItemMekanismHoe(Materials material) {
|
||||
super(material.getMaterial());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,8 +24,7 @@ public class ItemMekanismHoe extends ItemMekanism {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
public ItemStack getRepairStack() {
|
||||
return toolMaterial.getRepairItemStack();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,38 @@
|
||||
package mekanism.tools.item;
|
||||
|
||||
import java.util.HashSet;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.tools.common.ToolUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import java.util.List;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.tools.common.IHasRepairType;
|
||||
import mekanism.tools.common.Materials;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMekanismPaxel extends ItemMekanismTool {
|
||||
public class ItemMekanismPaxel extends ItemTool implements IHasRepairType {
|
||||
|
||||
public ItemMekanismPaxel(ToolMaterial toolMaterial) {
|
||||
super(4, -2.4F, toolMaterial, new HashSet<>());
|
||||
public ItemMekanismPaxel(Materials material) {
|
||||
this(material.getPaxelMaterial());
|
||||
}
|
||||
|
||||
public ItemMekanismPaxel(ToolMaterial material) {
|
||||
super(4, -2.4F, material, new HashSet<>());
|
||||
setHarvestLevel("pickaxe", material.getHarvestLevel());
|
||||
setHarvestLevel("shovel", material.getHarvestLevel());
|
||||
setHarvestLevel("axe", material.getHarvestLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(@Nonnull ItemStack stack, IBlockState blockState) {
|
||||
return blockState.getBlock() != Blocks.BEDROCK ? efficiency : 1.0F;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag) {
|
||||
list.add(LangUtils.localize("tooltip.hp") + ": " + (itemstack.getMaxDamage() - itemstack.getItemDamage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(@Nonnull IBlockState state, ItemStack stack) {
|
||||
return ToolUtils.canShovelHarvest(state.getBlock()) || ToolUtils.canPickaxeHarvest(state, toolMaterial);
|
||||
public ItemStack getRepairStack() {
|
||||
return toolMaterial.getRepairItemStack();
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,31 @@
|
||||
package mekanism.tools.item;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.tools.common.ToolUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import java.util.List;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.tools.common.IHasRepairType;
|
||||
import mekanism.tools.common.Materials;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMekanismPickaxe extends ItemMekanismTool {
|
||||
public class ItemMekanismPickaxe extends ItemPickaxe implements IHasRepairType {
|
||||
|
||||
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(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);
|
||||
|
||||
public ItemMekanismPickaxe(ToolMaterial toolMaterial) {
|
||||
super(1, -2.8F, toolMaterial, EFFECTIVE_ON);
|
||||
public ItemMekanismPickaxe(Materials material) {
|
||||
super(material.getMaterial());
|
||||
setHarvestLevel("pickaxe", material.getMaterial().getHarvestLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(@Nonnull IBlockState state, ItemStack stack) {
|
||||
return ToolUtils.canPickaxeHarvest(state, toolMaterial);
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag) {
|
||||
list.add(LangUtils.localize("tooltip.hp") + ": " + (itemstack.getMaxDamage() - itemstack.getItemDamage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(@Nonnull ItemStack itemstack, IBlockState blockState) {
|
||||
if (blockState != null && (blockState.getMaterial() == Material.IRON || blockState.getMaterial() == Material.ANVIL || blockState.getMaterial() == Material.ROCK)) {
|
||||
return efficiency;
|
||||
}
|
||||
return super.getDestroySpeed(itemstack, blockState);
|
||||
public ItemStack getRepairStack() {
|
||||
return toolMaterial.getRepairItemStack();
|
||||
}
|
||||
}
|
||||
@@ -1,55 +1,31 @@
|
||||
package mekanism.tools.item;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.tools.common.ToolUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import java.util.List;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.tools.common.IHasRepairType;
|
||||
import mekanism.tools.common.Materials;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMekanismShovel extends ItemMekanismTool {
|
||||
public class ItemMekanismShovel extends ItemSpade implements IHasRepairType {
|
||||
|
||||
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND,
|
||||
Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH);
|
||||
|
||||
public ItemMekanismShovel(ToolMaterial enumtoolmaterial) {
|
||||
super(1.5F, -3, enumtoolmaterial, EFFECTIVE_ON);
|
||||
public ItemMekanismShovel(Materials material) {
|
||||
super(material.getMaterial());
|
||||
setHarvestLevel("shovel", material.getMaterial().getHarvestLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(@Nonnull IBlockState state, ItemStack stack) {
|
||||
return ToolUtils.canShovelHarvest(state.getBlock());
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag) {
|
||||
list.add(LangUtils.localize("tooltip.hp") + ": " + (itemstack.getMaxDamage() - itemstack.getItemDamage()));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = playerIn.getHeldItem(hand);
|
||||
if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
if (facing != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && block == Blocks.GRASS) {
|
||||
IBlockState iblockstate1 = Blocks.GRASS_PATH.getDefaultState();
|
||||
worldIn.playSound(playerIn, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
if (!worldIn.isRemote) {
|
||||
worldIn.setBlockState(pos, iblockstate1, 11);
|
||||
stack.damageItem(1, playerIn);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
public ItemStack getRepairStack() {
|
||||
return toolMaterial.getRepairItemStack();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package mekanism.tools.item;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import mekanism.tools.common.IHasRepairType;
|
||||
import mekanism.tools.common.Materials;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
@@ -12,14 +11,10 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMekanismSword extends ItemSword {
|
||||
public class ItemMekanismSword extends ItemSword implements IHasRepairType {
|
||||
|
||||
private ToolMaterial toolMaterial;
|
||||
|
||||
public ItemMekanismSword(ToolMaterial enumtoolmaterial) {
|
||||
super(enumtoolmaterial);
|
||||
toolMaterial = enumtoolmaterial;
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
public ItemMekanismSword(Materials material) {
|
||||
super(material.getMaterial());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,7 +24,7 @@ public class ItemMekanismSword extends ItemSword {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack stack1, @Nonnull ItemStack stack2) {
|
||||
return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), stack2) || super.getIsRepairable(stack1, stack2);
|
||||
public ItemStack getRepairStack() {
|
||||
return material.getRepairItemStack();
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package mekanism.tools.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import mekanism.tools.common.MekanismTools;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemMekanismTool extends ItemTool {
|
||||
|
||||
public ItemMekanismTool(float attack, float speed, ToolMaterial toolMaterial, Set<Block> effectiveBlocksIn) {
|
||||
super(attack, speed, toolMaterial, effectiveBlocksIn);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
}
|
||||
|
||||
public static ItemStack getRepairStack(ToolMaterial material) {
|
||||
if (material == MekanismTools.toolOBSIDIAN || material == MekanismTools.toolOBSIDIAN2) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 0);
|
||||
} else if (material == MekanismTools.toolLAZULI || material == MekanismTools.toolLAZULI2) {
|
||||
return new ItemStack(Items.DYE, 1, 4);
|
||||
} else if (material == MekanismTools.toolOSMIUM || material == MekanismTools.toolOSMIUM2) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 1);
|
||||
} else if (material == MekanismTools.toolBRONZE || material == MekanismTools.toolBRONZE2) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 2);
|
||||
} else if (material == MekanismTools.toolGLOWSTONE || material == MekanismTools.toolGLOWSTONE2) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 3);
|
||||
} else if (material == MekanismTools.toolSTEEL || material == MekanismTools.toolSTEEL2) {
|
||||
return new ItemStack(MekanismItems.Ingot, 1, 4);
|
||||
}
|
||||
return material.getRepairItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag) {
|
||||
list.add(LangUtils.localize("tooltip.hp") + ": " + (itemstack.getMaxDamage() - itemstack.getItemDamage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack stack1, @Nonnull ItemStack stack2) {
|
||||
return StackUtils.equalsWildcard(getRepairStack(), stack2) || super.getIsRepairable(stack1, stack2);
|
||||
}
|
||||
|
||||
private ItemStack getRepairStack() {
|
||||
return getRepairStack(toolMaterial);
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,7 @@ public net.minecraft.block.BlockPortal$Size field_150861_f #bottomLeft
|
||||
public net.minecraft.block.BlockPortal$Size field_150862_g #height
|
||||
public net.minecraft.block.BlockPortal$Size field_150868_h #width
|
||||
public net.minecraft.block.BlockPortal$Size field_150863_d #leftDir
|
||||
public net.minecraft.block.BlockPortal$Size field_150866_c #rightDir
|
||||
public net.minecraft.block.BlockPortal$Size field_150866_c #rightDir
|
||||
|
||||
#net.minecraft.item.ItemSword
|
||||
protected net.minecraft.item.ItemSword field_150933_b #material
|
||||
Reference in new issue
Block a user