mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Corporea Funnel.
This commit is contained in:
1 parent
6f608edeed
commit
d698cad9f5
11 files changed
+164
-5
No files matched your search
@@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.block.corporea.BlockCorporeaFunnel;
|
||||
import vazkii.botania.common.block.corporea.BlockCorporeaIndex;
|
||||
import vazkii.botania.common.block.decor.BlockBuriedPetals;
|
||||
import vazkii.botania.common.block.decor.BlockCustomBrick;
|
||||
@@ -118,6 +119,7 @@ import vazkii.botania.common.block.tile.TileStarfield;
|
||||
import vazkii.botania.common.block.tile.TileTerraPlate;
|
||||
import vazkii.botania.common.block.tile.TileTinyPlanet;
|
||||
import vazkii.botania.common.block.tile.TileTinyPotato;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaFunnel;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
|
||||
import vazkii.botania.common.block.tile.mana.TileDistributor;
|
||||
import vazkii.botania.common.block.tile.mana.TileManaDetector;
|
||||
@@ -197,6 +199,7 @@ public final class ModBlocks {
|
||||
public static Block enchantedSoil;
|
||||
public static Block petalBlock;
|
||||
public static Block corporeaIndex;
|
||||
public static Block corporeaFunnel;
|
||||
|
||||
public static void init() {
|
||||
flower = new BlockModFlower();
|
||||
@@ -257,6 +260,7 @@ public final class ModBlocks {
|
||||
enchantedSoil = new BlockEnchantedSoil();
|
||||
petalBlock = new BlockPetalBlock();
|
||||
corporeaIndex = new BlockCorporeaIndex();
|
||||
corporeaFunnel = new BlockCorporeaFunnel();
|
||||
|
||||
ModFluffBlocks.init();
|
||||
|
||||
@@ -324,6 +328,7 @@ public final class ModBlocks {
|
||||
registerTile(TileManaFlame.class, LibBlockNames.MANA_FLAME);
|
||||
registerTile(TilePrism.class, LibBlockNames.PRISM);
|
||||
registerTile(TileCorporeaIndex.class, LibBlockNames.CORPOREA_INDEX);
|
||||
registerTile(TileCorporeaFunnel.class, LibBlockNames.CORPOREA_FUNNEL);
|
||||
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class);
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@ import vazkii.botania.common.block.BlockModContainer;
|
||||
import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
|
||||
|
||||
public abstract class BlockCorporea extends BlockModContainer<TileCorporeaBase> {
|
||||
public abstract class BlockCorporeaBase extends BlockModContainer<TileCorporeaBase> {
|
||||
|
||||
Random random;
|
||||
|
||||
public BlockCorporea(Material material, String name) {
|
||||
public BlockCorporeaBase(Material material, String name) {
|
||||
super(material);
|
||||
setBlockName(name);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Feb 16, 2015, 2:17:05 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.corporea;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaFunnel;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockCorporeaFunnel extends BlockCorporeaBase {
|
||||
|
||||
IIcon[] icons;
|
||||
|
||||
public BlockCorporeaFunnel() {
|
||||
super(Material.iron, LibBlockNames.CORPOREA_FUNNEL);
|
||||
setHardness(5.5F);
|
||||
setStepSound(soundTypeMetal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
icons = new IIcon[3];
|
||||
for(int i = 0; i < icons.length; i++)
|
||||
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
boolean powered = (meta & 8) != 0;
|
||||
|
||||
if(power && !powered) {
|
||||
((TileCorporeaFunnel) world.getTileEntity(x, y, z)).doRequest();
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4);
|
||||
} else if(!power && powered)
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int par1, int par2) {
|
||||
return icons[Math.min(2, par1)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileCorporeaBase createNewTileEntity(World world, int meta) {
|
||||
return new TileCorporeaFunnel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCorporeaIndex extends BlockCorporea {
|
||||
public class BlockCorporeaIndex extends BlockCorporeaBase {
|
||||
|
||||
public BlockCorporeaIndex() {
|
||||
super(Material.iron, LibBlockNames.CORPOREA_INDEX);
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Feb 16, 2015, 2:18:30 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.corporea;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class TileCorporeaFunnel extends TileCorporeaBase {
|
||||
|
||||
public void doRequest() {
|
||||
ICorporeaSpark spark = getSpark();
|
||||
if(spark != null && spark.getMaster() != null) {
|
||||
IInventory inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 1, zCoord);
|
||||
if(inv == null)
|
||||
inv = InventoryHelper.getInventory(worldObj, xCoord, yCoord - 2, zCoord);
|
||||
|
||||
List<ItemStack> filter = getFilter();
|
||||
if(!filter.isEmpty()) {
|
||||
ItemStack stack = filter.get(worldObj.rand.nextInt(filter.size()));
|
||||
|
||||
List<ItemStack> stacks = CorporeaHelper.requestItem(stack, spark, true, true);
|
||||
spark.onItemsRequested(stacks);
|
||||
for(ItemStack reqStack : stacks)
|
||||
if(stack != null) {
|
||||
if(inv != null && reqStack.stackSize == InventoryHelper.testInventoryInsertion(inv, stack, ForgeDirection.UP))
|
||||
InventoryHelper.insertItemIntoInventory(inv, reqStack);
|
||||
else {
|
||||
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ItemStack> getFilter() {
|
||||
List<ItemStack> filter = new ArrayList();
|
||||
|
||||
final int[] orientationToDir = new int[] {
|
||||
3, 4, 2, 5
|
||||
};
|
||||
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
List<EntityItemFrame> frames = worldObj.getEntitiesWithinAABB(EntityItemFrame.class, AxisAlignedBB.getBoundingBox(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1));
|
||||
for(EntityItemFrame frame : frames) {
|
||||
int orientation = frame.hangingDirection;
|
||||
if(orientationToDir[orientation] == dir.ordinal())
|
||||
filter.add(frame.getDisplayedItem());
|
||||
}
|
||||
}
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return LibBlockNames.CORPOREA_FUNNEL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import net.minecraftforge.event.ServerChatEvent;
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.common.core.helper.MathHelper;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class TileCorporeaIndex extends TileCorporeaBase {
|
||||
@@ -185,12 +186,12 @@ public class TileCorporeaIndex extends TileCorporeaBase {
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return null;
|
||||
return LibBlockNames.CORPOREA_INDEX;
|
||||
}
|
||||
|
||||
public static boolean isInRangeOfIndex(EntityPlayer player, TileCorporeaIndex index) {
|
||||
|
||||
@@ -73,6 +73,7 @@ public final class LibBlockNames {
|
||||
public static final String BIOME_STONE_B = "biomeStoneB";
|
||||
public static final String PETAL_BLOCK = "petalBlock";
|
||||
public static final String CORPOREA_INDEX = "corporeaIndex";
|
||||
public static final String CORPOREA_FUNNEL = "corporeaFunnel";
|
||||
|
||||
public static final String SUBTILE_PUREDAISY = "puredaisy";
|
||||
public static final String SUBTILE_MANASTAR = "manastar";
|
||||
|
||||
Reference in new issue
Block a user