mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Move EnumFarmBlock to its own file
This commit is contained in:
1 parent
2f6969e141
commit
d705f4f4db
6 files changed
+135
-104
No files matched your search
@@ -10,15 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.gadgets;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.core.gadgets.BlockStructure;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.farming.gadgets.TileFarm.EnumFarmBlock;
|
||||
import forestry.plugins.PluginFarming;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -33,6 +27,14 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.gadgets.BlockStructure;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.plugins.PluginFarming;
|
||||
|
||||
public class BlockFarm extends BlockStructure {
|
||||
|
||||
public BlockFarm() {
|
||||
@@ -152,7 +154,7 @@ public class BlockFarm extends BlockStructure {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getBlockTextureFromSideAndMetadata(EnumFarmBlock type, int side, int metadata) {
|
||||
return StackUtils.getBlock(type.base).getIcon(side, type.base.getItemDamage());
|
||||
return StackUtils.getBlock(type.getBase()).getIcon(side, type.getBase().getItemDamage());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -189,10 +191,10 @@ public class BlockFarm extends BlockStructure {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
ItemStack base = EnumFarmBlock.BRICK_STONE.base;
|
||||
ItemStack base = EnumFarmBlock.BRICK_STONE.getBase();
|
||||
|
||||
if (tile instanceof TileFarm)
|
||||
base = ((TileFarm) tile).farmBlock.base;
|
||||
base = ((TileFarm) tile).farmBlock.getBase();
|
||||
|
||||
return StackUtils.getBlock(base).getIcon(side, base.getItemDamage());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.farming.gadgets;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.render.TextureManager;
|
||||
|
||||
public enum EnumFarmBlock {
|
||||
BRICK_STONE(new ItemStack(Blocks.stonebrick, 1, 0)),
|
||||
BRICK_MOSSY(new ItemStack(Blocks.stonebrick, 1, 1)),
|
||||
BRICK_CRACKED(new ItemStack(Blocks.stonebrick, 1, 2)),
|
||||
BRICK(new ItemStack(Blocks.brick_block)),
|
||||
SANDSTONE_SMOOTH(new ItemStack(Blocks.sandstone, 1, 2)),
|
||||
SANDSTONE_CHISELED(new ItemStack(Blocks.sandstone, 1, 1)),
|
||||
BRICK_NETHER(new ItemStack(Blocks.nether_brick)),
|
||||
BRICK_CHISELED(new ItemStack(Blocks.stonebrick, 1, 3)),
|
||||
QUARTZ(new ItemStack(Blocks.quartz_block, 1, 0)),
|
||||
QUARTZ_CHISELED(new ItemStack(Blocks.quartz_block, 1, 1)),
|
||||
QUARTZ_LINES(new ItemStack(Blocks.quartz_block, 1, 2));
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static List<IIcon> icons;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerIcons(IIconRegister register) {
|
||||
TextureManager textureManager = TextureManager.getInstance();
|
||||
icons = Arrays.asList(
|
||||
textureManager.registerTex(register, "farm/plain"),
|
||||
textureManager.registerTex(register, "farm/reverse"),
|
||||
textureManager.registerTex(register, "farm/top"),
|
||||
textureManager.registerTex(register, "farm/band"),
|
||||
textureManager.registerTex(register, "farm/gears"),
|
||||
textureManager.registerTex(register, "farm/hatch"),
|
||||
textureManager.registerTex(register, "farm/valve"),
|
||||
textureManager.registerTex(register, "farm/control")
|
||||
);
|
||||
}
|
||||
|
||||
private final ItemStack base;
|
||||
|
||||
private EnumFarmBlock(ItemStack base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int type) {
|
||||
return icons.get(type);
|
||||
}
|
||||
|
||||
public void saveToCompound(NBTTagCompound compound) {
|
||||
compound.setInteger("FarmBlock", this.ordinal());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return base.getItem().getItemStackDisplayName(base);
|
||||
}
|
||||
|
||||
public ItemStack getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public static EnumFarmBlock getFromCompound(NBTTagCompound compound) {
|
||||
|
||||
if (compound != null) {
|
||||
int farmBlockOrdinal = compound.getInteger("FarmBlock");
|
||||
if (farmBlockOrdinal < EnumFarmBlock.values().length)
|
||||
return EnumFarmBlock.values()[farmBlockOrdinal];
|
||||
}
|
||||
|
||||
return EnumFarmBlock.BRICK_STONE;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,16 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.gadgets;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IStructureLogic;
|
||||
import forestry.api.core.ITileStructure;
|
||||
@@ -22,16 +30,6 @@ import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public abstract class TileFarm extends TileForestry implements IFarmComponent {
|
||||
|
||||
@@ -44,74 +42,6 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
|
||||
public static final int TYPE_VALVE = 6;
|
||||
public static final int TYPE_CONTROL = 7;
|
||||
|
||||
public enum EnumFarmBlock {
|
||||
|
||||
BRICK_STONE(new ItemStack(Blocks.stonebrick, 1, 0)),
|
||||
BRICK_MOSSY(new ItemStack(Blocks.stonebrick, 1, 1)),
|
||||
BRICK_CRACKED(new ItemStack(Blocks.stonebrick, 1, 2)),
|
||||
BRICK(new ItemStack(Blocks.brick_block)),
|
||||
SANDSTONE_SMOOTH(new ItemStack(Blocks.sandstone, 1, 2)),
|
||||
SANDSTONE_CHISELED(new ItemStack(Blocks.sandstone, 1, 1)),
|
||||
BRICK_NETHER(new ItemStack(Blocks.nether_brick)),
|
||||
BRICK_CHISELED(new ItemStack(Blocks.stonebrick, 1, 3)),
|
||||
QUARTZ(new ItemStack(Blocks.quartz_block, 1, 0)),
|
||||
QUARTZ_CHISELED(new ItemStack(Blocks.quartz_block, 1, 1)),
|
||||
QUARTZ_LINES(new ItemStack(Blocks.quartz_block, 1, 2));
|
||||
public final ItemStack base;
|
||||
|
||||
private EnumFarmBlock(ItemStack base) {
|
||||
this.base = base;
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon[] icons;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerIcons(IIconRegister register) {
|
||||
|
||||
icons = new IIcon[8];
|
||||
// for(int i = 0; i < values().length; i++) {
|
||||
// generateTexturesIfNeeded(values()[i]);
|
||||
|
||||
icons[0] = TextureManager.getInstance().registerTex(register, "farm/plain");
|
||||
icons[1] = TextureManager.getInstance().registerTex(register, "farm/reverse");
|
||||
icons[2] = TextureManager.getInstance().registerTex(register, "farm/top");
|
||||
icons[3] = TextureManager.getInstance().registerTex(register, "farm/band");
|
||||
icons[4] = TextureManager.getInstance().registerTex(register, "farm/gears");
|
||||
icons[5] = TextureManager.getInstance().registerTex(register, "farm/hatch");
|
||||
icons[6] = TextureManager.getInstance().registerTex(register, "farm/valve");
|
||||
icons[7] = TextureManager.getInstance().registerTex(register, "farm/control");
|
||||
// }
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int type) {
|
||||
return icons[type];
|
||||
}
|
||||
|
||||
public void saveToCompound(NBTTagCompound compound) {
|
||||
compound.setInteger("FarmBlock", this.ordinal());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return base.getItem().getItemStackDisplayName(base);
|
||||
}
|
||||
|
||||
public ItemStack getCraftingIngredient() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public static EnumFarmBlock getFromCompound(NBTTagCompound compound) {
|
||||
|
||||
if (compound != null) {
|
||||
int farmBlockOrdinal = compound.getInteger("FarmBlock");
|
||||
if (farmBlockOrdinal < EnumFarmBlock.values().length)
|
||||
return EnumFarmBlock.values()[farmBlockOrdinal];
|
||||
}
|
||||
|
||||
return EnumFarmBlock.BRICK_STONE;
|
||||
}
|
||||
}
|
||||
|
||||
public TileFarm() {
|
||||
this.structureLogic = Farmables.farmInterface.createFarmStructureLogic(this);
|
||||
}
|
||||
|
||||
@@ -10,14 +10,16 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.items;
|
||||
|
||||
import forestry.core.gadgets.IStructureBlockItem;
|
||||
import forestry.farming.gadgets.TileFarm.EnumFarmBlock;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gadgets.IStructureBlockItem;
|
||||
import forestry.farming.gadgets.EnumFarmBlock;
|
||||
|
||||
public class ItemFarmBlock extends ItemBlock implements IStructureBlockItem {
|
||||
|
||||
public ItemFarmBlock(Block block) {
|
||||
|
||||
@@ -10,15 +10,18 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.render;
|
||||
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.farming.gadgets.BlockFarm;
|
||||
import forestry.farming.gadgets.TileFarm.EnumFarmBlock;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.farming.gadgets.BlockFarm;
|
||||
import forestry.farming.gadgets.EnumFarmBlock;
|
||||
|
||||
public class FarmItemRenderer implements IItemRenderer {
|
||||
|
||||
private void renderFarmBlock(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
|
||||
|
||||
@@ -10,11 +10,23 @@
|
||||
******************************************************************************/
|
||||
package forestry.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.farming.Farmables;
|
||||
@@ -35,8 +47,8 @@ import forestry.farming.GuiHandlerFarming;
|
||||
import forestry.farming.circuits.CircuitFarmLogic;
|
||||
import forestry.farming.gadgets.BlockFarm;
|
||||
import forestry.farming.gadgets.BlockMushroom;
|
||||
import forestry.farming.gadgets.EnumFarmBlock;
|
||||
import forestry.farming.gadgets.TileControl;
|
||||
import forestry.farming.gadgets.TileFarm.EnumFarmBlock;
|
||||
import forestry.farming.gadgets.TileFarmPlain;
|
||||
import forestry.farming.gadgets.TileGearbox;
|
||||
import forestry.farming.gadgets.TileHatch;
|
||||
@@ -62,14 +74,6 @@ import forestry.farming.logic.FarmableVanillaSapling;
|
||||
import forestry.farming.logic.FarmableVanillaShroom;
|
||||
import forestry.farming.proxy.ProxyFarming;
|
||||
import forestry.farming.triggers.FarmingTriggers;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@Plugin(pluginID = "Farming", name = "Farming", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.farming.description")
|
||||
public class PluginFarming extends ForestryPlugin {
|
||||
@@ -294,8 +298,7 @@ public class PluginFarming extends ForestryPlugin {
|
||||
block.saveToCompound(compound);
|
||||
|
||||
basic.setTagCompound((NBTTagCompound) compound.copy());
|
||||
ShapedRecipeCustom.buildRecipe(basic.copy(), "I#I", "WCW", '#', block.getCraftingIngredient(), 'W', "slabWood", 'C', ForestryItem.tubes.getItemStack(1, 1), 'I', "ingotCopper");
|
||||
|
||||
ShapedRecipeCustom.buildRecipe(basic.copy(), "I#I", "WCW", '#', block.getBase(), 'W', "slabWood", 'C', ForestryItem.tubes.getItemStack(1, 1), 'I', "ingotCopper");
|
||||
}
|
||||
|
||||
ItemStack gearbox = ForestryBlock.farm.getItemStack(1, 2);
|
||||
|
||||
Reference in new issue
Block a user