Added a hoe handler for advanced farming.
This commit is contained in:
parent
9c6f5bd8ee
commit
8a4636cba3
6 changed files with 82 additions and 1 deletions
|
@ -49,6 +49,17 @@ public class ForgeHooks {
|
|||
|
||||
static LinkedList<IBonemealHandler> bonemealHandlers = new LinkedList<IBonemealHandler>();
|
||||
|
||||
public static boolean onUseHoe(ItemStack hoe, EntityPlayer player,
|
||||
World world, int i, int j, int k) {
|
||||
for(IHoeHandler handler : hoeHandlers) {
|
||||
if(handler.onUseHoe(hoe,player,world,i,j,k))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static LinkedList<IHoeHandler> hoeHandlers = new LinkedList<IHoeHandler>();
|
||||
|
||||
public static EnumStatus sleepInBedAt(EntityPlayer player, int i, int j, int k) {
|
||||
for (ISleepHandler handler : sleepHandlers) {
|
||||
EnumStatus status = handler.sleepInBedAt(player, i, j, k);
|
||||
|
|
21
forge/forge_common/net/minecraft/src/forge/IHoeHandler.java
Normal file
21
forge/forge_common/net/minecraft/src/forge/IHoeHandler.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* This software is provided under the terms of the Minecraft Forge Public
|
||||
* License v1.0.
|
||||
*/
|
||||
|
||||
package net.minecraft.src.forge;
|
||||
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
|
||||
public interface IHoeHandler {
|
||||
/** Called when a hoe is used on a block. This is called on both sides
|
||||
* in SMP.
|
||||
* @return true to consume a use of the hoe and return.
|
||||
*/
|
||||
public boolean onUseHoe(ItemStack hoe, EntityPlayer player, World world,
|
||||
int i, int j, int k);
|
||||
|
||||
}
|
||||
|
|
@ -36,6 +36,13 @@ public class MinecraftForge {
|
|||
ForgeHooks.bonemealHandlers.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new hoe handler.
|
||||
*/
|
||||
public static void registerHoeHandler(IHoeHandler handler) {
|
||||
ForgeHooks.hoeHandlers.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new destroy tool handler.
|
||||
*/
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
public boolean hitEntity(ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1)
|
||||
{
|
||||
return false;
|
||||
@@ -473,6 +497,18 @@
|
||||
@@ -473,6 +507,18 @@
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
21
forge/patches/minecraft/net/minecraft/src/ItemHoe.java.patch
Normal file
21
forge/patches/minecraft/net/minecraft/src/ItemHoe.java.patch
Normal file
|
@ -0,0 +1,21 @@
|
|||
--- ../src_base/minecraft/net/minecraft/src/ItemHoe.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src_work/minecraft/net/minecraft/src/ItemHoe.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
+import net.minecraft.src.forge.ForgeHooks;
|
||||
|
||||
// Referenced classes of package net.minecraft.src:
|
||||
// Item, EnumToolMaterial, EntityPlayer, World,
|
||||
@@ -25,6 +26,10 @@
|
||||
{
|
||||
return false;
|
||||
}
|
||||
+ if(ForgeHooks.onUseHoe(itemstack,entityplayer,world,i,j,k)) {
|
||||
+ itemstack.damageItem(1, entityplayer);
|
||||
+ return true;
|
||||
+ }
|
||||
int i1 = world.getBlockId(i, j, k);
|
||||
int j1 = world.getBlockId(i, j + 1, k);
|
||||
if(l != 0 && j1 == 0 && i1 == Block.grass.blockID || i1 == Block.dirt.blockID)
|
|
@ -0,0 +1,21 @@
|
|||
--- ../src_base/minecraft_server/net/minecraft/src/ItemHoe.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src_work/minecraft_server/net/minecraft/src/ItemHoe.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
+import net.minecraft.src.forge.ForgeHooks;
|
||||
|
||||
// Referenced classes of package net.minecraft.src:
|
||||
// Item, EnumToolMaterial, EntityPlayer, World,
|
||||
@@ -25,6 +26,10 @@
|
||||
{
|
||||
return false;
|
||||
}
|
||||
+ if(ForgeHooks.onUseHoe(itemstack,entityplayer,world,i,j,k)) {
|
||||
+ itemstack.damageItem(1, entityplayer);
|
||||
+ return true;
|
||||
+ }
|
||||
int i1 = world.getBlockId(i, j, k);
|
||||
int j1 = world.getBlockId(i, j + 1, k);
|
||||
if(l != 0 && j1 == 0 && i1 == Block.grass.blockID || i1 == Block.dirt.blockID)
|
Loading…
Reference in a new issue