Fixed Hoe module and a few other things.

This commit is contained in:
Leon 2016-12-03 19:41:38 -05:00
parent f3857432fa
commit 84d3356c2f
23 changed files with 65 additions and 36 deletions

View file

@ -8,7 +8,7 @@ import net.minecraft.world.World;
public interface IRightClickModule extends IPowerModule {
void onRightClick(EntityPlayer playerClicking, World world, ItemStack item);
void onItemUse(
boolean onItemUse(
ItemStack itemStack, EntityPlayer player, World world,
int x, int y, int z,
int side, float hitX, float hitY, float hitZ);

View file

@ -271,7 +271,7 @@ public class ItemPowerFist extends MPSItemElectricTool
IPowerModule module2;
IPowerModule module = module2 = ModuleManager.getModule(mode);
if (module2 instanceof IRightClickModule) {
((IRightClickModule)module2).onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ);
return ((IRightClickModule)module2).onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
return false;
}

View file

@ -18,7 +18,8 @@ public class RightClickPowerModule extends PowerModule implements IRightClickMod
}
@Override
public void onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -55,7 +55,8 @@ public class InPlaceAssemblerModule extends PowerModuleBase implements IRightCli
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -73,7 +73,8 @@ public class BlinkDriveModule extends PowerModuleBase implements IRightClickModu
}
@Override
public void onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -67,7 +67,8 @@ public class AppEngWirelessFluidModule extends PowerModuleBase implements IRight
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -61,7 +61,8 @@ public class AppEngWirelessModule extends PowerModuleBase implements IRightClick
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -88,7 +88,8 @@ public class DimensionalRiftModule extends PowerModuleBase implements IRightClic
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -47,8 +47,8 @@ public class FieldTinkerModule extends PowerModuleBase implements IRightClickMod
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -72,7 +72,7 @@ public class FlintAndSteelModule extends PowerModuleBase implements IRightClickM
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
double energyConsumption = ModuleManager.computeModularProperty(itemStack, IGNITION_ENERGY_CONSUMPTION);
if (energyConsumption < ElectricItemUtils.getPlayerEnergy(player)) {
x += (side == 5 ? 1 : side == 4 ? -1 : 0);
@ -86,9 +86,11 @@ public class FlintAndSteelModule extends PowerModuleBase implements IRightClickM
ElectricItemUtils.drainPlayerEnergy(player, energyConsumption);
world.playSoundEffect((double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "fire.ignite", 1.0F, ran.nextFloat() * 0.4F + 0.8F);
world.setBlock(x, y, z, Blocks.fire);
return true;
}
}
}
return false;
}
@Override

View file

@ -41,40 +41,50 @@ public class HoeModule extends PowerModuleBase implements IPowerModule, IRightCl
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
double energyConsumed = ModuleManager.computeModularProperty(itemStack, HOE_ENERGY_CONSUMPTION);
if (player.canPlayerEdit(x, y, z, side, itemStack) && ElectricItemUtils.getPlayerEnergy(player) > energyConsumed) {
UseHoeEvent event = new UseHoeEvent(player, itemStack, world, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event)) {
return;
return false;
}
if (event.getResult() == Event.Result.ALLOW) {
ElectricItemUtils.drainPlayerEnergy(player, energyConsumed);
return;
return true;
}
if (world.isRemote) {
return;
return true;
}
boolean used = false;
double radius = (int) ModuleManager.computeModularProperty(itemStack, HOE_SEARCH_RADIUS);
int newX, newZ;
for (int i = (int) Math.floor(-radius); i < radius; i++) {
for (int j = (int) Math.floor(-radius); j < radius; j++) {
if (i * i + j * j < radius * radius) {
Block block = world.getBlock(x + i, y, z + j);
if (block == Blocks.grass || block == Blocks.dirt) {
world.setBlock(x + i, y, z + j, Blocks.farmland);
newX = x + i;
newZ = z+ j;
Block block = world.getBlock(newX, y, newZ);
if (side != 0 && world.getBlock(newX, y + 1, newZ).isAir(world, newX, y + 1, newZ) && (block == Blocks.grass || block == Blocks.dirt)) {
world.setBlock(newX, y, newZ, Blocks.farmland);
ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(itemStack, HOE_ENERGY_CONSUMPTION));
used = true;
}
}
}
}
// TODO: Proper sound effect
// world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F),
// Blocks.farmland.stepSound.getStepSound(), (Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F,
// Blocks.farmland.stepSound.getPitch() * 0.8F);
if (used) {
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F),
Blocks.farmland.stepSound.getStepResourcePath(), (Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F,
Blocks.farmland.stepSound.getPitch() * 0.8F);
return true;
}
}
return false;
}
@Override

View file

@ -82,7 +82,7 @@ public class LeafBlowerModule extends PowerModuleBase implements IRightClickModu
return false;
// Plants
if ((blocktype == "plants") && (block instanceof BlockTallGrass || block instanceof BlockFlower) && block.canHarvestBlock(player, meta)) {
if ((blocktype == "plants") && (block instanceof BlockBush) && block.canHarvestBlock(player, meta)) {
block.harvestBlock(world, player, x, y, z, meta);
world.setBlockToAir(x, y, z);
return true;
@ -104,7 +104,7 @@ public class LeafBlowerModule extends PowerModuleBase implements IRightClickModu
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block blockID = world.getBlock(x, y, z);
int plant = (int) ModuleManager.computeModularProperty(itemStack, PLANT_RADIUS);
int leaf = (int) ModuleManager.computeModularProperty(itemStack, LEAF_RADIUS);
@ -117,6 +117,7 @@ public class LeafBlowerModule extends PowerModuleBase implements IRightClickModu
useBlower(leaf, "leaves", itemStack, player, world, x, y, z);
// Snow
useBlower(snow, "snow", itemStack, player, world, x, y, z);
return false;
}
private void useBlower(int radius, String blocktypename , ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z) {

View file

@ -74,7 +74,8 @@ public class LuxCapacitor extends PowerModuleBase implements IRightClickModule {
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -98,7 +98,8 @@ public class OmniProbeModule extends PowerModuleBase implements IRightClickModul
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -56,7 +56,8 @@ public class OmniWrenchModule extends PowerModuleBase implements IRightClickModu
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -175,8 +175,9 @@ public class OreScannerModule extends PowerModuleBase implements IRightClickModu
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
searchForValuables(itemStack, player, world, x, y, z, side);
return true;
}
@Override

View file

@ -63,7 +63,8 @@ public class PersonalShrinkingModule extends PowerModuleBase implements IRightCl
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -94,7 +94,8 @@ public class ShearsModule extends PowerModuleBase implements IBlockBreakingModul
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -60,7 +60,8 @@ public class BladeLauncherModule extends PowerModuleBase implements IRightClickM
}
@Override
public void onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -85,7 +85,8 @@ public class LightningModule extends PowerModuleBase implements IRightClickModul
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -69,7 +69,8 @@ public class PlasmaCannonModule extends PowerModuleBase implements IRightClickMo
}
@Override
public void onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -134,8 +134,8 @@ public class RailgunModule extends PowerModuleBase implements IRightClickModule,
}
@Override
public void onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override

View file

@ -47,7 +47,8 @@ public class SonicWeaponModule extends PowerModuleBase implements IRightClickMod
}
@Override
public void onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
return false;
}
@Override