mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Added the Crafty Crate, it's pretty crafty.
This commit is contained in:
1 parent
816baf9443
commit
031ad11ebd
10 files changed
+123
-7
No files matched your search
@@ -27,6 +27,7 @@ import net.minecraft.world.World;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.block.tile.TileCraftCrate;
|
||||
import vazkii.botania.common.block.tile.TileOpenCrate;
|
||||
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
@@ -85,7 +86,7 @@ public class BlockOpenCrate extends BlockModContainer implements ILexiconable {
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileOpenCrate();
|
||||
return meta == 0 ? new TileOpenCrate() : new TileCraftCrate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,6 +81,7 @@ import vazkii.botania.common.block.subtile.generating.SubTileThermalily;
|
||||
import vazkii.botania.common.block.tile.TileAlfPortal;
|
||||
import vazkii.botania.common.block.tile.TileAltar;
|
||||
import vazkii.botania.common.block.tile.TileBifrost;
|
||||
import vazkii.botania.common.block.tile.TileCraftCrate;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
import vazkii.botania.common.block.tile.TileForestEye;
|
||||
import vazkii.botania.common.block.tile.TileManaBeacon;
|
||||
@@ -367,6 +368,7 @@ public final class ModBlocks {
|
||||
registerTile(TileTurntable.class, LibBlockNames.TURNTABLE);
|
||||
registerTile(TileTinyPlanet.class, LibBlockNames.TINY_PLANET);
|
||||
registerTile(TileOpenCrate.class, LibBlockNames.OPEN_CRATE);
|
||||
registerTile(TileCraftCrate.class, LibBlockNames.CRAFT_CRATE);
|
||||
registerTile(TileForestEye.class, LibBlockNames.FOREST_EYE);
|
||||
registerTile(TilePlatform.class, LibBlockNames.PLATFORM);
|
||||
registerTile(TileAlfPortal.class, LibBlockNames.ALF_PORTAL);
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Jul 26, 2014, 4:50:20 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
public class TileCraftCrate extends TileOpenCrate {
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return i != 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if(!worldObj.isRemote && craft() && canEject())
|
||||
ejectAll();
|
||||
}
|
||||
|
||||
boolean craft() {
|
||||
if(!isFull())
|
||||
return false;
|
||||
|
||||
InventoryCrafting craft = new InventoryCrafting(new Container() {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_) {
|
||||
return false;
|
||||
}
|
||||
}, 3, 3);
|
||||
for(int i = 0; i < 9; i++) {
|
||||
ItemStack stack = getStackInSlot(i);
|
||||
if(stack == null)
|
||||
return false; // Should never get here, but just in case.
|
||||
|
||||
if(stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11)
|
||||
continue;
|
||||
craft.setInventorySlotContents(i, stack.copy());
|
||||
}
|
||||
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for(IRecipe recipe : recipes)
|
||||
if(recipe.matches(craft, worldObj)) {
|
||||
setInventorySlotContents(9, recipe.getCraftingResult(craft));
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
ItemStack stack = getStackInSlot(i);
|
||||
if(stack == null)
|
||||
continue;
|
||||
|
||||
ItemStack container = stack.getItem().getContainerItem(stack);
|
||||
setInventorySlotContents(i, container);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isFull() {
|
||||
for(int i = 0; i < 9; i++)
|
||||
if(getStackInSlot(i) == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ejectAll() {
|
||||
for(int i = 0; i < getSizeInventory(); i++) {
|
||||
ItemStack stack = getStackInSlot(i);
|
||||
if(stack != null)
|
||||
eject(stack, false);
|
||||
setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,19 +38,19 @@ public class TileOpenCrate extends TileSimpleInventory {
|
||||
redstone = true;
|
||||
}
|
||||
|
||||
if(canRelease()) {
|
||||
if(canEject()) {
|
||||
ItemStack stack = getStackInSlot(0);
|
||||
if(stack != null)
|
||||
release(stack, redstone);
|
||||
eject(stack, redstone);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canRelease() {
|
||||
public boolean canEject() {
|
||||
Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord);
|
||||
return blockBelow.isAir(worldObj, xCoord, yCoord - 1, zCoord);
|
||||
}
|
||||
|
||||
public void release(ItemStack stack, boolean redstone) {
|
||||
public void eject(ItemStack stack, boolean redstone) {
|
||||
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.5, zCoord + 0.5, stack);
|
||||
item.motionX = 0;
|
||||
item.motionY = 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemManaResource extends ItemMod implements IFlowerComponent, IElvenItem {
|
||||
|
||||
final int types = 11;
|
||||
final int types = 12;
|
||||
IIcon[] icons;
|
||||
|
||||
public ItemManaResource() {
|
||||
@@ -95,4 +95,10 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
|
||||
int meta = stack.getItemDamage();
|
||||
return meta == 7 || meta == 8 || meta == 9;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack) {
|
||||
return itemStack.getItemDamage() == 11 ? itemStack.copy() : null;
|
||||
}
|
||||
}
|
||||
@@ -233,5 +233,6 @@ public final class ModItems {
|
||||
OreDictionary.registerOre(LibOreDict.PIXIE_DUST, new ItemStack(manaResource, 1, 8));
|
||||
OreDictionary.registerOre(LibOreDict.DRAGONSTONE, new ItemStack(manaResource, 1, 9));
|
||||
OreDictionary.registerOre(LibOreDict.PRISMARINE_SHARD, new ItemStack(manaResource, 1, 10));
|
||||
OreDictionary.registerOre(LibOreDict.PLACEHOLDER, new ItemStack(manaResource, 1, 11));
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public final class LibBlockNames {
|
||||
public static final String TINY_PLANET = "tinyPlanetBlock";
|
||||
public static final String ALCHEMY_CATALYST = "alchemyCatalyst";
|
||||
public static final String OPEN_CRATE = "openCrate";
|
||||
public static final String CRAFT_CRATE = "craftCrate";
|
||||
public static final String FOREST_EYE = "forestEye";
|
||||
public static final String STORAGE = "storage";
|
||||
public static final String FOREST_DRUM = "forestDrum";
|
||||
|
||||
@@ -120,6 +120,7 @@ public final class LibItemNames {
|
||||
"elementium",
|
||||
"pixieDust",
|
||||
"dragonstone",
|
||||
"prismarineShard"
|
||||
"prismarineShard",
|
||||
"placeholder"
|
||||
};
|
||||
}
|
||||
@@ -30,6 +30,7 @@ public final class LibOreDict {
|
||||
public static final String PIXIE_DUST = "elvenPixieDust";
|
||||
public static final String DRAGONSTONE = "elvenDragonstone";
|
||||
public static final String PRISMARINE_SHARD = "shardPrismarine";
|
||||
public static final String PLACEHOLDER = "bPlaceholder";
|
||||
|
||||
public static final String[] FLOWER = new String[] {
|
||||
"mysticFlowerWhite", "mysticFlowerOrange", "mysticFlowerMagenta", "mysticFlowerLightBlue", "mysticFlowerYellow", "mysticFlowerLime", "mysticFlowerPink", "mysticFlowerGray", "mysticFlowerLightGray", "mysticFlowerCyan", "mysticFlowerPurple", "mysticFlowerBlue", "mysticFlowerBrown", "mysticFlowerGreen", "mysticFlowerRed", "mysticFlowerBlack",
|
||||
|
||||
@@ -619,6 +619,7 @@ item.botania:laputaShard.name=Shard of Laputa
|
||||
item.botania:virus0.name=Necrodermal Virus
|
||||
item.botania:virus1.name=Nullodermal Virus
|
||||
item.botania:skyDirtRod.name=Rod of the Highlands
|
||||
item.botania:placeholder.name=Placeholder
|
||||
|
||||
# GUI TEXT
|
||||
botania.gui.lexicon.header=Lexica Botania, %s Edition's Index - Pick which category you would like to study:
|
||||
|
||||
Reference in new issue
Block a user