mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Add flower interaction methods
- Add onBlockPlacedBy() - Add onBlockActivated() - Add onBlockAdded() - Add onBlockHarvested() - Add getDrops()
This commit is contained in:
1 parent
7bd3287878
commit
50d8cf5587
5 files changed
+111
-4
No files matched your search
@@ -11,19 +11,23 @@
|
||||
*/
|
||||
package vazkii.botania.api.subtile;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.wand.IWandBindable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A Sub-TileEntity, this is used for the flower system. Make sure to map subclasses
|
||||
@@ -101,6 +105,39 @@ public class SubTileEntity {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this sub tile is placed in the world (by an entity).
|
||||
*/
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player right clicks this sub tile.
|
||||
*/
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { return false; }
|
||||
|
||||
/**
|
||||
* Called when this sub tile is added to the world.
|
||||
*/
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this sub tile is harvested
|
||||
*/
|
||||
public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) {
|
||||
//NO-OP
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows additional processing of sub tile drops
|
||||
*/
|
||||
public ArrayList<ItemStack> getDrops(ArrayList<ItemStack> list) {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon.
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Random;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -71,8 +72,10 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) {
|
||||
if(!par6EntityPlayer.capabilities.isCreativeMode)
|
||||
if(!par6EntityPlayer.capabilities.isCreativeMode) {
|
||||
dropBlockAsItem(par1World, par2, par3, par4, par5, 0);
|
||||
((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)).onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,6 +86,7 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I
|
||||
if(tile != null) {
|
||||
String name = ((TileSpecialFlower) tile).subTileName;
|
||||
list.add(ItemBlockSpecialFlower.ofType(new ItemStack(world.getBlock(x, y, z)), name));
|
||||
((TileSpecialFlower) tile).getDrops(list);
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -100,6 +104,21 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I
|
||||
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||
((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
|
||||
((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res);
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -147,8 +148,10 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) {
|
||||
if(!par6EntityPlayer.capabilities.isCreativeMode)
|
||||
if(!par6EntityPlayer.capabilities.isCreativeMode) {
|
||||
dropBlockAsItem(par1World, par2, par3, par4, par5, 0);
|
||||
((TileSpecialFlower) par1World.getTileEntity(par2, par3, par4)).onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,6 +162,7 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid
|
||||
if(tile != null) {
|
||||
String name = ((TileSpecialFlower) tile).subTileName;
|
||||
list.add(ItemBlockSpecialFlower.ofType(name));
|
||||
((TileSpecialFlower) tile).getDrops(list);
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -186,6 +190,21 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid
|
||||
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||
((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entity, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockAdded(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
|
||||
((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res);
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -20,6 +21,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.ISubTileContainer;
|
||||
@@ -27,6 +29,8 @@ import vazkii.botania.api.subtile.SubTileEntity;
|
||||
import vazkii.botania.api.wand.IWandBindable;
|
||||
import vazkii.botania.common.block.tile.string.TileRedStringRelay;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTileContainer {
|
||||
|
||||
private static final String TAG_SUBTILE_NAME = "subTileName";
|
||||
@@ -132,6 +136,32 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil
|
||||
return subTile == null ? false : subTile.onWanded(player, wand);
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||
if (subTile != null)
|
||||
subTile.onBlockPlacedBy(world, x, y, z, entity, stack);
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
return subTile == null ? false : subTile.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
if (subTile != null)
|
||||
subTile.onBlockAdded(world, x, y, z);
|
||||
}
|
||||
|
||||
public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) {
|
||||
if (subTile != null)
|
||||
subTile.onBlockHarvested(world, x, y, z, side, player);
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getDrops(ArrayList<ItemStack> list) {
|
||||
if (subTile != null)
|
||||
subTile.getDrops(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
if(subTile != null)
|
||||
subTile.renderHUD(mc, res);
|
||||
|
||||
@@ -54,6 +54,8 @@ public class ItemBlockSpecialFlower extends ItemBlockMod implements IRecipeKeyPr
|
||||
if(te instanceof TileSpecialFlower) {
|
||||
TileSpecialFlower tile = (TileSpecialFlower) te;
|
||||
tile.setSubTile(type);
|
||||
tile.onBlockAdded(world, x, y, z);
|
||||
tile.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
if(!world.isRemote)
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user