Finished Force Mitts

This commit is contained in:
Timo Ley 2021-04-16 23:07:44 +02:00
parent 613df94604
commit 9c6d2e83b3
6 changed files with 97 additions and 3 deletions

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.arboriculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IToolGrafter {
/**
* Called by leaves to determine the increase in sapling droprate.
*
* @param stack ItemStack containing the grafter.
* @param world Minecraft world the player and the target block inhabit.
* @param x x-Coordinate of the broken leaf block.
* @param y y-Coordinate of the broken leaf block.
* @param z z-Coordinate of the broken leaf block.
* @return Float representing the factor the usual drop chance is to be multiplied by.
*/
float getSaplingModifier(ItemStack stack, World world, EntityPlayer player, int x, int y, int z);
}

View file

@ -1,10 +1,13 @@
package ley.modding.dartcraft.item.tool;
import cpw.mods.fml.common.eventhandler.Event;
import forestry.api.arboriculture.IToolGrafter;
import ley.modding.dartcraft.Dartcraft;
import ley.modding.dartcraft.api.IBreakable;
import ley.modding.dartcraft.item.DartItems;
import ley.modding.dartcraft.util.EntityUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@ -21,13 +24,14 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class ItemForceMitts extends ItemTool implements IBreakable {
public class ItemForceMitts extends ItemTool implements IBreakable, IToolGrafter {
private static int damage = 0;
private static float efficiency = 16.0F;
private static int toolLevel = 4;
public static ToolMaterial material = EnumHelper.addToolMaterial("FORCE", toolLevel, 256, efficiency, (float)damage, 0);
public ArrayList<Block> mineableBlocks = new ArrayList<Block>();
private int range = 2;
public ItemForceMitts() {
super(0.0F, material, new HashSet());
@ -111,7 +115,72 @@ public class ItemForceMitts extends ItemTool implements IBreakable {
stack.damageItem(1, player);
return true;
}
} //TODO Fix Hoe thing
return false;
}
Block block = world.getBlock(x, y, z);
if (par7 != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt))
{
Block block1 = Blocks.farmland;
world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
if (world.isRemote)
{
return true;
}
else
{
world.setBlock(x, y, z, block1);
stack.damageItem(1, player);
return true;
}
}
else
{
return false;
}
}
@Override
public float getSaplingModifier(ItemStack stack, World world, EntityPlayer player, int x, int y, int z) {
return 100.0F;
}
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
World world = player.worldObj;
if(!Dartcraft.proxy.isSimulating(world)) {
return false;
} else {
Block block = world.getBlock(x, y, z);
if (block != null) {
Material mat = block.getMaterial();
if ((!(block instanceof BlockFlower)) && (mat == null || mat != Material.leaves)) {
return false;
} else {
for (int i = 0 - this.range; i < 1 + this.range; ++i) {
for (int j = 0 - this.range; j < 1 + this.range; ++j) {
for (int k = 0 - this.range; k < 1 + this.range; ++k) {
int newX = x + i;
int newY = y + j;
int newZ = z + k;
Block block2 = world.getBlock(newX, newY, newZ);
if (block2 instanceof BlockFlower || block2 != null && block2.getMaterial() == Material.leaves) {
world.getBlock(x + i, y + j, z + k).harvestBlock(world, player, x + i, y + j, z + k, world.getBlockMetadata(x + i, y + j, z + k));
world.setBlockToAir(x + i, y + j, z + k);
if (i == 0 && j == 0 && k == 0) {
//PacketDispatcher.sendPacketToAllAround((double) x, (double) y, (double) z, 30.0D, player.field_71093_bK, (new FXPacket(17, (double) x, (double) y, (double) z)).getPacket());
}
}
}
}
}
stack.damageItem(1, player);
world.playSoundEffect((double) x, (double) y, (double) z, "dartcraft:fly", 0.75F, EntityUtils.randomPitch());
return true;
}
}
return false;
}
}
}

View file

@ -1,5 +1,6 @@
{
"bottle": {"category": "master","sounds": [{"name": "bottle","stream": false}]},
"swipe": {"category": "master","sounds": [{"name": "swipe","stream": false}]},
"fly": {"category": "master","sounds": [{"name": "fly1","stream": false}, {"name": "fly2","stream": false}, {"name": "fly3","stream": false}]},
"nope": {"category": "master","sounds": [{"name": "nope","stream": false}]}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.