mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 02:55:17 +00:00
Fix up dispenser handling, add in new params for the dispenser: breaks IDispenseHandler, sorry
This commit is contained in:
1 parent
38f4a22bc4
commit
6e6436ee41
8 files changed
+52
-7
No files matched your search
@@ -195,9 +195,10 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseModPr
|
|||||||
* @param item
|
* @param item
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item)
|
@Override
|
||||||
|
public int dispenseEntity(World world, ItemStack item, Random rnd, double x, double y, double z, int xVel, int zVel, double entX, double entY, double entZ)
|
||||||
{
|
{
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package cpw.mods.fml.common;
|
package cpw.mods.fml.common;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
import net.minecraft.src.World;
|
import net.minecraft.src.World;
|
||||||
|
|
||||||
@@ -21,13 +23,19 @@ public interface IDispenseHandler
|
|||||||
/**
|
/**
|
||||||
* Return -1 if you don't want to dispense anything. the other values seem to have specific meanings
|
* Return -1 if you don't want to dispense anything. the other values seem to have specific meanings
|
||||||
* to blockdispenser.
|
* to blockdispenser.
|
||||||
|
*
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
* @param z
|
* @param z
|
||||||
* @param xVelocity
|
* @param xVelocity
|
||||||
* @param zVelocity
|
* @param zVelocity
|
||||||
* @param data
|
* @param world
|
||||||
|
* @param item
|
||||||
|
* @param random
|
||||||
|
* @param entX
|
||||||
|
* @param entY
|
||||||
|
* @param entZ
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int dispense(double x, double y, double z, int xVelocity, int zVelocity, World world, ItemStack item);
|
int dispense(double x, double y, double z, int xVelocity, int zVelocity, World world, ItemStack item, Random random, double entX, double entY, double entZ);
|
||||||
}
|
}
|
||||||
@@ -85,4 +85,7 @@ public interface BaseModProxy
|
|||||||
public abstract void receiveChatPacket(String text);
|
public abstract void receiveChatPacket(String text);
|
||||||
|
|
||||||
public abstract void onItemPickup(EntityPlayer player, ItemStack item);
|
public abstract void onItemPickup(EntityPlayer player, ItemStack item);
|
||||||
|
|
||||||
|
public abstract int dispenseEntity(World world, ItemStack item, Random rnd, double x, double y, double z, int xVel, int zVel, double entX,
|
||||||
|
double entY, double entZ);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package cpw.mods.fml.common.modloader;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.src.ItemStack;
|
||||||
|
import net.minecraft.src.World;
|
||||||
|
import cpw.mods.fml.common.IDispenseHandler;
|
||||||
|
|
||||||
|
public class ModLoaderDispenseHelper implements IDispenseHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
private BaseModProxy mod;
|
||||||
|
|
||||||
|
public ModLoaderDispenseHelper(BaseModProxy mod)
|
||||||
|
{
|
||||||
|
this.mod = mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int dispense(double x, double y, double z, int xVelocity, int zVelocity, World world, ItemStack item, Random random, double entX, double entY,
|
||||||
|
double entZ)
|
||||||
|
{
|
||||||
|
return mod.dispenseEntity(world, item, random, x, y, z, xVelocity, zVelocity, entX, entY, entZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ import net.minecraft.src.Container;
|
|||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.ICraftingHandler;
|
import cpw.mods.fml.common.ICraftingHandler;
|
||||||
|
import cpw.mods.fml.common.IDispenseHandler;
|
||||||
import cpw.mods.fml.common.IFuelHandler;
|
import cpw.mods.fml.common.IFuelHandler;
|
||||||
import cpw.mods.fml.common.IPickupNotifier;
|
import cpw.mods.fml.common.IPickupNotifier;
|
||||||
import cpw.mods.fml.common.IWorldGenerator;
|
import cpw.mods.fml.common.IWorldGenerator;
|
||||||
@@ -145,4 +146,9 @@ public class ModLoaderHelper
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IDispenseHandler buildDispenseHelper(BaseModProxy mod)
|
||||||
|
{
|
||||||
|
return new ModLoaderDispenseHelper(mod);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -514,6 +514,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||||||
GameRegistry.registerFuelHandler(ModLoaderHelper.buildFuelHelper(mod));
|
GameRegistry.registerFuelHandler(ModLoaderHelper.buildFuelHelper(mod));
|
||||||
GameRegistry.registerCraftingHandler(ModLoaderHelper.buildCraftingHelper(mod));
|
GameRegistry.registerCraftingHandler(ModLoaderHelper.buildCraftingHelper(mod));
|
||||||
GameRegistry.registerPickupHandler(ModLoaderHelper.buildPickupHelper(mod));
|
GameRegistry.registerPickupHandler(ModLoaderHelper.buildPickupHelper(mod));
|
||||||
|
GameRegistry.registerDispenserHandler(ModLoaderHelper.buildDispenseHelper(mod));
|
||||||
NetworkRegistry.instance().registerConnectionHandler(ModLoaderHelper.buildConnectionHelper(mod));
|
NetworkRegistry.instance().registerConnectionHandler(ModLoaderHelper.buildConnectionHelper(mod));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -104,11 +104,11 @@ public class GameRegistry
|
|||||||
* @param item
|
* @param item
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static int tryDispense(World world, double x, double y, double z, int xVelocity, int zVelocity, ItemStack item)
|
public static int tryDispense(World world, double x, double y, double z, int xVelocity, int zVelocity, ItemStack item, Random random, double entX, double entY, double entZ)
|
||||||
{
|
{
|
||||||
for (IDispenseHandler handler : dispenserHandlers)
|
for (IDispenseHandler handler : dispenserHandlers)
|
||||||
{
|
{
|
||||||
int dispensed = handler.dispense(x, y, z, xVelocity, zVelocity, world, item);
|
int dispensed = handler.dispense(x, y, z, xVelocity, zVelocity, world, item, random, entX, entY, entZ);
|
||||||
if (dispensed>-1)
|
if (dispensed>-1)
|
||||||
{
|
{
|
||||||
return dispensed;
|
return dispensed;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
float var15 = 1.1F;
|
float var15 = 1.1F;
|
||||||
byte var16 = 6;
|
byte var16 = 6;
|
||||||
-
|
-
|
||||||
+ int modDispense = GameRegistry.tryDispense(p_72283_1_, p_72283_9_, p_72283_11_, p_72283_13_, p_72283_7_, p_72283_8_, p_72283_2_);
|
+ int modDispense = GameRegistry.tryDispense(p_72283_1_, p_72283_9_, p_72283_11_, p_72283_13_, p_72283_7_, p_72283_8_, p_72283_2_, p_72283_3_, p_72283_9_, p_72283_11_, p_72283_13_);
|
||||||
+ if (modDispense > -1)
|
+ if (modDispense > -1)
|
||||||
+ {
|
+ {
|
||||||
+ return modDispense;
|
+ return modDispense;
|
||||||
|
|||||||
Reference in new issue
Block a user