Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Spade behave more like a vanilla Hoe #82

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ dependencies {
api("com.github.GTNewHorizons:CropLoadCore:0.2.0:dev")
api("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")

devOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.50.49:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.50.61:dev")
compileOnly(deobf("https://media.forgecdn.net/files/2499/612/BiomesOPlenty-1.7.10-2.1.0.2308-universal.jar"))
compileOnly("com.github.GTNewHorizons:twilightforest:2.6.34:dev") {
compileOnly("com.github.GTNewHorizons:twilightforest:2.6.35:dev") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.12-GTNH:dev")
compileOnly("com.github.GTNewHorizons:Natura:2.7.4:dev") {
compileOnly("com.github.GTNewHorizons:Natura:2.7.5:dev") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:NewHorizonsCoreMod:2.6.68:dev") {
compileOnly("com.github.GTNewHorizons:NewHorizonsCoreMod:2.6.74:dev") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:Galacticraft:3.2.5-GTNH:dev") {
Expand All @@ -23,10 +23,10 @@ dependencies {

// for testing
//runtimeOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
//runtimeOnly("com.github.GTNewHorizons:twilightforest:2.6.34:dev")
//runtimeOnly("com.github.GTNewHorizons:twilightforest:2.6.35:dev")
//runtimeOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.12-GTNH:dev")
//runtimeOnly("com.github.GTNewHorizons:EnderIO:2.8.19:dev")
//runtimeOnly("com.github.GTNewHorizons:Natura:2.7.4:dev")
//runtimeOnly("com.github.GTNewHorizons:NewHorizonsCoreMod:2.6.68:dev")
//runtimeOnly("com.github.GTNewHorizons:EnderIO:2.8.20:dev")
//runtimeOnly("com.github.GTNewHorizons:Natura:2.7.5:dev")
//runtimeOnly("com.github.GTNewHorizons:NewHorizonsCoreMod:2.6.74:dev")
//runtimeOnly("com.github.GTNewHorizons:Galacticraft:3.2.5-GTNH:dev")
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.27'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.29'
}


Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
import net.minecraft.item.ItemTool;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.UseHoeEvent;

import com.github.bartimaeusnek.croploadcore.MyRandom;
import com.github.bartimaeusnek.croploadcore.Operators;
import com.google.common.collect.Sets;

import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ic2.core.IC2;
Expand Down Expand Up @@ -107,18 +110,43 @@ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world,
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float hitX, float hitY, float hitZ) {
if (side != 0 && world.getBlock(x, y + 1, z).getMaterial() == Material.air
&& (world.getBlock(x, y, z) == Blocks.grass || world.getBlock(x, y, z) == Blocks.dirt
|| world.getBlock(x, y, z) == Blocks.mycelium)) {
world.setBlock(x, y, z, Blocks.farmland);
if (!player.canPlayerEdit(x, y, z, side, stack)) {
return false;
}

var event = new UseHoeEvent(player, stack, world, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event)) {
return false;
}

if (event.getResult() == Event.Result.ALLOW) {
return true;
} else if (side != 0 && world.getBlock(x, y + 1, z).getMaterial() == Material.air
&& (world.getBlock(x, y, z) == Blocks.farmland)) {
world.setBlock(x, y, z, Blocks.dirt);
return true;
} else {
return false;
}

if (side != 0 && world.getBlock(x, y + 1, z).getMaterial() == Material.air) {
if (world.getBlock(x, y, z) == Blocks.grass || world.getBlock(x, y, z) == Blocks.dirt
|| world.getBlock(x, y, z) == Blocks.mycelium
|| world.getBlock(x, y, z) == Blocks.farmland) {
var spadeBlock = Blocks.farmland;
world.playSoundEffect(
x + 0.5f,
y + 0.5f,
z + 0.5f,
spadeBlock.stepSound.getStepResourcePath(),
(spadeBlock.stepSound.getVolume() + 1f) / 2f,
spadeBlock.stepSound.getPitch() * 0.8f);
if (!world.isRemote) {
world.setBlock(
x,
y,
z,
(world.getBlock(x, y, z) == Blocks.farmland) ? Blocks.dirt : Blocks.farmland);
}
return true;
}
}

return false;
}

@Override
Expand Down