Merge branch 'master' of https://data.tilera.xyz/git/Anvilcraft/Dartcraft
This commit is contained in:
commit
ee66d45a36
6 changed files with 258 additions and 0 deletions
|
@ -1,8 +1,10 @@
|
|||
package ley.modding.dartcraft.item;
|
||||
|
||||
import ley.modding.dartcraft.item.tool.ItemForceAxe;
|
||||
import ley.modding.dartcraft.item.tool.ItemForceMitts;
|
||||
import ley.modding.dartcraft.item.tool.ItemForcePickaxe;
|
||||
import ley.modding.dartcraft.item.tool.ItemForceShears;
|
||||
import ley.modding.dartcraft.item.tool.ItemForceShovel;
|
||||
import ley.modding.tileralib.api.IRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
|
@ -15,6 +17,8 @@ public class DartItems {
|
|||
public static Item forceshard;
|
||||
public static Item forceshears;
|
||||
public static Item forcepickaxe;
|
||||
public static Item forceshovel;
|
||||
public static Item forceaxe;
|
||||
public static Item forcemitts;
|
||||
public static Item forceflask;
|
||||
public static Item entitybottle;
|
||||
|
@ -36,6 +40,8 @@ public class DartItems {
|
|||
DartItems.forceshard = reg.registerItem(new BaseItem("forceshard"));
|
||||
DartItems.forcemitts = reg.registerItem(new ItemForceMitts());
|
||||
DartItems.forcepickaxe = reg.registerItem(new ItemForcePickaxe());
|
||||
DartItems.forceshovel = reg.registerItem(new ItemForceShovel());
|
||||
DartItems.forceaxe = reg.registerItem(new ItemForceAxe());
|
||||
DartItems.forceshears = reg.registerItem(new ItemForceShears());
|
||||
DartItems.forceflask = reg.registerItem(new ItemForceFlask());
|
||||
DartItems.entitybottle = reg.registerItem(new ItemEntityBottle());
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package ley.modding.dartcraft.item.tool;
|
||||
|
||||
import ley.modding.dartcraft.Dartcraft;
|
||||
import ley.modding.dartcraft.api.IBreakable;
|
||||
import ley.modding.dartcraft.api.IForceConsumer;
|
||||
import ley.modding.dartcraft.item.DartItems;
|
||||
import ley.modding.dartcraft.util.ForceConsumerUtils;
|
||||
import ley.modding.dartcraft.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
|
||||
public class ItemForceAxe extends ItemAxe implements IBreakable, IForceConsumer {
|
||||
|
||||
private static int damage = 1;
|
||||
private static float efficiency = 5.0F;
|
||||
private static int toolLevel = 10;
|
||||
public static ToolMaterial material = EnumHelper.addToolMaterial("FORCE", toolLevel, 512, efficiency, (float) damage, 0);
|
||||
|
||||
public ItemForceAxe() {
|
||||
super(material);
|
||||
Util.configureItem(this, "forceaxe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setBoolean("active", !stack.getTagCompound().getBoolean("active"));
|
||||
if (!Dartcraft.proxy.isSimulating(world)) {
|
||||
if (stack.getTagCompound().getBoolean("active")) {
|
||||
Dartcraft.proxy.sendChatToPlayer(player, "Area mode activated.");
|
||||
} else {
|
||||
Dartcraft.proxy.sendChatToPlayer(player, "Area mode deactivated");
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored(ItemStack stack) {
|
||||
return ForceConsumerUtils.getStoredForce(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStored(ItemStack var1) {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountUsedBase(ItemStack var1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useForce(ItemStack var1, int var2, boolean var3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attemptRepair(ItemStack stack) {
|
||||
return ForceConsumerUtils.attemptRepair(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemReturned() {
|
||||
return new ItemStack(DartItems.forceshard);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import ley.modding.dartcraft.item.DartItems;
|
|||
import ley.modding.dartcraft.util.ForceConsumerUtils;
|
||||
import ley.modding.dartcraft.util.ForceUpgradeManager;
|
||||
import ley.modding.dartcraft.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
|
@ -123,4 +124,49 @@ public class ItemForcePickaxe extends ItemPickaxe implements IBreakable, IForceC
|
|||
return new int[] { ForceUpgradeManager.HEAT.getID(), ForceUpgradeManager.SPEED.getID(), ForceUpgradeManager.LUCK.getID(), ForceUpgradeManager.TOUCH.getID(), ForceUpgradeManager.STURDY.getID(), ForceUpgradeManager.GRINDING.getID(), ForceUpgradeManager.REPAIR.getID(), ForceUpgradeManager.IMPERVIOUS.getID() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
Block tempBlock = world.getBlock(x, y, z);
|
||||
boolean force = false;
|
||||
if(!this.canHarvestBlock(tempBlock, stack)) {
|
||||
return false;
|
||||
} else {
|
||||
if(stack.hasTagCompound() && stack.getTagCompound().getBoolean("active")) {
|
||||
force = true;
|
||||
}
|
||||
|
||||
if(force) {
|
||||
for(int i = -1; i < 2; ++i) {
|
||||
for(int j = -1; j < 2; ++j) {
|
||||
for(int k = -1; k < 2; ++k) {
|
||||
if(i != 0 || j != 0 || k != 0) {
|
||||
if(stack == null || stack.getItemDamage() >= stack.getMaxDamage()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.tryBlock(stack, x + i, y + j, z + k, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stack != null && stack.getItemDamage() < stack.getMaxDamage())
|
||||
this.tryBlock(stack, x, y, z, player);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void tryBlock(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (this.canHarvestBlock(block, stack) && block.getBlockHardness(world, x, y, z) > 0F & world.getTileEntity(x, y, z) == null) {
|
||||
world.getBlock(x, y, z).harvestBlock(world, player, x, y, z, world.getBlockMetadata(x, y, z));
|
||||
world.setBlockToAir(x, y, z);
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
package ley.modding.dartcraft.item.tool;
|
||||
|
||||
import ley.modding.dartcraft.Dartcraft;
|
||||
import ley.modding.dartcraft.api.IBreakable;
|
||||
import ley.modding.dartcraft.api.IForceConsumer;
|
||||
import ley.modding.dartcraft.item.DartItems;
|
||||
import ley.modding.dartcraft.util.ForceConsumerUtils;
|
||||
import ley.modding.dartcraft.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
|
||||
public class ItemForceShovel extends ItemSpade implements IBreakable, IForceConsumer {
|
||||
|
||||
private static int damage = 1;
|
||||
private static float efficiency = 5.0F;
|
||||
private static int toolLevel = 10;
|
||||
public static ToolMaterial material = EnumHelper.addToolMaterial("FORCE", toolLevel, 512, efficiency, (float) damage, 0);
|
||||
|
||||
public ItemForceShovel() {
|
||||
super(material);
|
||||
Util.configureItem(this, "forceshovel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setBoolean("active", !stack.getTagCompound().getBoolean("active"));
|
||||
if (!Dartcraft.proxy.isSimulating(world)) {
|
||||
if (stack.getTagCompound().getBoolean("active")) {
|
||||
Dartcraft.proxy.sendChatToPlayer(player, "Area mode activated.");
|
||||
} else {
|
||||
Dartcraft.proxy.sendChatToPlayer(player, "Area mode deactivated");
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored(ItemStack stack) {
|
||||
return ForceConsumerUtils.getStoredForce(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStored(ItemStack var1) {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountUsedBase(ItemStack var1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useForce(ItemStack var1, int var2, boolean var3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attemptRepair(ItemStack stack) {
|
||||
return ForceConsumerUtils.attemptRepair(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemReturned() {
|
||||
return new ItemStack(DartItems.forceshard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(Block block, ItemStack itemStack) {
|
||||
return block.getMaterial() == Material.clay || block.getMaterial() == Material.craftedSnow || block.getMaterial() == Material.ground || block.getMaterial() == Material.sand || block.getMaterial() == Material.snow || block.getMaterial() == Material.grass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
Block tempBlock = world.getBlock(x, y, z);
|
||||
boolean force = false;
|
||||
|
||||
if(!this.canHarvestBlock(tempBlock, stack)) {
|
||||
return false;
|
||||
} else {
|
||||
if(stack.hasTagCompound() && stack.getTagCompound().getBoolean("active")) {
|
||||
force = true;
|
||||
}
|
||||
|
||||
if(force) {
|
||||
for(int i = -1; i < 2; ++i) {
|
||||
for(int j = -1; j < 2; ++j) {
|
||||
for(int k = -1; k < 2; ++k) {
|
||||
if(i != 0 || j != 0 || k != 0) {
|
||||
if(stack == null || stack.getItemDamage() >= stack.getMaxDamage()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.tryBlock(stack, x + i, y + j, z + k, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stack != null && stack.getItemDamage() < stack.getMaxDamage())
|
||||
this.tryBlock(stack, x, y, z, player);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void tryBlock(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (this.canHarvestBlock(block, stack) && block.getBlockHardness(world, x, y, z) > 0F & world.getTileEntity(x, y, z) == null) {
|
||||
world.getBlock(x, y, z).harvestBlock(world, player, x, y, z, world.getBlockMetadata(x, y, z));
|
||||
world.setBlockToAir(x, y, z);
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@ item.forcestick.name=Force Stick
|
|||
item.forceshard.name=Force Shard
|
||||
item.forcemitts.name=Force Mitts
|
||||
item.forceshears.name=Force Shears
|
||||
item.forceshovel.name=Force Shovel
|
||||
item.forceaxe.name=Force Axe
|
||||
item.forceflask_empty.name=Force Flask
|
||||
item.forceflask_milk.name=Milk Flask
|
||||
item.forceflask_potion_force.name=Liquid Force Flask
|
||||
|
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Loading…
Reference in a new issue