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

+16 -16
View File
@@ -16,22 +16,20 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.Type;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.Type;
import forestry.api.core.ForestryAPI;
import forestry.core.EventHandlerCore;
import forestry.core.config.Config;
@@ -99,6 +97,8 @@ public class Forestry {
ForestryAPI.activeMode = new GameMode(Config.gameMode);
PluginManager.runPreInit();
Proxies.render.registerModels();
}
@EventHandler
@@ -13,7 +13,7 @@ package forestry.apiculture;
import java.util.Random;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
@@ -32,7 +32,7 @@ public class HasFlowersCache implements INBTTagable {
private static final int flowerCheckInterval = 128;
private final int flowerCheckTime = random.nextInt(flowerCheckInterval);
private ChunkCoordinates flowerCoords = null;
private BlockPos flowerCoords = null;
private int cooldown = 0;
public boolean hasFlowers(IBee queen, IBeeHousing beeHousing) {
@@ -46,7 +46,7 @@ public class HasFlowersCache implements INBTTagable {
}
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
ChunkCoordinates housingCoords = beeHousing.getCoordinates();
BlockPos housingCoords = beeHousing.getCoordinates();
int[] genomeTerritory = queen.getGenome().getTerritory();
float housingModifier = beeModifier.getTerritoryModifier(queen.getGenome(), 1f);
@@ -76,11 +76,11 @@ public class HasFlowersCache implements INBTTagable {
if (!isFlowerCoordInRange(flowerCoords, min, max)) {
return false;
}
return FlowerManager.flowerRegistry.isAcceptedFlower(flowerType, world, flowerCoords.posX, flowerCoords.posY, flowerCoords.posZ);
return FlowerManager.flowerRegistry.isAcceptedFlower(flowerType, world, flowerCoords);
}
private static boolean isFlowerCoordInRange(ChunkCoordinates flowerCoords, Vect min, Vect max) {
return flowerCoords.posX >= min.x && flowerCoords.posX <= max.x && flowerCoords.posY >= min.y && flowerCoords.posY <= max.y && flowerCoords.posZ >= min.z && flowerCoords.posZ <= max.z;
private static boolean isFlowerCoordInRange(BlockPos flowerCoords, Vect min, Vect max) {
return flowerCoords.getX() >= min.getX() && flowerCoords.getX() <= max.getX() && flowerCoords.getY() >= min.getY() && flowerCoords.getY() <= max.getY() && flowerCoords.getZ() >= min.getZ() && flowerCoords.getZ() <= max.getZ();
}
@Override
@@ -94,7 +94,7 @@ public class HasFlowersCache implements INBTTagable {
int x = hasFlowerCacheNBT.getInteger("flowerX");
int y = hasFlowerCacheNBT.getInteger("flowerY");
int z = hasFlowerCacheNBT.getInteger("flowerZ");
flowerCoords = new ChunkCoordinates(x, y, z);
flowerCoords = new BlockPos(x, y, z);
}
cooldown = hasFlowerCacheNBT.getInteger("cooldown");
@@ -104,9 +104,9 @@ public class HasFlowersCache implements INBTTagable {
public void writeToNBT(NBTTagCompound nbttagcompound) {
NBTTagCompound hasFlowerCacheNBT = new NBTTagCompound();
if (flowerCoords != null) {
hasFlowerCacheNBT.setInteger("flowerX", flowerCoords.posX);
hasFlowerCacheNBT.setInteger("flowerY", flowerCoords.posY);
hasFlowerCacheNBT.setInteger("flowerZ", flowerCoords.posZ);
hasFlowerCacheNBT.setInteger("flowerX", flowerCoords.getX());
hasFlowerCacheNBT.setInteger("flowerY", flowerCoords.getY());
hasFlowerCacheNBT.setInteger("flowerZ", flowerCoords.getZ());
}
hasFlowerCacheNBT.setInteger("cooldown", cooldown);
@@ -11,7 +11,7 @@
package forestry.apiculture;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBeeHousingInventory;
@@ -43,7 +43,7 @@ public class InventoryBeeHousing extends InventoryAdapterRestricted implements I
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
public boolean canExtractItem(int slotIndex, ItemStack itemstack, EnumFacing side) {
if (!super.canExtractItem(slotIndex, itemstack, side)) {
return false;
}
@@ -10,34 +10,15 @@
******************************************************************************/
package forestry.apiculture;
import java.util.List;
import java.util.Random;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.village.MerchantRecipe;
import net.minecraft.village.MerchantRecipeList;
import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraft.world.gen.structure.StructureVillagePieces;
/**
* TODO: Make it to a {@link VillagerProfession} when Forge has Fixed the {@link VillagerRegistry}
*/
public class VillageHandlerApiculture /*implements IVillageCreationHandler, IVillageTradeHandler*/ {
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
import forestry.api.apiculture.EnumBeeType;
import forestry.apiculture.blocks.BlockApicultureType;
import forestry.apiculture.genetics.BeeDefinition;
import forestry.apiculture.worldgen.ComponentVillageBeeHouse;
import forestry.core.utils.Log;
import forestry.plugins.PluginApiculture;
public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler {
public static void registerVillageComponents() {
/*public static void registerVillageComponents() {
try {
MapGenStructureIO.func_143031_a(ComponentVillageBeeHouse.class, "Forestry:BeeHouse");
} catch (Throwable e) {
@@ -79,5 +60,5 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla
public Object buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2,
int p3, int p4, int p5) {
return ComponentVillageBeeHouse.buildComponent(startPiece, pieces, random, p1, p2, p3, p4, p5);
}
}*/
}
@@ -11,24 +11,34 @@
package forestry.apiculture.blocks;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
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.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
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.util.IStringSerializable;
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.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.apiculture.multiblock.TileAlveary;
import forestry.apiculture.multiblock.TileAlvearyClimatiser;
import forestry.apiculture.multiblock.TileAlvearyFan;
import forestry.apiculture.multiblock.TileAlvearyHeater;
import forestry.apiculture.multiblock.TileAlvearyHygroregulator;
@@ -37,20 +47,47 @@ import forestry.apiculture.multiblock.TileAlvearySieve;
import forestry.apiculture.multiblock.TileAlvearyStabiliser;
import forestry.apiculture.multiblock.TileAlvearySwarmer;
import forestry.core.blocks.BlockStructure;
import forestry.core.render.TextureManager;
import forestry.core.proxy.Proxies;
public class BlockAlveary extends BlockStructure {
public enum Type {
public class BlockAlveary extends BlockStructure implements IStateMapperRegister {
private static final PropertyEnum TYPE = PropertyEnum.create("alveary", Type.class);
private static final PropertyEnum STATE = PropertyEnum.create("state", State.class);
private static final PropertyEnum LEVEL = PropertyEnum.create("type", Level.class);
private enum State implements IStringSerializable {
ON, OFF;
@Override
public String getName() {
return name().toLowerCase();
}
}
private enum Level implements IStringSerializable {
BOTTOM, LEFT, RIGHT;
@Override
public String getName() {
return name().toLowerCase();
}
}
public enum Type implements IStringSerializable {
PLAIN,
ENTRANCE,
SWARMER,
FAN,
HEATER,
HYGRO,
STABILIZER,
STABILISER,
SIEVE;
public static final Type[] VALUES = values();
@Override
public String getName() {
return name().toLowerCase();
}
}
public BlockAlveary() {
@@ -58,6 +95,7 @@ public class BlockAlveary extends BlockStructure {
setHardness(1.0f);
setCreativeTab(Tabs.tabApiculture);
setHarvestLevel("axe", 0);
setDefaultState(this.blockState.getBaseState().withProperty(TYPE, Type.PLAIN).withProperty(STATE, State.OFF).withProperty(LEVEL, Level.BOTTOM));
}
@SuppressWarnings({"rawtypes", "unchecked"})
@@ -74,30 +112,31 @@ public class BlockAlveary extends BlockStructure {
@Override
public int getRenderType() {
return 0;
return 3;
}
@Override
public boolean renderAsNormalBlock() {
public boolean isNormalCube() {
return true;
}
@Override
public boolean isFullCube() {
return true;
}
@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) {
int metadata = getMetaFromState(state);
ArrayList<ItemStack> drop = new ArrayList<>();
drop.add(new ItemStack(this, 1, metadata != 1 ? metadata : 0));
return drop;
}
@Override
public int getDamageValue(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return meta != 1 ? meta : 0;
}
/* TILE ENTITY CREATION */
@Override
public TileEntity createTileEntity(World world, int metadata) {
public TileEntity createTileEntity(World world, IBlockState state) {
int metadata = getMetaFromState(state);
if (metadata < 0 || metadata > Type.VALUES.length) {
return null;
}
@@ -112,7 +151,7 @@ public class BlockAlveary extends BlockStructure {
return new TileAlvearyHeater();
case HYGRO:
return new TileAlvearyHygroregulator();
case STABILIZER:
case STABILISER:
return new TileAlvearyStabiliser();
case SIEVE:
return new TileAlvearySieve();
@@ -124,159 +163,146 @@ public class BlockAlveary extends BlockStructure {
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return createTileEntity(world, meta);
return createTileEntity(world, getStateFromMeta(meta));
}
/* ICONS */
public static final int PLAIN = 0;
public static final int ENTRANCE = 1;
public static final int BOTTOM = 2;
public static final int LEFT = 3;
public static final int RIGHT = 4;
public static final int ALVEARY_SWARMER_OFF = 5;
public static final int ALVEARY_SWARMER_ON = 6;
public static final int ALVEARY_HEATER_OFF = 7;
public static final int ALVEARY_HEATER_ON = 8;
public static final int ALVEARY_FAN_OFF = 9;
public static final int ALVEARY_FAN_ON = 10;
public static final int ALVEARY_HYGRO = 11;
public static final int STABILISER = 12;
public static final int SIEVE = 13;
@SideOnly(Side.CLIENT)
private IIcon[] icons;
/* ITEM MODELS */
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
icons = new IIcon[14];
icons[0] = TextureManager.registerTex(register, "apiculture/alveary.plain");
icons[1] = TextureManager.registerTex(register, "apiculture/alveary.entrance");
icons[2] = TextureManager.registerTex(register, "apiculture/alveary.bottom");
icons[3] = TextureManager.registerTex(register, "apiculture/alveary.left");
icons[4] = TextureManager.registerTex(register, "apiculture/alveary.right");
icons[5] = TextureManager.registerTex(register, "apiculture/alveary.swarmer.off");
icons[6] = TextureManager.registerTex(register, "apiculture/alveary.swarmer.on");
icons[7] = TextureManager.registerTex(register, "apiculture/alveary.heater.off");
icons[8] = TextureManager.registerTex(register, "apiculture/alveary.heater.on");
icons[9] = TextureManager.registerTex(register, "apiculture/alveary.fan.off");
icons[10] = TextureManager.registerTex(register, "apiculture/alveary.fan.on");
icons[11] = TextureManager.registerTex(register, "apiculture/alveary.valve");
icons[12] = TextureManager.registerTex(register, "apiculture/alveary.stabiliser");
icons[13] = TextureManager.registerTex(register, "apiculture/alveary.sieve");
public void registerModel(Item item, IModelManager manager) {
manager.registerItemModel(item, 0, "apiculture/alveary.plain");
manager.registerItemModel(item, 1, "apiculture/alveary.entrance");
manager.registerItemModel(item, 2, "apiculture/alveary.swarmer");
manager.registerItemModel(item, 3, "apiculture/alveary.fan");
manager.registerItemModel(item, 4, "apiculture/alveary.heater");
manager.registerItemModel(item, 5, "apiculture/alveary.hygro");
manager.registerItemModel(item, 6, "apiculture/alveary.stabiliser");
manager.registerItemModel(item, 7, "apiculture/alveary.sieve");
}
/* STATES */
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(TYPE, Type.values()[meta]);
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int metadata) {
if ((metadata <= 1
|| metadata == Type.SIEVE.ordinal() || metadata == Type.SWARMER.ordinal() || metadata == Type.STABILIZER.ordinal())
&& (side == 1 || side == 0)) {
return icons[BOTTOM];
}
Type type = Type.VALUES[metadata];
switch (type) {
case PLAIN:
return icons[PLAIN];
case ENTRANCE:
return icons[ENTRANCE];
case SWARMER:
return icons[ALVEARY_SWARMER_OFF];
case FAN:
return icons[ALVEARY_FAN_OFF];
case HEATER:
return icons[ALVEARY_HEATER_OFF];
case HYGRO:
return icons[ALVEARY_HYGRO];
case STABILIZER:
return icons[STABILISER];
case SIEVE:
return icons[SIEVE];
default:
return null;
}
public int getMetaFromState(IBlockState state) {
return ((Type) state.getValue(TYPE)).ordinal();
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 1) {
return this.getIcon(side, meta);
} else if (meta > 1) {
return getBlockTextureFromSideAndTile(world, x, y, z, side);
protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { TYPE, STATE, LEVEL });
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileAlveary) {
if (tile instanceof TileAlvearyClimatiser) {
TileAlvearyClimatiser alveary = (TileAlvearyClimatiser) tile;
if (alveary.isActive()) {
state = state.withProperty(STATE, State.ON);
} else {
state = state.withProperty(STATE, State.OFF);
}
} else if (tile instanceof TileAlvearySwarmer) {
TileAlvearySwarmer alveary = (TileAlvearySwarmer) tile;
if (alveary.isActive()) {
state = state.withProperty(STATE, State.ON);
} else {
state = state.withProperty(STATE, State.OFF);
}
}
}
Block blockXP = world.getBlock(x + 1, y, z);
Block blockXM = world.getBlock(x - 1, y, z);
int meta = ((Type) state.getValue(TYPE)).ordinal();
Block blockXP = world.getBlockState(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ())).getBlock();
Block blockXM = world.getBlockState(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ())).getBlock();
state = state.withProperty(LEVEL, Level.BOTTOM);
if (blockXP == this && blockXM != this) {
if (world.getBlockMetadata(x + 1, y, z) == 1) {
IBlockState stateNeighbor = world.getBlockState(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()));
if (stateNeighbor.getBlock().getMetaFromState(stateNeighbor) == 1) {
if (world.getBlock(x, y, z + 1) != this) {
return switchForSide(42, side);
if (world.getBlockState(new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1)).getBlock() != this) {
switchForSide(state, world, pos);
} else {
return switchForSide(41, side);
switchForSide(state, world, pos);
}
} else {
return this.getIcon(side, meta);
}
} else if (blockXP != this && blockXM == this) {
if (world.getBlockMetadata(x - 1, y, z) == 1) {
IBlockState stateNeighbor = world.getBlockState(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()));
if (stateNeighbor.getBlock().getMetaFromState(stateNeighbor) == 1) {
if (world.getBlock(x, y, z + 1) != this) {
return switchForSide(41, side);
if (world.getBlockState(new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1)).getBlock() != this) {
switchForSide(state, world, pos);
} else {
return switchForSide(42, side);
switchForSide(state, world, pos);
}
} else {
return this.getIcon(side, meta);
}
}
return this.getIcon(side, meta);
return super.getActualState(state, world, pos);
}
private void switchForSide(IBlockState state, IBlockAccess world, BlockPos pos) {
@SideOnly(Side.CLIENT)
private IIcon getBlockTextureFromSideAndTile(IBlockAccess world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileAlveary)) {
return getIcon(side, 0);
Block blockX = world.getBlockState(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ())).getBlock();
Block blockY = world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())).getBlock();
if (blockX != this && blockY == this) {
state = state.withProperty(LEVEL, Level.LEFT);
} else if (blockX == this && blockY == this) {
state = state.withProperty(LEVEL, Level.RIGHT);
} else if (blockX == this && blockY != this) {
state = state.withProperty(LEVEL, Level.LEFT);
} else if (blockX != this && blockY != this) {
state = state.withProperty(LEVEL, Level.RIGHT);
}
return icons[((TileAlveary) tile).getIcon(side)];
}
@Override
public void registerStateMapper() {
Proxies.render.registerStateMapper(this, new AlvearyStateMapper());
}
@SideOnly(Side.CLIENT)
private IIcon switchForSide(int textureId, int side) {
private static class AlvearyStateMapper extends StateMapperBase {
if (side == 4 || side == 5) {
if (textureId == 41) {
return icons[LEFT];
} else {
return icons[RIGHT];
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
LinkedHashMap linkedhashmap = Maps.newLinkedHashMap(state.getProperties());
if (linkedhashmap.get(TYPE) != Type.PLAIN) {
linkedhashmap.remove(LEVEL);
}
} else if (textureId == 41) {
return icons[RIGHT];
} else {
return icons[LEFT];
if (linkedhashmap.get(TYPE) == Type.SIEVE
|| linkedhashmap.get(TYPE) == Type.ENTRANCE
|| linkedhashmap.get(TYPE) == Type.STABILISER
|| linkedhashmap.get(TYPE) == Type.HYGRO
|| linkedhashmap.get(TYPE) == Type.PLAIN) {
linkedhashmap.remove(STATE);
}
String s = String.format("%s:%s",
Block.blockRegistry.getNameForObject(state.getBlock()).getResourceDomain(),
"apiculture/alveary_" + TYPE.getName((Enum) linkedhashmap.remove(TYPE)));
;
return new ModelResourceLocation(s, this.getPropertyString(linkedhashmap));
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
TileEntity tileEntity = world.getTileEntity(x, y, z);
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) {
super.onNeighborBlockChange(world, pos, state, neighborBlock);
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof TileAlveary) {
TileAlveary tileAlveary = (TileAlveary) tileEntity;
@@ -15,7 +15,7 @@ import forestry.core.blocks.BlockBase;
public class BlockApiculture extends BlockBase<BlockApicultureType> {
public BlockApiculture() {
super();
super(BlockApicultureType.class);
setCreativeTab(Tabs.tabApiculture);
setHarvestLevel("axe", 0);
}
@@ -0,0 +1,51 @@
/*******************************************************************************
* 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.apiculture.blocks;
import java.util.Locale;
import forestry.apiculture.tiles.TileApiaristChest;
import forestry.core.blocks.IMachineProperties;
import forestry.core.tiles.TileForestry;
public enum BlockApicultureChestType implements IMachineProperties {
APIARIST_CHEST(TileApiaristChest.class, "ApiaristChest");
public static final BlockApicultureChestType[] VALUES = values();
private final String teIdent;
private final Class<? extends TileForestry> teClass;
BlockApicultureChestType(Class<? extends TileForestry> teClass, String name) {
this.teIdent = "forestry." + name;
this.teClass = teClass;
}
@Override
public int getMeta() {
return ordinal();
}
@Override
public String getTeIdent() {
return teIdent;
}
@Override
public Class<? extends TileForestry> getTeClass() {
return teClass;
}
@Override
public String getName() {
return name().toLowerCase(Locale.ENGLISH);
}
}
@@ -55,4 +55,9 @@ public enum BlockApicultureType implements IMachineProperties {
public Class<? extends TileForestry> getTeClass() {
return teClass;
}
@Override
public String getName() {
return name().toLowerCase(Locale.ENGLISH);
}
}
@@ -15,44 +15,57 @@ import java.util.Collections;
import java.util.List;
import net.minecraft.block.BlockContainer;
import net.minecraft.client.renderer.texture.IIconRegister;
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.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
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.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.apiculture.hives.IHiveRegistry.HiveType;
import forestry.api.core.IModelManager;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.apiculture.tiles.TileSwarm;
import forestry.apiculture.worldgen.HiveRegistry;
import forestry.core.config.Config;
import forestry.core.render.TextureManager;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.plugins.PluginApiculture;
public class BlockBeehives extends BlockContainer {
public enum Type {
LEGACY,
FOREST,
MEADOWS;
}
public class BlockBeehives extends BlockContainer implements IItemModelRegister {
private static final PropertyEnum HIVETYPES = PropertyEnum.create("hive", HiveType.class);
public BlockBeehives() {
super(new MaterialBeehive(true));
setLightLevel(0.8f);
setHardness(1.0f);
setCreativeTab(Tabs.tabApiculture);
setHarvestLevel("scoop", 0);
setDefaultState(this.blockState.getBaseState().withProperty(HIVETYPES, HiveType.FOREST));
}
@Override
protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { HIVETYPES });
}
@Override
public int getMetaFromState(IBlockState state) {
return ((HiveType) state.getValue(HIVETYPES)).ordinal() + 1;
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(HIVETYPES, HiveType.values()[meta - 1]);
}
@Override
@@ -61,42 +74,36 @@ public class BlockBeehives extends BlockContainer {
}
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
public boolean canEntityDestroy(IBlockAccess world, BlockPos pos, Entity entity) {
return false;
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
if (canHarvestBlock(player, world.getBlockMetadata(x, y, z))) {
public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
if (canHarvestBlock(world, pos, player)) {
// Handle TE'd beehives
TileEntity tile = world.getTileEntity(x, y, z);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileSwarm) {
TileSwarm swarm = (TileSwarm) tile;
if (swarm.containsBees()) {
for (ItemStack beeStack : InventoryUtil.getStacks(swarm.contained)) {
if (beeStack != null) {
ItemStackUtil.dropItemStackAsEntity(beeStack, world, x, y, z);
ItemStackUtil.dropItemStackAsEntity(beeStack, 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> ret = new ArrayList<>();
// Handle legacy block
if (metadata == 0) {
ret.add(new ItemStack(this));
return ret;
}
List<IHiveDrop> dropList = getDropsForHive(metadata);
List<IHiveDrop> dropList = getDropsForHive(getMetaFromState(state));
Collections.shuffle(dropList);
// Grab a princess
@@ -106,8 +113,8 @@ public class BlockBeehives extends BlockContainer {
tries++;
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.add(drop.getPrincess(world, x, y, z, fortune));
if (RANDOM.nextInt(100) < drop.getChance((World) world, pos)) {
ret.add(drop.getPrincess((World) world, pos, fortune));
hasPrincess = true;
break;
}
@@ -116,15 +123,15 @@ public class BlockBeehives extends BlockContainer {
// Grab drones
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.addAll(drop.getDrones(world, x, y, z, fortune));
if (RANDOM.nextInt(100) < drop.getChance((World) world, pos)) {
ret.addAll(drop.getDrones((World) world, pos, fortune));
break;
}
}
// Grab anything else on offer
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.addAll(drop.getAdditional(world, x, y, z, fortune));
if (RANDOM.nextInt(100) < drop.getChance((World) world, pos)) {
ret.addAll(drop.getAdditional((World) world, pos, fortune));
break;
}
}
@@ -134,8 +141,8 @@ public class BlockBeehives extends BlockContainer {
// / CREATIVE INVENTORY
@Override
public int damageDropped(int meta) {
return meta;
public int damageDropped(IBlockState state) {
return getMetaFromState(state);
}
private static List<IHiveDrop> getDropsForHive(int meta) {
@@ -149,19 +156,19 @@ public class BlockBeehives extends BlockContainer {
private static String getHiveNameForMeta(int meta) {
switch (meta) {
case 1:
return HiveRegistry.forest;
return HiveType.FOREST.getHiveName();
case 2:
return HiveRegistry.meadows;
return HiveType.MEADOWS.getHiveName();
case 3:
return HiveRegistry.desert;
return HiveType.DESERT.getHiveName();
case 4:
return HiveRegistry.jungle;
return HiveType.JUNGLE.getHiveName();
case 5:
return HiveRegistry.end;
return HiveType.END.getHiveName();
case 6:
return HiveRegistry.snow;
return HiveType.SNOW.getHiveName();
case 7:
return HiveRegistry.swamp;
return HiveType.SWAMP.getHiveName();
}
return null;
}
@@ -181,38 +188,22 @@ public class BlockBeehives extends BlockContainer {
// Swarm hive not added
}
/* ICONS */
@SideOnly(Side.CLIENT)
private IIcon[] icons;
/* IETM MODELS */
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
icons = new IIcon[18];
for (int i = 1; i < 9; i++) {
icons[i * 2] = TextureManager.registerTex(register, "beehives/beehive." + i + ".top");
icons[(i * 2) + 1] = TextureManager.registerTex(register, "beehives/beehive." + i + ".side");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j) {
if (j == 0 || j > 8) {
return null;
}
if (i == 0 || i == 1) {
if (j * 2 < icons.length && icons[j * 2] != null) {
return icons[j * 2];
} else {
return icons[2];
}
} else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null) {
return icons[j * 2 + 1];
} else {
return icons[3];
}
public void registerModel(Item item, IModelManager manager) {
manager.registerItemModel(item, 1, "beehives/" + HiveType.FOREST.getName());
manager.registerItemModel(item, 2, "beehives/" + HiveType.MEADOWS.getName());
manager.registerItemModel(item, 3, "beehives/" + HiveType.DESERT.getName());
manager.registerItemModel(item, 4, "beehives/" + HiveType.JUNGLE.getName());
manager.registerItemModel(item, 5, "beehives/" + HiveType.END.getName());
manager.registerItemModel(item, 6, "beehives/" + HiveType.SNOW.getName());
manager.registerItemModel(item, 7, "beehives/" + HiveType.SWAMP.getName());
}
@Override
public int getRenderType()
{
return 3;
}
}
@@ -22,7 +22,10 @@ import java.util.Random;
import java.util.Set;
import net.minecraft.block.BlockTorch;
import net.minecraft.client.renderer.texture.IIconRegister;
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.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -32,29 +35,38 @@ 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.IStringSerializable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.Tabs;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.proxy.Proxies;
import forestry.core.render.TextureManager;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.StringUtil;
public class BlockCandle extends BlockTorch {
public class BlockCandle extends BlockTorch implements IItemModelRegister {
private static final ImmutableMap<String, Integer> colours;
private static final Set<Item> lightingItems;
public static final String colourTagName = "colour";
private static final PropertyEnum STATE = PropertyEnum.create("state", State.class);
private enum State implements IStringSerializable {
ON, OFF;
@Override
public String getName() {
return name();
}
}
static {
colours = ImmutableMap.<String, Integer>builder()
.put("dyeWhite", new Color(255, 255, 255).getRGB())
@@ -82,74 +94,57 @@ public class BlockCandle extends BlockTorch {
));
}
@SideOnly(Side.CLIENT)
private IIcon litStump;
@SideOnly(Side.CLIENT)
private IIcon litTip;
@SideOnly(Side.CLIENT)
private IIcon unlitStump;
@SideOnly(Side.CLIENT)
private IIcon unlitTip;
public BlockCandle() {
super();
this.setHardness(0.0F);
this.setStepSound(soundTypeWood);
setCreativeTab(Tabs.tabApiculture);
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.UP).withProperty(STATE, State.OFF));
}
@Override
protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { FACING, STATE });
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
if(((TileCandle)world.getTileEntity(pos)).isLit())
state = state.withProperty(STATE, State.ON);
return super.getActualState(state, world, pos);
}
@Override
public boolean hasTileEntity(int metadata) {
public boolean hasTileEntity(IBlockState state) {
return true;
}
@Override
public TileEntity createTileEntity(World world, int metadata) {
public TileEntity createTileEntity(World world, IBlockState state) {
return new TileCandle();
}
@Override
public int getRenderType() {
return Proxies.render.getCandleRenderId();
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
String fileBase = StringUtil.cleanBlockName(this);
this.blockIcon = TextureManager.registerTex(register, "stump");
this.litStump = TextureManager.registerTex(register, fileBase + "StumpLit");
this.litTip = TextureManager.registerTex(register, fileBase + "TipLit");
this.unlitStump = TextureManager.registerTex(register, fileBase + "StumpUnlit");
this.unlitTip = TextureManager.registerTex(register, fileBase + "TipUnlit");
public void registerModel(Item item, IModelManager manager) {
manager.registerItemModel(item, 0, "candle");
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
public int getLightValue(IBlockAccess world, BlockPos pos) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof TileCandle && ((TileCandle) tileEntity).isLit()) {
return 14;
}
return 0;
}
@SideOnly(Side.CLIENT)
public IIcon getTextureFromPassAndLit(int pass, boolean isLit) {
IIcon i;
if (pass == 0) {
if (isLit) {
i = this.litTip;
} else {
i = this.unlitTip;
}
} else {
if (isLit) {
i = this.litStump;
} else {
i = this.unlitStump;
}
@Override
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) {
if(renderPass < 3){
return ((TileCandle)worldIn.getTileEntity(pos)).getColour();
}
return i;
return 16777215;
}
@SuppressWarnings({"rawtypes", "unchecked"})
@@ -159,8 +154,8 @@ public class BlockCandle extends BlockTorch {
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float facingX, float facingY, float facingZ) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
TileEntity tileEntity = world.getTileEntity(pos);
if (!(tileEntity instanceof TileCandle)) {
return false;
}
@@ -197,7 +192,7 @@ public class BlockCandle extends BlockTorch {
} else {
boolean dyed = tryDye(heldItem, isLit, tileCandle);
if (dyed) {
world.markBlockForUpdate(x, y, z);
world.markBlockForUpdate(pos);
toggleLitState = false;
flag = true;
}
@@ -206,7 +201,10 @@ public class BlockCandle extends BlockTorch {
if (toggleLitState) {
tileCandle.setLit(!isLit);
world.markBlockForUpdate(x, y, z);
world.markBlockForUpdate(pos);
world.theProfiler.startSection("checkLight");
world.checkLight(pos);
world.theProfiler.endSection();
flag = true;
}
return flag;
@@ -236,21 +234,21 @@ public class BlockCandle extends BlockTorch {
private final ThreadLocal<ItemStack> drop = new ThreadLocal<>();
@Override
public void onBlockHarvested(World world, int x, int y, int z, int metadata, EntityPlayer player) {
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
if (!world.isRemote) {
ItemStack itemStack = getCandleDrop(world, x, y, z);
ItemStack itemStack = getCandleDrop(world, pos);
drop.set(itemStack);
}
}
@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) {
ItemStack dropStack = drop.get();
drop.remove();
// not harvested, get drops normally
if (dropStack == null) {
dropStack = getCandleDrop(world, x, y, z);
dropStack = getCandleDrop(world, pos);
}
ArrayList<ItemStack> drops = new ArrayList<>(1);
@@ -260,12 +258,12 @@ public class BlockCandle extends BlockTorch {
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return getCandleDrop(world, x, y, z);
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
return getCandleDrop(world, pos);
}
private ItemStack getCandleDrop(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
private ItemStack getCandleDrop(IBlockAccess world, BlockPos pos) {
TileEntity tileEntity = world.getTileEntity(pos);
if (!(tileEntity instanceof TileCandle)) {
return null;
}
@@ -284,20 +282,20 @@ public class BlockCandle extends BlockTorch {
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
TileCandle tileCandle = (TileCandle) (world.getTileEntity(x, y, z));
int colour = getColourValueFromItemStack(itemStack);
boolean isLit = isLit(itemStack);
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
TileCandle tileCandle = (TileCandle) (world.getTileEntity(pos));
int colour = getColourValueFromItemStack(stack);
boolean isLit = isLit(stack);
tileCandle.setColour(colour);
tileCandle.setLit(isLit);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof TileCandle && ((TileCandle) tileEntity).isLit()) {
super.randomDisplayTick(world, x, y, z, random);
super.randomDisplayTick(world, pos, state, rand);
}
}
@@ -27,7 +27,7 @@ public class BlockRegistryApiculture extends BlockRegistry {
public BlockRegistryApiculture() {
apiculture = registerBlock(new BlockApiculture(), ItemBlockForestry.class, "apiculture");
apicultureChest = registerBlock(new BlockBase(true), ItemBlockForestry.class, "apicultureChest");
apicultureChest = registerBlock(new BlockBase(true, BlockApicultureChestType.class), ItemBlockForestry.class, "apicultureChest");
apicultureChest.setCreativeTab(Tabs.tabApiculture);
apicultureChest.setHarvestLevel("axe", 0);
@@ -14,27 +14,28 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.BlockTorch;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
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.util.EnumFacing;
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.core.IModelManager;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.Tabs;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.config.Constants;
import forestry.core.render.TextureManager;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
public class BlockStump extends BlockTorch {
public class BlockStump extends BlockTorch implements IItemModelRegister {
public BlockStump() {
super();
@@ -45,8 +46,8 @@ public class BlockStump extends BlockTorch {
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
this.blockIcon = TextureManager.registerTex(register, StringUtil.cleanBlockName(this));
public void registerModel(Item item, IModelManager manager) {
manager.registerItemModel(item, 0, "stump");
}
@SuppressWarnings({"rawtypes", "unchecked"})
@@ -56,17 +57,17 @@ public class BlockStump extends BlockTorch {
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float facingX, float facingY, float facingZ) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack held = player.getCurrentEquippedItem();
if (held != null &&
(held.getItem() == Items.flint_and_steel ||
held.getItem() == Items.flint ||
ItemStackUtil.equals(Blocks.torch, held))) {
world.setBlock(x, y, z, PluginApiculture.blocks.candle, world.getBlockMetadata(x, y, z) | 0x08, Constants.FLAG_BLOCK_SYNCH);
world.setBlockState(pos, PluginApiculture.blocks.candle.getStateFromMeta(BlockUtil.getBlockMetadata(world, pos) | 0x08), Constants.FLAG_BLOCK_SYNCH);
TileCandle tc = new TileCandle();
tc.setColour(0); // default to white
world.setTileEntity(x, y, z, tc);
world.setTileEntity(pos, tc);
return true;
}
@@ -75,11 +76,11 @@ public class BlockStump extends BlockTorch {
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int par1) {
public int getRenderColor(IBlockState state) {
return 0xee0000;
}
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
}
}
@@ -15,9 +15,10 @@ import java.util.Iterator;
import java.util.List;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.PlayerNotFoundException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -63,7 +64,7 @@ public class CommandBeeGive extends SubCommand {
}
@Override
public void processSubCommand(ICommandSender sender, String[] arguments) {
public void processSubCommand(ICommandSender sender, String[] arguments) throws SpeciesNotFoundException, TemplateNotFoundException, PlayerNotFoundException {
if (arguments.length < 2) {
printHelp(sender);
return;
@@ -80,7 +81,7 @@ public class CommandBeeGive extends SubCommand {
if (arguments.length == 3) {
player = CommandHelpers.getPlayer(sender, arguments[2]);
} else {
player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName());
player = CommandHelpers.getPlayer(sender, sender.getName());
}
if (player == null) {
printHelp(sender);
@@ -96,10 +97,10 @@ public class CommandBeeGive extends SubCommand {
ItemStack beeStack = BeeManager.beeRoot.getMemberStack(bee, beeType.ordinal());
player.dropPlayerItemWithRandomChoice(beeStack, true);
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.bee.give.given", player.getCommandSenderName(), bee.getGenome().getPrimary().getName(), beeType.getName());
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.bee.give.given", player.getName(), bee.getGenome().getPrimary().getName(), beeType.getName());
}
private static IBeeGenome getBeeGenome(String speciesName) {
private static IBeeGenome getBeeGenome(String speciesName) throws SpeciesNotFoundException, TemplateNotFoundException {
IAlleleBeeSpecies species = null;
for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
@@ -137,7 +138,7 @@ public class CommandBeeGive extends SubCommand {
}
@Override
public List<String> addTabCompletionOptions(ICommandSender sender, String[] parameters) {
public List<String> addTabCompletionOptions(ICommandSender sender, String[] parameters, BlockPos pos) {
if (parameters.length == 1) {
List<String> tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies());
tabCompletion.add("help");
@@ -55,7 +55,7 @@ public class AIAvoidPlayers extends EntityAIBase {
}
Vec3 randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 16, 7,
Vec3.createVectorHelper(player.posX, player.posY, player.posZ));
new Vec3(player.posX, player.posY, player.posZ));
if (randomTarget == null) {
return false;
@@ -14,10 +14,8 @@ import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.util.ResourceLocation;
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.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -11,7 +11,8 @@
package forestry.apiculture.entities;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
public class EntityFXBee extends EntityFX {
@@ -51,7 +52,7 @@ public class EntityFXBee extends EntityFX {
}
@Override
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {
public void renderParticle(WorldRenderer wR, Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
float minU = 0;
float maxU = 1;
float minV = 0;
@@ -69,11 +70,13 @@ public class EntityFXBee extends EntityFX {
float f12 = (float) ((prevPosY + (posY - prevPosY) * f) - interpPosY);
float f13 = (float) ((prevPosZ + (posZ - prevPosZ) * f) - interpPosZ);
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 1.0F);
tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, maxU, maxV);
tessellator.addVertexWithUV((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10, maxU, minV);
tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, minU, minV);
tessellator.addVertexWithUV((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10, minU, maxV);
int i = this.getBrightnessForRender(f);
int j = i >> 16 & 65535;
int k = i & 65535;
wR.pos(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10).tex(maxU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
wR.pos((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10).tex(maxU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
wR.pos(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10).tex(minU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
wR.pos((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
}
@Override
@@ -15,7 +15,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@@ -69,15 +69,10 @@ public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implement
public IBeeHousingInventory getBeeInventory() {
return inventory;
}
@Override
public Block func_145820_n() {
return PluginApiculture.blocks.apiculture;
}
@Override
public int getDisplayTileData() {
return BlockApicultureType.APIARY.ordinal();
public IBlockState getDisplayTile() {
return PluginApiculture.blocks.apiculture.getStateFromMeta(BlockApicultureType.APIARY.ordinal());
}
@Override
@@ -14,13 +14,12 @@ import java.io.IOException;
import java.util.Random;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingLogic;
@@ -71,7 +70,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
public EnumTemperature getTemperature() {
return EnumTemperature.getFromBiome(getBiome(), (int) posX, (int) posY, (int) posZ);
return EnumTemperature.getFromBiome(getBiome(), getPosition());
}
@Override
@@ -91,12 +90,12 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
public int getBlockLightValue() {
return worldObj.getBlockLightValue((int) posX, (int) posY + 1, (int) posZ);
return worldObj.getLightFromNeighbors(getPosition().add(0, +1, 0));
}
@Override
public boolean canBlockSeeTheSky() {
return worldObj.canBlockSeeTheSky((int) posX, (int) posY + 1, (int) posZ);
return worldObj.canBlockSeeSky(getPosition().add(0, +1, 0));
}
@Override
@@ -106,7 +105,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
public BiomeGenBase getBiome() {
return worldObj.getBiomeGenForCoords((int) posX, (int) posZ);
return worldObj.getBiomeGenForCoords(getPosition());
}
@Override
@@ -120,13 +119,13 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
}
@Override
public ChunkCoordinates getCoordinates() {
return new ChunkCoordinates((int) posX, (int) posY, (int) posZ);
public BlockPos getCoordinates() {
return getPosition();
}
@Override
public Vec3 getBeeFXCoordinates() {
return Vec3.createVectorHelper(posX, posY + 0.25, posZ);
return new Vec3(posX, posY + 0.25, posZ);
}
@Override
@@ -13,7 +13,7 @@ package forestry.apiculture.entities;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@@ -51,15 +51,10 @@ public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
public List<String> getHints() {
return Config.hints.get("bee.house");
}
@Override
public Block func_145820_n() {
return PluginApiculture.blocks.apiculture;
}
@Override
public int getDisplayTileData() {
return BlockApicultureType.BEEHOUSE.ordinal();
public IBlockState getDisplayTile() {
return PluginApiculture.blocks.apiculture.getStateFromMeta(BlockApicultureType.BEEHOUSE.ordinal());
}
@Override
@@ -32,6 +32,7 @@ final class Flower implements IFlower {
this.weight = weight;
}
@Override
public boolean isPlantable() {
return this.weight != 0.0;
}
@@ -11,15 +11,13 @@
package forestry.apiculture.flowers;
import java.util.EnumSet;
import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
@@ -55,24 +53,14 @@ public class FlowerProvider implements IFlowerProvider {
}
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
return FlowerManager.flowerRegistry.growFlower(this.flowerType, world, individual, x, y, z);
}
@Override
public String getDescription() {
return StringUtil.localize(this.description);
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
public ItemStack[] affectProducts(World world, IIndividual individual, BlockPos pos, ItemStack[] products) {
return products;
}
@Override
public Set<IFlower> getFlowers() {
return FlowerManager.flowerRegistry.getAcceptableFlowers(this.flowerType);
}
}
@@ -26,19 +26,14 @@ import java.util.TreeMap;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlowerPot;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.registry.GameRegistry;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IBee;
@@ -52,10 +47,10 @@ import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Constants;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.Log;
import forestry.core.utils.vect.MutableVect;
import forestry.core.utils.vect.Vect;
import forestry.plugins.PluginManager;
public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelper {
@@ -151,7 +146,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
}
@Override
public ChunkCoordinates getAcceptedFlowerCoordinates(IBeeHousing beeHousing, IBee bee, String flowerType) {
public BlockPos getAcceptedFlowerCoordinates(IBeeHousing beeHousing, IBee bee, String flowerType) {
if (!this.registeredFlowers.containsKey(flowerType)) {
return null;
}
@@ -164,7 +159,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
Vect area = getArea(bee.getGenome(), beeModifier);
Vect housingPos = new Vect(beeHousing.getCoordinates()).add(-area.x / 2, -area.y / 2, -area.z / 2);
Vect housingPos = new Vect(beeHousing.getCoordinates()).add(-area.getX() / 2, -area.getY() / 2, -area.getZ() / 2);
MutableVect posCurrent = new MutableVect(0, 0, 0);
while (posCurrent.advancePositionInArea(area)) {
@@ -172,13 +167,13 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
Vect posBlock = Vect.add(housingPos, posCurrent);
for (IFlowerAcceptableRule acceptableRule : acceptableRules) {
if (acceptableRule.isAcceptableFlower(flowerType, world, posBlock.x, posBlock.y, posBlock.z)) {
return new ChunkCoordinates(posBlock.x, posBlock.y, posBlock.z);
if (acceptableRule.isAcceptableFlower(flowerType, world, posBlock)) {
return posBlock;
}
}
if (isAcceptedFlower(flowerType, acceptedBlocks, acceptedFlowers, world, posBlock.x, posBlock.y, posBlock.z)) {
return new ChunkCoordinates(posBlock.x, posBlock.y, posBlock.z);
if (isAcceptedFlower(flowerType, acceptedBlocks, acceptedFlowers, world, posBlock)) {
return posBlock;
}
}
@@ -186,14 +181,14 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
}
@Override
public boolean isAcceptedFlower(String flowerType, World world, int x, int y, int z) {
public boolean isAcceptedFlower(String flowerType, World world, BlockPos pos) {
if (!this.registeredFlowers.containsKey(flowerType)) {
return false;
}
Set<IFlowerAcceptableRule> acceptedCustom = this.registeredRules.get(flowerType);
for (IFlowerAcceptableRule acceptableFlower : acceptedCustom) {
if (acceptableFlower.isAcceptableFlower(flowerType, world, x, y, z)) {
if (acceptableFlower.isAcceptableFlower(flowerType, world, pos)) {
return true;
}
}
@@ -201,16 +196,16 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
Set<Block> acceptedBlocks = this.registeredBlocks.get(flowerType);
Set<Flower> acceptedFlowers = this.registeredFlowers.get(flowerType);
return isAcceptedFlower(flowerType, acceptedBlocks, acceptedFlowers, world, x, y, z);
return isAcceptedFlower(flowerType, acceptedBlocks, acceptedFlowers, world, pos);
}
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<Flower> acceptedFlowers, World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<Flower> acceptedFlowers, World world, BlockPos pos) {
Block block = BlockUtil.getBlock(world, pos);
final int meta;
if (block instanceof BlockFlowerPot) {
TileEntity tile = world.getTileEntity(x, y, z);
TileEntity tile = world.getTileEntity(pos);
TileEntityFlowerPot tileFlowerPot = (TileEntityFlowerPot) tile;
Item item = tileFlowerPot.getFlowerPotItem();
block = Block.getBlockFromItem(item);
@@ -219,10 +214,10 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
if (!acceptedBlocks.contains(block)) {
return false;
}
meta = world.getBlockMetadata(x, y, z);
meta = block.getMetaFromState(world.getBlockState(pos));
}
if (PluginManager.Module.AGRICRAFT.isEnabled()) {
/*if (PluginManager.Module.AGRICRAFT.isEnabled()) {
Block cropBlock = GameRegistry.findBlock("AgriCraft", "crops");
if (block == cropBlock) {
if (block instanceof IPlantable) {
@@ -239,28 +234,20 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
}
}
}
}
}*/
Flower flower = new Flower(block, meta, 0);
return acceptedFlowers.contains(flower);
}
@Override
public boolean growFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
public boolean growFlower(String flowerType, World world, IIndividual individual, BlockPos pos) {
if (!this.growthRules.containsKey(flowerType)) {
return false;
}
for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) {
boolean success;
try {
success = rule.growFlower(this, flowerType, world, x, y, z);
} catch (Throwable ignored) {
// legacy method
success = rule.growFlower(this, flowerType, world, individual, x, y, z);
}
if (success) {
if (rule.growFlower(this, flowerType, world, pos)) {
return true;
}
}
@@ -323,8 +310,8 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
}
@Override
public boolean plantRandomFlower(String flowerType, World world, int x, int y, int z) {
public boolean plantRandomFlower(String flowerType, World world, BlockPos pos) {
IFlower flower = getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
return world.setBlockState(pos, flower.getBlock().getStateFromMeta(flower.getMeta()), Constants.FLAG_BLOCK_SYNCH);
}
}
@@ -12,44 +12,26 @@ package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Constants;
public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
if (!world.isAirBlock(pos)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
Block ground = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
IFlower flower = flowerRegistry.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
return helper.plantRandomFlower(flowerType, world, x, y, z);
return helper.plantRandomFlower(flowerType, world, pos);
}
}
@@ -14,12 +14,12 @@ import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class GrowthRuleFertilize implements IFlowerGrowthRule {
@@ -30,21 +30,17 @@ public class GrowthRuleFertilize implements IFlowerGrowthRule {
}
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
return growFlower(world, x, y, z);
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
return growFlower(world, pos);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
return growFlower(world, x, y, z);
}
private boolean growFlower(World world, int x, int y, int z) {
Block ground = world.getBlock(x, y, z);
private boolean growFlower(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
Block ground = state.getBlock();
int groundMeta;
for (Block b : this.allowedItems) {
if (b == ground) {
groundMeta = world.getBlockMetadata(x, y, z);
groundMeta = ground.getMetaFromState(state);
if (groundMeta > 6) {
return false;
}
@@ -54,7 +50,7 @@ public class GrowthRuleFertilize implements IFlowerGrowthRule {
groundMeta = 7;
}
return world.setBlockMetadataWithNotify(x, y, z, groundMeta, 2);
return world.setBlockState(pos, ground.getStateFromMeta(groundMeta), 2);
}
}
@@ -14,28 +14,22 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockFlowerPot;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
return growFlower(flowerType, world, x, y, z);
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
return growFlower(flowerType, world, pos);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
return growFlower(flowerType, world, x, y, z);
}
private static boolean growFlower(String flowerType, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
private static boolean growFlower(String flowerType, World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (!(tile instanceof TileEntityFlowerPot)) {
return false;
}
@@ -45,7 +39,7 @@ public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
return false;
}
Block block = world.getBlock(x, y, z);
Block block = world.getBlockState(pos).getBlock();
if (!(block instanceof BlockFlowerPot)) {
return false;
}
@@ -73,11 +67,11 @@ public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
TileEntityFlowerPot newTile = (TileEntityFlowerPot) flowerPot.createNewTileEntity(world, flower);
flowerPotTile.func_145964_a(newTile.getFlowerPotItem(), newTile.getFlowerPotData());
flowerPotTile.setFlowerPotData(newTile.getFlowerPotItem(), newTile.getFlowerPotData());
flowerPotTile.markDirty();
if (!world.setBlockMetadataWithNotify(x, y, z, 1, 2)) {
world.markBlockForUpdate(x, y, z);
if (!world.setBlockState(pos, world.getBlockState(pos).getBlock().getStateFromMeta(1), 2)) {
world.markBlockForUpdate(pos);
}
return true;
@@ -12,44 +12,26 @@ package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Constants;
public class GrowthRuleMycelium implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
if (!world.isAirBlock(pos)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
Block ground = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
if (ground != Blocks.mycelium) {
return false;
}
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.mycelium) {
return false;
}
return helper.plantRandomFlower(flowerType, world, x, y, z);
return helper.plantRandomFlower(flowerType, world, pos);
}
}
@@ -10,22 +10,16 @@
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class GrowthRuleNone implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
return true;
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
return true;
}
@@ -12,44 +12,26 @@ package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Constants;
public class GrowthRuleSnow implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (world.getBlock(x, y, z) != Blocks.snow) {
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
if (world.getBlockState(pos).getBlock() != Blocks.snow) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
Block ground = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
if (world.getBlock(x, y, z) != Blocks.snow) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
return helper.plantRandomFlower(flowerType, world, x, y, z);
return helper.plantRandomFlower(flowerType, world, pos);
}
}
@@ -21,7 +21,7 @@ import net.minecraft.item.EnumRarity;
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.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
@@ -141,14 +141,17 @@ public class Bee extends IndividualLiving implements IBee {
}
}
@Override
public void setIsNatural(boolean flag) {
this.isNatural = flag;
}
@Override
public boolean isNatural() {
return this.isNatural;
}
@Override
public int getGeneration() {
return generation;
}
@@ -385,13 +388,13 @@ public class Bee extends IndividualLiving implements IBee {
if (generation > 0) {
EnumRarity rarity;
if (generation >= 1000) {
rarity = EnumRarity.epic;
rarity = EnumRarity.EPIC;
} else if (generation >= 100) {
rarity = EnumRarity.rare;
rarity = EnumRarity.RARE;
} else if (generation >= 10) {
rarity = EnumRarity.uncommon;
rarity = EnumRarity.UNCOMMON;
} else {
rarity = EnumRarity.common;
rarity = EnumRarity.COMMON;
}
String generationString = rarity.rarityColor + StringUtil.localizeAndFormat("gui.beealyzer.generations", generation);
@@ -527,8 +530,8 @@ public class Bee extends IndividualLiving implements IBee {
}
ItemStack[] productsArray = products.toArray(new ItemStack[products.size()]);
ChunkCoordinates housingCoordinates = housing.getCoordinates();
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housingCoordinates.posX, housingCoordinates.posY, housingCoordinates.posZ, productsArray);
BlockPos housingCoordinates = housing.getCoordinates();
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housingCoordinates, productsArray);
}
/* REPRODUCTION */
@@ -560,8 +563,8 @@ public class Bee extends IndividualLiving implements IBee {
List<IBee> bees = new ArrayList<>();
ChunkCoordinates housingCoordinates = housing.getCoordinates();
int toCreate = BeeManager.beeRoot.getBeekeepingMode(world).getFinalFertility(this, world, housingCoordinates.posX, housingCoordinates.posY, housingCoordinates.posZ);
BlockPos housingPos = housing.getCoordinates();
int toCreate = BeeManager.beeRoot.getBeekeepingMode(world).getFinalFertility(this, world, housingPos);
if (toCreate <= 0) {
toCreate = 1;
@@ -683,7 +686,7 @@ public class Bee extends IndividualLiving implements IBee {
}
Vect area = getArea(genome, beeModifier);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
Vect offset = new Vect(-area.getX()/ 2, -area.getY() / 4, -area.getZ() / 2);
Vect housingPos = new Vect(housing.getCoordinates());
IIndividual pollen = null;
@@ -691,7 +694,7 @@ public class Bee extends IndividualLiving implements IBee {
for (int i = 0; i < 20; i++) {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect blockPos = Vect.add(housingPos, randomPos, offset);
TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z);
TileEntity tile = world.getTileEntity(blockPos);
if (tile instanceof IPollinatable) {
IPollinatable pitcher = (IPollinatable) tile;
@@ -699,7 +702,7 @@ public class Bee extends IndividualLiving implements IBee {
pollen = pitcher.getPollen();
}
} else {
pollen = GeneticsUtil.getErsatzPollen(world, blockPos.x, blockPos.y, blockPos.z);
pollen = GeneticsUtil.getErsatzPollen(world, blockPos);
}
if (pollen != null) {
@@ -726,7 +729,7 @@ public class Bee extends IndividualLiving implements IBee {
}
Vect area = getArea(genome, beeModifier);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
Vect offset = new Vect(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2);
Vect housingPos = new Vect(housing.getCoordinates());
for (int i = 0; i < 30; i++) {
@@ -734,7 +737,7 @@ public class Bee extends IndividualLiving implements IBee {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect posBlock = Vect.add(housingPos, randomPos, offset);
ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock.x, posBlock.y, posBlock.z);
ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock);
if (checkPollinatable == null) {
continue;
}
@@ -746,7 +749,7 @@ public class Bee extends IndividualLiving implements IBee {
continue;
}
IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwner(), world, posBlock.x, posBlock.y, posBlock.z);
IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwner(), world, posBlock);
if (realPollinatable != null) {
realPollinatable.mateWith(pollen);
@@ -775,14 +778,14 @@ public class Bee extends IndividualLiving implements IBee {
// Gather required info
IFlowerProvider provider = genome.getFlowerProvider();
Vect area = getArea(genome, beeModifier);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
Vect offset = new Vect(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2);
Vect housingPos = new Vect(housing.getCoordinates());
for (int i = 0; i < 10; i++) {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect posBlock = Vect.add(housingPos, randomPos, offset);
if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock.x, posBlock.y, posBlock.z)) {
if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock)) {
break;
}
}
@@ -989,6 +989,10 @@ public enum BeeDefinition implements IBeeDefinition {
bee.registerMutations();
}
}
public static void preInit(){
}
private void init() {
if (!overworldHiveBees.contains(this)) {
@@ -162,7 +162,7 @@ public class BeeGenome extends Genome implements IBeeGenome {
@Override
public int[] getTerritory() {
Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea();
return new int[]{area.x, area.y, area.z};
return area.toArray();
}
@Override
@@ -20,11 +20,10 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
@@ -10,7 +10,7 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
@@ -37,12 +37,9 @@ public class BeeMutation extends Mutation implements IBeeMutationCustom {
@Override
public float getChance(IBeeHousing housing, IAlleleBeeSpecies allele0, IAlleleBeeSpecies allele1, IBeeGenome genome0, IBeeGenome genome1) {
World world = housing.getWorld();
ChunkCoordinates housingCoordinates = housing.getCoordinates();
int x = housingCoordinates.posX;
int y = housingCoordinates.posY;
int z = housingCoordinates.posZ;
BlockPos housingPos = housing.getCoordinates();
float processedChance = super.getChance(world, x, y, z, allele0, allele1, genome0, genome1);
float processedChance = super.getChance(world, housingPos, allele0, allele1, genome0, genome1);
if (processedChance <= 0) {
return 0;
}
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Locale;
import java.util.Random;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
@@ -64,7 +65,7 @@ public class BeekeepingMode implements IBeekeepingMode {
}
@Override
public int getFinalFertility(IBee queen, World world, int x, int y, int z) {
public int getFinalFertility(IBee queen, World world, BlockPos pos) {
int toCreate = queen.getGenome().getFertility();
if (reducesFertility) {
@@ -1,64 +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.apiculture.genetics;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBeeIconProvider;
import forestry.core.render.TextureManager;
public class DefaultBeeIconProvider implements IBeeIconProvider {
public static final DefaultBeeIconProvider instance = new DefaultBeeIconProvider();
private DefaultBeeIconProvider() {
}
private static final IIcon[][] icons = new IIcon[EnumBeeType.values().length][3];
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
String beeIconDir = "bees/default/";
IIcon body1 = TextureManager.registerTex(register, beeIconDir + "body1");
for (int i = 0; i < EnumBeeType.values().length; i++) {
EnumBeeType beeType = EnumBeeType.values()[i];
if (beeType == EnumBeeType.NONE) {
continue;
}
String beeTypeNameBase = beeIconDir + beeType.toString().toLowerCase(Locale.ENGLISH);
icons[i][0] = TextureManager.registerTex(register, beeTypeNameBase + ".outline");
if (beeType == EnumBeeType.LARVAE) {
icons[i][1] = TextureManager.registerTex(register, beeTypeNameBase + ".body");
} else {
icons[i][1] = body1;
}
icons[i][2] = TextureManager.registerTex(register, beeTypeNameBase + ".body2");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(EnumBeeType type, int renderPass) {
return icons[type.ordinal()][renderPass];
}
}
@@ -0,0 +1,50 @@
/*******************************************************************************
* 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.apiculture.genetics;
import java.util.Locale;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBeeModelProvider;
import forestry.api.core.IModelManager;
import forestry.apiculture.items.ItemBeeGE;
@SideOnly(Side.CLIENT)
public class DefaultBeeModelProvider implements IBeeModelProvider {
public static final DefaultBeeModelProvider instance = new DefaultBeeModelProvider();
private DefaultBeeModelProvider() {
}
private static final ModelResourceLocation[] models = new ModelResourceLocation[EnumBeeType.values().length];
@Override
public void registerModels(Item item, IModelManager manager) {
String beeIconDir = "bees/default/";
EnumBeeType beeType = ((ItemBeeGE)item).getType();
String beeTypeNameBase = beeIconDir + beeType.toString().toLowerCase(Locale.ENGLISH);
models[beeType.ordinal()] = manager.getModelLocation(beeTypeNameBase);
manager.registerVariant(item, new ResourceLocation("forestry:" + beeTypeNameBase));
}
@Override
public ModelResourceLocation getModel(EnumBeeType type) {
return models[type.ordinal()];
}
}
@@ -1,34 +1,34 @@
/*******************************************************************************
* 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.apiculture.genetics;
import forestry.api.apiculture.IBeeIconColourProvider;
public class DefaultBeeIconColourProvider implements IBeeIconColourProvider {
private final int primaryColour;
private final int secondaryColour;
public DefaultBeeIconColourProvider(int primaryColour, int secondaryColour) {
this.primaryColour = primaryColour;
this.secondaryColour = secondaryColour;
}
@Override
public int getIconColour(int renderPass) {
if (renderPass == 0) {
return primaryColour;
}
if (renderPass == 1) {
return secondaryColour;
}
return 0xffffff;
}
}
/*******************************************************************************
* 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.apiculture.genetics;
import forestry.api.apiculture.IBeeSpriteColourProvider;
public class DefaultBeeSpriteColourProvider implements IBeeSpriteColourProvider {
private final int primaryColour;
private final int secondaryColour;
public DefaultBeeSpriteColourProvider(int primaryColour, int secondaryColour) {
this.primaryColour = primaryColour;
this.secondaryColour = secondaryColour;
}
@Override
public int getSpriteColour(int renderPass) {
if (renderPass == 0) {
return primaryColour;
}
if (renderPass == 1) {
return secondaryColour;
}
return 0xffffff;
}
}
@@ -15,6 +15,7 @@ import java.util.Collections;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
@@ -42,7 +43,7 @@ public class HiveDrop implements IHiveDrop {
}
@Override
public ItemStack getPrincess(World world, int x, int y, int z, int fortune) {
public ItemStack getPrincess(World world, BlockPos pos, int fortune) {
IBee bee = beeTemplate.getIndividual();
if (world.rand.nextFloat() < ignobleShare) {
bee.setIsNatural(false);
@@ -52,13 +53,13 @@ public class HiveDrop implements IHiveDrop {
}
@Override
public List<ItemStack> getDrones(World world, int x, int y, int z, int fortune) {
public List<ItemStack> getDrones(World world, BlockPos pos, int fortune) {
ItemStack drone = beeTemplate.getMemberStack(EnumBeeType.DRONE);
return Collections.singletonList(drone);
}
@Override
public ArrayList<ItemStack> getAdditional(World world, int x, int y, int z, int fortune) {
public ArrayList<ItemStack> getAdditional(World world, BlockPos pos, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<>();
for (ItemStack stack : additional) {
ret.add(stack.copy());
@@ -68,7 +69,7 @@ public class HiveDrop implements IHiveDrop {
}
@Override
public int getChance(World world, int x, int y, int z) {
public int getChance(World world, BlockPos pos) {
return chance;
}
@@ -11,8 +11,9 @@
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -32,11 +33,10 @@ public class JubilanceRequiresResource implements IJubilanceProvider {
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorld();
ChunkCoordinates housingCoords = housing.getCoordinates();
BlockPos housingCoords = housing.getCoordinates();
Block block = world.getBlock(housingCoords.posX, housingCoords.posY - 1, housingCoords.posZ);
int meta = world.getBlockMetadata(housingCoords.posX, housingCoords.posY - 1, housingCoords.posZ);
return ItemStackUtil.equals(block, meta, blockRequired);
IBlockState state = world.getBlockState(housingCoords.add(0, -1, 0));
return ItemStackUtil.equals(state, blockRequired);
}
}
@@ -15,30 +15,30 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpeciesCustom;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeIconColourProvider;
import forestry.api.apiculture.IBeeIconProvider;
import forestry.api.apiculture.IBeeSpriteColourProvider;
import forestry.api.apiculture.IBeeModelProvider;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.api.core.IIconProvider;
import forestry.api.core.IModelManager;
import forestry.api.core.IModelProvider;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.genetics.DefaultBeeIconColourProvider;
import forestry.apiculture.genetics.DefaultBeeIconProvider;
import forestry.apiculture.genetics.DefaultBeeSpriteColourProvider;
import forestry.apiculture.genetics.DefaultBeeModelProvider;
import forestry.apiculture.genetics.JubilanceDefault;
import forestry.core.genetics.alleles.AlleleSpecies;
import forestry.core.utils.ItemStackUtil;
@@ -47,16 +47,16 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
private final Map<ItemStack, Float> productChances = new HashMap<>();
private final Map<ItemStack, Float> specialtyChances = new HashMap<>();
private IBeeIconProvider beeIconProvider;
private IBeeIconColourProvider beeIconColourProvider;
private IBeeModelProvider beeModelProvider;
private IBeeSpriteColourProvider beeSpriteColourProvider;
private IJubilanceProvider jubilanceProvider;
private boolean nocturnal = false;
public AlleleBeeSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
super(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial);
beeIconProvider = DefaultBeeIconProvider.instance;
beeIconColourProvider = new DefaultBeeIconColourProvider(primaryColor, secondaryColor);
beeModelProvider = DefaultBeeModelProvider.instance;
beeSpriteColourProvider = new DefaultBeeSpriteColourProvider(primaryColor, secondaryColor);
jubilanceProvider = JubilanceDefault.instance;
}
@@ -100,16 +100,16 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
nocturnal = true;
return this;
}
@Override
public IAlleleBeeSpeciesCustom setCustomBeeIconProvider(IBeeIconProvider beeIconProvider) {
this.beeIconProvider = beeIconProvider;
public IAlleleBeeSpeciesCustom setCustomBeeModelProvider(IBeeModelProvider beeIconProvider) {
this.beeModelProvider = beeIconProvider;
return this;
}
@Override
public IAlleleBeeSpeciesCustom setCustomBeeIconColourProvider(IBeeIconColourProvider beeIconColourProvider) {
this.beeIconColourProvider = beeIconColourProvider;
public IAlleleBeeSpeciesCustom setCustomBeeSpriteColourProvider(IBeeSpriteColourProvider beeIconColourProvider) {
this.beeSpriteColourProvider = beeIconColourProvider;
return this;
}
@@ -173,18 +173,18 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return new BeeIconProviderWrapper(beeIconProvider);
public IModelProvider getModelProvider() {
return new BeeModelProviderWrapper(beeModelProvider);
}
@Override
public IIcon getIcon(EnumBeeType type, int renderPass) {
return beeIconProvider.getIcon(type, renderPass);
public ModelResourceLocation getModel(EnumBeeType type) {
return beeModelProvider.getModel(type);
}
@Override
public int getIconColour(int renderPass) {
return beeIconColourProvider.getIconColour(renderPass);
public int getSpriteColour(int renderPass) {
return beeSpriteColourProvider.getSpriteColour(renderPass);
}
@Override
@@ -192,22 +192,23 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
return null;
}
private static class BeeIconProviderWrapper implements IIconProvider {
@SideOnly(Side.CLIENT)
private static class BeeModelProviderWrapper implements IModelProvider {
private final IBeeIconProvider beeIconProvider;
private final IBeeModelProvider beeModelProvider;
public BeeIconProviderWrapper(IBeeIconProvider beeIconProvider) {
this.beeIconProvider = beeIconProvider;
public BeeModelProviderWrapper(IBeeModelProvider beeModelProvider) {
this.beeModelProvider = beeModelProvider;
}
@Override
public IIcon getIcon(short texUID) {
public ModelResourceLocation getModel() {
return null;
}
@Override
public void registerIcons(IIconRegister register) {
beeIconProvider.registerIcons(register);
public void registerModels(Item item, IModelManager manager) {
beeModelProvider.registerModels(item, manager);
}
}
}
@@ -16,7 +16,7 @@ import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.potion.Potion;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import forestry.api.apiculture.BeeManager;
@@ -105,7 +105,7 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
@Override
public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
Vec3 beeFXCoordinates = getFXCoordinates(housing);
Proxies.render.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), beeFXCoordinates.xCoord, beeFXCoordinates.yCoord, beeFXCoordinates.zCoord, genome.getPrimary().getIconColour(0));
Proxies.render.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), beeFXCoordinates.xCoord, beeFXCoordinates.yCoord, beeFXCoordinates.zCoord, genome.getPrimary().getSpriteColour(0));
return storedData;
}
@@ -114,8 +114,8 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
return housing.getBeeFXCoordinates();
} catch (Throwable error) {
// getBeeFXCoordinates() is only newly added to the API, fall back on getCoordinates()
ChunkCoordinates coordinates = housing.getCoordinates();
return Vec3.createVectorHelper(coordinates.posX + 0.5D, coordinates.posY + 0.5D, coordinates.posZ + 0.5D);
BlockPos coordinates = housing.getCoordinates();
return new Vec3(coordinates.getX() + 0.5D, coordinates.getY() + 0.5D, coordinates.getZ() + 0.5D);
}
}
@@ -150,7 +150,7 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
Vect min = new Vect(housing.getCoordinates()).add(offset);
Vect max = min.add(area);
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
return AxisAlignedBB.fromBounds(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getX());
}
public static <T extends Entity> List<T> getEntitiesInRange(IBeeGenome genome, IBeeHousing housing, Class<T> entityClass) {
@@ -13,7 +13,7 @@ package forestry.apiculture.genetics.alleles;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
@@ -50,11 +50,11 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
World world = housing.getWorld();
ChunkCoordinates housingCoords = housing.getCoordinates();
BlockPos housingCoords = housing.getCoordinates();
// If we are already triggered, we continue the explosion sequence.
if (storedData.getInteger(indexExplosionTimer) > 0) {
progressExplosion(storedData, world, housingCoords.posX, housingCoords.posY, housingCoords.posZ);
progressExplosion(storedData, world, housingCoords);
return storedData;
}
@@ -82,7 +82,7 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
continue;
}
world.playSoundEffect(housingCoords.posX, housingCoords.posY, housingCoords.posZ, "mob.creeper", 4F,
world.playSoundEffect(housingCoords.getX(), housingCoords.getY(), housingCoords.getZ(), "mob.creeper", 4F,
(1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
storedData.setInteger(indexExplosionTimer, 2); // Set explosion timer
}
@@ -90,7 +90,7 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
return storedData;
}
private static void progressExplosion(IEffectData storedData, World world, int x, int y, int z) {
private static void progressExplosion(IEffectData storedData, World world, BlockPos pos) {
int explosionTimer = storedData.getInteger(indexExplosionTimer);
explosionTimer--;
@@ -100,7 +100,7 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
return;
}
world.createExplosion(null, x, y, z, storedData.getInteger(indexExplosionForce), false);
world.createExplosion(null, pos.getX(), pos.getY(), pos.getZ(), storedData.getInteger(indexExplosionForce), false);
}
}
@@ -14,7 +14,7 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
@@ -36,20 +36,20 @@ public class AlleleEffectFertile extends AlleleEffectThrottled {
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
World world = housing.getWorld();
ChunkCoordinates housingCoordinates = housing.getCoordinates();
BlockPos housingCoordinates = housing.getCoordinates();
IVect area = getModifiedArea(genome, housing);
int blockX = getRandomOffset(world.rand, housingCoordinates.posX, area.getX());
int blockZ = getRandomOffset(world.rand, housingCoordinates.posZ, area.getZ());
int blockMaxY = housingCoordinates.posY + (area.getY() / 2) + 1;
int blockMinY = housingCoordinates.posY - (area.getY() / 2) - 1;
int blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX());
int blockZ = getRandomOffset(world.rand, housingCoordinates.getZ(), area.getZ());
int blockMaxY = housingCoordinates.getY() + (area.getY() / 2) + 1;
int blockMinY = housingCoordinates.getY() - (area.getY() / 2) - 1;
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
if (tryTickColumn(world, blockX, blockZ, blockMaxY, blockMinY)) {
break;
}
blockX = getRandomOffset(world.rand, housingCoordinates.posX, area.getX());
blockZ = getRandomOffset(world.rand, housingCoordinates.posZ, area.getZ());
blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX());
blockZ = getRandomOffset(world.rand, housingCoordinates.getZ(), area.getZ());
}
return storedData;
@@ -61,9 +61,9 @@ public class AlleleEffectFertile extends AlleleEffectThrottled {
private static boolean tryTickColumn(World world, int x, int z, int maxY, int minY) {
for (int y = maxY; y >= minY; --y) {
Block block = world.getBlock(x, y, z);
Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock();
if (block.getTickRandomly() && (block instanceof IGrowable || block instanceof IPlantable)) {
world.scheduleBlockUpdate(x, y, z, block, 5);
world.scheduleUpdate(new BlockPos(x, y, z), block, 5);
return true;
}
}
@@ -7,7 +7,8 @@ import net.minecraft.block.Block;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.init.Blocks;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
@@ -54,25 +55,26 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorld();
ChunkCoordinates housingCoordinates = housing.getCoordinates();
BlockPos housingCoordinates = housing.getCoordinates();
IVect area = getModifiedArea(genome, housing);
int blockX = getRandomOffset(world.rand, housingCoordinates.posX, area.getX());
int blockY = getRandomOffset(world.rand, housingCoordinates.posY, area.getY());
int blockZ = getRandomOffset(world.rand, housingCoordinates.posZ, area.getZ());
int blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX());
int blockY = getRandomOffset(world.rand, housingCoordinates.getY(), area.getY());
int blockZ = getRandomOffset(world.rand, housingCoordinates.getZ(), area.getZ());
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
Block block = world.getBlock(blockX, blockY, blockZ);
if (isSuitableForMycelium(world, block, blockX, blockY, blockZ)) {
world.setBlock(blockX, blockY, blockZ, Blocks.mycelium);
BlockPos pos = new BlockPos(blockX, blockY, blockZ);
Block block = world.getBlockState(pos).getBlock();
if (isSuitableForMycelium(world, block, pos)) {
world.setBlockState(pos, Blocks.mycelium.getStateFromMeta(0));
break;
} else if (isSuitableForGrowth(block)) {
doMushroomGrowth(block, world, blockX, blockY, blockZ);
doMushroomGrowth(block, world, pos);
break;
}
blockX = getRandomOffset(world.rand, housingCoordinates.posX, area.getX());
blockY = getRandomOffset(world.rand, housingCoordinates.posY, area.getY());
blockZ = getRandomOffset(world.rand, housingCoordinates.posZ, area.getZ());
blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX());
blockY = getRandomOffset(world.rand, housingCoordinates.getY(), area.getY());
blockZ = getRandomOffset(world.rand, housingCoordinates.getZ(), area.getZ());
}
}
@@ -88,8 +90,8 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
return centrePos + random.nextInt(offset) - (offset / 2);
}
private static boolean isSuitableForMycelium(World world, Block block, int blockX, int blockY, int blockZ) {
return block == Blocks.grass || (block == Blocks.dirt && world.canBlockSeeTheSky(blockX, blockY, blockZ));
private static boolean isSuitableForMycelium(World world, Block block, BlockPos pos) {
return block == Blocks.grass || (block == Blocks.dirt && world.canBlockSeeSky(pos));
}
private static boolean isSuitableForGrowth(Block block) {
@@ -107,19 +109,15 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
mooshroom.setHealth(cow.getHealth());
mooshroom.renderYawOffset = cow.renderYawOffset;
worldObj.spawnEntityInWorld(mooshroom);
worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double) (cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D);
worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, cow.posX, cow.posY + cow.height / 2.0F, cow.posZ, 0.0D, 0.0D, 0.0D);
}
private static void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) {
private static void doMushroomGrowth(Block block, World world, BlockPos pos) {
WorldGenBigMushroom giantMushroomGenerator;
if (block == Blocks.brown_mushroom) {
giantMushroomGenerator = new WorldGenBigMushroom(0);
} else {
giantMushroomGenerator = new WorldGenBigMushroom(1);
}
giantMushroomGenerator = new WorldGenBigMushroom(block);
world.setBlockToAir(blockX, blockY, blockZ);
giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ);
world.setBlockToAir(pos);
giantMushroomGenerator.generate(world, world.rand, pos);
}
}
@@ -12,6 +12,7 @@ package forestry.apiculture.genetics.alleles;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
@@ -52,16 +53,16 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
Vect posBlock = Vect.add(randomPos, housingCoords, offset);
// Freeze water
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
Block block = world.getBlockState(posBlock).getBlock();
if (block != Blocks.water) {
continue;
}
if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z)) {
if (!world.isAirBlock(new BlockPos(posBlock.getX(), posBlock.getY() + 1, posBlock.getZ()))) {
continue;
}
world.setBlock(posBlock.x, posBlock.y, posBlock.z, Blocks.ice, 0, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
world.setBlockState(posBlock, Blocks.ice.getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
}
return storedData;
@@ -21,9 +21,7 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
@@ -72,35 +72,35 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
Vect posBlock = randomPos.add(posHousing);
posBlock = posBlock.add(offset);
if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) {
if (posBlock.getY() <= 1 || posBlock.getY() >= housing.getWorld().getActualHeight()) {
continue;
}
// Don't destroy ourselves or blocks below us.
if (posBlock.x == posHousing.x && posBlock.z == posHousing.z && posBlock.y <= posHousing.y) {
if (posBlock.getX() == posHousing.getX() && posBlock.getZ() == posHousing.getZ() && posBlock.getY() <= posHousing.getY()) {
continue;
}
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
if (world.isAirBlock(posBlock)) {
continue;
}
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
Block block = world.getBlockState(posBlock).getBlock();
if (block instanceof BlockAlveary) {
continue;
}
TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z);
TileEntity tile = world.getTileEntity(posBlock);
if (tile instanceof IBeeHousing) {
continue;
}
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
if (block.getBlockHardness(world, posBlock) < 0) {
continue;
}
world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z);
world.setBlockToAir(posBlock);
break;
}
@@ -11,12 +11,12 @@
package forestry.apiculture.genetics.alleles;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.EnumTemperature;
@@ -57,19 +57,20 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
posBlock = posBlock.add(offset);
// Put snow on the ground
if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false)) {
if (!world.isSideSolid(new BlockPos(posBlock.getX(), posBlock.getY() - 1, posBlock.getZ()), EnumFacing.UP, false)) {
continue;
}
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
IBlockState state = world.getBlockState(posBlock);
Block block = state.getBlock();
if (block == Blocks.snow_layer) {
int meta = world.getBlockMetadata(posBlock.x, posBlock.y, posBlock.z);
int meta = block.getMetaFromState(state);
if (meta < 7) {
world.setBlockMetadataWithNotify(posBlock.x, posBlock.y, posBlock.z, meta + 1, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
world.setBlockState(posBlock, block.getStateFromMeta(meta + 1), Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
}
} else if (block.isReplaceable(world, posBlock.x, posBlock.y, posBlock.z)) {
world.setBlock(posBlock.x, posBlock.y, posBlock.z, Blocks.snow_layer, 0, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
} else if (block.isReplaceable(world, posBlock)) {
world.setBlockState(posBlock, Blocks.snow_layer.getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
}
}
@@ -82,11 +83,11 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
Vect area = getModifiedArea(genome, housing);
Vect offset = area.multiply(-0.5F);
ChunkCoordinates coordinates = housing.getCoordinates();
BlockPos coordinates = housing.getCoordinates();
World world = housing.getWorld();
Vect spawn = Vect.getRandomPositionInArea(world.rand, area).add(coordinates).add(offset);
Proxies.render.addEntitySnowFX(world, spawn.x, spawn.y, spawn.z);
Proxies.render.addEntitySnowFX(world, spawn.getX(), spawn.getY(), spawn.getZ());
return storedData;
} else {
return super.doFX(genome, storedData, housing);
@@ -29,6 +29,7 @@ import forestry.core.genetics.alleles.AlleleBoolean;
import forestry.core.gui.ContainerAlyzer;
import forestry.core.gui.GuiAlyzer;
import forestry.core.gui.widgets.ItemStackWidget;
import forestry.core.inventory.ItemInventoryAlyzer;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
@@ -55,8 +56,8 @@ public class GuiBeealyzer extends GuiAlyzer {
IBee bee = null;
EnumBeeType beeType = EnumBeeType.DRONE;
for (int k = ItemInventoryBeealyzer.SLOT_SPECIMEN; k <= ItemInventoryBeealyzer.SLOT_ANALYZE_5; k++) {
if (k == ItemInventoryBeealyzer.SLOT_ENERGY) {
for (int k = ItemInventoryAlyzer.SLOT_SPECIMEN; k <= ItemInventoryAlyzer.SLOT_ANALYZE_5; k++) {
if (k == ItemInventoryAlyzer.SLOT_ENERGY) {
continue;
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.gui;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -91,7 +92,7 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter, ItemInventoryI
}
@Override
protected void mouseClicked(int i, int j, int k) {
protected void mouseClicked(int i, int j, int k) throws IOException {
super.mouseClicked(i, j, k);
int cornerX = (width - xSize) / 2;
@@ -14,17 +14,18 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import forestry.core.gui.widgets.Widget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.render.TextureManager;
public class HabitatSlot extends Widget {
@@ -45,7 +46,8 @@ public class HabitatSlot extends Widget {
return name;
}
public IIcon getIcon() {
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon() {
return TextureManager.getInstance().getDefault(iconIndex);
}
@@ -62,8 +64,8 @@ public class HabitatSlot extends Widget {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
Proxies.render.bindTexture(SpriteSheet.ITEMS);
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIcon(), 16, 16);
Proxies.render.bindTexture(TextureMap.locationBlocksTexture);
manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, getIcon(), 16, 16);
}
}
}
@@ -69,6 +69,7 @@ public class InventoryApiary extends InventoryBeeHousing implements IApiaryInven
return hiveFrames;
}
@Override
public void wearOutFrames(IBeeHousing beeHousing, int amount) {
IBeekeepingMode beekeepingMode = BeeManager.beeRoot.getBeekeepingMode(beeHousing.getWorld());
int wear = Math.round(amount * beekeepingMode.getWearModifier());
@@ -124,7 +124,7 @@ public class ItemInventoryImprinter extends ItemInventory {
}
@Override
public String getInventoryName() {
public String getName() {
return "Imprinter";
}
@@ -18,7 +18,7 @@ import java.util.Set;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
@@ -70,7 +70,7 @@ public class HabitatLocatorLogic {
this.biomeFound = false;
this.searchCenter = new Vect(player);
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords(searchCenter.x, searchCenter.z);
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords(searchCenter);
removeInvalidBiomes(currentBiome, targetBiomes);
// reset the locator coordinates
@@ -91,7 +91,7 @@ public class HabitatLocatorLogic {
return;
}
ChunkCoordinates target = findNearestBiome(player, targetBiomes);
BlockPos target = findNearestBiome(player, targetBiomes);
// send an update if we find the biome
if (target != null && player instanceof EntityPlayerMP) {
@@ -100,15 +100,15 @@ public class HabitatLocatorLogic {
}
}
private ChunkCoordinates findNearestBiome(Entity player, Collection<BiomeGenBase> biomesToSearch) {
private BlockPos findNearestBiome(Entity player, Collection<BiomeGenBase> biomesToSearch) {
Vect playerPos = new Vect(player);
// If we are in a valid spot, we point to ourselves.
ChunkCoordinates coordinates = getChunkCoordinates(playerPos, player.worldObj, biomesToSearch);
BlockPos coordinates = getChunkCoordinates(playerPos, player.worldObj, biomesToSearch);
if (coordinates != null) {
searchAngleIteration = 0;
searchRadiusIteration = 0;
return new ChunkCoordinates(playerPos.x, playerPos.y, playerPos.z);
return playerPos;
}
// check in a circular pattern, starting at the center and increasing radius each step
@@ -151,35 +151,35 @@ public class HabitatLocatorLogic {
return null;
}
private static ChunkCoordinates getChunkCoordinates(Vect pos, World world, Collection<BiomeGenBase> biomesToSearch) {
private static BlockPos getChunkCoordinates(Vect pos, World world, Collection<BiomeGenBase> biomesToSearch) {
BiomeGenBase biome;
biome = world.getBiomeGenForCoords(pos.x, pos.z);
biome = world.getBiomeGenForCoords(pos);
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x - minBiomeRadius, pos.z);
biome = world.getBiomeGenForCoords(pos.add(-minBiomeRadius, 0, 0));
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x + minBiomeRadius, pos.z);
biome = world.getBiomeGenForCoords(pos.add(minBiomeRadius, 0, 0));
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x, pos.z - minBiomeRadius);
biome = world.getBiomeGenForCoords(pos.add(0, 0, -minBiomeRadius));
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x, pos.z + minBiomeRadius);
biome = world.getBiomeGenForCoords(pos.add(0, 0, minBiomeRadius));
if (!biomesToSearch.contains(biome)) {
return null;
}
return new ChunkCoordinates(pos.x, pos.y, pos.z);
return pos;
}
private static void removeInvalidBiomes(BiomeGenBase currentBiome, Set<BiomeGenBase> biomesToSearch) {
@@ -10,29 +10,26 @@
******************************************************************************/
package forestry.apiculture.items;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
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.apiculture.IArmorApiarist;
import forestry.api.core.IArmorNaturalist;
import forestry.api.core.IModelManager;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.Tabs;
import forestry.core.config.Constants;
import forestry.core.render.TextureManager;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArmorNaturalist {
public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArmorNaturalist, IItemModelRegister {
public ItemArmorApiarist(int slot) {
super(ArmorMaterial.CLOTH, 0, slot);
super(ArmorMaterial.LEATHER, 0, slot);
this.setMaxDamage(100);
setCreativeTab(Tabs.tabApiculture);
}
@@ -48,19 +45,8 @@ public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArm
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
itemIcon = TextureManager.registerTex(register, StringUtil.cleanItemName(this));
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIconFromDamageForRenderPass(int par1, int par2) {
return itemIcon;
}
@Override
public boolean requiresMultipleRenderPasses() {
return false;
public void registerModel(Item item, IModelManager manager) {
manager.registerItemModel(item, 0, true);
}
@Override
@@ -12,22 +12,21 @@ package forestry.apiculture.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
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.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
@@ -141,52 +140,40 @@ public class ItemBeeGE extends ItemGE {
public int getColourFromSpecies(IAlleleSpecies species, int renderPass) {
if (species instanceof IAlleleBeeSpecies) {
return species.getIconColour(renderPass);
return species.getSpriteColour(renderPass);
} else {
return 0xffffff;
}
}
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
@Override
public int getRenderPasses(int metadata) {
return 3;
}
/* ICONS */
@Override
/* MODELS */
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
@Override
public void registerModel(Item item, IModelManager manager) {
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies) {
((IAlleleBeeSpecies) allele).getIconProvider().registerIcons(register);
((IAlleleBeeSpecies) allele).getModelProvider().registerModels(item, manager);
}
}
manager.registerItemModel(item, new BeeMeshDefinition());
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack itemstack, int renderPass) {
return getIconFromSpecies(BeeGenome.getSpecies(itemstack), renderPass);
}
private class BeeMeshDefinition implements ItemMeshDefinition {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack stack) {
return getIcon(stack, 0);
}
@SideOnly(Side.CLIENT)
public IIcon getIconFromSpecies(IAlleleBeeSpecies species, int renderPass) {
if (species == null) {
species = (IAlleleBeeSpecies) BeeManager.beeRoot.getDefaultTemplate()[EnumBeeChromosome.SPECIES.ordinal()];
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
IAlleleBeeSpecies species = (IAlleleBeeSpecies) getSpecies(stack);
if (species == null) {
species = (IAlleleBeeSpecies) BeeManager.beeRoot.getDefaultTemplate()[EnumBeeChromosome.SPECIES
.ordinal()];
}
return species.getModel(type);
}
return species.getIcon(type, renderPass);
}
public final EnumBeeType getType() {
return type;
}
}
@@ -13,11 +13,8 @@ package forestry.apiculture.items;
import net.minecraft.block.Block;
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.apiculture.blocks.BlockCandle;
import forestry.core.items.ItemBlockForestry;
@@ -54,22 +51,4 @@ public class ItemBlockCandle extends ItemBlockForestry {
}
return value;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamageForRenderPass(int meta, int pass) {
return this.getBlock().getIcon((meta != 0) ? 8 : 0, pass);
}
@Override
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses() {
return true;
}
@Override
public int getRenderPasses(int metadata) {
return 2;
}
}
@@ -12,7 +12,6 @@ package forestry.apiculture.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
@@ -20,10 +19,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
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.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.Tabs;
@@ -59,21 +56,21 @@ public class ItemHabitatLocator extends ItemWithGui {
/* TEXTURES */
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
if (register instanceof TextureMap) {
TextureAtlasSprite texture = new TextureHabitatLocator(iconName);
((TextureMap) register).setTextureEntry(iconName, texture);
itemIcon = texture;
}
public static TextureAtlasSprite sprite;
@SideOnly(Side.CLIENT)
public static void registerIcon(TextureMap map) {
TextureAtlasSprite texture = new TextureHabitatLocator(iconName);
map.setTextureEntry("forestry:biomefinder", texture);
sprite = texture;
}
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ);
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords(player.getPosition());
float temperatureValue = currentBiome.getFloatTemperature((int) player.posX, (int) player.posY, (int) player.posZ);
float temperatureValue = currentBiome.getFloatTemperature(player.getPosition());
EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue);
EnumHumidity humidity = EnumHumidity.getFromValue(currentBiome.rainfall);
@@ -17,12 +17,14 @@ import java.util.Random;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.core.config.Config;
import forestry.core.items.ItemForestryMultiPass;
import forestry.core.items.ItemForestry;
public class ItemHoneycomb extends ItemForestryMultiPass {
public class ItemHoneycomb extends ItemForestry {
public ItemHoneycomb() {
super();
setMaxDamage(0);
@@ -40,6 +42,14 @@ public class ItemHoneycomb extends ItemForestryMultiPass {
return false;
}
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
for (int i = 0; i < EnumHoneyComb.VALUES.length; i++) {
manager.registerItemModel(item, i, "beecombs/" + EnumHoneyComb.VALUES[i].name);
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
EnumHoneyComb honeyComb = EnumHoneyComb.VALUES[stack.getItemDamage()];
@@ -14,50 +14,63 @@ import java.util.List;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockRailBase;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemMinecart;
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 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.apiculture.entities.EntityMinecartApiary;
import forestry.apiculture.entities.EntityMinecartBeeHousingBase;
import forestry.apiculture.entities.EntityMinecartBeehouse;
import forestry.core.render.TextureManager;
public class ItemMinecartBeehouse extends ItemMinecart {
public class ItemMinecartBeehouse extends ItemMinecart implements IItemModelRegister {
private final String[] definition = new String[]{"cart.beehouse", "cart.apiary"};
private static final IBehaviorDispenseItem dispenserMinecartBehavior = new BehaviorDefaultDispenseItem()
{
private final BehaviorDefaultDispenseItem behaviourDefaultDispenseItem = new BehaviorDefaultDispenseItem();
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
return stack;
}
};
public ItemMinecartBeehouse() {
super(0);
super(null);
setMaxDamage(0);
setHasSubtypes(true);
BlockDispenser.dispenseBehaviorRegistry.putObject(this, null);
BlockDispenser.dispenseBehaviorRegistry.putObject(this,new BehaviorDefaultDispenseItem());
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float facingX, float facingY, float facingZ) {
if (!BlockRailBase.func_150051_a(world.getBlock(x, y, z))) {
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!BlockRailBase.isRailBlock(world.getBlockState(pos))) {
return false;
}
if (!world.isRemote) {
EntityMinecartBeeHousingBase entityMinecart;
if (itemStack.getItemDamage() == 0) {
entityMinecart = new EntityMinecartBeehouse(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F));
entityMinecart = new EntityMinecartBeehouse(world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F);
} else {
entityMinecart = new EntityMinecartApiary(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F));
entityMinecart = new EntityMinecartApiary(world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F);
}
entityMinecart.setOwner(player.getGameProfile());
if (itemStack.hasDisplayName()) {
entityMinecart.setMinecartName(itemStack.getDisplayName());
entityMinecart.setCustomNameTag(itemStack.getDisplayName());
}
world.spawnEntityInWorld(entityMinecart);
@@ -76,25 +89,12 @@ public class ItemMinecartBeehouse extends ItemMinecart {
}
}
/* ICONS */
@SideOnly(Side.CLIENT)
private IIcon[] icons;
/* MODELS */
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
icons = new IIcon[definition.length];
public void registerModel(Item item, IModelManager manager) {
for (int i = 0; i < definition.length; i++) {
icons[i] = TextureManager.registerTex(register, definition[i]);
}
}
@Override
public IIcon getIconFromDamage(int damage) {
if (damage >= definition.length || damage < 0) {
return icons[0];
} else {
return icons[damage];
manager.registerItemModel(item, i, definition[i]);
}
}
@@ -14,6 +14,7 @@ import net.minecraftforge.oredict.OreDictionary;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.core.Tabs;
import forestry.apiculture.genetics.BeeDefinition;
import forestry.core.items.ItemForestry;
import forestry.core.items.ItemOverlay;
import forestry.core.items.ItemRegistry;
@@ -52,6 +53,7 @@ public class ItemRegistryApiculture extends ItemRegistry {
public ItemRegistryApiculture() {
// / BEES
BeeDefinition.preInit();
beeQueenGE = registerItem(new ItemBeeGE(EnumBeeType.QUEEN), "beeQueenGE");
beeDroneGE = registerItem(new ItemBeeGE(EnumBeeType.DRONE), "beeDroneGE");
beePrincessGE = registerItem(new ItemBeeGE(EnumBeeType.PRINCESS), "beePrincessGE");
@@ -15,9 +15,10 @@ import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
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.util.Vec3;
import net.minecraft.world.World;
@@ -162,20 +163,22 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
protected void isMachineWhole() throws MultiblockValidationException {
super.isMachineWhole();
final ChunkCoordinates maximumCoord = getMaximumCoord();
final ChunkCoordinates minimumCoord = getMinimumCoord();
final BlockPos maximumCoord = getMaximumCoord();
final BlockPos minimumCoord = getMinimumCoord();
// check that the top is covered in wood slabs
final int slabY = maximumCoord.posY + 1;
for (int slabX = minimumCoord.posX; slabX <= maximumCoord.posX; slabX++) {
for (int slabZ = minimumCoord.posZ; slabZ <= maximumCoord.posZ; slabZ++) {
Block block = worldObj.getBlock(slabX, slabY, slabZ);
final int slabY = maximumCoord.getY() + 1;
for (int slabX = minimumCoord.getX(); slabX <= maximumCoord.getX(); slabX++) {
for (int slabZ = minimumCoord.getZ(); slabZ <= maximumCoord.getZ(); slabZ++) {
BlockPos pos = new BlockPos(slabX, slabY, slabZ);
IBlockState state = worldObj.getBlockState(pos);
Block block = state.getBlock();
if (!BlockUtil.isWoodSlabBlock(block)) {
throw new MultiblockValidationException(StatCollector.translateToLocal("for.multiblock.alveary.error.needSlabs"));
}
int meta = worldObj.getBlockMetadata(slabX, slabY, slabZ);
int meta = block.getMetaFromState(state);
if ((meta & 8) != 0) {
throw new MultiblockValidationException(StatCollector.translateToLocal("for.multiblock.alveary.error.needSlabs"));
}
@@ -184,13 +187,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
// check that there is space all around the alveary entrances
int airY = maximumCoord.posY;
for (int airX = minimumCoord.posX - 1; airX <= maximumCoord.posX + 1; airX++) {
for (int airZ = minimumCoord.posZ - 1; airZ <= maximumCoord.posZ + 1; airZ++) {
int airY = maximumCoord.getY();
for (int airX = minimumCoord.getX() - 1; airX <= maximumCoord.getX() + 1; airX++) {
for (int airZ = minimumCoord.getZ() - 1; airZ <= maximumCoord.getZ() + 1; airZ++) {
if (isCoordInMultiblock(airX, airY, airZ)) {
continue;
}
Block block = worldObj.getBlock(airX, airY, airZ);
Block block = BlockUtil.getBlock(worldObj, new BlockPos(airX, airY, airZ));
if (block.isOpaqueCube()) {
throw new MultiblockValidationException(StatCollector.translateToLocal("for.multiblock.alveary.error.needSpace"));
}
@@ -265,10 +268,10 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
beekeepingLogic.doBeeFX();
if (updateOnInterval(50)) {
ChunkCoordinates center = getCenterCoord();
float fxX = center.posX + 0.5F;
float fxY = center.posY + 1.0F;
float fxZ = center.posZ + 0.5F;
BlockPos center = getCenterCoord();
float fxX = center.getX() + 0.5F;
float fxY = center.getY() + 1.0F;
float fxZ = center.getZ() + 0.5F;
float distanceFromCenter = 1.6F;
float leftRightSpreadFromCenter = distanceFromCenter * (worldObj.rand.nextFloat() - 0.5F);
@@ -320,15 +323,15 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
/* IActivatable */
@Override
public ChunkCoordinates getCoordinates() {
ChunkCoordinates coord = getCenterCoord();
return new ChunkCoordinates(coord.posX, coord.posY + 1, coord.posZ);
public BlockPos getCoordinates() {
BlockPos coord = getCenterCoord();
return coord.add(0, +1, 0);
}
@Override
public Vec3 getBeeFXCoordinates() {
ChunkCoordinates coord = getCenterCoord();
return Vec3.createVectorHelper(coord.posX + 0.5, coord.posY + 1.5, coord.posZ + 0.5);
BlockPos coord = getCenterCoord();
return new Vec3(coord.getX() + 0.5, coord.getY() + 1.5, coord.getZ() + 0.5);
}
@Override
@@ -338,7 +341,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
for (IMultiblockComponent part : connectedParts) {
if (part instanceof TileEntity) {
TileEntity tile = (TileEntity) part;
worldObj.notifyBlocksOfNeighborChange(tile.xCoord, tile.yCoord, tile.zCoord, tile.getBlockType());
worldObj.notifyBlockOfStateChange(tile.getPos(), tile.getBlockType());
}
}
markDirty();
@@ -347,8 +350,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
@Override
public float getExactTemperature() {
ChunkCoordinates coords = getReferenceCoord();
return getBiome().getFloatTemperature(coords.posX, coords.posY, coords.posZ) + tempChange;
BlockPos coords = getReferenceCoord();
return getBiome().getFloatTemperature(coords) + tempChange;
}
@Override
@@ -384,29 +387,29 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
@Override
public BiomeGenBase getBiome() {
if (cachedBiome == null) {
ChunkCoordinates coords = getReferenceCoord();
cachedBiome = worldObj.getBiomeGenForCoords(coords.posX, coords.posZ);
BlockPos coords = getReferenceCoord();
cachedBiome = worldObj.getBiomeGenForCoords(coords);
}
return cachedBiome;
}
@Override
public int getBlockLightValue() {
ChunkCoordinates topCenter = getTopCenterCoord();
return worldObj.getBlockLightValue(topCenter.posX, topCenter.posY + 1, topCenter.posZ);
BlockPos topCenter = getTopCenterCoord();
return worldObj.getLightFromNeighbors(topCenter.add(0, 1, 0));
}
@Override
public boolean canBlockSeeTheSky() {
ChunkCoordinates topCenter = getTopCenterCoord();
return worldObj.canBlockSeeTheSky(topCenter.posX, topCenter.posY + 2, topCenter.posZ);
BlockPos topCenter = getTopCenterCoord();
return worldObj.canBlockSeeSky(topCenter.add(0, 2, 0));
}
@Override
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
ChunkCoordinates coordinates = getCoordinates();
BlockPos coordinates = getCoordinates();
float temperature = getBiome().getFloatTemperature(coordinates.posX, coordinates.posY, coordinates.posZ);
float temperature = getBiome().getFloatTemperature(coordinates);
tempChange += change;
tempChange = Math.max(boundaryDown - temperature, tempChange);
@@ -13,7 +13,7 @@ package forestry.apiculture.multiblock;
import java.util.Collections;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraft.world.biome.BiomeGenBase;
@@ -71,7 +71,7 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
}
@Override
public ChunkCoordinates getCoordinates() {
public BlockPos getCoordinates() {
return null;
}
@@ -29,6 +29,7 @@ public class MultiblockLogicAlveary extends MultiblockLogic<IAlvearyControllerIn
}
}
@Override
public IAlvearyControllerInternal createNewController(World world) {
return new AlvearyController(world);
}
@@ -14,7 +14,7 @@ import java.io.IOException;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraft.world.biome.BiomeGenBase;
@@ -56,28 +56,23 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry<Multibloc
this.unlocalizedTitle = "tile.for.alveary." + type.ordinal() + ".name";
}
/* TEXTURES */
public int getIcon(int side) {
return BlockAlveary.PLAIN;
}
@Override
public void onMachineAssembled(IMultiblockController multiblockController, ChunkCoordinates minCoord, ChunkCoordinates maxCoord) {
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
// Re-render this block on the client
if (worldObj.isRemote) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
this.worldObj.markBlockForUpdate(getPos());
}
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
markDirty();
worldObj.notifyBlockOfStateChange(getPos(), getBlockType());
//markDirty();
}
@Override
public void onMachineBroken() {
// Re-render this block on the client
if (worldObj.isRemote) {
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
this.worldObj.markBlockForUpdate(getPos());
}
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
worldObj.notifyBlockOfStateChange(getPos(), getBlockType());
markDirty();
}
@@ -11,9 +11,7 @@
package forestry.apiculture.multiblock;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import forestry.api.core.IClimateControlled;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.apiculture.network.packets.PacketActiveUpdate;
@@ -34,10 +32,6 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
float getBoundaryUp();
float getBoundaryDown();
int getIconOff();
int getIconOn();
}
private final EnergyManager energyManager;
@@ -71,16 +65,6 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
setActive(workingTime > 0);
}
/* TEXTURES */
@Override
public int getIcon(int side) {
if (active) {
return definition.getIconOn();
} else {
return definition.getIconOff();
}
}
/* LOADING & SAVING */
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
@@ -126,7 +110,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.func_147479_m(xCoord, yCoord, zCoord);
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
} else {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj);
}
@@ -135,27 +119,27 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
/* IEnergyHandler */
@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);
}
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.apiculture.multiblock;
import forestry.apiculture.blocks.BlockAlveary;
public class TileAlvearyFan extends TileAlvearyClimatiser {
private static final FanDefinition definition = new FanDefinition();
@@ -36,15 +34,5 @@ public class TileAlvearyFan extends TileAlvearyClimatiser {
public float getBoundaryDown() {
return 0.05f;
}
@Override
public int getIconOff() {
return BlockAlveary.ALVEARY_FAN_OFF;
}
@Override
public int getIconOn() {
return BlockAlveary.ALVEARY_FAN_ON;
}
}
}
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.apiculture.multiblock;
import forestry.apiculture.blocks.BlockAlveary;
public class TileAlvearyHeater extends TileAlvearyClimatiser {
private static final HeaterDefinition definition = new HeaterDefinition();
@@ -36,15 +34,5 @@ public class TileAlvearyHeater extends TileAlvearyClimatiser {
public float getBoundaryDown() {
return 0.0f;
}
@Override
public int getIconOff() {
return BlockAlveary.ALVEARY_HEATER_OFF;
}
@Override
public int getIconOn() {
return BlockAlveary.ALVEARY_HEATER_ON;
}
}
}
@@ -13,8 +13,7 @@ package forestry.apiculture.multiblock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
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;
@@ -138,12 +137,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
}
/* TEXTURES */
@Override
public int getIcon(int side) {
return BlockAlveary.ALVEARY_HYGRO;
}
/* ILIQUIDTANKCONTAINER */
@Override
public TankManager getTankManager() {
@@ -151,32 +144,32 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
return tankManager.fill(from, resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
return tankManager.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
return tankManager.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
public boolean canFill(EnumFacing from, Fluid fluid) {
return tankManager.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
public boolean canDrain(EnumFacing from, Fluid fluid) {
return tankManager.canDrain(from, fluid);
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
public FluidTankInfo[] getTankInfo(EnumFacing from) {
return tankManager.getTankInfo(from);
}
@@ -14,12 +14,9 @@ import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.common.Optional;
import forestry.api.multiblock.IMultiblockController;
import forestry.apiculture.blocks.BlockAlveary;
import forestry.apiculture.trigger.ApicultureTriggers;
@@ -33,14 +30,14 @@ import buildcraft.api.statements.ITriggerProvider;
public class TileAlvearyPlain extends TileAlveary implements ITriggerProvider {
@Override
public void onMachineAssembled(IMultiblockController multiblockController, ChunkCoordinates minCoord, ChunkCoordinates maxCoord) {
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
super.onMachineAssembled(multiblockController, minCoord, maxCoord);
if (!worldObj.isRemote) {
// set alveary entrance block meta
if (yCoord == maxCoord.posY) {
if ((xCoord > minCoord.posX && xCoord < maxCoord.posX) || (zCoord > minCoord.posZ && zCoord < maxCoord.posZ)) {
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, BlockAlveary.Type.ENTRANCE.ordinal(), 2);
if (getPos().getY() == maxCoord.getY()) {
if ((getPos().getX() > minCoord.getX() && getPos().getX() < maxCoord.getX()) || (getPos().getZ() > minCoord.getZ() && getPos().getZ() < maxCoord.getZ())) {
this.worldObj.setBlockState(getPos(), getBlockType().getStateFromMeta(BlockAlveary.Type.ENTRANCE.ordinal()), 2);
}
}
}
@@ -52,7 +49,7 @@ public class TileAlvearyPlain extends TileAlveary implements ITriggerProvider {
if (!worldObj.isRemote) {
// set alveary entrance block meta back to normal
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, BlockAlveary.Type.PLAIN.ordinal(), 2);
this.worldObj.setBlockState(getPos(), getBlockType().getStateFromMeta(BlockAlveary.Type.PLAIN.ordinal()), 2);
}
}
@@ -70,7 +67,7 @@ public class TileAlvearyPlain extends TileAlveary implements ITriggerProvider {
@Optional.Method(modid = "BuildCraftAPI|statements")
@Override
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
Collection<ITriggerExternal> res = new ArrayList<>();
res.add(ApicultureTriggers.missingQueen);
res.add(ApicultureTriggers.missingDrone);
@@ -51,14 +51,6 @@ public class TileAlvearySieve extends TileAlveary implements IAlvearyComponent.B
public IBeeListener getBeeListener() {
return beeListener;
}
@Override
public int getIcon(int side) {
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
return BlockAlveary.SIEVE;
}
@Override
public Object getGui(EntityPlayer player, int data) {
@@ -14,22 +14,11 @@ import forestry.api.apiculture.DefaultBeeModifier;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.apiculture.blocks.BlockAlveary;
public class TileAlvearyStabiliser extends TileAlveary implements IAlvearyComponent.BeeModifier {
private static final IBeeModifier beeModifier = new AlvearyStabiliserBeeModifier();
/* TEXTURES */
@Override
public int getIcon(int side) {
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
return BlockAlveary.STABILISER;
}
@Override
public IBeeModifier getBeeModifier() {
return beeModifier;
@@ -135,8 +135,8 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
HiveDescriptionSwarmer hiveDescription = new HiveDescriptionSwarmer(toSpawn);
Hive hive = new Hive(hiveDescription);
int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
int chunkX = (getPos().getX() + worldObj.rand.nextInt(40 * 2) - 40) / 16;
int chunkZ = (getPos().getZ() + worldObj.rand.nextInt(40 * 2) - 40) / 16;
if (HiveDecorator.genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive)) {
pendingSpawns.pop();
@@ -157,20 +157,6 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
setActive(packetData.getBoolean("Active"));
}
/* TEXTURES */
@Override
public int getIcon(int side) {
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
if (active) {
return BlockAlveary.ALVEARY_SWARMER_ON;
} else {
return BlockAlveary.ALVEARY_SWARMER_OFF;
}
}
/* SAVING & LOADING */
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
@@ -13,8 +13,7 @@ package forestry.apiculture.network.packets;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.IForestryPacketClient;
import forestry.core.network.PacketIdClient;
@@ -26,7 +25,7 @@ public class PacketHabitatBiomePointer extends PacketCoordinates implements IFor
public PacketHabitatBiomePointer() {
}
public PacketHabitatBiomePointer(ChunkCoordinates coordinates) {
public PacketHabitatBiomePointer(BlockPos coordinates) {
super(coordinates);
}
@@ -37,6 +36,6 @@ public class PacketHabitatBiomePointer extends PacketCoordinates implements IFor
@Override
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
Proxies.render.setHabitatLocatorTexture(player, getCoordinates());
Proxies.render.setHabitatLocatorTexture(player, getPos());
}
}
@@ -10,11 +10,11 @@
******************************************************************************/
package forestry.apiculture.proxy;
import forestry.core.render.IBlockRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
public class ProxyApiculture {
public IBlockRenderer getRendererAnalyzer(String string) {
public TileEntitySpecialRenderer getRendererAnalyzer(String string) {
return null;
}
@@ -10,32 +10,25 @@
******************************************************************************/
package forestry.apiculture.proxy;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.RenderingRegistry;
import forestry.apiculture.entities.EntityBee;
import forestry.apiculture.render.RenderBeeEntity;
import forestry.apiculture.render.RenderBeeItem;
import forestry.core.render.IBlockRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import forestry.core.render.RenderAnalyzer;
import forestry.plugins.PluginApiculture;
import forestry.core.tiles.TileAnalyzer;
public class ProxyApicultureClient extends ProxyApiculture {
@Override
public void initializeRendering() {
if (PluginApiculture.fancyRenderedBees) {
/*if (PluginApiculture.fancyRenderedBees) {
RenderingRegistry.registerEntityRenderingHandler(EntityBee.class, new RenderBeeEntity());
MinecraftForgeClient.registerItemRenderer(PluginApiculture.items.beeDroneGE, new RenderBeeItem());
MinecraftForgeClient.registerItemRenderer(PluginApiculture.items.beePrincessGE, new RenderBeeItem());
MinecraftForgeClient.registerItemRenderer(PluginApiculture.items.beeQueenGE, new RenderBeeItem());
}
}*/
}
@Override
public IBlockRenderer getRendererAnalyzer(String gfxBase) {
public TileEntitySpecialRenderer<TileAnalyzer> getRendererAnalyzer(String gfxBase) {
return new RenderAnalyzer(gfxBase);
}
@@ -12,10 +12,9 @@ package forestry.apiculture.render;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import forestry.core.proxy.Proxies;
@@ -56,7 +55,7 @@ public class ModelAnalyzer extends ModelBase {
}
public void render(ForgeDirection orientation, float posX, float posY, float posZ) {
public void render(EnumFacing orientation, float posX, float posY, float posZ) {
GL11.glPushMatrix();
@@ -64,7 +63,7 @@ public class ModelAnalyzer extends ModelBase {
float[] angle = {0, 0, 0};
if (orientation == null) {
orientation = ForgeDirection.WEST;
orientation = EnumFacing.WEST;
}
switch (orientation) {
case EAST:
@@ -122,6 +122,7 @@ public class ModelBee extends ModelBase {
this.type = type;
}
@Override
public void render(Entity entity, float f, float f1, float swing, float f3, float f4, float f5) {
super.render(entity, f, f1, swing, f3, f4, f5);
//setRotationAngles(f, f1, f2, f3, f4, f5, entity);
@@ -160,6 +161,7 @@ public class ModelBee extends ModelBase {
model.rotateAngleZ = z;
}
@Override
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
@@ -18,19 +18,20 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import org.lwjgl.opengl.GL11;
@@ -117,19 +118,19 @@ public class ParticleRenderer {
private synchronized void render(float partialTicks) {
Minecraft.getMinecraft().mcProfiler.startSection(name + "-render");
float rotationX = ActiveRenderInfo.rotationX;
float rotationZ = ActiveRenderInfo.rotationZ;
float rotationYZ = ActiveRenderInfo.rotationYZ;
float rotationXY = ActiveRenderInfo.rotationXY;
float rotationXZ = ActiveRenderInfo.rotationXZ;
float rotationX = ActiveRenderInfo.getRotationX();
float rotationZ = ActiveRenderInfo.getRotationZ();
float rotationYZ = ActiveRenderInfo.getRotationYZ();
float rotationXY = ActiveRenderInfo.getRotationXY();
float rotationXZ = ActiveRenderInfo.getRotationXZ();
EntityLivingBase player = Minecraft.getMinecraft().renderViewEntity;
EntityLivingBase player = (EntityLivingBase) Minecraft.getMinecraft().getRenderViewEntity();
EntityFX.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
EntityFX.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
EntityFX.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
// bind the texture
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
// save the old gl state
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
@@ -141,13 +142,12 @@ public class ParticleRenderer {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
worldRenderer.begin(7, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
for (EntityFX particle : particles) {
tessellator.setBrightness(particle.getBrightnessForRender(partialTicks));
particle.renderParticle(tessellator, partialTicks, rotationX, rotationXZ, rotationZ, rotationYZ, rotationXY);
particle.renderParticle(worldRenderer, particle, partialTicks, rotationX, rotationXZ, rotationZ, rotationYZ, rotationXY);
}
tessellator.draw();
@@ -12,16 +12,18 @@ package forestry.apiculture.render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation;
import forestry.apiculture.entities.EntityBee;
import forestry.core.proxy.Proxies;
public class RenderBeeEntity extends RenderLiving {
private final ModelBee beeModel;
public RenderBeeEntity() {
super(new ModelBee(), 0.15f);
super(Proxies.common.getClientInstance().getRenderManager(), new ModelBee(), 0.15f);
beeModel = (ModelBee) mainModel;
}
@@ -29,10 +31,10 @@ public class RenderBeeEntity extends RenderLiving {
beeModel.setType(entity.getType());
this.doRender(entity, posX, posY, posZ, par8, par9);
}
@Override
public void doRender(Entity entity, double posX, double posY, double posZ, float par8, float par9) {
renderBee((EntityBee) entity, posX, posY, posZ, par8, par9);
public void doRender(EntityLiving entity, double x, double y, double z, float entityYaw, float partialTicks) {
renderBee((EntityBee) entity, x, y, z, entityYaw, partialTicks);
}
@Override
@@ -10,24 +10,9 @@
******************************************************************************/
package forestry.apiculture.render;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.item.ItemStack;
public class RenderBeeItem/* implements IItemRenderer*/ {
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.apiculture.entities.EntityBee;
import forestry.core.proxy.Proxies;
public class RenderBeeItem implements IItemRenderer {
private EntityBee entity;
/*private EntityBee entity;
private static float getWingYaw(IBee bee) {
float wingYaw = 1f;
@@ -75,7 +60,7 @@ public class RenderBeeItem implements IItemRenderer {
entity = new EntityBee(Proxies.common.getClientInstance().theWorld);
}
entity.setSpecies(bee.getGenome().getPrimary());
entity.setType(BeeManager.beeRoot.getType(item));
entity.setType(BeeManager.beeRoot.getType(item));*/
/*
if(scaled)
entity.setScale(butterfly.getSize());
@@ -83,8 +68,8 @@ public class RenderBeeItem implements IItemRenderer {
entity.setScale(EntityButterfly.DEFAULT_BUTTERFLY_SIZE);
*/
return bee;
}
/* return bee;
}*/
/*private void renderBeeHalo() {
@@ -102,7 +87,7 @@ public class RenderBeeItem implements IItemRenderer {
tessellator.draw();
}*/
private void renderBeeItem(IBee bee, float translateX, float translateY, float translateZ) {
/*private void renderBeeItem(IBee bee, float translateX, float translateY, float translateZ) {
float yaw = 1;
float pitch = 1;
@@ -136,7 +121,7 @@ public class RenderBeeItem implements IItemRenderer {
}
private void renderBeeInInventory(IBee bee) {
private void renderBeeInInventory(IBee bee) {*/
/*
GL11.glPushMatrix();
@@ -148,9 +133,9 @@ public class RenderBeeItem implements IItemRenderer {
//GL11.glRotatef(-((float) Math.atan((double) (1 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
renderBeeHalo();
GL11.glPopMatrix();
*/
*/
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
/*GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
RenderHelper.enableStandardItemLighting();
@@ -219,6 +204,6 @@ public class RenderBeeItem implements IItemRenderer {
break;
default:
}
}
}*/
}
@@ -1,146 +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.apiculture.render;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import forestry.apiculture.blocks.BlockCandle;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.proxy.Proxies;
public class RenderCandleBlock implements ISimpleBlockRenderingHandler {
@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) {
if (block.getRenderType() == Proxies.render.getCandleRenderId()) {
renderBlockCandle(world, x, y, z, (BlockCandle) block);
}
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return false;
}
@Override
public int getRenderId() {
return Proxies.render.getCandleRenderId();
}
private static boolean renderBlockCandle(IBlockAccess world, int x, int y, int z, BlockCandle block) {
int meta = world.getBlockMetadata(x, y, z);
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileCandle)) {
return false;
}
TileCandle tileCandle = (TileCandle) tileEntity;
boolean isLit = tileCandle.isLit();
IIcon iconA = block.getTextureFromPassAndLit(0, isLit);
IIcon iconB = block.getTextureFromPassAndLit(1, isLit);
int colour = tileCandle.getColour();
Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(world.getLightBrightnessForSkyBlocks(x, y, z, block.getLightValue(world, x, y, z)));
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
double d0 = 0.4000000059604645D;
double d1 = 0.5D - d0;
double d2 = 0.20000000298023224D;
if (meta == 1) {
renderCandleAtAngle(iconA, x - d1, y + d2, z, -d0, 0.0D, 0xffffff);
renderCandleAtAngle(iconB, x - d1, y + d2, z, -d0, 0.0D, colour);
} else if (meta == 2) {
renderCandleAtAngle(iconA, x + d1, y + d2, z, d0, 0.0D, 0xffffff);
renderCandleAtAngle(iconB, x + d1, y + d2, z, d0, 0.0D, colour);
} else if (meta == 3) {
renderCandleAtAngle(iconA, x, y + d2, z - d1, 0.0D, -d0, 0xffffff);
renderCandleAtAngle(iconB, x, y + d2, z - d1, 0.0D, -d0, colour);
} else if (meta == 4) {
renderCandleAtAngle(iconA, x, y + d2, z + d1, 0.0D, d0, 0xffffff);
renderCandleAtAngle(iconB, x, y + d2, z + d1, 0.0D, d0, colour);
} else {
renderCandleAtAngle(iconA, x, y, z, 0.0D, 0.0D, 0xffffff);
renderCandleAtAngle(iconB, x, y, z, 0.0D, 0.0D, colour);
}
return true;
}
private static void renderCandleAtAngle(IIcon icon, double x, double y, double z, double par8, double par10, int colour) {
Tessellator tessellator = Tessellator.instance;
double minU = icon.getMinU();
double minV = icon.getMinV();
double maxU = icon.getMaxU();
double maxV = icon.getMaxV();
double textureLightTopU = icon.getInterpolatedU(7.0D);
double d10 = icon.getInterpolatedV(6.0D);
double textureLightBottomU = icon.getInterpolatedU(9.0D);
double d12 = icon.getInterpolatedV(8.0D);
//double d13 = (double)icon.getInterpolatedV(7.0D);
double d14 = icon.getInterpolatedV(13.0D);
//double textureLightBottomV = (double)icon.getInterpolatedV(8.0D);
double d16 = icon.getInterpolatedV(15.0D);
x += 0.5D;
z += 0.5D;
double d17 = x - 0.5D;
double d18 = x + 0.5D;
double d19 = z - 0.5D;
double d20 = z + 0.5D;
double d21 = 0.0625D;
double d22 = 0.625D;
tessellator.setColorOpaque_I(colour);
// top quad
tessellator.addVertexWithUV(x + par8 * (1.0D - d22) - d21, y + d22, z + par10 * (1.0D - d22) - d21, textureLightTopU, d10);
tessellator.addVertexWithUV(x + par8 * (1.0D - d22) - d21, y + d22, z + par10 * (1.0D - d22) + d21, textureLightTopU, d12);
tessellator.addVertexWithUV(x + par8 * (1.0D - d22) + d21, y + d22, z + par10 * (1.0D - d22) + d21, textureLightBottomU, d12);
tessellator.addVertexWithUV(x + par8 * (1.0D - d22) + d21, y + d22, z + par10 * (1.0D - d22) - d21, textureLightBottomU, d10);
// -x quad
tessellator.addVertexWithUV(x - d21, y + 1d, d19, minU, minV);
tessellator.addVertexWithUV(x - d21 + par8, y, d19 + par10, minU, maxV);
tessellator.addVertexWithUV(x - d21 + par8, y, d20 + par10, maxU, maxV);
tessellator.addVertexWithUV(x - d21, y + 1d, d20, maxU, minV);
// +x quad
tessellator.addVertexWithUV(x + d21, y + 1.0D, d20, minU, minV);
tessellator.addVertexWithUV(x + par8 + d21, y, d20 + par10, minU, maxV);
tessellator.addVertexWithUV(x + par8 + d21, y, d19 + par10, maxU, maxV);
tessellator.addVertexWithUV(x + d21, y + 1.0D, d19, maxU, minV);
// -z quad
tessellator.addVertexWithUV(d18, y + 1.0D, z - d21, minU, minV);
tessellator.addVertexWithUV(d18 + par8, y, z - d21 + par10, minU, maxV);
tessellator.addVertexWithUV(d17 + par8, y, z - d21 + par10, maxU, maxV);
tessellator.addVertexWithUV(d17, y + 1.0D, z - d21, maxU, minV);
// +z quad
tessellator.addVertexWithUV(d17, y + 1.0D, z + d21, minU, minV);
tessellator.addVertexWithUV(d17 + par8, y, z + d21 + par10, minU, maxV);
tessellator.addVertexWithUV(d18 + par8, y, z + d21 + par10, maxU, maxV);
tessellator.addVertexWithUV(d18, y + 1.0D, z + d21, maxU, minV);
// bottom quad
tessellator.addVertexWithUV(x + d21 + par8, y, z - d21 + par10, textureLightBottomU, d14);
tessellator.addVertexWithUV(x + d21 + par8, y, z + d21 + par10, textureLightBottomU, d16);
tessellator.addVertexWithUV(x - d21 + par8, y, z + d21 + par10, textureLightTopU, d16);
tessellator.addVertexWithUV(x - d21 + par8, y, z - d21 + par10, textureLightTopU, d14);
}
}
@@ -13,7 +13,7 @@ package forestry.apiculture.render;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class TextureHabitatLocator extends TextureAtlasSprite {
@@ -24,7 +24,7 @@ public class TextureHabitatLocator extends TextureAtlasSprite {
return instance;
}
private ChunkCoordinates targetBiome;
private BlockPos targetBiome;
private boolean targetBiomeFound;
private double currentAngle;
@@ -35,7 +35,7 @@ public class TextureHabitatLocator extends TextureAtlasSprite {
instance = this;
}
public void setTargetCoordinates(ChunkCoordinates coordinates) {
public void setTargetCoordinates(BlockPos coordinates) {
this.targetBiome = coordinates;
this.targetBiomeFound = false;
}
@@ -59,8 +59,8 @@ public class TextureHabitatLocator extends TextureAtlasSprite {
// No target has the locator spinning wildly.
targetAngle = Math.random() * Math.PI * 2.0d;
} else {
double xPart = targetBiome.posX - playerX;
double zPart = targetBiome.posZ - playerZ;
double xPart = targetBiome.getX() - playerX;
double zPart = targetBiome.getZ() - playerZ;
if (Math.abs(xPart) + Math.abs(zPart) < 10 || targetBiomeFound) {
// spin steadily when the biome is found
@@ -100,7 +100,7 @@ public class TextureHabitatLocator extends TextureAtlasSprite {
if (i != this.frameCounter) {
this.frameCounter = i;
TextureUtil.uploadTextureMipmap((int[][]) this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
TextureUtil.uploadTextureMipmap(this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
}
}
@@ -19,6 +19,7 @@ import forestry.core.config.Constants;
import forestry.core.inventory.InventoryPlain;
import forestry.core.tiles.TileNaturalistChest;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.BlockUtil;
import forestry.plugins.PluginApiculture;
public class TileApiaristChest extends TileNaturalistChest {
@@ -32,7 +33,7 @@ public class TileApiaristChest extends TileNaturalistChest {
@Override
protected void updateServerSide() {
if (worldObj != null && !checkedForLegacyBlock) {
Block block = worldObj.getBlock(xCoord, yCoord, zCoord);
Block block = BlockUtil.getBlock(worldObj, getPos());
if (PluginApiculture.blocks.apiculture == block) {
migrateFromLegacyBlock();
}
@@ -50,10 +51,10 @@ public class TileApiaristChest extends TileNaturalistChest {
setInventorySlotContents(i, null);
}
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
worldObj.setBlock(xCoord, yCoord, zCoord, PluginApiculture.blocks.apicultureChest, 0, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
worldObj.setBlockToAir(getPos());
worldObj.setBlockState(getPos(), PluginApiculture.blocks.apicultureChest.getStateFromMeta(0), Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
TileApiaristChest tile = TileUtil.getTile(worldObj, xCoord, yCoord, zCoord, TileApiaristChest.class);
TileApiaristChest tile = TileUtil.getTile(worldObj, getPos(), TileApiaristChest.class);
for (int i = 0; i < getSizeInventory(); i++) {
ItemStack stack = inventoryCopy.getStackInSlot(i);
tile.setInventorySlotContents(i, stack);
@@ -18,11 +18,8 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
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.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
@@ -79,7 +76,7 @@ public class TileApiary extends TileBeeHousingBase implements IApiary {
/* ITRIGGERPROVIDER */
@Optional.Method(modid = "BuildCraftAPI|statements")
@Override
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
LinkedList<ITriggerExternal> res = new LinkedList<>();
res.add(ApicultureTriggers.missingQueen);
res.add(ApicultureTriggers.missingDrone);
@@ -72,7 +72,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
/* ICLIMATISED */
@Override
public EnumTemperature getTemperature() {
return EnumTemperature.getFromBiome(getBiome(), xCoord, yCoord, zCoord);
return EnumTemperature.getFromBiome(getBiome(), getPos());
}
@Override
@@ -82,7 +82,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
@Override
public float getExactTemperature() {
return getBiome().getFloatTemperature(xCoord, yCoord, zCoord);
return getBiome().getFloatTemperature(getPos());
}
@Override
@@ -97,7 +97,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
beeLogic.doBeeFX();
if (updateOnInterval(50)) {
doPollenFX(worldObj, xCoord, yCoord, zCoord);
doPollenFX(worldObj, getPos().getX(), getPos().getY(), getPos().getZ());
}
}
}
@@ -143,19 +143,19 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
@Override
public BiomeGenBase getBiome() {
if (cachedBiome == null) {
cachedBiome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
cachedBiome = worldObj.getBiomeGenForCoordsBody(getPos());
}
return cachedBiome;
}
@Override
public int getBlockLightValue() {
return worldObj.getBlockLightValue(xCoord, yCoord + 1, zCoord);
return worldObj.getLightFromNeighbors(getPos().add(0, 1, 0));
}
@Override
public boolean canBlockSeeTheSky() {
return worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord);
return worldObj.canBlockSeeSky(getPos().add(0, 1, 0));
}
@Override
@@ -170,7 +170,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
@Override
public Vec3 getBeeFXCoordinates() {
return Vec3.createVectorHelper(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
return new Vec3(getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5);
}
}
@@ -20,12 +20,6 @@ public class TileCandle extends TileEntity {
private int colour;
private boolean lit;
// This is a non-ticking Tile Entity.
@Override
public boolean canUpdate() {
return false;
}
@Override
public Packet getDescriptionPacket() {
PacketCandleUpdate updateCandle = new PacketCandleUpdate(this);
@@ -13,31 +13,25 @@ package forestry.apiculture.tiles;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
import net.minecraft.world.EnumSkyBlock;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.InventoryUtil;
public class TileSwarm extends TileEntity {
public class TileSwarm extends TileEntity implements ITickable {
public final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
@Override
public boolean canUpdate() {
return true;
}
// Hack to make sure that hives glow.
// TODO: remove when Mojang fixes this bug: https://bugs.mojang.com/browse/MC-3329
// Hives should not need to tick normally.
private boolean updatedLight;
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
if (worldObj.isRemote && !updatedLight && worldObj.getWorldTime() % 20 == 0) {
updatedLight = worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
updatedLight = worldObj.checkLightFor(EnumSkyBlock.BLOCK, getPos());
}
}
@@ -11,9 +11,7 @@
package forestry.apiculture.trigger;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import forestry.api.core.IErrorLogicSource;
import forestry.core.errors.EnumErrorCode;
import forestry.core.triggers.Trigger;
@@ -31,7 +29,7 @@ public class TriggerMissingDrone 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 IErrorLogicSource)) {
return false;
@@ -11,9 +11,7 @@
package forestry.apiculture.trigger;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import forestry.api.core.IErrorLogicSource;
import forestry.core.errors.EnumErrorCode;
import forestry.core.triggers.Trigger;
@@ -31,7 +29,7 @@ public class TriggerMissingQueen 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 IErrorLogicSource)) {
return false;
@@ -11,9 +11,7 @@
package forestry.apiculture.trigger;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import forestry.apiculture.inventory.InventoryApiary;
import forestry.apiculture.tiles.TileApiary;
import forestry.core.triggers.Trigger;
@@ -31,7 +29,7 @@ public class TriggerNoFrames 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 TileApiary)) {
return false;
@@ -15,8 +15,11 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.structure.StructureBoundingBox;
@@ -24,8 +27,6 @@ import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.FlowerManager;
@@ -70,7 +71,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
createBuildingBlocks(random);
}
public ComponentVillageBeeHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, int coordBaseMode) {
public ComponentVillageBeeHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, EnumFacing coordBaseMode) {
super(startPiece, componentType, random, boundingBox, coordBaseMode);
isInDesert = startPiece.inDesert;
@@ -97,12 +98,12 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
logs = new BlockType(Blocks.log, random.nextInt(4));
planks = new BlockType(Blocks.planks, roofMeta);
stairs = new BlockTypeVanillaStairs(roofMeta);
fence = new BlockType(Blocks.fence, 0);
fence = new BlockType(Blocks.oak_fence, 0);
}
}
@SuppressWarnings("rawtypes")
public static ComponentVillageBeeHouse buildComponent(StructureVillagePieces.Start startPiece, List par1List, Random random, int par3, int par4, int par5, int par6, int par7) {
public static ComponentVillageBeeHouse buildComponent(StructureVillagePieces.Start startPiece, List par1List, Random random, int par3, int par4, int par5, EnumFacing par6, int par7) {
StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 10, 9, 11, par6);
if (!canVillageGoDeeper(bbox) || StructureComponent.findIntersecting(par1List, bbox) != null) {
return null;
@@ -123,8 +124,8 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
boundingBox.offset(0, averageGroundLevel - boundingBox.maxY + 8 - 1, 0);
}
fillWithBlocks(world, structBoundingBox, 1, 1, 1, 7, 4, 4, Blocks.air, Blocks.air, false);
fillWithBlocks(world, structBoundingBox, 2, 1, 6, 8, 4, 10, Blocks.air, Blocks.air, false);
fillWithBlocks(world, structBoundingBox, 1, 1, 1, 7, 4, 4, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
fillWithBlocks(world, structBoundingBox, 2, 1, 6, 8, 4, 10, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
// Garden
buildGarden(world, structBoundingBox);
@@ -141,12 +142,12 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
buildApiaries(world, structBoundingBox);
// Floor
fillWithBlocks(world, structBoundingBox, 1, 0, 1, 7, 0, 4, Blocks.planks, Blocks.planks, false);
fillWithBlocks(world, structBoundingBox, 1, 0, 1, 7, 0, 4, Blocks.planks.getDefaultState(), Blocks.planks.getDefaultState(), false);
fillWithBlocks(world, structBoundingBox, 0, 0, 0, 0, 3, 5, Blocks.cobblestone, Blocks.cobblestone, false);
fillWithBlocks(world, structBoundingBox, 8, 0, 0, 8, 3, 5, Blocks.cobblestone, Blocks.cobblestone, false);
fillWithBlocks(world, structBoundingBox, 1, 0, 0, 7, 1, 0, Blocks.cobblestone, Blocks.cobblestone, false);
fillWithBlocks(world, structBoundingBox, 1, 0, 5, 7, 1, 5, Blocks.cobblestone, Blocks.cobblestone, false);
fillWithBlocks(world, structBoundingBox, 0, 0, 0, 0, 3, 5, Blocks.cobblestone.getDefaultState(), Blocks.cobblestone.getDefaultState(), false);
fillWithBlocks(world, structBoundingBox, 8, 0, 0, 8, 3, 5, Blocks.cobblestone.getDefaultState(), Blocks.cobblestone.getDefaultState(), false);
fillWithBlocks(world, structBoundingBox, 1, 0, 0, 7, 1, 0, Blocks.cobblestone.getDefaultState(), Blocks.cobblestone.getDefaultState(), false);
fillWithBlocks(world, structBoundingBox, 1, 0, 5, 7, 1, 5, Blocks.cobblestone.getDefaultState(), Blocks.cobblestone.getDefaultState(), false);
fillBoxWith(world, structBoundingBox, 1, 2, 0, 7, 3, 0, planks, false);
fillBoxWith(world, structBoundingBox, 1, 2, 5, 7, 3, 5, planks, false);
@@ -165,55 +166,55 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
placeBlockAtCurrentPosition(world, logs, 0, 2, 4, structBoundingBox);
placeBlockAtCurrentPosition(world, logs, 8, 2, 1, structBoundingBox);
placeBlockAtCurrentPosition(world, logs, 8, 2, 4, structBoundingBox);
setBlockState(world, Blocks.glass_pane.getStateFromMeta(0), 0, 2, 2, structBoundingBox);
setBlockState(world, Blocks.glass_pane.getStateFromMeta(0), 0, 2, 3, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 0, 2, 2, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 0, 2, 3, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 2, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 3, structBoundingBox);
setBlockState(world, Blocks.glass_pane.getStateFromMeta(0), 8, 2, 2, structBoundingBox);
setBlockState(world, Blocks.glass_pane.getStateFromMeta(0), 8, 2, 3, structBoundingBox);
// Windows garden side
placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 5, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 3, 2, 5, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 4, 2, 5, structBoundingBox);
setBlockState(world, Blocks.glass_pane.getStateFromMeta(0), 2, 2, 5, structBoundingBox);
setBlockState(world, Blocks.glass_pane.getStateFromMeta(0), 3, 2, 5, structBoundingBox);
setBlockState(world, Blocks.glass_pane.getStateFromMeta(0), 4, 2, 5, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 5, 2, 0, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 6, 2, 5, structBoundingBox);
setBlockState(world, Blocks.glass_pane.getStateFromMeta(0), 5, 2, 0, structBoundingBox);
setBlockState(world, Blocks.glass_pane.getStateFromMeta(0), 6, 2, 5, structBoundingBox);
// Escritoire
if (random.nextInt(2) == 0) {
IBlockType escritoireBlock = new BlockTypeTileForestry(PluginCore.blocks.core, BlockCoreType.ESCRITOIRE.ordinal());
escritoireBlock.setDirection(getRotatedDirection(ForgeDirection.EAST));
escritoireBlock.setDirection(getRotatedDirection(EnumFacing.EAST));
placeBlockAtCurrentPosition(world, escritoireBlock, 1, 1, 3, structBoundingBox);
}
placeBlockAtCurrentPosition(world, Blocks.air, 0, 2, 1, 0, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.air, 0, 2, 2, 0, structBoundingBox);
placeDoorAtCurrentPosition(world, structBoundingBox, random, 2, 1, 0, getMetadataWithOffset(Blocks.wooden_door, 1));
setBlockState(world, Blocks.air.getStateFromMeta(0), 2, 1, 0, structBoundingBox);
setBlockState(world, Blocks.air.getStateFromMeta(0), 2, 2, 0, structBoundingBox);
placeDoorCurrentPosition(world, structBoundingBox, random, 2, 1, 0, coordBaseMode);
if (isAirBlockAtCurrentPosition(world, 2, 0, -1, structBoundingBox) && !isAirBlockAtCurrentPosition(world, 2, -1, -1, structBoundingBox)) {
placeBlockAtCurrentPosition(world, Blocks.stone_stairs, getMetadataWithOffset(Blocks.stone_stairs, 3), 2, 0, -1, structBoundingBox);
if (isAirBlockAtCurrentPosition(world, new BlockPos(2, 0, -1), structBoundingBox) && !isAirBlockAtCurrentPosition(world, new BlockPos(2, -1, -1), structBoundingBox)) {
setBlockState(world, Blocks.stone_stairs.getStateFromMeta(getMetadataWithOffset(Blocks.stone_stairs, 3)), 2, 0, -1, structBoundingBox);
}
placeBlockAtCurrentPosition(world, Blocks.air, 0, 6, 1, 5, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.air, 0, 6, 2, 5, structBoundingBox);
setBlockState(world, Blocks.air.getStateFromMeta(0), 6, 1, 5, structBoundingBox);
setBlockState(world, Blocks.air.getStateFromMeta(0), 6, 2, 5, structBoundingBox);
// Candles / Lighting
placeBlockAtCurrentPosition(world, Blocks.torch, 0, 2, 3, 4, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 4, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.torch, 0, 2, 3, 1, structBoundingBox);
placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 1, structBoundingBox);
setBlockState(world, Blocks.torch.getStateFromMeta(0), 2, 3, 4, structBoundingBox);
setBlockState(world, Blocks.torch.getStateFromMeta(0), 6, 3, 4, structBoundingBox);
setBlockState(world, Blocks.torch.getStateFromMeta(0), 2, 3, 1, structBoundingBox);
setBlockState(world, Blocks.torch.getStateFromMeta(0), 6, 3, 1, structBoundingBox);
placeDoorAtCurrentPosition(world, structBoundingBox, random, 6, 1, 5, getMetadataWithOffset(Blocks.wooden_door, 1));
placeDoorCurrentPosition(world, structBoundingBox, random, 6, 1, 5, coordBaseMode);
for (int i = 0; i < 5; ++i) {
for (int j = 0; j < 9; ++j) {
clearCurrentPositionBlocksUpwards(world, j, 7, i, structBoundingBox);
func_151554_b(world, Blocks.cobblestone, 0, j, -1, i, structBoundingBox);
replaceAirAndLiquidDownwards(world, Blocks.cobblestone.getStateFromMeta(0), j, -1, i, structBoundingBox);
}
}
generateStructureChestContents(world, structBoundingBox, random, 7, 1, 4,
generateChestContents(world, structBoundingBox, random, 7, 1, 4,
ChestGenHooks.getItems(Constants.CHEST_GEN_HOOK_NATURALIST_CHEST, random),
random.nextInt(4) + random.nextInt(4) + 5);
@@ -225,10 +226,10 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
private void buildRoof(World world, StructureBoundingBox structBoundingBox) {
for (int i = -1; i <= 2; ++i) {
for (int j = 0; j <= 8; ++j) {
stairs.setDirection(getRotatedDirection(ForgeDirection.NORTH));
stairs.setDirection(getRotatedDirection(EnumFacing.NORTH));
placeBlockAtCurrentPosition(world, stairs, j, 4 + i, i, structBoundingBox);
stairs.setDirection(getRotatedDirection(ForgeDirection.SOUTH));
stairs.setDirection(getRotatedDirection(EnumFacing.SOUTH));
placeBlockAtCurrentPosition(world, stairs, j, 4 + i, 5 - i, structBoundingBox);
}
}
@@ -243,7 +244,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
for (int i = 1; i <= 8; i++) {
for (int j = 6; j <= 10; j++) {
func_151554_b(world, ground, 0, i, 0, j, box);
replaceAirAndLiquidDownwards(world, ground.getStateFromMeta(0), i, 0, j, box);
}
}
}
@@ -251,7 +252,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
private void plantFlowerGarden(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
if (isInDesert) {
placeBlockAtCurrentPosition(world, Blocks.cactus, 0, 4, 1, 7, box);
setBlockState(world, Blocks.cactus.getStateFromMeta(0), 4, 1, 7, box);
return;
}
@@ -263,12 +264,12 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
int yCoord = getYWithOffset(i);
int zCoord = getZWithOffset(j, k);
if (!Blocks.red_flower.canBlockStay(world, xCoord, yCoord, zCoord)) {
if (!Blocks.red_flower.canBlockStay(world, new BlockPos(xCoord, yCoord, zCoord), world.getBlockState(new BlockPos(xCoord, yCoord, zCoord)))) {
continue;
}
IFlower flower = FlowerManager.flowerRegistry.getRandomPlantableFlower(FlowerManager.FlowerTypeVanilla, world.rand);
placeBlockAtCurrentPosition(world, flower.getBlock(), flower.getMeta(), j, i, k, box);
setBlockState(world, flower.getBlock().getStateFromMeta(flower.getMeta()), j, i, k, box);
}
}
}
@@ -276,36 +277,37 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
}
private void buildApiaries(World world, StructureBoundingBox box) {
populateApiary(world, box, 3, 1, 8);
populateApiary(world, box, 6, 1, 8);
populateApiary(world, box, new BlockPos(3, 1, 8));
populateApiary(world, box, new BlockPos(6, 1, 8));
}
private void populateApiary(World world, StructureBoundingBox box, int x, int y, int z) {
int xCoord = getXWithOffset(x, z);
int yCoord = getYWithOffset(y);
int zCoord = getZWithOffset(x, z);
private void populateApiary(World world, StructureBoundingBox box, BlockPos pos) {
int xCoord = getXWithOffset(pos.getX(), pos.getZ());
int yCoord = getYWithOffset(pos.getY());
int zCoord = getZWithOffset(pos.getX(), pos.getZ());
BlockPos posNew = new BlockPos(xCoord, yCoord, zCoord);
if (!box.isVecInside(xCoord, yCoord, zCoord)) {
if (!box.isVecInside(posNew)) {
return;
}
Block block = world.getBlock(xCoord, yCoord, zCoord);
if (PluginApiculture.blocks.apiculture == block || !world.blockExists(xCoord, yCoord - 1, zCoord)) {
IBlockState blockState = world.getBlockState(posNew);
if (PluginApiculture.blocks.apiculture == blockState.getBlock() || !world.isBlockLoaded(posNew.add(0, -1, 0))) {
return;
}
world.setBlock(xCoord, yCoord, zCoord, PluginApiculture.blocks.apiculture, BlockApicultureType.APIARY.ordinal(), Constants.FLAG_BLOCK_SYNCH);
PluginApiculture.blocks.apiculture.onBlockAdded(world, xCoord, yCoord, zCoord);
world.setBlockState(posNew, PluginApiculture.blocks.apiculture.getStateFromMeta(BlockApicultureType.APIARY.ordinal()), Constants.FLAG_BLOCK_SYNCH);
PluginApiculture.blocks.apiculture.onBlockAdded(world, posNew, PluginApiculture.blocks.apiculture.getStateFromMeta(BlockApicultureType.APIARY.ordinal()));
TileApiary apiary = TileUtil.getTile(world, xCoord, yCoord, zCoord, TileApiary.class);
TileApiary apiary = TileUtil.getTile(world, posNew, TileApiary.class);
if (apiary == null) {
return;
}
ItemStack randomVillagePrincess = getRandomVillageBeeStack(world, xCoord, yCoord, zCoord, EnumBeeType.PRINCESS);
ItemStack randomVillagePrincess = getRandomVillageBeeStack(world, posNew, EnumBeeType.PRINCESS);
apiary.getBeeInventory().setQueen(randomVillagePrincess);
ItemStack randomVillageDrone = getRandomVillageBeeStack(world, xCoord, yCoord, zCoord, EnumBeeType.DRONE);
ItemStack randomVillageDrone = getRandomVillageBeeStack(world, posNew, EnumBeeType.DRONE);
apiary.getBeeInventory().setDrone(randomVillageDrone);
for (int i = InventoryApiary.SLOT_FRAMES_1; i < InventoryApiary.SLOT_FRAMES_1 + InventoryApiary.SLOT_FRAMES_COUNT; i++) {
@@ -327,15 +329,15 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
}
}
private static ItemStack getRandomVillageBeeStack(World world, int xCoord, int yCoord, int zCoord, EnumBeeType beeType) {
IBee randomVillageBee = getRandomVillageBee(world, xCoord, yCoord, zCoord);
private static ItemStack getRandomVillageBeeStack(World world, BlockPos pos, EnumBeeType beeType) {
IBee randomVillageBee = getRandomVillageBee(world, pos);
return BeeManager.beeRoot.getMemberStack(randomVillageBee, beeType.ordinal());
}
private static IBee getRandomVillageBee(World world, int xCoord, int yCoord, int zCoord) {
private static IBee getRandomVillageBee(World world, BlockPos pos) {
// Get current biome
BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord);
BiomeGenBase biome = world.getBiomeGenForCoords(pos);
ArrayList<IBeeGenome> candidates;
if (BeeManager.villageBees[1] != null && BeeManager.villageBees[1].size() > 0 && world.rand.nextDouble() < 0.2) {
@@ -344,7 +346,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
candidates = BeeManager.villageBees[0];
}
EnumTemperature biomeTemperature = EnumTemperature.getFromBiome(biome, xCoord, yCoord, zCoord);
EnumTemperature biomeTemperature = EnumTemperature.getFromBiome(biome, pos);
EnumHumidity biomeHumidity = EnumHumidity.getFromValue(biome.rainfall);
// Add bees that can live in this environment
@@ -375,7 +377,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
for (int var14 = par4; var14 <= par7; ++var14) {
for (int var15 = par3; var15 <= par6; ++var15) {
for (int var16 = par5; var16 <= par8; ++var16) {
if (!replace || !isAirBlockAtCurrentPosition(world, var15, var14, var16, box)) {
if (!replace || !isAirBlockAtCurrentPosition(world, new BlockPos(var15, var14, var16), box)) {
placeBlockAtCurrentPosition(world, block, var15, var14, var16, box);
}
}
@@ -383,18 +385,19 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
}
}
private void placeBlockAtCurrentPosition(World world, IBlockType block, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox) {
int x = getXWithOffset(par4, par6);
int y = getYWithOffset(par5);
int z = getZWithOffset(par4, par6);
private void placeBlockAtCurrentPosition(World world, IBlockType block, int x, int y, int z, StructureBoundingBox par7StructureBoundingBox) {
int xC = getXWithOffset(x, z);
int yC = getYWithOffset(y);
int zC = getZWithOffset(x, z);
BlockPos pos = new BlockPos(xC, yC, zC);
if (par7StructureBoundingBox.isVecInside(x, y, z)) {
block.setBlock(world, x, y, z);
if (par7StructureBoundingBox.isVecInside(pos)) {
block.setBlock(world, pos);
}
}
@Override
protected int getVillagerType(int villagerCount) {
protected int func_180779_c(int villagerCount, int p_180779_2_) {
if (villagerCount <= 0) {
return Constants.ID_VILLAGER_BEEKEEPER;
} else {
@@ -402,15 +405,15 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
}
}
private boolean isAirBlockAtCurrentPosition(World world, int x, int y, int z, StructureBoundingBox box) {
return getBlockAtCurrentPosition(world, x, y, z, box).isAir(world, x, y, z);
private boolean isAirBlockAtCurrentPosition(World world, BlockPos pos, StructureBoundingBox box) {
return getBlockStateFromPos(world, pos.getX(), pos.getY(), pos.getZ(), box).getBlock().isAir(world, pos);
}
/** rotates a direction according to the way the structure is facing **/
private ForgeDirection getRotatedDirection(ForgeDirection direction) {
private EnumFacing getRotatedDirection(EnumFacing direction) {
int stairDirection = 5 - direction.ordinal();
int meta = getMetadataWithOffset(Blocks.oak_stairs, stairDirection);
return ForgeDirection.getOrientation(5 - meta);
return EnumFacing.values()[5 - meta];
}
}
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
@@ -54,8 +55,8 @@ public final class Hive {
return hiveDescription.getGenChance();
}
public void postGen(World world, int x, int y, int z) {
hiveDescription.postGen(world, x, y, z);
public void postGen(World world, BlockPos pos) {
hiveDescription.postGen(world, pos);
}
public boolean isGoodBiome(BiomeGenBase biome) {
@@ -70,12 +71,12 @@ public final class Hive {
return hiveDescription.isGoodTemperature(temperature);
}
public boolean isValidLocation(World world, int x, int y, int z) {
return hiveDescription.getHiveGen().isValidLocation(world, x, y, z);
public boolean isValidLocation(World world, BlockPos pos) {
return hiveDescription.getHiveGen().isValidLocation(world, pos);
}
public boolean canReplace(World world, int x, int y, int z) {
return hiveDescription.getHiveGen().canReplace(world, x, y, z);
public boolean canReplace(World world, BlockPos pos) {
return hiveDescription.getHiveGen().canReplace(world, pos);
}
public int getYForHive(World world, int x, int z) {
@@ -15,6 +15,8 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
@@ -66,7 +68,7 @@ public abstract class HiveDecorator {
int worldX = chunkX * 16;
int worldZ = chunkZ * 16;
BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
BiomeGenBase biome = world.getBiomeGenForCoords(new BlockPos(worldX, 0, worldZ));
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) {
@@ -88,7 +90,7 @@ public abstract class HiveDecorator {
private static void decorateHivesDebug(World world, int chunkX, int chunkZ, List<Hive> hives) {
int worldX = chunkX * 16;
int worldZ = chunkZ * 16;
BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
BiomeGenBase biome = world.getBiomeGenForCoords(new BlockPos(chunkX, 0, chunkZ));
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
for (int x = 0; x < 16; x++) {
@@ -113,40 +115,41 @@ public abstract class HiveDecorator {
return false;
}
if (!hive.canReplace(world, x, y, z)) {
if (!hive.canReplace(world, new BlockPos(x, y, z))) {
return false;
}
BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
EnumTemperature temperature = EnumTemperature.getFromValue(biome.getFloatTemperature(x, y, z));
BiomeGenBase biome = world.getBiomeGenForCoords(new BlockPos(x, 0, z));
EnumTemperature temperature = EnumTemperature.getFromValue(biome.getFloatTemperature(new BlockPos(x, 0, z)));
if (!hive.isGoodTemperature(temperature)) {
return false;
}
if (!hive.isValidLocation(world, x, y, z)) {
if (!hive.isValidLocation(world, new BlockPos(x, y, z))) {
return false;
}
return setHive(world, x, y, z, hive);
return setHive(world, new BlockPos(x, y, z), hive);
}
private static boolean setHive(World world, int x, int y, int z, Hive hive) {
private static boolean setHive(World world, BlockPos pos, Hive hive) {
Block hiveBlock = hive.getHiveBlock();
boolean placed = world.setBlock(x, y, z, hiveBlock, hive.getHiveMeta(), Constants.FLAG_BLOCK_SYNCH);
boolean placed = world.setBlockState(pos, hiveBlock.getStateFromMeta(hive.getHiveMeta()), Constants.FLAG_BLOCK_SYNCH);
if (!placed) {
return false;
}
Block placedBlock = world.getBlock(x, y, z);
IBlockState state = world.getBlockState(pos);
Block placedBlock = state.getBlock();
if (!Block.isEqualTo(hiveBlock, placedBlock)) {
return false;
}
hiveBlock.onBlockAdded(world, x, y, z);
world.markBlockForUpdate(x, y, z);
hiveBlock.onBlockAdded(world, pos, state);
world.markBlockForUpdate(pos);
if (!Config.generateBeehivesDebug) {
hive.postGen(world, x, y, z);
hive.postGen(world, pos);
}
return true;
}
@@ -12,6 +12,7 @@ package forestry.apiculture.worldgen;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
@@ -43,9 +44,9 @@ public enum HiveDescription implements IHiveDescription {
},
SNOW(6, 2.0f, BeeDefinition.WINTRY, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.snow)) {
@Override
public void postGen(World world, int x, int y, int z) {
if (world.isAirBlock(x, y + 1, z)) {
world.setBlock(x, y + 1, z, Blocks.snow_layer, 0, 0);
public void postGen(World world, BlockPos pos) {
if (world.isAirBlock(pos.add(0, 1, 0))) {
world.setBlockState(pos.add(0, 1, 0), Blocks.snow_layer.getStateFromMeta(0), 0);
}
}
},
@@ -103,7 +104,7 @@ public enum HiveDescription implements IHiveDescription {
}
@Override
public void postGen(World world, int x, int y, int z) {
public void postGen(World world, BlockPos pos) {
}
}
@@ -14,6 +14,7 @@ import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
@@ -68,8 +69,8 @@ public class HiveDescriptionSwarmer implements IHiveDescription {
}
@Override
public void postGen(World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
public void postGen(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileSwarm) {
((TileSwarm) tile).setContained(bees);
}
@@ -12,15 +12,17 @@ package forestry.apiculture.worldgen;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.hives.IHiveGen;
import forestry.core.utils.BlockUtil;
public abstract class HiveGen implements IHiveGen {
@Override
public boolean canReplace(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
public boolean canReplace(World world, BlockPos pos) {
Block block = BlockUtil.getBlock(world, pos);
Material material = block.getMaterial();
return (material.isReplaceable() && !material.isLiquid()) ||
material == Material.air ||
@@ -13,8 +13,10 @@ package forestry.apiculture.worldgen;
import java.util.HashSet;
import java.util.Set;
import forestry.core.utils.BlockUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class HiveGenGround extends HiveGen {
@@ -28,17 +30,17 @@ public class HiveGenGround extends HiveGen {
}
@Override
public boolean isValidLocation(World world, int x, int y, int z) {
Block ground = world.getBlock(x, y - 1, z);
public boolean isValidLocation(World world, BlockPos pos) {
Block ground = BlockUtil.getBlock(world, pos.add(0, -1, 0));
return groundMaterials.contains(ground.getMaterial());
}
@Override
public int getYForHive(World world, int x, int z) {
int y = world.getHeightValue(x, z);
int y = world.getHeight(new BlockPos(x, 0, z)).getY();
// get to the ground
while (y >= 0 && (world.getBlock(x, y - 1, z).isLeaves(world, x, y - 1, z) || canReplace(world, x, y - 1, z))) {
while (y >= 0 && (world.getBlockState(new BlockPos(x, y - 1, z)).getBlock().isLeaves(world, new BlockPos(x, y - 1, z)) || canReplace(world, new BlockPos(x, y - 1, z)))) {
y--;
}
@@ -11,33 +11,34 @@
package forestry.apiculture.worldgen;
import net.minecraft.block.Block;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class HiveGenTree extends HiveGen {
@Override
public boolean isValidLocation(World world, int x, int y, int z) {
Block blockAbove = world.getBlock(x, y + 1, z);
if (!blockAbove.isLeaves(world, x, y + 1, z)) {
public boolean isValidLocation(World world, BlockPos pos) {
Block blockAbove = world.getBlockState(pos.add(0, 1, 0)).getBlock();
if (!blockAbove.isLeaves(world, pos.add(0, 1, 0))) {
return false;
}
// not a good location if right on top of something
return canReplace(world, x, y - 1, z);
return canReplace(world, pos.add(0, -1, 0));
}
@Override
public int getYForHive(World world, int x, int z) {
// get top leaf block
int y = world.getHeightValue(x, z) - 1;
if (!world.getBlock(x, y, z).isLeaves(world, x, y, z)) {
int y = world.getHeight(new BlockPos(x, 0, z)).getY() - 1;
if (!world.getBlockState(new BlockPos(x, y, z)).getBlock().isLeaves(world, new BlockPos(x, y, z))) {
return -1;
}
// get to the bottom of the leaves
do {
y--;
} while (world.getBlock(x, y, z).isLeaves(world, x, y, z));
} while (world.getBlockState(new BlockPos(x, y, z)).getBlock().isLeaves(world,new BlockPos(x, y, z)));
return y;
}
@@ -12,14 +12,11 @@ package forestry.arboriculture;
import java.util.HashMap;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.genetics.IFruitFamily;
@@ -70,7 +67,7 @@ public class FruitProviderNone implements IFruitProvider {
}
@Override
public ItemStack[] getFruits(ITreeGenome genome, World world, int x, int y, int z, int ripeningTime) {
public ItemStack[] getFruits(ITreeGenome genome, World world, BlockPos pos, int ripeningTime) {
return new ItemStack[0];
}
@@ -80,17 +77,17 @@ public class FruitProviderNone implements IFruitProvider {
}
@Override
public boolean trySpawnFruitBlock(ITreeGenome genome, World world, int x, int y, int z) {
public boolean trySpawnFruitBlock(ITreeGenome genome, World world, BlockPos pos) {
return false;
}
@Override
public int getColour(ITreeGenome genome, IBlockAccess world, int x, int y, int z, int ripeningTime) {
public int getColour(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime) {
return 0xffffff;
}
@Override
public boolean markAsFruitLeaf(ITreeGenome genome, World world, int x, int y, int z) {
public boolean markAsFruitLeaf(ITreeGenome genome, World world, BlockPos pos) {
return false;
}
@@ -113,21 +110,30 @@ public class FruitProviderNone implements IFruitProvider {
public String getDescription() {
return "fruits." + key;
}
@Override
public short getIconIndex(ITreeGenome genome, IBlockAccess world, int x, int y, int z, int ripeningTime, boolean fancy) {
public short getSpriteIndex(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime, boolean fancy) {
if (overlay != null) {
return overlay.texUID;
} else {
return -1;
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
public void registerSprites() {
if (overlay != null) {
TextureManager.registerTexUID(register, overlay.texUID, "leaves/fruits." + overlay.ident);
TextureManager.registerSpriteUID(overlay.texUID, "blocks/leaves/fruits." + overlay.ident);
}
}
@Override
public String getModelName() {
return null;
}
@Override
public String getModID() {
return "forestry";
}
}
Loaded 100 of 1657 files, more files were not shown because too many files have changed in this diff. Show more