mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 11:49:23 +01:00
Started on Tool Table tools, noticed how I was doing stupidly much for the tooltip event that I didn't need to do, probably more stuff that I can't remember
This commit is contained in:
parent
7145c273f1
commit
835e8734ab
17 changed files with 407 additions and 75 deletions
|
@ -29,6 +29,7 @@ import ellpeck.actuallyadditions.inventory.GuiHandler;
|
|||
import ellpeck.actuallyadditions.items.InitForeignPaxels;
|
||||
import ellpeck.actuallyadditions.items.InitItems;
|
||||
import ellpeck.actuallyadditions.items.ItemCoffee;
|
||||
import ellpeck.actuallyadditions.items.tools.table.InitToolTableTools;
|
||||
import ellpeck.actuallyadditions.material.InitArmorMaterials;
|
||||
import ellpeck.actuallyadditions.material.InitToolMaterials;
|
||||
import ellpeck.actuallyadditions.misc.DispenserHandlerEmptyBucket;
|
||||
|
@ -38,7 +39,6 @@ import ellpeck.actuallyadditions.ore.InitOreDict;
|
|||
import ellpeck.actuallyadditions.proxy.IProxy;
|
||||
import ellpeck.actuallyadditions.recipe.FuelHandler;
|
||||
import ellpeck.actuallyadditions.recipe.HairyBallHandler;
|
||||
import ellpeck.actuallyadditions.recipe.ToolTableHandler;
|
||||
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||
import ellpeck.actuallyadditions.update.UpdateChecker;
|
||||
|
@ -97,9 +97,9 @@ public class ActuallyAdditions{
|
|||
CrusherCrafting.init();
|
||||
ItemCrafting.initMashedFoodRecipes();
|
||||
HairyBallHandler.init();
|
||||
ToolTableHandler.init();
|
||||
TreasureChestHandler.init();
|
||||
InitForeignPaxels.init();
|
||||
InitToolTableTools.init();
|
||||
proxy.postInit(event);
|
||||
|
||||
ModUtil.LOGGER.info("PostInitialization Finished.");
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package ellpeck.actuallyadditions.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
||||
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||
|
@ -20,17 +19,12 @@ import ellpeck.actuallyadditions.items.InitItems;
|
|||
import ellpeck.actuallyadditions.util.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class TooltipEvent{
|
||||
|
||||
|
@ -41,46 +35,28 @@ public class TooltipEvent{
|
|||
@SubscribeEvent
|
||||
public void onTooltipEvent(ItemTooltipEvent event){
|
||||
//Booklet Access
|
||||
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
||||
if(screen != null && !(screen instanceof GuiBooklet) && screen instanceof GuiContainer){
|
||||
GuiContainer gui = (GuiContainer)screen;
|
||||
if(gui.inventorySlots != null && gui.inventorySlots.inventorySlots != null && !gui.inventorySlots.inventorySlots.isEmpty()){
|
||||
for(int i = 0; i < gui.inventorySlots.inventorySlots.size(); i++){
|
||||
Slot slot = gui.inventorySlots.getSlot(i);
|
||||
|
||||
int guiLeft = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 4);
|
||||
int guiTop = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 5);
|
||||
int mouseX = Mouse.getEventX()*gui.width/Minecraft.getMinecraft().displayWidth-guiLeft;
|
||||
int mouseY = gui.height-Mouse.getEventY()*gui.height/Minecraft.getMinecraft().displayHeight-1-guiTop;
|
||||
|
||||
if(mouseX >= slot.xDisplayPosition-1 && mouseY >= slot.yDisplayPosition-1 && mouseX <= slot.xDisplayPosition+16 && mouseY <= slot.yDisplayPosition+16){
|
||||
ItemStack stack = slot.getStack();
|
||||
if(stack != null){
|
||||
for(BookletPage page : InitBooklet.pagesWithItemStackData){
|
||||
if(ItemUtil.areItemsEqual(stack, page.getItemStackForPage(), true)){
|
||||
int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode();
|
||||
if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){
|
||||
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
||||
event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]"));
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){
|
||||
GuiBooklet book = new GuiBooklet();
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
Minecraft.getMinecraft().displayGuiScreen(book);
|
||||
book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.BUTTONS_PER_PAGE+1, true);
|
||||
book.openChapter(page.getChapter(), page);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
||||
event.toolTip.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(EnumChatFormatting.DARK_RED+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".noBookletInInventory"), GuiBooklet.TOOLTIP_SPLIT_LENGTH));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(event.itemStack != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiBooklet)){
|
||||
for(BookletPage page : InitBooklet.pagesWithItemStackData){
|
||||
if(ItemUtil.areItemsEqual(event.itemStack, page.getItemStackForPage(), true)){
|
||||
int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode();
|
||||
if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){
|
||||
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
||||
event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]"));
|
||||
}
|
||||
if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){
|
||||
GuiBooklet book = new GuiBooklet();
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
Minecraft.getMinecraft().displayGuiScreen(book);
|
||||
book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.BUTTONS_PER_PAGE+1, true);
|
||||
book.openChapter(page.getChapter(), page);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
||||
event.toolTip.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(EnumChatFormatting.DARK_RED+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".noBookletInInventory"), GuiBooklet.TOOLTIP_SPLIT_LENGTH));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ItemBattery extends ItemEnergy implements INameableItem{
|
|||
private String name;
|
||||
|
||||
public ItemBattery(String name, int capacity, int transfer){
|
||||
super(capacity, transfer, 1);
|
||||
super(capacity, transfer);
|
||||
this.setMaxStackSize(1);
|
||||
this.name = name;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import ellpeck.actuallyadditions.config.values.ConfigFloatValues;
|
|||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||
import ellpeck.actuallyadditions.util.INameableItem;
|
||||
import ellpeck.actuallyadditions.util.ItemUtil;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -49,7 +50,7 @@ import java.util.Set;
|
|||
public class ItemDrill extends ItemEnergy implements INameableItem{
|
||||
|
||||
public ItemDrill(){
|
||||
super(500000, 5000, 4);
|
||||
super(500000, 5000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -379,15 +380,8 @@ public class ItemDrill extends ItemEnergy implements INameableItem{
|
|||
else toReturn = this.breakBlocks(stack, 0, player.worldObj, x, y, z, player);
|
||||
|
||||
//Removes Enchantments added above
|
||||
NBTTagList ench = stack.getEnchantmentTagList();
|
||||
if(ench != null){
|
||||
for(int i = 0; i < ench.tagCount(); i++){
|
||||
short id = ench.getCompoundTagAt(i).getShort("id");
|
||||
if(id == Enchantment.silkTouch.effectId || id == Enchantment.fortune.effectId){
|
||||
ench.removeTag(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemUtil.removeEnchantment(stack, Enchantment.silkTouch);
|
||||
ItemUtil.removeEnchantment(stack, Enchantment.fortune);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
|
|
@ -24,13 +24,10 @@ import java.util.List;
|
|||
|
||||
public abstract class ItemEnergy extends ItemEnergyContainer{
|
||||
|
||||
private int infoLines;
|
||||
|
||||
public ItemEnergy(int maxPower, int transfer, int infoLines){
|
||||
public ItemEnergy(int maxPower, int transfer){
|
||||
super(maxPower, transfer);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxStackSize(1);
|
||||
this.infoLines = infoLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,7 +36,7 @@ import java.util.Random;
|
|||
public class ItemGrowthRing extends ItemEnergy implements INameableItem{
|
||||
|
||||
public ItemGrowthRing(){
|
||||
super(1000000, 5000, 1);
|
||||
super(1000000, 5000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.util.ArrayList;
|
|||
public class ItemMagnetRing extends ItemEnergy implements INameableItem{
|
||||
|
||||
public ItemMagnetRing(){
|
||||
super(3000000, 5000, 1);
|
||||
super(3000000, 5000);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -32,7 +32,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
public class ItemTeleStaff extends ItemEnergy implements INameableItem{
|
||||
|
||||
public ItemTeleStaff(){
|
||||
super(500000, 10000, 2);
|
||||
super(500000, 10000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,7 @@ import net.minecraft.world.World;
|
|||
public class ItemWaterRemovalRing extends ItemEnergy implements INameableItem{
|
||||
|
||||
public ItemWaterRemovalRing(){
|
||||
super(1000000, 5000, 1);
|
||||
super(1000000, 5000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* This file ("InitToolTableTools.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.items.tools.table;
|
||||
|
||||
import ellpeck.actuallyadditions.items.tools.table.ItemPickaxeFixedEnchants.EnchantmentCombo;
|
||||
import ellpeck.actuallyadditions.util.ItemUtil;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class InitToolTableTools{
|
||||
|
||||
public static Item itemMinersPickaxe;
|
||||
public static Item itemSilkyMinersPickaxe;
|
||||
|
||||
public static void init(){
|
||||
itemMinersPickaxe = new ItemPickaxeFixedEnchants(Item.ToolMaterial.EMERALD, "itemMinersPickaxe", EnumRarity.rare, new EnchantmentCombo(Enchantment.fortune, 2), new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 1));
|
||||
ItemUtil.register(itemMinersPickaxe);
|
||||
|
||||
itemSilkyMinersPickaxe = new ItemPickaxeFixedEnchants(Item.ToolMaterial.EMERALD, "itemSilkyMinersPickaxe", EnumRarity.rare, new EnchantmentCombo(Enchantment.silkTouch, 1), new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 1));
|
||||
ItemUtil.register(itemSilkyMinersPickaxe);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* This file ("ItemAxeFixedEnchants.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.items.tools.table;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.items.tools.ItemAxeAA;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemAxeFixedEnchants extends ItemAxeAA{
|
||||
|
||||
public static class EnchantmentCombo{
|
||||
public Enchantment enchantment;
|
||||
public int level;
|
||||
|
||||
public EnchantmentCombo(Enchantment ench, int level){
|
||||
this.enchantment = ench;
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
|
||||
private EnchantmentCombo[] enchantments;
|
||||
|
||||
public ItemAxeFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){
|
||||
super(toolMat, "", unlocalizedName, rarity);
|
||||
this.enchantments = enchantments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack, int pass){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2){
|
||||
return this.isRepairable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability(ItemStack stack){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player){
|
||||
for(EnchantmentCombo combo : this.enchantments){
|
||||
stack.addEnchantment(combo.enchantment, combo.level);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list){
|
||||
ItemStack stack = new ItemStack(item);
|
||||
for(EnchantmentCombo combo : this.enchantments){
|
||||
stack.addEnchantment(combo.enchantment, combo.level);
|
||||
}
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* This file ("ItemPickaxeNoEnchants.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.items.tools.table;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.items.tools.ItemPickaxeAA;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPickaxeFixedEnchants extends ItemPickaxeAA{
|
||||
|
||||
public static class EnchantmentCombo{
|
||||
public Enchantment enchantment;
|
||||
public int level;
|
||||
|
||||
public EnchantmentCombo(Enchantment ench, int level){
|
||||
this.enchantment = ench;
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
|
||||
private EnchantmentCombo[] enchantments;
|
||||
|
||||
public ItemPickaxeFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){
|
||||
super(toolMat, "", unlocalizedName, rarity);
|
||||
this.enchantments = enchantments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack, int pass){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2){
|
||||
return this.isRepairable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability(ItemStack stack){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player){
|
||||
for(EnchantmentCombo combo : this.enchantments){
|
||||
stack.addEnchantment(combo.enchantment, combo.level);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list){
|
||||
ItemStack stack = new ItemStack(item);
|
||||
for(EnchantmentCombo combo : this.enchantments){
|
||||
stack.addEnchantment(combo.enchantment, combo.level);
|
||||
}
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* This file ("ItemShovelFixedEnchants.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.items.tools.table;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.items.tools.ItemShovelAA;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemShovelFixedEnchants extends ItemShovelAA{
|
||||
|
||||
public static class EnchantmentCombo{
|
||||
public Enchantment enchantment;
|
||||
public int level;
|
||||
|
||||
public EnchantmentCombo(Enchantment ench, int level){
|
||||
this.enchantment = ench;
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
|
||||
private EnchantmentCombo[] enchantments;
|
||||
|
||||
public ItemShovelFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){
|
||||
super(toolMat, "", unlocalizedName, rarity);
|
||||
this.enchantments = enchantments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack, int pass){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2){
|
||||
return this.isRepairable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability(ItemStack stack){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player){
|
||||
for(EnchantmentCombo combo : this.enchantments){
|
||||
stack.addEnchantment(combo.enchantment, combo.level);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list){
|
||||
ItemStack stack = new ItemStack(item);
|
||||
for(EnchantmentCombo combo : this.enchantments){
|
||||
stack.addEnchantment(combo.enchantment, combo.level);
|
||||
}
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* This file ("ItemSwordFixedEnchants.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.items.tools.table;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.items.tools.ItemSwordAA;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSwordFixedEnchants extends ItemSwordAA{
|
||||
|
||||
public static class EnchantmentCombo{
|
||||
public Enchantment enchantment;
|
||||
public int level;
|
||||
|
||||
public EnchantmentCombo(Enchantment ench, int level){
|
||||
this.enchantment = ench;
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
|
||||
private EnchantmentCombo[] enchantments;
|
||||
|
||||
public ItemSwordFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){
|
||||
super(toolMat, "", unlocalizedName, rarity);
|
||||
this.enchantments = enchantments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack, int pass){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2){
|
||||
return this.isRepairable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability(ItemStack stack){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player){
|
||||
for(EnchantmentCombo combo : this.enchantments){
|
||||
stack.addEnchantment(combo.enchantment, combo.level);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list){
|
||||
ItemStack stack = new ItemStack(item);
|
||||
for(EnchantmentCombo combo : this.enchantments){
|
||||
stack.addEnchantment(combo.enchantment, combo.level);
|
||||
}
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
|
@ -10,10 +10,7 @@
|
|||
|
||||
package ellpeck.actuallyadditions.recipe;
|
||||
|
||||
import ellpeck.actuallyadditions.items.InitItems;
|
||||
import ellpeck.actuallyadditions.util.ItemUtil;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -22,12 +19,7 @@ public class ToolTableHandler{
|
|||
|
||||
public static ArrayList<Recipe> recipes = new ArrayList<Recipe>();
|
||||
|
||||
public static void init(){
|
||||
//TODO Actual real recipes
|
||||
addRecipe(new ItemStack(InitItems.itemPhantomConnector), new ItemStack(Items.diamond_pickaxe), new ItemStack(Blocks.stone_brick_stairs), new ItemStack(Blocks.planks));
|
||||
}
|
||||
|
||||
private static void addRecipe(ItemStack output, ItemStack... itemsNeeded){
|
||||
public static void addRecipe(ItemStack output, ItemStack... itemsNeeded){
|
||||
recipes.add(new Recipe(output, itemsNeeded));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,10 @@ package ellpeck.actuallyadditions.util;
|
|||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import ellpeck.actuallyadditions.creative.CreativeTab;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class ItemUtil{
|
||||
|
||||
|
@ -78,4 +80,16 @@ public class ItemUtil{
|
|||
public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard){
|
||||
return stack1 != null && stack2 != null && (stack1.isItemEqual(stack2) || (checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD)));
|
||||
}
|
||||
|
||||
public static void removeEnchantment(ItemStack stack, Enchantment e){
|
||||
NBTTagList ench = stack.getEnchantmentTagList();
|
||||
if(ench != null){
|
||||
for(int i = 0; i < ench.tagCount(); i++){
|
||||
short id = ench.getCompoundTagAt(i).getShort("id");
|
||||
if(id == e.effectId){
|
||||
ench.removeTag(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ public class WorldUtil{
|
|||
Block block = world.getBlock(xPos, yPos, zPos);
|
||||
int meta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
//If the Block can be harvested or not
|
||||
boolean canHarvest = block.canHarvestBlock(player, meta) && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem().canHarvestBlock(block, player.getCurrentEquippedItem());
|
||||
boolean canHarvest = block.canHarvestBlock(player, meta);
|
||||
|
||||
if(!world.isRemote){
|
||||
//Server-Side only, special cases
|
||||
|
|
Loading…
Reference in a new issue