From ffbf75a533c1e24987f1bf5adea68353144122cb Mon Sep 17 00:00:00 2001 From: KingPhygieBoo Date: Wed, 22 Nov 2017 02:10:06 -0600 Subject: [PATCH] Added the Swetty Ball ability base. Will be buffed in the future. --- .../aether/common/items/ItemSwettyBall.java | 48 +++++++++++++++++++ .../aether/common/items/ItemsAether.java | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/legacy/aether/common/items/ItemSwettyBall.java diff --git a/src/main/java/com/legacy/aether/common/items/ItemSwettyBall.java b/src/main/java/com/legacy/aether/common/items/ItemSwettyBall.java new file mode 100644 index 0000000..062e945 --- /dev/null +++ b/src/main/java/com/legacy/aether/common/items/ItemSwettyBall.java @@ -0,0 +1,48 @@ +package com.legacy.aether.common.items; + +import com.legacy.aether.common.blocks.BlocksAether; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class ItemSwettyBall extends Item +{ + + public ItemSwettyBall(CreativeTabs tab) + { + this.setCreativeTab(tab); + } + + @Override + public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + { + if (worldIn.getBlockState(pos).getBlock() == BlocksAether.aether_dirt) + { + worldIn.setBlockState(pos, BlocksAether.aether_grass.getDefaultState()); + } + else if (worldIn.getBlockState(pos).getBlock() == Blocks.DIRT) + { + worldIn.setBlockState(pos, Blocks.GRASS.getDefaultState()); + } + else + { + return EnumActionResult.FAIL; + } + + if (!playerIn.capabilities.isCreativeMode) + { + --stack.stackSize; + } + + return EnumActionResult.SUCCESS; + } + +} \ No newline at end of file diff --git a/src/main/java/com/legacy/aether/common/items/ItemsAether.java b/src/main/java/com/legacy/aether/common/items/ItemsAether.java index d181f64..c291d4a 100644 --- a/src/main/java/com/legacy/aether/common/items/ItemsAether.java +++ b/src/main/java/com/legacy/aether/common/items/ItemsAether.java @@ -116,7 +116,7 @@ public class ItemsAether ambrosium_shard = register("ambrosium_shard", new ItemAmbrosiumShard()); golden_amber = register("golden_amber", new ItemAether(AetherCreativeTabs.material)); aechor_petal = register("aechor_petal", new ItemAether(AetherCreativeTabs.material)); - swetty_ball = register("swetty_ball", new ItemAether(AetherCreativeTabs.material)); + swetty_ball = register("swetty_ball", new ItemSwettyBall(AetherCreativeTabs.material)); skyroot_pickaxe = register("skyroot_pickaxe", new ItemSkyrootTool(EnumAetherToolType.PICKAXE)); skyroot_axe = register("skyroot_axe", new ItemSkyrootTool(EnumAetherToolType.AXE));