First 1.8.9 Version

This commit is contained in:
Nedelosk committed 2016-01-22 19:33:35 +01:00
1 parent d35cc1df09
commit 5a3850c264
1657 files changed
+26844 -13269

No files matched your search

@@ -14,10 +14,9 @@ import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.farming.FarmDirection;
import forestry.api.multiblock.IFarmComponent;
import forestry.core.utils.vect.MutableVect;
@@ -35,8 +34,8 @@ public class FarmHelper {
);
private static FarmDirection getOpposite(FarmDirection farmDirection) {
ForgeDirection forgeDirection = farmDirection.getForgeDirection();
ForgeDirection forgeDirectionOpposite = forgeDirection.getOpposite();
EnumFacing forgeDirection = farmDirection.getForgeDirection();
EnumFacing forgeDirectionOpposite = forgeDirection.getOpposite();
return FarmDirection.getFarmDirection(forgeDirectionOpposite);
}
@@ -15,8 +15,13 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -24,16 +29,25 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
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 net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.core.blocks.BlockStructure;
import forestry.core.blocks.propertys.UnlistedBlockAccess;
import forestry.core.blocks.propertys.UnlistedBlockPos;
import forestry.core.render.ParticleHelper;
import forestry.core.render.ParticleHelper.DefaultCallback;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.farming.render.EnumFarmBlockTexture;
import forestry.farming.tiles.TileFarm;
@@ -42,17 +56,42 @@ import forestry.farming.tiles.TileFarmGearbox;
import forestry.farming.tiles.TileFarmHatch;
import forestry.farming.tiles.TileFarmPlain;
import forestry.farming.tiles.TileFarmValve;
import forestry.plugins.PluginFarming;
public class BlockFarm extends BlockStructure {
private final ParticleHelper.Callback particleCallback;
public static final PropertyEnum META = PropertyEnum.create("meta", EnumBlockFarmType.class);
public BlockFarm() {
super(Material.rock);
setHardness(1.0f);
setHarvestLevel("pickaxe", 0);
this.particleCallback = new ParticleHelper.DefaultCallback(this);
this.particleCallback = new FarmCallback(this);
setDefaultState(blockState.getBaseState().withProperty(META, EnumBlockFarmType.BASIC));
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(META, EnumBlockFarmType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state) {
return ((EnumBlockFarmType) state.getValue(META)).ordinal();
}
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
return ((IExtendedBlockState) super.getExtendedState(state, world, pos)).withProperty(UnlistedBlockPos.POS, pos)
.withProperty(UnlistedBlockAccess.BLOCKACCESS, world);
}
@Override
protected BlockState createBlockState() {
return new ExtendedBlockState(this, new IProperty[] { META },
new IUnlistedProperty[] { UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS });
}
@Override
@@ -73,44 +112,45 @@ public class BlockFarm extends BlockStructure {
}
}
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
ArrayList<ItemStack> drops = getDrops(world, x, y, z, 0, 0);
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
List<ItemStack> drops = getDrops(world, pos, BlockUtil.getBlockState(world, pos), 0);
if (drops.isEmpty()) {
return super.getPickBlock(target, world, x, y, z);
return super.getPickBlock(target, world, pos, player);
}
return drops.get(0);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, entityLiving, stack);
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);
if (!stack.hasTagCompound()) {
return;
}
TileFarm tile = (TileFarm) world.getTileEntity(x, y, z);
TileFarm tile = (TileFarm) world.getTileEntity(pos);
tile.setFarmBlockTexture(EnumFarmBlockTexture.getFromCompound(stack.getTagCompound()));
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if (!world.isRemote && canHarvestBlock(player, meta)) {
List<ItemStack> drops = getDrops(world, x, y, z, 0, 0);
public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
int meta = BlockUtil.getBlockMetadata(world, pos);
if (!world.isRemote && canHarvestBlock(world, pos, player)) {
List<ItemStack> drops = getDrops(world, pos, BlockUtil.getBlockState(world, pos), 0);
for (ItemStack drop : drops) {
ItemStackUtil.dropItemStackAsEntity(drop, world, x, y, z);
ItemStackUtil.dropItemStackAsEntity(drop, world, pos);
}
}
return world.setBlockToAir(x, y, z);
return world.setBlockToAir(pos);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<>();
int meta = world.getBlockMetadata(x, y, z);
TileEntity tile = world.getTileEntity(x, y, z);
int meta = getMetaFromState(state);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileFarm) {
TileFarm farm = (TileFarm) tile;
@@ -124,14 +164,14 @@ public class BlockFarm extends BlockStructure {
}
@Override
public int getDamageValue(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
public int getDamageValue(World world, BlockPos pos) {
int meta = getMetaFromState(world.getBlockState(pos));
return meta != 1 ? meta : 0;
}
@Override
public TileEntity createTileEntity(World world, int metadata) {
switch (metadata) {
public TileEntity createTileEntity(World world, IBlockState state) {
switch (getMetaFromState(state)) {
case 2:
return new TileFarmGearbox();
case 3:
@@ -147,59 +187,25 @@ public class BlockFarm extends BlockStructure {
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return createTileEntity(world, meta);
}
/* ICONS */
@Override
public int getRenderType() {
return PluginFarming.modelIdFarmBlock;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
EnumFarmBlockTexture.registerIcons(register);
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int metadata) {
return getBlockTextureForSide(EnumFarmBlockTexture.BRICK, side);
}
@SideOnly(Side.CLIENT)
public static IIcon getBlockTextureForSide(EnumFarmBlockTexture type, int side) {
Block block = ItemStackUtil.getBlock(type.getBase());
if (block == null) {
return null;
}
int damage = type.getBase().getItemDamage();
return block.getIcon(side, damage);
}
@SideOnly(Side.CLIENT)
public static IIcon getOverlayTextureForBlock(int side, int metadata) {
BlockFarmType type = BlockFarmType.VALUES[metadata];
return EnumFarmBlockTexture.getIcon(type, side);
return createTileEntity(world, getStateFromMeta(meta));
}
/* MODELS */
@Override
@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 = EnumFarmBlockTexture.BRICK_STONE.getBase();
if (tile instanceof TileFarm) {
base = ((TileFarm) tile).getFarmBlockTexture().getBase();
}
Block block = ItemStackUtil.getBlock(base);
if (block == null) {
return null;
}
return block.getIcon(side, base.getItemDamage());
public EnumWorldBlockLayer getBlockLayer() {
return EnumWorldBlockLayer.CUTOUT;
}
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation("forestry:ffarm", "inventory"));
ModelLoader.setCustomModelResourceLocation(item, 1, new ModelResourceLocation("forestry:ffarm", "inventory"));
ModelLoader.setCustomModelResourceLocation(item, 2, new ModelResourceLocation("forestry:ffarm", "inventory"));
ModelLoader.setCustomModelResourceLocation(item, 3, new ModelResourceLocation("forestry:ffarm", "inventory"));
ModelLoader.setCustomModelResourceLocation(item, 4, new ModelResourceLocation("forestry:ffarm", "inventory"));
ModelLoader.setCustomModelResourceLocation(item, 5, new ModelResourceLocation("forestry:ffarm", "inventory"));
}
/* Particles */
@@ -211,16 +217,30 @@ public class BlockFarm extends BlockStructure {
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
public boolean addDestroyEffects(World world, BlockPos pos, EffectRenderer effectRenderer) {
return ParticleHelper.addDestroyEffects(world, this, world.getBlockState(pos), pos, effectRenderer, particleCallback);
}
public class FarmCallback extends DefaultCallback{
public FarmCallback(Block block) {
super(block);
}
@Override
protected void setTexture(EntityDiggingFX fx, BlockPos pos, IBlockState state) {
IExtendedBlockState extend = (IExtendedBlockState) state;
fx.setParticleIcon(EnumFarmBlockTexture.getSprite(EnumFarmBlockTexture.BRICK, 0));
}
}
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
return world.getBlockMetadata(x, y, z) == 5;
public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, EnumFacing side) {
return getMetaFromState(world.getBlockState(pos)) == 5;
}
public ItemStack get(BlockFarmType type, int amount) {
public ItemStack get(EnumBlockFarmType type, int amount) {
return new ItemStack(this, amount, type.ordinal());
}
}
@@ -1,22 +0,0 @@
/*******************************************************************************
* 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.blocks;
public enum BlockFarmType {
BASIC,
BAND,
GEARBOX,
HATCH,
VALVE,
CONTROL;
public static final BlockFarmType[] VALUES = values();
}
@@ -15,27 +15,41 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.block.BlockBush;
import net.minecraft.block.IGrowable;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import net.minecraft.world.gen.feature.WorldGenerator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.api.core.IItemModelRegister;
import forestry.core.blocks.IItemTyped;
import forestry.core.config.Constants;
import forestry.core.utils.BlockUtil;
public class BlockMushroom extends BlockSapling implements IItemTyped {
public class BlockMushroom extends BlockBush implements IItemTyped, IItemModelRegister, IGrowable {
public enum MushroomType {
BROWN, RED
public static final PropertyEnum MUSHROOM = PropertyEnum.create("mushroom", MushroomType.class);
public enum MushroomType implements IStringSerializable {
BROWN, RED;
@Override
public String getName() {
return name().toLowerCase();
}
}
private final WorldGenerator[] generators;
@@ -44,11 +58,27 @@ public class BlockMushroom extends BlockSapling implements IItemTyped {
public BlockMushroom() {
super();
setHardness(0.0f);
this.generators = new WorldGenerator[]{new WorldGenBigMushroom(MushroomType.BROWN.ordinal()), new WorldGenBigMushroom(MushroomType.RED.ordinal())};
this.generators = new WorldGenerator[]{new WorldGenBigMushroom(Blocks.brown_mushroom_block), new WorldGenBigMushroom(Blocks.red_mushroom_block)};
this.drops = new ItemStack[]{new ItemStack(Blocks.brown_mushroom), new ItemStack(Blocks.red_mushroom)};
setCreativeTab(null);
setDefaultState(this.blockState.getBaseState().withProperty(MUSHROOM, MushroomType.BROWN));
setTickRandomly(true);
}
@Override
protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { MUSHROOM });
}
@Override
public int getMetaFromState(IBlockState state) {
return ((MushroomType) state.getValue(MUSHROOM)).ordinal();
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(MUSHROOM, MushroomType.values()[meta]);
}
@Override
public boolean getTickRandomly() {
@@ -57,10 +87,10 @@ public class BlockMushroom extends BlockSapling implements IItemTyped {
// / DROPS
@Override
public ArrayList<ItemStack> getDrops(World world, int X, int Y, int Z, int metadata, int fortune) {
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<>();
MushroomType type = getTypeFromMeta(metadata);
MushroomType type = getTypeFromMeta(state.getBlock().getMetaFromState(state));
ret.add(drops[type.ordinal()]);
@@ -71,24 +101,23 @@ public class BlockMushroom extends BlockSapling implements IItemTyped {
protected boolean canPlaceBlockOn(Block block) {
return block == Blocks.mycelium;
}
@Override
public void updateTick(World world, int i, int j, int k, Random random) {
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
if (world.isRemote) {
return;
}
int meta = world.getBlockMetadata(i, j, k);
int meta = BlockUtil.getBlockMetadata(world, pos);
MushroomType type = getTypeFromMeta(meta);
int maturity = meta >> 2;
tickGermling(world, i, j, k, random, type, maturity);
tickGermling(world, pos.getX(), pos.getY(), pos.getZ(), rand, type, maturity);
}
private void tickGermling(World world, int i, int j, int k, Random random, MushroomType type, int maturity) {
int lightvalue = world.getBlockLightValue(i, j + 1, k);
int lightvalue = world.getLight(new BlockPos(i, j + 1, k));
if (random.nextInt(2) != 0) {
return;
@@ -98,21 +127,24 @@ public class BlockMushroom extends BlockSapling implements IItemTyped {
maturity = 3;
int matX = maturity << 2;
int meta = (matX | type.ordinal());
world.setBlockMetadataWithNotify(i, j, k, meta, Constants.FLAG_BLOCK_SYNCH);
world.setBlockState(new BlockPos(i, j, k), world.getBlockState(new BlockPos(i, j, k)).getBlock().getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH);
} else if (lightvalue <= 7) {
func_149878_d(world, i, j, k, random);
generateTree(world, new BlockPos(i, j, k), world.getBlockState(new BlockPos(i, j, k)), random);
}
}
public void generateTree(World world, BlockPos pos, IBlockState state, Random rand) {
MushroomType type = getTypeFromMeta(BlockUtil.getBlockMetadata(world, pos));
@Override
public void func_149878_d(World world, int i, int j, int k, Random random) {
MushroomType type = getTypeFromMeta(world.getBlockMetadata(i, j, k));
world.setBlockToAir(i, j, k);
if (!generators[type.ordinal()].generate(world, random, i, j, k)) {
world.setBlock(i, j, k, this, type.ordinal(), 0);
world.setBlockToAir(pos);
if (!generators[type.ordinal()].generate(world, rand, pos)) {
world.setBlockState(pos, getStateFromMeta(type.ordinal()), 0);
}
}
public void grow(World worldIn, BlockPos pos, IBlockState state, Random rand) {
this.generateTree(worldIn, pos, state, rand);
}
@Override
public MushroomType getTypeFromMeta(int meta) {
@@ -129,24 +161,26 @@ public class BlockMushroom extends BlockSapling implements IItemTyped {
list.add(new ItemStack(item, 1, 1));
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
manager.registerItemModel(item, 0, "minecraft", "red_mushroom");
manager.registerItemModel(item, 0, "minecraft", "brown_mushroom");
}
@Override
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) {
return true;
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
MushroomType type = getTypeFromMeta(meta);
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) {
return worldIn.rand.nextFloat() < 0.45D;
}
switch (type) {
case BROWN:
return Blocks.brown_mushroom.getIcon(side, meta);
case RED:
return Blocks.red_mushroom.getIcon(side, meta);
default:
return null;
}
@Override
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) {
this.grow(worldIn, pos, state, rand);
}
}
@@ -0,0 +1,21 @@
package forestry.farming.blocks;
import java.util.Locale;
import net.minecraft.util.IStringSerializable;
public enum EnumBlockFarmType implements IStringSerializable {
BASIC,
BAND,
GEARBOX,
HATCH,
VALVE,
CONTROL;
public static final EnumBlockFarmType[] VALUES = values();
@Override
public String getName() {
return name().toLowerCase(Locale.ENGLISH);
}
}
@@ -10,10 +10,13 @@
******************************************************************************/
package forestry.farming.gui;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import forestry.core.gui.ledgers.Ledger;
import forestry.core.gui.ledgers.LedgerManager;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
public class FarmLedger extends Ledger {
@@ -39,7 +42,9 @@ public class FarmLedger extends Ledger {
int xHeader = x + 22;
// Draw icon
drawIcon(Items.water_bucket.getIconFromDamage(0), xIcon, y);
IBakedModel iBakedModel = Proxies.common.getClientInstance().getRenderItem().getItemModelMesher().getItemModel(new ItemStack(Items.water_bucket));
TextureAtlasSprite textureAtlasSprite = Proxies.common.getClientInstance().getTextureMapBlocks().getAtlasSprite(iBakedModel.getParticleTexture().getIconName());
drawSprite(textureAtlasSprite, xIcon, y);
y += 4;
if (!isFullyOpened()) {
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.farming.gui.widgets;
import net.minecraft.util.IIcon;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmLogic;
import forestry.core.gui.tooltips.ToolTip;
@@ -19,6 +17,8 @@ import forestry.core.gui.widgets.Widget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.farming.multiblock.IFarmControllerInternal;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
public class FarmLogicSlot extends Widget {
@@ -34,19 +34,20 @@ public class FarmLogicSlot extends Widget {
private IFarmLogic getLogic() {
return farmController.getFarmLogic(farmDirection);
}
private IIcon getIconIndex() {
private ItemStack getStackIndex() {
if (getLogic() == null) {
return null;
}
return getLogic().getIcon();
return getLogic().getStack();
}
@Override
public void draw(int startX, int startY) {
if (getIconIndex() != null) {
Proxies.render.bindTexture(getLogic().getSpriteSheet());
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIconIndex(), 16, 16);
if (getStackIndex() != null) {
Proxies.render.bindTexture(getLogic().getTextureMap());
RenderItem renderItem = Proxies.common.getClientInstance().getRenderItem();
renderItem.renderItemIntoGUI(getStackIndex(), startX + xPos, startY + yPos);
}
}
@@ -13,11 +13,13 @@ package forestry.farming.logic;
import java.util.Collection;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.core.config.Constants;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.vect.Vect;
public abstract class Crop implements ICrop {
@@ -31,15 +33,19 @@ public abstract class Crop implements ICrop {
}
protected final void setBlock(Vect position, Block block, int meta) {
world.setBlock(position.x, position.y, position.z, block, meta, Constants.FLAG_BLOCK_SYNCH);
world.setBlockState(position, block.getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH);
}
protected final Block getBlock(Vect position) {
return world.getBlock(position.x, position.y, position.z);
return getBlockState(position).getBlock();
}
protected final IBlockState getBlockState(Vect position) {
return BlockUtil.getBlockState(world, position);
}
protected final int getBlockMeta(Vect position) {
return world.getBlockMetadata(position.x, position.y, position.z);
return getBlock(position).getMetaFromState(getBlockState(position));
}
protected abstract boolean isCrop(Vect pos);
@@ -10,8 +10,8 @@
******************************************************************************/
package forestry.farming.logic;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
@@ -40,13 +40,13 @@ public class CropBasicAgriCraft extends Crop {
@Override
protected Collection<ItemStack> harvestBlock(Vect pos) {
ArrayList<ItemStack> harvest = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
List<ItemStack> harvest = block.getDrops(world, pos, block.getStateFromMeta(meta), 0);
if (harvest.size() > 1) {
harvest.remove(1); //AgriCraft returns cropsticks in 0, seeds in 1 in getDrops, removing since harvesting doesn't return them.
}
harvest.remove(0);
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, Blocks.melon_block, 0);
world.setBlockMetadataWithNotify(pos.x, pos.y, pos.z, 0, Constants.FLAG_BLOCK_SYNCH);
Proxies.common.addBlockDestroyEffects(world, pos, Blocks.melon_block.getStateFromMeta(0));
world.setBlockState(pos, getBlock(pos).getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH);
return harvest;
}
@@ -38,9 +38,9 @@ public class CropBasicFruit extends Crop {
@Override
protected Collection<ItemStack> harvestBlock(Vect pos) {
Collection<ItemStack> harvested = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
world.setBlock(pos.x, pos.y, pos.z, block, 0, Constants.FLAG_BLOCK_SYNCH);
Collection<ItemStack> harvested = block.getDrops(world, pos, block.getStateFromMeta(meta), 0);
Proxies.common.addBlockDestroyEffects(world, pos, block.getStateFromMeta(0));
world.setBlockState(pos, block.getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH);
return harvested;
}
@@ -10,8 +10,8 @@
******************************************************************************/
package forestry.farming.logic;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
@@ -43,20 +43,20 @@ public class CropBasicGrowthCraft extends Crop {
@Override
protected Collection<ItemStack> harvestBlock(Vect pos) {
ArrayList<ItemStack> harvest = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
List<ItemStack> harvest = block.getDrops(world, pos, block.getStateFromMeta(meta), 0);
if (harvest.size() > 1) {
harvest.remove(0); //Hops have rope as first drop.
}
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
Proxies.common.addBlockDestroyEffects(world, pos, block.getStateFromMeta(0));
if (isGrape) {
world.setBlockToAir(pos.x, pos.y, pos.z);
world.setBlockToAir(pos);
} else {
world.setBlockMetadataWithNotify(pos.x, pos.y, pos.z, 0, Constants.FLAG_BLOCK_SYNCH);
world.setBlockState(pos, block.getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH);
}
if (isRice) {
world.setBlockMetadataWithNotify(pos.x, pos.y - 1, pos.z, 7, Constants.FLAG_BLOCK_SYNCH);
world.setBlockState(pos.add(0, -1, 0), block.getStateFromMeta(7), Constants.FLAG_BLOCK_SYNCH);
}
return harvest;
@@ -37,10 +37,10 @@ public class CropBlock extends Crop {
@Override
protected Collection<ItemStack> harvestBlock(Vect pos) {
Collection<ItemStack> harvested = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
Collection<ItemStack> harvested = block.getDrops(world, pos, block.getStateFromMeta(meta), 0);
Proxies.common.addBlockDestroyEffects(world, pos, block.getStateFromMeta(0));
// Block.breakBlock() is called by vanilla itself, removing TEs.
world.setBlockToAir(pos.x, pos.y, pos.z);
world.setBlockToAir(pos);
return harvested;
}
@@ -30,7 +30,7 @@ public class CropFruit extends Crop {
@Override
protected boolean isCrop(Vect pos) {
TileEntity tile = world.getTileEntity(pos.x, pos.y, pos.z);
TileEntity tile = world.getTileEntity(pos);
if (!(tile instanceof IFruitBearer)) {
return false;
}
@@ -47,13 +47,13 @@ public class CropFruit extends Crop {
@Override
protected Collection<ItemStack> harvestBlock(Vect pos) {
TileEntity tile = world.getTileEntity(pos.x, pos.y, pos.z);
TileEntity tile = world.getTileEntity(pos);
if (!(tile instanceof IFruitBearer)) {
return new ArrayList<>();
}
Proxies.common.sendFXSignal(PacketFXSignal.VisualFXType.BLOCK_DESTROY, PacketFXSignal.SoundFXType.LEAF, world, pos.x, pos.y, pos.z,
world.getBlock(pos.x, pos.y, pos.z), 0);
Proxies.common.sendFXSignal(PacketFXSignal.VisualFXType.BLOCK_DESTROY, PacketFXSignal.SoundFXType.LEAF, world, pos,
getBlock(pos).getStateFromMeta(0));
return ((IFruitBearer) tile).pickFruit(null);
}
@@ -47,7 +47,7 @@ public class CropPeat extends Crop {
List<ItemStack> drops = new ArrayList<>();
drops.add(PluginCore.items.peat.getItemStack());
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, world.getBlock(pos.x, pos.y, pos.z), 0);
Proxies.common.addBlockDestroyEffects(world, pos, getBlock(pos).getStateFromMeta(0));
setBlock(pos, Blocks.dirt, 0);
return drops;
}
@@ -32,8 +32,8 @@ public class CropRubber extends CropBlock {
protected Collection<ItemStack> harvestBlock(Vect pos) {
Collection<ItemStack> harvested = new ArrayList<>();
harvested.add(PluginIC2.resin.copy());
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
world.setBlock(pos.x, pos.y, pos.z, block, meta + 6, Constants.FLAG_BLOCK_SYNCH);
Proxies.common.addBlockDestroyEffects(world, pos, block.getStateFromMeta(0));
world.setBlockState(pos, block.getStateFromMeta(meta + 6), Constants.FLAG_BLOCK_SYNCH);
return harvested;
}
@@ -15,19 +15,23 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmLogic;
import forestry.core.config.Constants;
import forestry.core.entities.EntitySelector;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.EntityUtil;
import forestry.core.utils.vect.Vect;
@@ -40,6 +44,7 @@ public abstract class FarmLogic implements IFarmLogic {
this.housing = housing;
}
@Override
public FarmLogic setManual(boolean flag) {
isManual = flag;
return this;
@@ -48,10 +53,25 @@ public abstract class FarmLogic implements IFarmLogic {
protected World getWorld() {
return housing.getWorld();
}
@SideOnly(Side.CLIENT)
@Override
public ResourceLocation getSpriteSheet() {
return SpriteSheet.ITEMS.getLocation();
public ResourceLocation getTextureMap() {
return TextureMap.locationBlocksTexture;
}
@Override
@SideOnly(Side.CLIENT)
public ItemStack getStack() {
return new ItemStack(getItem(), 1, getMetadata());
}
@SideOnly(Side.CLIENT)
public abstract Item getItem();
@SideOnly(Side.CLIENT)
public int getMetadata() {
return 0;
}
public abstract boolean isAcceptedWindfall(ItemStack stack);
@@ -61,16 +81,20 @@ public abstract class FarmLogic implements IFarmLogic {
}
protected final boolean isWaterSourceBlock(World world, Vect position) {
return world.getBlock(position.x, position.y, position.z) == Blocks.water &&
world.getBlockMetadata(position.x, position.y, position.z) == 0;
return BlockUtil.getBlock(world, position) == Blocks.water &&
BlockUtil.getBlockMetadata(world, position) == 0;
}
protected final Vect translateWithOffset(int x, int y, int z, FarmDirection farmDirection, int step) {
return new Vect(farmDirection.getForgeDirection()).multiply(step).add(x, y, z);
}
protected final Vect translateWithOffset(BlockPos pos, FarmDirection farmDirection, int step) {
return new Vect(farmDirection.getForgeDirection()).multiply(step).add(pos);
}
protected final void setBlock(Vect position, Block block, int meta) {
getWorld().setBlock(position.x, position.y, position.z, block, meta, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
getWorld().setBlockState(position, block.getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
}
private AxisAlignedBB getHarvestBox(IFarmHousing farmHousing, boolean toWorldHeight) {
@@ -81,12 +105,12 @@ public abstract class FarmLogic implements IFarmLogic {
Vect min = coords.add(offset);
Vect max = min.add(area);
int maxY = max.y;
int maxY = max.getY();
if (toWorldHeight) {
maxY = getWorld().getHeight();
}
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, maxY, max.z);
return AxisAlignedBB.fromBounds(min.getX(), min.getY(), min.getZ(), max.getX(), maxY, max.getZ());
}
protected List<ItemStack> collectEntityItems(boolean toWorldHeight) {
@@ -20,21 +20,18 @@ import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmable;
import forestry.core.blocks.BlockSoil;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.vect.Vect;
import forestry.core.utils.vect.VectUtil;
import forestry.plugins.PluginCore;
@@ -56,7 +53,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
return true;
}
Block block = BlockSoil.getBlockFromItem(soil.getItem());
Block block = Block.getBlockFromItem(soil.getItem());
if (!(block instanceof BlockSoil)) {
return false;
}
@@ -68,16 +65,11 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
public String getName() {
return "Managed Arboretum";
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Blocks.sapling.getBlockTextureFromSide(0);
}
@Override
public ResourceLocation getSpriteSheet() {
return SpriteSheet.BLOCKS.getLocation();
public Item getItem() {
return Item.getItemFromBlock(Blocks.sapling);
}
@Override
@@ -100,9 +92,9 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
private final HashMap<Vect, Integer> lastExtentsHarvest = new HashMap<>();
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
Vect start = new Vect(x, y, z);
Vect start = new Vect(pos);
if (!lastExtentsHarvest.containsKey(start)) {
lastExtentsHarvest.put(start, 0);
}
@@ -112,7 +104,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
lastExtent = 0;
}
Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent);
Collection<ICrop> crops = getHarvestBlocks(position);
lastExtent++;
lastExtentsHarvest.put(start, lastExtent);
@@ -130,7 +122,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
// Determine what type we want to harvest.
IFarmable germling = null;
for (IFarmable germl : germlings) {
ICrop crop = germl.getCropAt(world, position.x, position.y, position.z);
ICrop crop = germl.getCropAt(world, position);
if (crop == null) {
continue;
}
@@ -173,10 +165,10 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
if (candidate.equals(position)) {
continue;
}
if (Math.abs(candidate.x - start.x) > BRANCH_RANGE) {
if (Math.abs(candidate.getX() - start.getX()) > BRANCH_RANGE) {
continue;
}
if (Math.abs(candidate.z - start.z) > BRANCH_RANGE) {
if (Math.abs(candidate.getZ() - start.getZ()) > BRANCH_RANGE) {
continue;
}
@@ -185,7 +177,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
continue;
}
ICrop crop = germling.getCropAt(world, candidate.x, candidate.y, candidate.z);
ICrop crop = germling.getCropAt(world, candidate);
if (crop != null) {
crops.push(crop);
candidates.add(candidate);
@@ -199,15 +191,15 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
}
@Override
protected boolean maintainGermlings(int x, int ySaplings, int z, FarmDirection direction, int extent) {
protected boolean maintainGermlings(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, ySaplings, z, direction, i);
Vect position = translateWithOffset(pos, direction, i);
if (VectUtil.isAirBlock(world, position)) {
Vect soilBelowPosition = new Vect(position.x, position.y - 1, position.z);
Vect soilBelowPosition = new Vect(position.getX(), position.getY() - 1, position.getZ());
ItemStack soilBelow = VectUtil.getAsItemStack(world, soilBelowPosition);
if (isAcceptedSoil(soilBelow)) {
return plantSapling(position);
@@ -221,7 +213,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
World world = getWorld();
Collections.shuffle(germlings);
for (IFarmable candidate : germlings) {
if (housing.plantGermling(candidate, world, position.x, position.y, position.z)) {
if (housing.plantGermling(candidate, world, position)) {
return true;
}
}
@@ -11,11 +11,9 @@
package forestry.farming.logic;
import net.minecraft.init.Items;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.Farmables;
import forestry.api.farming.IFarmHousing;
@@ -36,8 +34,8 @@ public class FarmLogicCereal extends FarmLogicCrops {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Items.wheat.getIconFromDamage(0);
public Item getItem() {
return Items.wheat;
}
}
@@ -18,21 +18,20 @@ import java.util.Set;
import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.block.BlockPlanks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmable;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.vect.MutableVect;
import forestry.core.utils.vect.Vect;
import forestry.core.utils.vect.VectUtil;
@@ -47,8 +46,8 @@ public class FarmLogicCocoa extends FarmLogic {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Items.dye.getIconFromDamage(3);
public Item getItem() {
return Items.dye;
}
@Override
@@ -89,9 +88,9 @@ public class FarmLogicCocoa extends FarmLogic {
private final HashMap<Vect, Integer> lastExtentsCultivation = new HashMap<>();
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) {
Vect start = new Vect(x, y, z);
Vect start = new Vect(pos);
if (!lastExtentsCultivation.containsKey(start)) {
lastExtentsCultivation.put(start, 0);
}
@@ -101,7 +100,7 @@ public class FarmLogicCocoa extends FarmLogic {
lastExtent = 0;
}
Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent);
boolean result = tryPlantingCocoa(position);
lastExtent++;
@@ -113,9 +112,9 @@ public class FarmLogicCocoa extends FarmLogic {
private final HashMap<Vect, Integer> lastExtentsHarvest = new HashMap<>();
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
Vect start = new Vect(x, y, z);
Vect start = new Vect(pos);
if (!lastExtentsHarvest.containsKey(start)) {
lastExtentsHarvest.put(start, 0);
}
@@ -125,7 +124,7 @@ public class FarmLogicCocoa extends FarmLogic {
lastExtent = 0;
}
Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent);
Collection<ICrop> crops = getHarvestBlocks(position);
lastExtent++;
lastExtentsHarvest.put(start, lastExtent);
@@ -138,21 +137,21 @@ public class FarmLogicCocoa extends FarmLogic {
World world = getWorld();
MutableVect current = new MutableVect(position);
while (VectUtil.isWoodBlock(world, current) && BlockLog.func_150165_c(VectUtil.getBlockMeta(world, current)) == 3) {
while (VectUtil.isWoodBlock(world, current) && BlockUtil.getBlockState(world, current).getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE) {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (direction == ForgeDirection.UP || direction == ForgeDirection.DOWN) {
for (EnumFacing direction : EnumFacing.values()) {
if (direction == EnumFacing.UP || direction == EnumFacing.DOWN) {
continue;
}
Vect candidate = new Vect(current.x + direction.offsetX, current.y, current.z + direction.offsetZ);
Vect candidate = new Vect(current.x + direction.getFrontOffsetX(), current.y, current.z + direction.getFrontOffsetZ());
if (VectUtil.isAirBlock(world, candidate)) {
return housing.plantGermling(cocoa, world, candidate.x, candidate.y, candidate.z);
return housing.plantGermling(cocoa, world, candidate);
}
}
current.y++;
if (current.y - position.y > 1) {
if (current.getY() - position.getY() > 1) {
break;
}
}
@@ -169,8 +168,8 @@ public class FarmLogicCocoa extends FarmLogic {
Block block = VectUtil.getBlock(getWorld(), position);
ICrop crop = null;
if (!block.isWood(getWorld(), position.x, position.y, position.z)) {
crop = cocoa.getCropAt(getWorld(), position.x, position.y, position.z);
if (!block.isWood(getWorld(), position)) {
crop = cocoa.getCropAt(getWorld(), position);
if (crop == null) {
return crops;
}
@@ -209,10 +208,10 @@ public class FarmLogicCocoa extends FarmLogic {
if (candidate.equals(position)) {
continue;
}
if (Math.abs(candidate.x - start.x) > 5) {
if (Math.abs(candidate.getX() - start.getX()) > 5) {
continue;
}
if (Math.abs(candidate.z - start.z) > 5) {
if (Math.abs(candidate.getZ() - start.getZ()) > 5) {
continue;
}
@@ -221,7 +220,7 @@ public class FarmLogicCocoa extends FarmLogic {
continue;
}
ICrop crop = cocoa.getCropAt(world, candidate.x, candidate.y, candidate.z);
ICrop crop = cocoa.getCropAt(world, candidate);
if (crop != null) {
crops.push(crop);
candidates.add(candidate);
@@ -15,6 +15,7 @@ import java.util.Stack;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
@@ -72,13 +73,13 @@ public abstract class FarmLogicCrops extends FarmLogicWatered {
}
@Override
protected boolean maintainCrops(int x, int y, int z, FarmDirection direction, int extent) {
protected boolean maintainCrops(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y, z, direction, i);
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getWorld(), position.x, position.y, position.z)) {
Vect position = translateWithOffset(pos, direction, i);
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getWorld(), position)) {
continue;
}
@@ -100,7 +101,7 @@ public abstract class FarmLogicCrops extends FarmLogicWatered {
World world = getWorld();
for (IFarmable candidate : seeds) {
if (housing.plantGermling(candidate, world, position.getX(), position.getY(), position.getZ())) {
if (housing.plantGermling(candidate, world, position)) {
return true;
}
}
@@ -109,14 +110,14 @@ public abstract class FarmLogicCrops extends FarmLogicWatered {
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
Stack<ICrop> crops = new Stack<>();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y + 1, z, direction, i);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i);
for (IFarmable seed : seeds) {
ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
ICrop crop = seed.getCropAt(world, position);
if (crop != null) {
crops.push(crop);
}
@@ -15,13 +15,12 @@ import java.util.Stack;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -44,8 +43,8 @@ public class FarmLogicEnder extends FarmLogicHomogeneous {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Items.ender_eye.getIconFromDamage(0);
public Item getItem() {
return Items.ender_eye;
}
@Override
@@ -64,14 +63,14 @@ public class FarmLogicEnder extends FarmLogicHomogeneous {
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
Stack<ICrop> crops = new Stack<>();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y + 1, z, direction, i);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i);
for (IFarmable farmable : germlings) {
ICrop crop = farmable.getCropAt(world, position.x, position.y, position.z);
ICrop crop = farmable.getCropAt(world, position);
if (crop != null) {
crops.push(crop);
}
@@ -83,12 +82,12 @@ public class FarmLogicEnder extends FarmLogicHomogeneous {
}
@Override
protected boolean maintainGermlings(int x, int y, int z, FarmDirection direction, int extent) {
protected boolean maintainGermlings(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y, z, direction, i);
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position.x, position.y, position.z)) {
Vect position = translateWithOffset(pos, direction, i);
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position)) {
continue;
}
@@ -107,7 +106,7 @@ public class FarmLogicEnder extends FarmLogicHomogeneous {
World world = getWorld();
for (IFarmable candidate : germlings) {
if (housing.plantGermling(candidate, world, position.x, position.y, position.z)) {
if (housing.plantGermling(candidate, world, position)) {
return true;
}
}
@@ -14,13 +14,12 @@ import java.util.Collection;
import java.util.Stack;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -40,8 +39,8 @@ public class FarmLogicGourd extends FarmLogic {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Items.melon.getIconFromDamage(0);
public Item getItem() {
return Items.melon;
}
@Override
@@ -80,19 +79,19 @@ public class FarmLogicGourd extends FarmLogic {
}
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) {
return false;
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
Stack<ICrop> crops = new Stack<>();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y + 1, z, direction, i);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i);
for (IFarmable seed : seeds) {
ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
ICrop crop = seed.getCropAt(world, position);
if (crop != null) {
crops.push(crop);
}
@@ -15,6 +15,7 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.farming.FarmDirection;
@@ -74,16 +75,16 @@ public abstract class FarmLogicHomogeneous extends FarmLogic {
}
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) {
if (maintainSoil(x, y, z, direction, extent)) {
if (maintainSoil(pos, direction, extent)) {
return true;
}
return maintainGermlings(x, y + 1, z, direction, extent);
return maintainGermlings(pos.add(0, 1, 0), direction, extent);
}
private boolean maintainSoil(int x, int yGround, int z, FarmDirection direction, int extent) {
private boolean maintainSoil(BlockPos pos, FarmDirection direction, int extent) {
ItemStack[] resources = new ItemStack[]{resource};
if (!housing.getFarmInventory().hasResources(resources)) {
return false;
@@ -92,7 +93,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogic {
World world = getWorld();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, yGround, z, direction, i);
Vect position = translateWithOffset(pos, direction, i);
Block soil = VectUtil.getBlock(world, position);
if (FarmHelper.bricks.contains(soil)) {
@@ -121,5 +122,5 @@ public abstract class FarmLogicHomogeneous extends FarmLogic {
return false;
}
protected abstract boolean maintainGermlings(int x, int ySaplings, int z, FarmDirection direction, int extent);
protected abstract boolean maintainGermlings(BlockPos pos, FarmDirection direction, int extent);
}
@@ -15,13 +15,12 @@ import java.util.Stack;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -44,8 +43,8 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Items.nether_wart.getIconFromDamage(0);
public Item getItem() {
return Items.nether_wart;
}
@Override
@@ -64,14 +63,14 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
Stack<ICrop> crops = new Stack<>();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y + 1, z, direction, i);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i);
for (IFarmable farmable : germlings) {
ICrop crop = farmable.getCropAt(world, position.x, position.y, position.z);
ICrop crop = farmable.getCropAt(world, position);
if (crop != null) {
crops.push(crop);
}
@@ -83,12 +82,12 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
}
@Override
protected boolean maintainGermlings(int x, int y, int z, FarmDirection direction, int extent) {
protected boolean maintainGermlings(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y, z, direction, i);
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position.x, position.y, position.z)) {
Vect position = translateWithOffset(pos, direction, i);
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position)) {
continue;
}
@@ -107,7 +106,7 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
World world = getWorld();
for (IFarmable candidate : germlings) {
if (housing.plantGermling(candidate, world, position.x, position.y, position.z)) {
if (housing.plantGermling(candidate, world, position)) {
return true;
}
}
@@ -21,16 +21,13 @@ import java.util.Set;
import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -40,7 +37,6 @@ import forestry.api.genetics.IFruitBearer;
import forestry.core.utils.vect.Vect;
import forestry.core.utils.vect.VectUtil;
import forestry.plugins.PluginCore;
import forestry.plugins.PluginManager;
public class FarmLogicOrchard extends FarmLogic {
@@ -52,7 +48,7 @@ public class FarmLogicOrchard extends FarmLogic {
super(housing);
this.farmables = Farmables.farmables.get("farmOrchard");
ImmutableList.Builder<Block> traversalBlocksBuilder = ImmutableList.builder();
if (PluginManager.Module.AGRICRAFT.isEnabled()) {
/*if (PluginManager.Module.AGRICRAFT.isEnabled()) {
traversalBlocksBuilder.add(Blocks.farmland);
}
if (PluginManager.Module.GROWTHCRAFT.isEnabled()) {
@@ -63,7 +59,7 @@ public class FarmLogicOrchard extends FarmLogic {
}
if (PluginManager.Module.PLANTMEGAPACK.isEnabled()) {
traversalBlocksBuilder.add(Blocks.water);
}
}*/
traversalBlocksBuilder.build();
this.traversalBlocks = traversalBlocksBuilder.build();
}
@@ -99,14 +95,14 @@ public class FarmLogicOrchard extends FarmLogic {
}
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) {
return false;
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
Vect start = new Vect(x, y, z);
Vect start = new Vect(pos);
if (!lastExtents.containsKey(start)) {
lastExtents.put(start, 0);
}
@@ -116,7 +112,7 @@ public class FarmLogicOrchard extends FarmLogic {
lastExtent = 0;
}
Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent);
Collection<ICrop> crops = getHarvestBlocks(position);
lastExtent++;
lastExtents.put(start, lastExtent);
@@ -126,8 +122,8 @@ public class FarmLogicOrchard extends FarmLogic {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return PluginCore.items.fruits.getIconFromDamage(0);
public Item getItem() {
return PluginCore.items.fruits;
}
@Override
@@ -171,10 +167,10 @@ public class FarmLogicOrchard extends FarmLogic {
for (int j = 0; j < 2; j++) {
for (int k = -1; k < 2; k++) {
Vect candidate = position.add(i, j, k);
if (Math.abs(candidate.x - start.x) > 5) {
if (Math.abs(candidate.getX() - start.getX()) > 5) {
continue;
}
if (Math.abs(candidate.z - start.z) > 5) {
if (Math.abs(candidate.getZ() - start.getZ()) > 5) {
continue;
}
@@ -206,13 +202,13 @@ public class FarmLogicOrchard extends FarmLogic {
private boolean isFruitBearer(World world, Vect position) {
TileEntity tile = world.getTileEntity(position.x, position.y, position.z);
TileEntity tile = world.getTileEntity(position);
if (tile instanceof IFruitBearer) {
return true;
}
for (IFarmable farmable : farmables) {
if (farmable.isSaplingAt(world, position.x, position.y, position.z)) {
if (farmable.isSaplingAt(world, position)) {
return true;
}
}
@@ -233,7 +229,7 @@ public class FarmLogicOrchard extends FarmLogic {
private ICrop getCrop(World world, Vect position) {
TileEntity tile = world.getTileEntity(position.x, position.y, position.z);
TileEntity tile = world.getTileEntity(position);
if (tile instanceof IFruitBearer) {
IFruitBearer fruitBearer = (IFruitBearer) tile;
@@ -242,7 +238,7 @@ public class FarmLogicOrchard extends FarmLogic {
}
} else {
for (IFarmable seed : farmables) {
ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
ICrop crop = seed.getCropAt(world, position);
if (crop != null) {
return crop;
}
@@ -14,13 +14,12 @@ import java.util.Collection;
import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
@@ -42,7 +41,7 @@ public class FarmLogicPeat extends FarmLogicWatered {
return true;
}
Block block = BlockSoil.getBlockFromItem(itemStack.getItem());
Block block = Block.getBlockFromItem(itemStack.getItem());
if (!(block instanceof BlockSoil)) {
return false;
}
@@ -76,12 +75,12 @@ public class FarmLogicPeat extends FarmLogicWatered {
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
Stack<ICrop> crops = new Stack<>();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y, z, direction, i);
Vect position = translateWithOffset(pos, direction, i);
ItemStack occupant = VectUtil.getAsItemStack(world, position);
if (occupant.getItem() == null) {
@@ -105,8 +104,8 @@ public class FarmLogicPeat extends FarmLogicWatered {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return PluginCore.items.peat.getIconFromDamage(0);
public Item getItem() {
return PluginCore.items.peat;
}
}
@@ -15,13 +15,12 @@ import java.util.Stack;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -42,8 +41,8 @@ public class FarmLogicReeds extends FarmLogic {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Items.reeds.getIconFromDamage(0);
public Item getItem() {
return Items.reeds;
}
@Override
@@ -94,19 +93,19 @@ public class FarmLogicReeds extends FarmLogic {
}
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) {
return false;
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
Stack<ICrop> crops = new Stack<>();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y + 1, z, direction, i);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i);
for (IFarmable seed : germlings) {
ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
ICrop crop = seed.getCropAt(world, position);
if (crop != null) {
crops.push(crop);
}
@@ -19,13 +19,12 @@ import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
@@ -49,11 +48,11 @@ public class FarmLogicRubber extends FarmLogic {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
public Item getItem() {
if (!inActive) {
return PluginIC2.resin.getIconIndex();
return PluginIC2.resin.getItem();
} else {
return Items.gunpowder.getIconFromDamage(0);
return Items.gunpowder;
}
}
@@ -93,19 +92,19 @@ public class FarmLogicRubber extends FarmLogic {
}
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) {
return false;
}
private final HashMap<Vect, Integer> lastExtents = new HashMap<>();
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
if (inActive) {
return null;
}
Vect start = new Vect(x, y, z);
Vect start = new Vect(pos);
if (!lastExtents.containsKey(start)) {
lastExtents.put(start, 0);
}
@@ -115,7 +114,7 @@ public class FarmLogicRubber extends FarmLogic {
lastExtent = 0;
}
Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent);
Collection<ICrop> crops = getHarvestBlocks(position);
lastExtent++;
lastExtents.put(start, lastExtent);
@@ -162,7 +161,7 @@ public class FarmLogicRubber extends FarmLogic {
// Get additional candidates to return
for (int j = 0; j < 2; j++) {
Vect candidate = new Vect(position.x, position.y + j, position.z);
Vect candidate = new Vect(position.getX(), position.getY() + j, position.getZ());
if (candidate.equals(position)) {
continue;
}
@@ -14,12 +14,10 @@ import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.Farmables;
import forestry.api.farming.IFarmHousing;
@@ -40,8 +38,8 @@ public class FarmLogicShroom extends FarmLogicArboreal {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Blocks.red_mushroom.getBlockTextureFromSide(0);
public Item getItem() {
return Item.getItemFromBlock(Blocks.red_mushroom);
}
@Override
@@ -15,13 +15,12 @@ import java.util.Stack;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -42,8 +41,14 @@ public class FarmLogicSucculent extends FarmLogic {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Items.dye.getIconFromDamage(2);
public Item getItem() {
return Items.dye;
}
@Override
@SideOnly(Side.CLIENT)
public int getMetadata() {
return 2;
}
@Override
@@ -94,19 +99,19 @@ public class FarmLogicSucculent extends FarmLogic {
}
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) {
return false;
}
@Override
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
Stack<ICrop> crops = new Stack<>();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y + 1, z, direction, i);
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i);
for (IFarmable seed : germlings) {
ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
ICrop crop = seed.getCropAt(world, position);
if (crop != null) {
crops.push(crop);
}
@@ -11,11 +11,9 @@
package forestry.farming.logic;
import net.minecraft.init.Items;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.Farmables;
import forestry.api.farming.IFarmHousing;
@@ -27,8 +25,8 @@ public class FarmLogicVegetable extends FarmLogicCrops {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return Items.carrot.getIconFromDamage(0);
public Item getItem() {
return Items.carrot;
}
@Override
@@ -17,6 +17,7 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
@@ -72,30 +73,30 @@ public abstract class FarmLogicWatered extends FarmLogic {
}
@Override
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) {
if (maintainSoil(x, y, z, direction, extent)) {
if (maintainSoil(pos, direction, extent)) {
return true;
}
if (!isManual && maintainWater(x, y, z, direction, extent)) {
if (!isManual && maintainWater(pos, direction, extent)) {
return true;
}
if (maintainCrops(x, y + 1, z, direction, extent)) {
if (maintainCrops(pos.add(0, 1, 0), direction, extent)) {
return true;
}
return false;
}
private boolean maintainSoil(int x, int y, int z, FarmDirection direction, int extent) {
private boolean maintainSoil(BlockPos pos, FarmDirection direction, int extent) {
World world = getWorld();
ItemStack[] resources = new ItemStack[]{resource};
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y, z, direction, i);
Vect position = translateWithOffset(pos, direction, i);
Block soil = VectUtil.getBlock(world, position);
ItemStack soilStack = VectUtil.getAsItemStack(world, position);
@@ -129,11 +130,11 @@ public abstract class FarmLogicWatered extends FarmLogic {
return false;
}
private boolean maintainWater(int x, int y, int z, FarmDirection direction, int extent) {
private boolean maintainWater(BlockPos pos, FarmDirection direction, int extent) {
// Still not done, check water then
World world = getWorld();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, y, z, direction, i);
Vect position = translateWithOffset(pos, direction, i);
Vect platformPosition = position.add(0, -1, 0);
Block platformBlock = VectUtil.getBlock(world, platformPosition);
@@ -149,7 +150,7 @@ public abstract class FarmLogicWatered extends FarmLogic {
return false;
}
protected boolean maintainCrops(int x, int y, int z, FarmDirection direction, int extent) {
protected boolean maintainCrops(BlockPos pos, FarmDirection direction, int extent) {
return false;
}
@@ -13,11 +13,13 @@ package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.core.config.Constants;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
@@ -32,19 +34,19 @@ public class FarmableBasicAgricraft implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSaplingAt(World world, BlockPos pos) {
return BlockUtil.getBlock(world, pos) == block;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) != block) {
public ICrop getCropAt(World world, BlockPos pos) {
if (BlockUtil.getBlock(world, pos) != block) {
return null;
}
if (world.getBlockMetadata(x, y, z) != matureMeta) {
if (BlockUtil.getBlockMetadata(world, pos) != matureMeta) {
return null;
}
return new CropBasicAgriCraft(world, block, matureMeta, new Vect(x, y, z));
return new CropBasicAgriCraft(world, block, matureMeta, new Vect(pos));
}
@Override
@@ -58,8 +60,8 @@ public class FarmableBasicAgricraft implements IFarmable {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return world.setBlock(x, y, z, block, 0, Constants.FLAG_BLOCK_SYNCH);
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return world.setBlockState(pos, block.getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH);
}
}
@@ -13,11 +13,13 @@ package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.core.config.Constants;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
@@ -32,19 +34,19 @@ public class FarmableBasicFruit implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSaplingAt(World world, BlockPos pos) {
return BlockUtil.getBlock(world, pos) == block;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) != block) {
public ICrop getCropAt(World world, BlockPos pos) {
if (BlockUtil.getBlock(world, pos) != block) {
return null;
}
if (world.getBlockMetadata(x, y, z) != matureMeta) {
if (BlockUtil.getBlockMetadata(world, pos) != matureMeta) {
return null;
}
return new CropBasicFruit(world, block, matureMeta, new Vect(x, y, z));
return new CropBasicFruit(world, block, matureMeta, new Vect(pos));
}
@Override
@@ -53,8 +55,8 @@ public class FarmableBasicFruit implements IFarmable {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return world.setBlock(x, y, z, block, 0, Constants.FLAG_BLOCK_SYNCH);
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return world.setBlockState(pos, block.getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH);
}
@Override
@@ -13,11 +13,13 @@ package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.core.config.Constants;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
@@ -36,19 +38,19 @@ public class FarmableBasicGrowthCraft implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSaplingAt(World world, BlockPos pos) {
return BlockUtil.getBlock(world, pos) == block;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) != block) {
public ICrop getCropAt(World world, BlockPos pos) {
if (BlockUtil.getBlock(world, pos) != block) {
return null;
}
if (world.getBlockMetadata(x, y, z) != matureMeta) {
if (BlockUtil.getBlockMetadata(world, pos) != matureMeta) {
return null;
}
return new CropBasicGrowthCraft(world, block, matureMeta, new Vect(x, y, z), isRice, isGrape);
return new CropBasicGrowthCraft(world, block, matureMeta, new Vect(pos), isRice, isGrape);
}
@Override
@@ -57,8 +59,8 @@ public class FarmableBasicGrowthCraft implements IFarmable {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return world.setBlock(x, y, z, block, 0, Constants.FLAG_BLOCK_SYNCH);
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return world.setBlockState(pos, block.getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH);
}
@Override
@@ -7,12 +7,13 @@ import forestry.plugins.compat.PluginIC2;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class FarmableBasicIC2Crop implements IFarmable {
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
TileEntity crop = world.getTileEntity(x, y, z);
public boolean isSaplingAt(World world, BlockPos pos) {
TileEntity crop = world.getTileEntity(pos);
if(PluginIC2.instance.isIC2Crop(crop)) {
PluginIC2.instance.babysitCrop(crop);
return true;
@@ -21,8 +22,8 @@ public class FarmableBasicIC2Crop implements IFarmable {
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
TileEntity crop = world.getTileEntity(x, y, z);
public ICrop getCropAt(World world, BlockPos pos) {
TileEntity crop = world.getTileEntity(pos);
if (crop == null) {
return null;
}
@@ -32,7 +33,7 @@ public class FarmableBasicIC2Crop implements IFarmable {
if (!PluginIC2.instance.canHarvestCrop(crop)) {
return null;
}
return new CropBasicIC2Crop(world, crop, new Vect(x, y, z));
return new CropBasicIC2Crop(world, crop, new Vect(pos));
}
@Override
@@ -46,7 +47,7 @@ public class FarmableBasicIC2Crop implements IFarmable {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return false;
}
}
@@ -16,6 +16,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
@@ -30,22 +31,22 @@ public class FarmableCocoa implements IFarmable {
public static final int COCOA_META = 3;
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == COCOA_PLANT;
public boolean isSaplingAt(World world, BlockPos pos) {
return BlockUtil.getBlock(world, pos) == COCOA_PLANT;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
public ICrop getCropAt(World world, BlockPos pos) {
Block block = BlockUtil.getBlock(world, pos);
if (block != COCOA_PLANT) {
return null;
}
int meta = world.getBlockMetadata(x, y, z);
if (BlockUtil.getMaturityPod(meta) < 2) {
int meta = BlockUtil.getBlockMetadata(world, pos);
if (BlockUtil.getMaturityPod(BlockUtil.getBlockState(world, pos)) < 2) {
return null;
}
return new CropBlock(world, block, meta, new Vect(x, y, z));
return new CropBlock(world, block, meta, new Vect(pos));
}
@Override
@@ -59,8 +60,8 @@ public class FarmableCocoa implements IFarmable {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return BlockUtil.tryPlantPot(world, x, y, z, COCOA_PLANT);
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return BlockUtil.tryPlantPot(world, pos, COCOA_PLANT);
}
}
@@ -13,42 +13,45 @@ package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.arboriculture.genetics.TreeGenome;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.vect.Vect;
import forestry.plugins.PluginArboriculture;
public class FarmableGE implements IFarmable {
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
public boolean isSaplingAt(World world, BlockPos pos) {
if (world.isAirBlock(x, y, z)) {
if (world.isAirBlock(pos)) {
return false;
}
Block block = world.getBlock(x, y, z);
Block block = BlockUtil.getBlock(world, pos);
return PluginArboriculture.blocks.saplingGE == block;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
public ICrop getCropAt(World world, BlockPos pos) {
Block block = BlockUtil.getBlock(world, pos);
if (!block.isWood(world, x, y, z)) {
if (!block.isWood(world, pos)) {
return null;
}
return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z));
return new CropBlock(world, block, BlockUtil.getBlockMetadata(world, pos), new Vect(pos));
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return germling.copy().tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0, 0, 0);
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return germling.copy().onItemUse(player, world, pos.add(0, -1, 0), EnumFacing.UP, 0, 0, 0);
}
@Override
@@ -13,10 +13,13 @@ package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.vect.Vect;
public class FarmableGenericCrop implements IFarmable {
@@ -34,20 +37,20 @@ public class FarmableGenericCrop implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSaplingAt(World world, BlockPos pos) {
return BlockUtil.getBlock(world, pos) == block;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) != block) {
public ICrop getCropAt(World world, BlockPos pos) {
if (BlockUtil.getBlock(world, pos) != block) {
return null;
}
if (world.getBlockMetadata(x, y, z) != mature) {
if (BlockUtil.getBlockMetadata(world, pos) != mature) {
return null;
}
return new CropBlock(world, block, mature, new Vect(x, y, z));
return new CropBlock(world, block, mature, new Vect(pos));
}
@Override
@@ -64,8 +67,8 @@ public class FarmableGenericCrop implements IFarmable {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return germling.copy().tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0, 0, 0);
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return germling.copy().onItemUse(player, world, pos.add(0, -1, 0), EnumFacing.UP, 0, 0, 0);
}
@Override
@@ -13,10 +13,13 @@ package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
@@ -33,18 +36,18 @@ public class FarmableGenericSapling implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
public boolean isSaplingAt(World world, BlockPos pos) {
if (world.isAirBlock(x, y, z)) {
if (world.isAirBlock(pos)) {
return false;
}
if (world.getBlock(x, y, z) == sapling) {
if (BlockUtil.getBlock(world, pos) == sapling) {
return true;
}
if (saplingMeta >= 0) {
return world.getBlockMetadata(x, y, z) == saplingMeta;
return BlockUtil.getBlockMetadata(world, pos) == saplingMeta;
} else {
return true;
}
@@ -52,13 +55,13 @@ public class FarmableGenericSapling implements IFarmable {
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (!block.isWood(world, x, y, z)) {
public ICrop getCropAt(World world, BlockPos pos) {
Block block = BlockUtil.getBlock(world, pos);
if (!block.isWood(world,pos)) {
return null;
}
return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z));
return new CropBlock(world, block, BlockUtil.getBlockMetadata(world, pos), new Vect(pos));
}
@Override
@@ -86,8 +89,8 @@ public class FarmableGenericSapling implements IFarmable {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return germling.copy().tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0, 0, 0);
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return germling.copy().onItemUse(player, world, pos.add(0, -1, 0), EnumFacing.UP, 0, 0, 0);
}
}
@@ -12,11 +12,13 @@ package forestry.farming.logic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.core.config.Constants;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
@@ -33,29 +35,29 @@ public class FarmableGourd implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
if (world.isAirBlock(x, y, z)) {
public boolean isSaplingAt(World world, BlockPos pos) {
if (world.isAirBlock(pos)) {
return false;
}
return ItemStackUtil.equals(world.getBlock(x, y, z), stem);
return ItemStackUtil.equals(BlockUtil.getBlock(world, pos), stem);
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
if (world.isAirBlock(x, y, z)) {
public ICrop getCropAt(World world, BlockPos pos) {
if (world.isAirBlock(pos)) {
return null;
}
if (!ItemStackUtil.equals(world.getBlock(x, y, z), fruit)) {
if (!ItemStackUtil.equals(BlockUtil.getBlock(world, pos), fruit)) {
return null;
}
if (world.getBlockMetadata(x, y, z) != fruit.getItemDamage()) {
if (BlockUtil.getBlockMetadata(world, pos) != fruit.getItemDamage()) {
return null;
}
return new CropBlock(world, ItemStackUtil.getBlock(fruit), fruit.getItemDamage(), new Vect(x, y, z));
return new CropBlock(world, ItemStackUtil.getBlock(fruit), fruit.getItemDamage(), new Vect(pos));
}
@Override
@@ -69,8 +71,8 @@ public class FarmableGourd implements IFarmable {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return world.setBlock(x, y, z, ItemStackUtil.getBlock(stem), 0, Constants.FLAG_BLOCK_SYNCH);
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return world.setBlockState(pos, ItemStackUtil.getBlock(stem).getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH);
}
}
@@ -13,11 +13,13 @@ package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.core.config.Constants;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
@@ -34,16 +36,16 @@ public class FarmableStacked implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSaplingAt(World world, BlockPos pos) {
return BlockUtil.getBlock(world, pos) == block;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
if (world.getBlock(x, y + (matureHeight - 1), z) != block) {
public ICrop getCropAt(World world, BlockPos pos) {
if (BlockUtil.getBlock(world, new BlockPos(pos.getX(), pos.getY() + (matureHeight - 1), pos.getZ())) != block) {
return null;
}
return new CropBlock(world, block, matureMeta, new Vect(x, y + (matureHeight - 1), z));
return new CropBlock(world, block, matureMeta, new Vect(pos.getX(), pos.getY() + (matureHeight - 1), pos.getZ()));
}
@Override
@@ -52,8 +54,8 @@ public class FarmableStacked implements IFarmable {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return world.setBlock(x, y, z, block, 0, Constants.FLAG_BLOCK_SYNCH);
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
return world.setBlockState(pos, block.getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH);
}
@Override
@@ -14,11 +14,13 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
import forestry.plugins.PluginFarming;
@@ -30,14 +32,14 @@ public class FarmableVanillaMushroom extends FarmableGenericSapling {
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
public ICrop getCropAt(World world, BlockPos pos) {
Block block = BlockUtil.getBlock(world, pos);
if (block != Blocks.brown_mushroom_block && block != Blocks.red_mushroom_block) {
return null;
}
return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z));
return new CropBlock(world, block, BlockUtil.getBlockMetadata(world, pos), new Vect(pos));
}
@Override
@@ -46,13 +48,13 @@ public class FarmableVanillaMushroom extends FarmableGenericSapling {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
int meta = 0;
if (ItemStackUtil.equals(Blocks.red_mushroom, germling)) {
meta = 1;
}
Proxies.common.addBlockPlaceEffects(world, x, y, z, Blocks.brown_mushroom, 0);
return world.setBlock(x, y, z, PluginFarming.blocks.mushroom, meta, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
Proxies.common.addBlockPlaceEffects(world, pos, Blocks.brown_mushroom.getStateFromMeta(0));
return world.setBlockState(pos, PluginFarming.blocks.mushroom.getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
}
}
@@ -14,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import forestry.api.arboriculture.ITree;
@@ -29,16 +31,16 @@ public class FarmableVanillaSapling extends FarmableGenericSapling {
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
if (PluginManager.Module.ARBORICULTURE.isEnabled()) {
IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling);
if (!(tree instanceof ITree)) {
return false;
}
return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), x, y, z);
return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), pos);
} else {
return germling.copy().tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0, 0, 0);
return germling.copy().onItemUse(player, world, pos.add(0, -1, 0), EnumFacing.UP, 0, 0, 0);
}
}
@@ -12,6 +12,7 @@ package forestry.farming.multiblock;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
@@ -69,7 +70,7 @@ public class FakeFarmController extends FakeMultiblockController implements IFar
}
@Override
public boolean plantGermling(IFarmable farmable, World world, int x, int y, int z) {
public boolean plantGermling(IFarmable farmable, World world, BlockPos pos) {
return false;
}
@@ -27,7 +27,7 @@ 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.BlockPos;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
@@ -171,8 +171,8 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
private BiomeGenBase getBiome() {
if (cachedBiome == null) {
ChunkCoordinates coords = getReferenceCoord();
cachedBiome = worldObj.getBiomeGenForCoords(coords.posX, coords.posZ);
BlockPos coords = getReferenceCoord();
cachedBiome = worldObj.getBiomeGenForCoords(coords);
}
return cachedBiome;
}
@@ -337,9 +337,9 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
}
@Override
public ChunkCoordinates getCoordinates() {
ChunkCoordinates coord = getReferenceCoord();
return new ChunkCoordinates(coord);
public BlockPos getCoordinates() {
BlockPos coord = getReferenceCoord();
return new BlockPos(coord);
}
@Override
@@ -349,7 +349,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
for (IMultiblockComponent part : connectedParts) {
if (part instanceof TileEntity) {
TileEntity tile = (TileEntity) part;
tile.getWorldObj().notifyBlocksOfNeighborChange(tile.xCoord, tile.yCoord, tile.zCoord, tile.getBlockType());
tile.getWorld().notifyBlockOfStateChange(tile.getPos(), tile.getBlockType());
}
}
markDirty();
@@ -387,8 +387,8 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
@Override
public EnumTemperature getTemperature() {
ChunkCoordinates coords = getReferenceCoord();
return EnumTemperature.getFromBiome(getBiome(), coords.posX, coords.posY, coords.posZ);
BlockPos coords = getReferenceCoord();
return EnumTemperature.getFromBiome(getBiome(), coords);
}
@Override
@@ -398,8 +398,8 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
@Override
public float getExactTemperature() {
ChunkCoordinates coords = getReferenceCoord();
return getBiome().getFloatTemperature(coords.posX, coords.posY, coords.posZ);
BlockPos coords = getReferenceCoord();
return getBiome().getFloatTemperature(coords);
}
@Override
@@ -414,8 +414,8 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
@Override
public int[] getCoords() {
if (coords == null) {
ChunkCoordinates centerCoord = getCenterCoord();
coords = new int[]{centerCoord.posX, centerCoord.posY, centerCoord.posZ};
BlockPos centerCoord = getCenterCoord();
coords = new int[]{centerCoord.getX(), centerCoord.getY(), centerCoord.getZ()};
}
return coords;
}
@@ -524,11 +524,11 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
private void setUpFarmlandTargets() {
Vect targetStart = new Vect(getCoords());
ChunkCoordinates max = getMaximumCoord();
ChunkCoordinates min = getMinimumCoord();
BlockPos max = getMaximumCoord();
BlockPos min = getMinimumCoord();
int sizeNorthSouth = Math.abs(max.posZ - min.posZ) + 1;
int sizeEastWest = Math.abs(max.posX - min.posX) + 1;
int sizeNorthSouth = Math.abs(max.getZ() - min.getZ()) + 1;
int sizeEastWest = Math.abs(max.getX() - min.getX()) + 1;
// Set the maximum allowed extent.
allowedExtent = Math.max(sizeNorthSouth, sizeEastWest) * Config.farmSize + 1;
@@ -665,9 +665,9 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
private static boolean cultivateTarget(FarmTarget target, IFarmLogic logic, Iterable<IFarmListener> farmListeners) {
Vect targetPosition = target.getStart().add(0, target.getYOffset(), 0);
if (logic.cultivate(targetPosition.x, targetPosition.y, targetPosition.z, target.getDirection(), target.getExtent())) {
if (logic.cultivate(targetPosition, target.getDirection(), target.getExtent())) {
for (IFarmListener listener : farmListeners) {
listener.hasCultivated(logic, targetPosition.x, targetPosition.y, targetPosition.z, target.getDirection(), target.getExtent());
listener.hasCultivated(logic, targetPosition, target.getDirection(), target.getExtent());
}
return true;
}
@@ -689,14 +689,15 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
}
private static Collection<ICrop> harvestTarget(FarmTarget target, IFarmLogic logic, Iterable<IFarmListener> farmListeners) {
Collection<ICrop> harvested = logic.harvest(target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, target.getDirection(), target.getExtent());
BlockPos pos = new BlockPos(target.getStart().getX(), target.getStart().getX() + target.getYOffset(), target.getStart().getZ());
Collection<ICrop> harvested = logic.harvest(pos, target.getDirection(), target.getExtent());
if (harvested == null || harvested.size() == 0) {
return Collections.emptyList();
}
// Let event handlers know.
for (IFarmListener listener : farmListeners) {
listener.hasScheduledHarvest(harvested, logic, target.getStart().x, target.getStart().y + target.getYOffset(), target.getStart().z, target.getDirection(), target.getExtent());
listener.hasScheduledHarvest(harvested, logic, pos, target.getDirection(), target.getExtent());
}
return harvested;
@@ -787,9 +788,9 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
}
@Override
public boolean plantGermling(IFarmable germling, World world, int x, int y, int z) {
public boolean plantGermling(IFarmable germling, World world, BlockPos pos) {
EntityPlayer player = PlayerUtil.getPlayer(world, getAccessHandler().getOwner());
return inventory.plantGermling(germling, player, x, y, z);
return inventory.plantGermling(germling, player, pos);
}
@Override
@@ -16,7 +16,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.Fluid;
import forestry.api.farming.FarmDirection;
@@ -80,7 +81,7 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
public boolean canExtractItem(int slotIndex, ItemStack stack, EnumFacing side) {
return SlotUtil.isSlotInRange(slotIndex, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT);
}
@@ -161,14 +162,14 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
FluidHelper.drainContainers(tankManager, this, SLOT_CAN);
}
public boolean plantGermling(IFarmable germling, EntityPlayer player, int x, int y, int z) {
public boolean plantGermling(IFarmable germling, EntityPlayer player, BlockPos pos) {
for (int i = 0; i < germlingsInventory.getSizeInventory(); i++) {
ItemStack germlingStack = germlingsInventory.getStackInSlot(i);
if (germlingStack == null || !germling.isGermling(germlingStack)) {
continue;
}
if (germling.plantSaplingAt(player, germlingStack, player.worldObj, x, y, z)) {
if (germling.plantSaplingAt(player, germlingStack, player.worldObj, pos)) {
germlingsInventory.decrStackSize(i, 1);
return true;
}
@@ -29,6 +29,7 @@ public class MultiblockLogicFarm extends MultiblockLogic<IFarmControllerInternal
}
}
@Override
public IFarmControllerInternal createNewController(World world) {
return new FarmController(world);
}
@@ -12,6 +12,6 @@ package forestry.farming.proxy;
public class ProxyFarming {
public void initializeRendering() {
public void initializeModels() {
}
}
@@ -10,23 +10,18 @@
******************************************************************************/
package forestry.farming.proxy;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.RenderingRegistry;
import forestry.farming.render.RenderFarmBlock;
import forestry.farming.render.RenderFarmItem;
import net.minecraft.client.resources.model.ModelResourceLocation;
import forestry.core.proxy.Proxies;
import forestry.core.render.model.BlockModelIndex;
import forestry.farming.render.ModelFarmBlock;
import forestry.plugins.PluginFarming;
public class ProxyFarmingClient extends ProxyFarming {
@Override
public void initializeRendering() {
PluginFarming.modelIdFarmBlock = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new RenderFarmBlock());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(PluginFarming.blocks.farm), new RenderFarmItem());
public void initializeModels() {
Proxies.render.registerBlockModel(new BlockModelIndex(new ModelResourceLocation("forestry:ffarm"),
new ModelResourceLocation("forestry:ffarm", "inventory"), new ModelFarmBlock(),
PluginFarming.blocks.farm));
}
}
@@ -13,17 +13,14 @@ package forestry.farming.render;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
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 net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.core.render.TextureManager;
import forestry.farming.blocks.BlockFarmType;
import forestry.farming.blocks.EnumBlockFarmType;
public enum EnumFarmBlockTexture {
BRICK_STONE(new ItemStack(Blocks.stonebrick, 1, 0)),
@@ -48,19 +45,19 @@ public enum EnumFarmBlockTexture {
private static final int TYPE_CONTROL = 7;
@SideOnly(Side.CLIENT)
private static List<IIcon> icons;
private static List<TextureAtlasSprite> sprites;
@SideOnly(Side.CLIENT)
public static void registerIcons(IIconRegister register) {
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")
public static void registerSprites() {
sprites = Arrays.asList(
TextureManager.registerSprite("blocks/farm/plain"),
TextureManager.registerSprite("blocks/farm/reverse"),
TextureManager.registerSprite("blocks/farm/top"),
TextureManager.registerSprite("blocks/farm/band"),
TextureManager.registerSprite("blocks/farm/gears"),
TextureManager.registerSprite("blocks/farm/hatch"),
TextureManager.registerSprite("blocks/farm/valve"),
TextureManager.registerSprite("blocks/farm/control")
);
}
@@ -69,31 +66,84 @@ public enum EnumFarmBlockTexture {
EnumFarmBlockTexture(ItemStack base) {
this.base = base;
}
/**
* @return The texture sprite from the type of the farm block
*/
@SideOnly(Side.CLIENT)
public static IIcon getIcon(BlockFarmType type, int side) {
public static TextureAtlasSprite getSprite(EnumBlockFarmType type, int side) {
switch (type) {
case BASIC: {
if (side == 2) {
return icons.get(TYPE_REVERSE);
return sprites.get(TYPE_REVERSE);
} else if (side == 0 || side == 1) {
return icons.get(TYPE_TOP);
return sprites.get(TYPE_TOP);
} else {
return icons.get(TYPE_PLAIN);
return sprites.get(TYPE_PLAIN);
}
}
case BAND:
return icons.get(TYPE_BAND);
return sprites.get(TYPE_BAND);
case GEARBOX:
return icons.get(TYPE_GEARS);
return sprites.get(TYPE_GEARS);
case HATCH:
return icons.get(TYPE_HATCH);
return sprites.get(TYPE_HATCH);
case VALVE:
return icons.get(TYPE_VALVE);
return sprites.get(TYPE_VALVE);
case CONTROL:
return icons.get(TYPE_CONTROL);
return sprites.get(TYPE_CONTROL);
default:
return icons.get(TYPE_PLAIN);
return sprites.get(TYPE_PLAIN);
}
}
/**
* @return The texture sprite from the material of the farm block
*/
@SideOnly(Side.CLIENT)
public static TextureAtlasSprite getSprite(EnumFarmBlockTexture texture, int side) {
TextureManager manager = TextureManager.getInstance();
switch (texture) {
case BRICK:
return manager.getSprite("minecraft", "blocks/brick");
case BRICK_STONE:
return manager.getSprite("minecraft", "blocks/stonebrick");
case BRICK_CHISELED:
return manager.getSprite("minecraft", "blocks/stonebrick_carved");
case BRICK_CRACKED:
return manager.getSprite("minecraft", "blocks/stonebrick_cracked");
case BRICK_MOSSY:
return manager.getSprite("minecraft", "blocks/stonebrick_mossy");
case BRICK_NETHER:
return manager.getSprite("minecraft", "blocks/nether_brick");
case SANDSTONE_CHISELED:
if (side == 0)
return manager.getSprite("minecraft", "blocks/sandstone_bottom");
else if (side == 1)
return manager.getSprite("minecraft", "blocks/sandstone_top");
return manager.getSprite("minecraft", "blocks/sandstone_carved");
case SANDSTONE_SMOOTH:
if (side == 0)
return manager.getSprite("minecraft", "blocks/sandstone_bottom");
else if (side == 1)
return manager.getSprite("minecraft", "blocks/sandstone_top");
return manager.getSprite("minecraft", "blocks/sandstone_smooth");
case QUARTZ:
if (side == 0)
return manager.getSprite("minecraft", "blocks/quartz_block_bottom");
else if (side == 1)
return manager.getSprite("minecraft", "blocks/quartz_block_top");
return manager.getSprite("minecraft", "blocks/quartz_block_side");
case QUARTZ_CHISELED:
if (side == 0 || side == 1)
return manager.getSprite("minecraft", "blocks/quartz_block_chiseled_top");
return manager.getSprite("minecraft", "blocks/quartz_block_chiseled");
case QUARTZ_LINES:
if (side == 0 || side == 1)
return manager.getSprite("minecraft", "blocks/quartz_block_lines_top");
return manager.getSprite("minecraft", "blocks/quartz_block_lines");
default:
return null;
}
}
@@ -0,0 +1,117 @@
package forestry.farming.render;
import forestry.api.core.IModelBaker;
import forestry.core.render.model.ModelBlockOverlay;
import forestry.farming.blocks.BlockFarm;
import forestry.farming.blocks.EnumBlockFarmType;
import forestry.farming.tiles.TileFarm;
import forestry.plugins.PluginFarming;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
public class ModelFarmBlock extends ModelBlockOverlay {
@Override
public void renderInventory(Block block, ItemStack item, IModelBaker renderer) {
if (block == null) {
return;
}
EnumFarmBlockTexture type = EnumFarmBlockTexture.getFromCompound(item.getTagCompound());
TextureAtlasSprite[] textures = getSprites(type);
TextureAtlasSprite[] texturesOverlay = getOverlaySprites(EnumBlockFarmType.VALUES[item.getItemDamage()]);
block.setBlockBoundsForItemRender();
renderer.setRenderBoundsFromBlock(block);
// GL11.glTranslatef(translateX, translateY, translateZ);
renderer.renderFaceYNeg(null, textures[0]);
renderer.renderFaceYNeg(null, texturesOverlay[0]);
renderer.renderFaceYPos(null, textures[1]);
renderer.renderFaceYPos(null, texturesOverlay[1]);
renderer.renderFaceZNeg(null, textures[2]);
renderer.renderFaceZNeg(null, texturesOverlay[2]);
renderer.renderFaceZPos(null, textures[3]);
renderer.renderFaceZPos(null, texturesOverlay[3]);
renderer.renderFaceXNeg(null, textures[4]);
renderer.renderFaceXNeg(null, texturesOverlay[4]);
renderer.renderFaceXPos(null, textures[5]);
renderer.renderFaceXPos(null, texturesOverlay[5]);
// GL11.glTranslatef(0.5F, 0.5F, 0.5F);
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public boolean renderInWorld(Block block, IBlockAccess world, BlockPos pos, IModelBaker renderer) {
TileFarm farm = (TileFarm) world.getTileEntity(pos);
TextureAtlasSprite[] textures = getSprites(farm.getFarmBlockTexture());
TextureAtlasSprite[] texturesOverlay = getOverlaySprites(EnumBlockFarmType.VALUES[farm.getBlockMetadata()]);
// Render the plain block.
renderer.renderStandardBlock(block, pos, textures);
renderFarmOverlay(world, PluginFarming.blocks.farm, pos, renderer, texturesOverlay);
return true;
}
private static void renderFarmOverlay(IBlockAccess world, BlockFarm block, BlockPos pos, IModelBaker renderer,
TextureAtlasSprite[] texturesOverlay) {
int mixedBrightness = block.getMixedBrightnessForBlock(world, pos);
float adjR = 0.5f;
float adjG = 0.5f;
float adjB = 0.5f;
renderBottomFace(world, block, pos, renderer, texturesOverlay[0], mixedBrightness, adjR, adjG, adjB);
renderTopFace(world, block, pos, renderer, texturesOverlay[1], mixedBrightness, adjR, adjG, adjB);
renderEastFace(world, block, pos, renderer, texturesOverlay[2], mixedBrightness, adjR, adjG, adjB);
renderWestFace(world, block, pos, renderer, texturesOverlay[3], mixedBrightness, adjR, adjG, adjB);
renderNorthFace(world, block, pos, renderer, texturesOverlay[4], mixedBrightness, adjR, adjG, adjB);
renderSouthFace(world, block, pos, renderer, texturesOverlay[5], mixedBrightness, adjR, adjG, adjB);
}
private static TextureAtlasSprite[] getSprites(EnumFarmBlockTexture texture) {
TextureAtlasSprite[] textures = new TextureAtlasSprite[6];
textures[0] = EnumFarmBlockTexture.getSprite(texture, 0);
textures[1] = EnumFarmBlockTexture.getSprite(texture, 1);
textures[2] = EnumFarmBlockTexture.getSprite(texture, 2);
textures[3] = EnumFarmBlockTexture.getSprite(texture, 3);
textures[4] = EnumFarmBlockTexture.getSprite(texture, 4);
textures[5] = EnumFarmBlockTexture.getSprite(texture, 5);
return textures;
}
private static TextureAtlasSprite[] getOverlaySprites(EnumBlockFarmType type) {
TextureAtlasSprite[] textures = new TextureAtlasSprite[6];
textures[0] = getOverlaySprite(type, 0);
textures[1] = getOverlaySprite(type, 1);
textures[2] = getOverlaySprite(type, 2);
textures[3] = getOverlaySprite(type, 3);
textures[4] = getOverlaySprite(type, 4);
textures[5] = getOverlaySprite(type, 5);
return textures;
}
private static TextureAtlasSprite getOverlaySprite(EnumBlockFarmType texture, int side) {
return EnumFarmBlockTexture.getSprite(texture, side);
}
@Override
public TextureAtlasSprite getParticleTexture() {
return getSprites(EnumFarmBlockTexture.BRICK)[0];
}
}
@@ -1,62 +0,0 @@
/*******************************************************************************
* 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.render;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import forestry.core.render.RenderOverlayBlock;
import forestry.farming.blocks.BlockFarm;
import forestry.plugins.PluginFarming;
public class RenderFarmBlock extends RenderOverlayBlock {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
// Render the plain block.
renderer.renderStandardBlock(block, x, y, z);
renderFarmOverlay(world, PluginFarming.blocks.farm, x, y, z, renderer);
return true;
}
private static void renderFarmOverlay(IBlockAccess world, BlockFarm block, int x, int y, int z, RenderBlocks renderer) {
int mixedBrightness = block.getMixedBrightnessForBlock(world, x, y, z);
int metadata = world.getBlockMetadata(x, y, z);
float adjR = 0.5f;
float adjG = 0.5f;
float adjB = 0.5f;
renderBottomFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(0, metadata), mixedBrightness, adjR, adjG, adjB);
renderTopFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(1, metadata), mixedBrightness, adjR, adjG, adjB);
renderEastFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(2, metadata), mixedBrightness, adjR, adjG, adjB);
renderWestFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(3, metadata), mixedBrightness, adjR, adjG, adjB);
renderNorthFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(4, metadata), mixedBrightness, adjR, adjG, adjB);
renderSouthFace(world, block, x, y, z, renderer, BlockFarm.getOverlayTextureForBlock(5, metadata), mixedBrightness, adjR, adjG, adjB);
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId() {
return PluginFarming.modelIdFarmBlock;
}
}
@@ -1,123 +0,0 @@
/*******************************************************************************
* 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.render;
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.ItemStackUtil;
import forestry.farming.blocks.BlockFarm;
public class RenderFarmItem implements IItemRenderer {
private static void renderFarmBlock(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
Tessellator tessellator = Tessellator.instance;
BlockFarm block = (BlockFarm) ItemStackUtil.getBlock(item);
if (block == null) {
return;
}
block.setBlockBoundsForItemRender();
render.setRenderBoundsFromBlock(block);
EnumFarmBlockTexture type = EnumFarmBlockTexture.getFromCompound(item.getTagCompound());
GL11.glTranslatef(translateX, translateY, translateZ);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1F, 0.0F);
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, BlockFarm.getBlockTextureForSide(type, 0));
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, BlockFarm.getOverlayTextureForBlock(0, item.getItemDamage()));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, BlockFarm.getBlockTextureForSide(type, 1));
render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, BlockFarm.getOverlayTextureForBlock(1, item.getItemDamage()));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1F);
render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, BlockFarm.getBlockTextureForSide(type, 2));
render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, BlockFarm.getOverlayTextureForBlock(2, item.getItemDamage()));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, BlockFarm.getBlockTextureForSide(type, 3));
render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, BlockFarm.getOverlayTextureForBlock(3, item.getItemDamage()));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1F, 0.0F, 0.0F);
render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, BlockFarm.getBlockTextureForSide(type, 4));
render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, BlockFarm.getOverlayTextureForBlock(4, item.getItemDamage()));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, BlockFarm.getBlockTextureForSide(type, 5));
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, BlockFarm.getOverlayTextureForBlock(5, item.getItemDamage()));
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
switch (type) {
case ENTITY:
case EQUIPPED_FIRST_PERSON:
case EQUIPPED:
case INVENTORY:
return true;
default:
return false;
}
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
switch (type) {
case ENTITY:
renderFarmBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f);
break;
case EQUIPPED:
case EQUIPPED_FIRST_PERSON:
renderFarmBlock((RenderBlocks) data[0], item, 0f, 0f, 0f);
break;
case INVENTORY:
renderFarmBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f);
break;
default:
}
GL11.glPopAttrib();
}
}
@@ -16,8 +16,7 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.IErrorLogic;
import forestry.api.core.IErrorLogicSource;
@@ -49,14 +48,14 @@ public abstract class TileFarm extends MultiblockTileEntityForestry<MultiblockLo
}
@Override
public void onMachineAssembled(IMultiblockController multiblockController, ChunkCoordinates minCoord, ChunkCoordinates maxCoord) {
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
worldObj.notifyBlockOfStateChange(getPos(), getBlockType());
markDirty();
}
@Override
public void onMachineBroken() {
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
worldObj.notifyBlockOfStateChange(getPos(), getBlockType());
markDirty();
}
@@ -88,7 +87,7 @@ public abstract class TileFarm extends MultiblockTileEntityForestry<MultiblockLo
public void setFarmBlockTexture(EnumFarmBlockTexture farmBlockTexture) {
if (this.farmBlockTexture != farmBlockTexture) {
this.farmBlockTexture = farmBlockTexture;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
}
}
@@ -10,10 +10,9 @@
******************************************************************************/
package forestry.farming.tiles;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.farming.DefaultFarmListener;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmListener;
@@ -43,15 +42,15 @@ public class TileFarmControl extends TileFarm implements IFarmComponent.Listener
@Override
public boolean cancelTask(IFarmLogic logic, FarmDirection direction) {
return hasRedstoneSignal(direction.getForgeDirection()) || hasRedstoneSignal(ForgeDirection.UP) || hasRedstoneSignal(ForgeDirection.DOWN);
return hasRedstoneSignal(direction.getForgeDirection()) || hasRedstoneSignal(EnumFacing.UP) || hasRedstoneSignal(EnumFacing.DOWN);
}
private boolean hasRedstoneSignal(ForgeDirection direction) {
private boolean hasRedstoneSignal(EnumFacing direction) {
Vect side = new Vect(tile).add(direction);
int dir = direction.getOpposite().ordinal();
World world = tile.getWorldObj();
EnumFacing dir = direction.getOpposite();
World world = tile.getWorld();
return world.getIndirectPowerLevelTo(side.x, side.y, side.z, dir) > 0 || world.isBlockProvidingPowerTo(side.x, side.y, side.z, dir) > 0;
return world.getRedstonePower(side, dir) > 0 || world.getStrongPower(side,dir) > 0;
}
}
@@ -11,9 +11,7 @@
package forestry.farming.tiles;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import forestry.api.multiblock.IFarmComponent;
import forestry.api.multiblock.IFarmController;
import forestry.core.tiles.IPowerHandler;
@@ -94,27 +92,27 @@ public class TileFarmGearbox extends TileFarm implements IPowerHandler, IFarmCom
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) {
return energyManager.receiveEnergy(from, maxReceive, simulate);
}
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) {
return energyManager.extractEnergy(from, maxExtract, simulate);
}
@Override
public int getEnergyStored(ForgeDirection from) {
public int getEnergyStored(EnumFacing from) {
return energyManager.getEnergyStored(from);
}
@Override
public int getMaxEnergyStored(ForgeDirection from) {
public int getMaxEnergyStored(EnumFacing from) {
return energyManager.getMaxEnergyStored(from);
}
@Override
public boolean canConnectEnergy(ForgeDirection from) {
public boolean canConnectEnergy(EnumFacing from) {
return energyManager.canConnectEnergy(from);
}
@@ -16,11 +16,8 @@ import java.util.Collections;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.common.Optional;
import forestry.api.multiblock.IFarmComponent;
import forestry.core.inventory.AdjacentInventoryCache;
import forestry.core.tiles.AdjacentTileCache;
@@ -35,7 +32,7 @@ import buildcraft.api.statements.ITriggerProvider;
@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmComponent.Active, ITriggerProvider {
private static final ForgeDirection[] dumpDirections = new ForgeDirection[]{ForgeDirection.DOWN};
private static final EnumFacing[] dumpDirections = new EnumFacing[]{EnumFacing.DOWN};
private final AdjacentTileCache tileCache;
private final AdjacentInventoryCache inventoryCache;
@@ -45,7 +42,7 @@ public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmCom
this.inventoryCache = new AdjacentInventoryCache(this, tileCache, new AdjacentInventoryCache.ITileFilter() {
@Override
public boolean matches(TileEntity tile) {
return !(tile instanceof TileFarm) && tile.yCoord < yCoord;
return !(tile instanceof TileFarm) && tile.getPos().getY() < getPos().getY();
}
});
}
@@ -80,7 +77,7 @@ public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmCom
/* ITRIGGERPROVIDER */
@Optional.Method(modid = "BuildCraftAPI|statements")
@Override
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
if (!getMultiblockLogic().isConnected()) {
return Collections.emptyList();
}
@@ -10,19 +10,18 @@
******************************************************************************/
package forestry.farming.tiles;
import net.minecraft.util.ChunkCoordinates;
import forestry.api.multiblock.IMultiblockController;
import net.minecraft.util.BlockPos;
public class TileFarmPlain extends TileFarm {
@Override
public void onMachineAssembled(IMultiblockController multiblockController, ChunkCoordinates minCoord, ChunkCoordinates maxCoord) {
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
super.onMachineAssembled(multiblockController, minCoord, maxCoord);
// set band block meta
int bandY = maxCoord.posY - 1;
if (yCoord == bandY) {
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2);
int bandY = maxCoord.getY() - 1;
if (getPos().getY() == bandY) {
this.worldObj.setBlockState(getPos(), getBlockType().getStateFromMeta(1), 2);
}
}
@@ -31,6 +30,6 @@ public class TileFarmPlain extends TileFarm {
super.onMachineBroken();
// set band block meta back to normal
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2);
this.worldObj.setBlockState(getPos(), getBlockType().getStateFromMeta(0), 2);
}
}
@@ -10,7 +10,7 @@
******************************************************************************/
package forestry.farming.tiles;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
@@ -23,32 +23,32 @@ public class TileFarmValve extends TileFarm implements ILiquidTankTile, IFluidHa
/* ILIQUIDTANKCONTAINER */
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
return getTankManager().fill(from, resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
return getTankManager().drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
return getTankManager().drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
public boolean canFill(EnumFacing from, Fluid fluid) {
return getTankManager().canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
public boolean canDrain(EnumFacing from, Fluid fluid) {
return getTankManager().canDrain(from, fluid);
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
public FluidTankInfo[] getTankInfo(EnumFacing from) {
return getTankManager().getTankInfo(from);
}
@@ -12,9 +12,7 @@ package forestry.farming.triggers;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import forestry.core.triggers.Trigger;
import forestry.core.utils.InventoryUtil;
import forestry.farming.tiles.TileFarmHatch;
@@ -37,7 +35,7 @@ public class TriggerLowFertilizer extends Trigger {
}
@Override
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
if (!(tile instanceof TileFarmHatch)) {
return false;
}
@@ -12,9 +12,7 @@ package forestry.farming.triggers;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import forestry.core.triggers.Trigger;
import forestry.core.utils.InventoryUtil;
import forestry.farming.tiles.TileFarmHatch;
@@ -40,7 +38,7 @@ public class TriggerLowGermlings extends Trigger {
* Return true if the tile given in parameter activates the trigger, given the parameters.
*/
@Override
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
if (!(tile instanceof TileFarmHatch)) {
return false;
}
@@ -11,8 +11,7 @@
package forestry.farming.triggers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.IFluidTank;
import forestry.core.fluids.ITankManager;
@@ -41,7 +40,7 @@ public class TriggerLowLiquid extends Trigger {
* the parameters.
*/
@Override
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
if (!(tile instanceof TileFarmHatch)) {
return false;
}
@@ -13,9 +13,7 @@ package forestry.farming.triggers;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import forestry.api.farming.IFarmInventory;
import forestry.api.multiblock.IFarmController;
import forestry.core.triggers.Trigger;
@@ -54,7 +52,7 @@ public class TriggerLowSoil extends Trigger {
* the parameters.
*/
@Override
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
IStatementParameter parameter = null;
if (parameters.length > 0) {
parameter = parameters[0];