Make hive bees aggressive, add Bee Smoker item to calm them

This commit is contained in:
mezz committed 2016-04-24 23:22:16 -07:00
1 parent 801d8f2752
commit c7b94cc8af
55 files changed
+958 -277

No files matched your search

@@ -0,0 +1,23 @@
package forestry.api.apiculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public interface IHiveTile {
/**
* Call to calm agitated bees. Used by the smoker to stop wild bees from attacking as much.
* Bees will not stay calm for very long.
*/
void calmBees();
/**
* Called when the hive is attacked.
*/
void onAttack(World world, BlockPos pos, EntityPlayer player);
/**
* Called when the hive is broken.
*/
void onBroken(World world, BlockPos pos, EntityPlayer player, boolean canHarvest);
}
@@ -5,6 +5,7 @@
******************************************************************************/
package forestry.api.apiculture.hives;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.util.IStringSerializable;
@@ -15,30 +16,45 @@ public interface IHiveRegistry {
/* Forestry Hive Names */
enum HiveType implements IStringSerializable {
FOREST("Forestry:forest"),
MEADOWS("Forestry:meadows"),
DESERT("Forestry:desert"),
JUNGLE("Forestry:jungle"),
END("Forestry:end"),
SNOW("Forestry:snow"),
SWAMP("Forestry:swamp");
FOREST("Forestry:forest", "Forestry.speciesForest"),
MEADOWS("Forestry:meadows", "Forestry.speciesMeadows"),
DESERT("Forestry:desert", "Forestry.speciesModest"),
JUNGLE("Forestry:jungle", "Forestry.speciesTropical"),
END("Forestry:end", "Forestry.speciesEnded"),
SNOW("Forestry:snow", "Forestry.speciesWintry"),
SWAMP("Forestry:swamp", "Forestry.speciesMarshy"),
SWARM("Forestry:swarm", "Forestry.speciesForest");
public static final HiveType[] VALUES = values();
HiveType(String name) {
this.name = name;
@Nonnull
private final String hiveUid;
@Nonnull
private final String speciesUid;
HiveType(@Nonnull String hiveUid, @Nonnull String speciesUid) {
this.hiveUid = hiveUid;
this.speciesUid = speciesUid;
}
private final String name;
public String getHiveName() {
return name;
@Nonnull
public String getHiveUid() {
return hiveUid;
}
@Nonnull
public String getSpeciesUid() {
return speciesUid;
}
@Override
public String getName() {
return name().toLowerCase();
}
public int getMeta() {
return ordinal();
}
}
@@ -45,6 +45,11 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
}
}
ItemStack heldItem = entity.getHeldItem();
if (isArmorApiarist(heldItem, entity, cause, doProtect)) {
count++;
}
return count;
}
}
@@ -27,12 +27,15 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Property;
@@ -57,6 +60,7 @@ import forestry.api.core.ForestryAPI;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IClassification.EnumClassLevel;
import forestry.api.genetics.IFlowerAcceptableRule;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.ICrateRegistry;
import forestry.api.storage.StorageManager;
@@ -94,7 +98,7 @@ import forestry.apiculture.multiblock.TileAlvearySwarmer;
import forestry.apiculture.network.PacketRegistryApiculture;
import forestry.apiculture.proxy.ProxyApiculture;
import forestry.apiculture.tiles.TileCandle;
import forestry.apiculture.tiles.TileSwarm;
import forestry.apiculture.tiles.TileHive;
import forestry.apiculture.trigger.ApicultureTriggers;
import forestry.apiculture.worldgen.HiveDecorator;
import forestry.apiculture.worldgen.HiveDescription;
@@ -275,7 +279,7 @@ public class PluginApiculture extends BlankForestryPlugin {
BeeManager.inducers.put(items.royalJelly.getItemStack(), 10);
GameRegistry.registerTileEntity(TileAlvearyPlain.class, "forestry.Alveary");
GameRegistry.registerTileEntity(TileSwarm.class, "forestry.Swarm");
GameRegistry.registerTileEntity(TileHive.class, "forestry.Swarm");
GameRegistry.registerTileEntity(TileAlvearySwarmer.class, "forestry.AlvearySwarmer");
GameRegistry.registerTileEntity(TileAlvearyHeater.class, "forestry.AlvearyHeater");
GameRegistry.registerTileEntity(TileAlvearyFan.class, "forestry.AlvearyFan");
@@ -323,6 +327,8 @@ public class PluginApiculture extends BlankForestryPlugin {
FlowerRegistry flowerRegistry = (FlowerRegistry) FlowerManager.flowerRegistry;
flowerRegistry.registerAcceptableFlowerRule(new EndFlowerAcceptableRule(), FlowerManager.FlowerTypeEnd);
// Register acceptable plants
flowerRegistry.registerAcceptableFlower(Blocks.dragon_egg, FlowerManager.FlowerTypeEnd);
flowerRegistry.registerAcceptableFlower(Blocks.vine, FlowerManager.FlowerTypeJungle);
@@ -443,6 +449,11 @@ public class PluginApiculture extends BlankForestryPlugin {
"#X#", "###", " # ",
'#', "stickWood",
'X', Blocks.wool);
RecipeUtil.addRecipe(items.smoker,
"LS#",
"LF#",
"###",
'#', "ingotTin", 'S', "stickWood", 'F', Items.flint_and_steel, 'L', "leather");
RecipeUtil.addRecipe(new ItemStack(Items.slime_ball),
"#X#", "#X#", "#X#",
'#', items.propolis,
@@ -755,42 +766,42 @@ public class PluginApiculture extends BlankForestryPlugin {
private static void registerBeehiveDrops() {
ItemStack honeyComb = items.beeComb.get(EnumHoneyComb.HONEY, 1);
hiveRegistry.addDrops(HiveType.FOREST.getHiveName(),
hiveRegistry.addDrops(HiveType.FOREST.getHiveUid(),
new HiveDrop(0.80, BeeDefinition.FOREST, honeyComb).setIgnobleShare(0.7),
new HiveDrop(0.08, BeeDefinition.FOREST.getRainResist(), honeyComb),
new HiveDrop(0.03, BeeDefinition.VALIANT, honeyComb)
);
hiveRegistry.addDrops(HiveType.MEADOWS.getHiveName(),
hiveRegistry.addDrops(HiveType.MEADOWS.getHiveUid(),
new HiveDrop(0.80, BeeDefinition.MEADOWS, honeyComb).setIgnobleShare(0.7),
new HiveDrop(0.03, BeeDefinition.VALIANT, honeyComb)
);
ItemStack parchedComb = items.beeComb.get(EnumHoneyComb.PARCHED, 1);
hiveRegistry.addDrops(HiveType.DESERT.getHiveName(),
hiveRegistry.addDrops(HiveType.DESERT.getHiveUid(),
new HiveDrop(0.80, BeeDefinition.MODEST, parchedComb).setIgnobleShare(0.7),
new HiveDrop(0.03, BeeDefinition.VALIANT, parchedComb)
);
ItemStack silkyComb = items.beeComb.get(EnumHoneyComb.SILKY, 1);
hiveRegistry.addDrops(HiveType.JUNGLE.getHiveName(),
hiveRegistry.addDrops(HiveType.JUNGLE.getHiveUid(),
new HiveDrop(0.80, BeeDefinition.TROPICAL, silkyComb).setIgnobleShare(0.7),
new HiveDrop(0.03, BeeDefinition.VALIANT, silkyComb)
);
ItemStack mysteriousComb = items.beeComb.get(EnumHoneyComb.MYSTERIOUS, 1);
hiveRegistry.addDrops(HiveType.END.getHiveName(),
hiveRegistry.addDrops(HiveType.END.getHiveUid(),
new HiveDrop(0.90, BeeDefinition.ENDED, mysteriousComb)
);
ItemStack frozenComb = items.beeComb.get(EnumHoneyComb.FROZEN, 1);
hiveRegistry.addDrops(HiveType.SNOW.getHiveName(),
hiveRegistry.addDrops(HiveType.SNOW.getHiveUid(),
new HiveDrop(0.80, BeeDefinition.WINTRY, frozenComb).setIgnobleShare(0.5),
new HiveDrop(0.03, BeeDefinition.VALIANT, frozenComb)
);
ItemStack mossyComb = items.beeComb.get(EnumHoneyComb.MOSSY, 1);
hiveRegistry.addDrops(HiveType.SWAMP.getHiveName(),
hiveRegistry.addDrops(HiveType.SWAMP.getHiveUid(),
new HiveDrop(0.80, BeeDefinition.MARSHY, mossyComb).setIgnobleShare(0.4),
new HiveDrop(0.03, BeeDefinition.VALIANT, mossyComb)
);
@@ -813,6 +824,7 @@ public class PluginApiculture extends BlankForestryPlugin {
ChestGenHooks.addItem(Constants.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(stack, 7, 12, 12));
ChestGenHooks.addItem(Constants.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(items.scoop.getItemStack(), 1, 1, 8));
ChestGenHooks.addItem(Constants.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(items.smoker.getItemStack(), 1, 1, 8));
ChestGenHooks.addItem(Constants.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(items.propolis.get(EnumPropolis.NORMAL, 1), 2, 4, 6));
ChestGenHooks.addItem(Constants.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(items.beeComb.get(EnumHoneyComb.HONEY, 1), 4, 12, 7));
ChestGenHooks.addItem(Constants.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(items.beeComb.get(EnumHoneyComb.FROZEN, 1), 2, 10, 7));
@@ -824,13 +836,13 @@ public class PluginApiculture extends BlankForestryPlugin {
}
private static void createHives() {
hiveRegistry.registerHive(HiveType.FOREST.getHiveName(), HiveDescription.FOREST);
hiveRegistry.registerHive(HiveType.MEADOWS.getHiveName(), HiveDescription.MEADOWS);
hiveRegistry.registerHive(HiveType.DESERT.getHiveName(), HiveDescription.DESERT);
hiveRegistry.registerHive(HiveType.JUNGLE.getHiveName(), HiveDescription.JUNGLE);
hiveRegistry.registerHive(HiveType.END.getHiveName(), HiveDescription.END);
hiveRegistry.registerHive(HiveType.SNOW.getHiveName(), HiveDescription.SNOW);
hiveRegistry.registerHive(HiveType.SWAMP.getHiveName(), HiveDescription.SWAMP);
hiveRegistry.registerHive(HiveType.FOREST.getHiveUid(), HiveDescription.FOREST);
hiveRegistry.registerHive(HiveType.MEADOWS.getHiveUid(), HiveDescription.MEADOWS);
hiveRegistry.registerHive(HiveType.DESERT.getHiveUid(), HiveDescription.DESERT);
hiveRegistry.registerHive(HiveType.JUNGLE.getHiveUid(), HiveDescription.JUNGLE);
hiveRegistry.registerHive(HiveType.END.getHiveUid(), HiveDescription.END);
hiveRegistry.registerHive(HiveType.SNOW.getHiveUid(), HiveDescription.SNOW);
hiveRegistry.registerHive(HiveType.SWAMP.getHiveUid(), HiveDescription.SWAMP);
}
private static void createAlleles() {
@@ -940,4 +952,12 @@ public class PluginApiculture extends BlankForestryPlugin {
}
ItemHabitatLocator.registerSprite();
}
private static class EndFlowerAcceptableRule implements IFlowerAcceptableRule {
@Override
public boolean isAcceptableFlower(String flowerType, World world, BlockPos pos) {
BiomeGenBase biomeGenForCoords = world.getBiomeGenForCoords(pos);
return BiomeDictionary.isBiomeOfType(biomeGenForCoords, BiomeDictionary.Type.END);
}
}
}
@@ -33,25 +33,23 @@ import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.apiculture.IHiveTile;
import forestry.api.apiculture.hives.IHiveRegistry.HiveType;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.tiles.TileSwarm;
import forestry.apiculture.tiles.TileHive;
import forestry.core.blocks.IBlockWithMeta;
import forestry.core.config.Config;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.ItemStackUtil;
public class BlockBeeHives extends BlockContainer implements IItemModelRegister, IBlockWithMeta {
private static final PropertyEnum<HiveType> HIVE_TYPES = PropertyEnum.create("hive", HiveType.class);
public BlockBeeHives() {
super(new MaterialBeehive(true));
setLightLevel(0.8f);
setHardness(1.0f);
setLightLevel(0.4f);
setHardness(2.5f);
setCreativeTab(Tabs.tabApiculture);
setHarvestLevel("scoop", 0);
setDefaultState(this.blockState.getBaseState().withProperty(HIVE_TYPES, HiveType.FOREST));
@@ -64,7 +62,7 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(HIVE_TYPES).ordinal();
return state.getValue(HIVE_TYPES).getMeta();
}
@Override
@@ -74,7 +72,7 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileSwarm();
return new TileHive();
}
@Override
@@ -83,24 +81,23 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
}
@Override
public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
if (canHarvestBlock(world, pos, player)) {
// Handle TE'd beehives
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, pos);
}
}
}
}
public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) {
super.onBlockClicked(world, pos, player);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof IHiveTile) {
IHiveTile hive = (IHiveTile) tile;
hive.onAttack(world, pos, player);
}
}
return world.setBlockToAir(pos);
@Override
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
boolean canHarvest = canHarvestBlock(world, pos, player);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof IHiveTile) {
IHiveTile hive = (IHiveTile) tile;
hive.onBroken(world, pos, player, canHarvest);
}
}
@Override
@@ -169,28 +166,28 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
}
private static String getHiveNameForMeta(int meta) {
return HiveType.VALUES[meta].getHiveName();
return HiveType.VALUES[meta].getHiveUid();
}
public static HiveType getHiveType(IBlockState state) {
return state.getValue(HIVE_TYPES);
}
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List<ItemStack> itemList) {
itemList.add(new ItemStack(this, 1, 0));
itemList.add(new ItemStack(this, 1, 1));
itemList.add(new ItemStack(this, 1, 2));
itemList.add(new ItemStack(this, 1, 3));
if (Config.isDebug) {
itemList.add(new ItemStack(this, 1, 4));
for (IBlockState blockState : getBlockState().getValidStates()) {
if (getHiveType(blockState) != HiveType.SWARM) {
int meta = getMetaFromState(blockState);
itemList.add(new ItemStack(this, 1, meta));
}
}
itemList.add(new ItemStack(this, 1, 5));
itemList.add(new ItemStack(this, 1, 6));
// Swarm hive not added
}
/* ITEM MODELS */
@Override
public void registerModel(Item item, IModelManager manager) {
for(int i = 0;i < HiveType.VALUES.length;i++){
manager.registerItemModel(item, i, "beehives/" + HiveType.VALUES[i].getName());
for (HiveType hiveType : HiveType.VALUES) {
manager.registerItemModel(item, hiveType.getMeta(), "beehives/" + hiveType.getName());
}
}
@@ -96,11 +96,6 @@ public class EntityFXBee extends EntityFX {
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
public int getBrightnessForRender(float partialTicks) {
return 0x0000f0;
}
@Override
public int getFXLayer() {
return 1;
@@ -12,8 +12,6 @@ package forestry.apiculture.flowers;
import com.google.common.base.Objects;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraftforge.oredict.OreDictionary;
@@ -45,10 +43,6 @@ public final class Flower {
return Block.isEqualTo(this.block, flower.getBlock()) && (this.meta == OreDictionary.WILDCARD_VALUE || flower.getMeta() == OreDictionary.WILDCARD_VALUE || this.meta == flower.getMeta());
}
public int compareTo(@Nonnull Flower other) {
return this.weight.compareTo(other.getWeight());
}
@Override
public int hashCode() {
return Objects.hashCode(block);
@@ -47,7 +47,6 @@ 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;
@@ -95,11 +94,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
@Override
public void registerAcceptableFlowerRule(IFlowerAcceptableRule acceptableFlower, String... flowerTypes) {
for (String flowerType : flowerTypes) {
if (defaultFlowerTypes.contains(flowerType)) {
Log.error("IFlowerAcceptableRules are too slow to be applied to Forestry's built-in flower type: " + flowerType + ".");
} else {
registeredRules.put(flowerType, acceptableFlower);
}
registeredRules.put(flowerType, acceptableFlower);
}
}
@@ -216,25 +211,6 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
meta = block.getMetaFromState(world.getBlockState(pos));
}
/*if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.AGRICRAFT)) {
Block cropBlock = GameRegistry.findBlock("AgriCraft", "crops");
if (block == cropBlock) {
if (block instanceof IPlantable) {
//For agricraft versions which implement IPlantable in the BlockCrop class
block = ((IPlantable) block).getPlant(world, x, y, z);
} else {
//For earlier versions of AgriCraft
ArrayList<ItemStack> drops = block.getDrops(world, x, y, z, 7, 0);
if (drops.get(1).getItem() == Items.wheat_seeds && flowerType.equals(FlowerManager.FlowerTypeWheat)) {
return true;
}
if (drops.get(1).getItem() == Items.nether_wart && flowerType.equals(FlowerManager.FlowerTypeNether)) {
return true;
}
}
}
}*/
Flower flower = new Flower(block, meta, 0);
return acceptedFlowers.contains(flower);
}
@@ -255,7 +255,7 @@ public class Bee extends IndividualLiving implements IBee {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
// / Rain needs tolerant flyers
if (world.isRainingAt(housingCoords) && !canFlyInRain(beeModifier)) {
if (world.isRainingAt(housingCoords.add(0, 1, 0)) && !canFlyInRain(beeModifier)) {
errorStates.add(EnumErrorCode.IS_RAINING);
}
@@ -139,7 +139,7 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
Vect min = new Vect(housing.getCoordinates()).add(offset);
Vect max = min.add(area);
return AxisAlignedBB.fromBounds(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getX());
return AxisAlignedBB.fromBounds(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ());
}
public static <T extends Entity> List<T> getEntitiesInRange(IBeeGenome genome, IBeeHousing housing, Class<T> entityClass) {
@@ -49,6 +49,7 @@ public class ItemRegistryApiculture extends ItemRegistry {
public final ItemArmorApiarist apiaristBoots;
public final ItemScoop scoop;
public final ItemSmoker smoker;
public ItemRegistryApiculture() {
// / BEES
@@ -98,5 +99,7 @@ public class ItemRegistryApiculture extends ItemRegistry {
// TOOLS
scoop = registerItem(new ItemScoop(), "scoop");
scoop.setHarvestLevel("scoop", 3);
smoker = registerItem(new ItemSmoker(), "smoker");
}
}
@@ -0,0 +1,90 @@
package forestry.apiculture.items;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import forestry.api.apiculture.IArmorApiarist;
import forestry.api.apiculture.IHiveTile;
import forestry.api.core.Tabs;
import forestry.core.items.ItemForestry;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Translator;
public class ItemSmoker extends ItemForestry implements IArmorApiarist {
private static final int RANGE = 5;
public ItemSmoker() {
super(Tabs.tabApiculture);
setMaxStackSize(1);
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
if (worldIn.isRemote && isSelected && worldIn.rand.nextInt(40) == 0) {
addSmoke(worldIn, entityIn, 1);
}
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
super.onUsingTick(stack, player, count);
World worldObj = player.worldObj;
addSmoke(worldObj, player, count % RANGE);
}
private static void addSmoke(World worldObj, Entity entity, int distance) {
Vec3 look = entity.getLookVec();
Vec3 handOffset = look.crossProduct(new Vec3(0, 1, 0));
Vec3 lookDistance = new Vec3(look.xCoord * distance, look.yCoord * distance, look.zCoord * distance);
Vec3 smokePos = lookDistance.add(entity.getPositionVector()).add(handOffset);
Proxies.render.addEntitySmokeFX(worldObj, smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord);
BlockPos blockPos = new BlockPos(smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord);
TileEntity tileEntity = worldObj.getTileEntity(blockPos);
if (tileEntity instanceof IHiveTile) {
IHiveTile hive = (IHiveTile) tileEntity;
hive.calmBees();
}
}
@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
return itemStackIn;
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof IHiveTile) {
IHiveTile hive = (IHiveTile) tileEntity;
hive.calmBees();
}
return super.onItemUseFirst(stack, player, world, pos, side, hitX, hitY, hitZ);
}
@Override
public int getMaxItemUseDuration(ItemStack stack) {
return 32;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
super.addInformation(stack, playerIn, tooltip, advanced);
tooltip.add(Translator.translateToLocal("item.for.smoker.description"));
}
@Override
public boolean protectEntity(EntityLivingBase entity, ItemStack armor, String cause, boolean doProtect) {
return true;
}
}
@@ -12,7 +12,6 @@ package forestry.apiculture.multiblock;
import java.util.Collections;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraft.world.biome.BiomeGenBase;
@@ -24,6 +23,7 @@ import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.apiculture.FakeBeekeepingLogic;
import forestry.apiculture.tiles.FakeBeeHousingInventory;
import forestry.core.inventory.FakeInventoryAdapter;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.multiblock.FakeMultiblockController;
@@ -95,36 +95,4 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
return 0;
}
private static class FakeBeeHousingInventory implements IBeeHousingInventory {
public static final FakeBeeHousingInventory instance = new FakeBeeHousingInventory();
private FakeBeeHousingInventory() {
}
@Override
public ItemStack getQueen() {
return null;
}
@Override
public ItemStack getDrone() {
return null;
}
@Override
public void setQueen(ItemStack itemstack) {
}
@Override
public void setDrone(ItemStack itemstack) {
}
@Override
public boolean addProduct(ItemStack product, boolean all) {
return false;
}
}
}
@@ -201,7 +201,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
this.active = active;
if (!worldObj.isRemote) {
if (worldObj != null && !worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj);
}
}
@@ -0,0 +1,38 @@
package forestry.apiculture.tiles;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.IBeeHousingInventory;
public class FakeBeeHousingInventory implements IBeeHousingInventory {
public static final FakeBeeHousingInventory instance = new FakeBeeHousingInventory();
private FakeBeeHousingInventory() {
}
@Override
public ItemStack getQueen() {
return null;
}
@Override
public ItemStack getDrone() {
return null;
}
@Override
public void setQueen(ItemStack itemstack) {
}
@Override
public void setDrone(ItemStack itemstack) {
}
@Override
public boolean addProduct(ItemStack product, boolean all) {
return false;
}
}
@@ -0,0 +1,58 @@
package forestry.apiculture.tiles;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousingInventory;
class HiveBeeHousingInventory implements IBeeHousingInventory {
private ItemStack queen;
private ItemStack drone;
private final TileHive hive;
public HiveBeeHousingInventory(@Nonnull TileHive hive) {
this.hive = hive;
}
@Override
public ItemStack getQueen() {
if (queen == null) {
IBee bee = hive.getContainedBee();
if (bee != null) {
queen = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.QUEEN);
}
}
return queen;
}
@Override
public ItemStack getDrone() {
if (drone == null) {
IBee bee = hive.getContainedBee();
if (bee != null) {
drone = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE);
}
}
return drone;
}
@Override
public void setQueen(ItemStack itemstack) {
this.queen = itemstack;
}
@Override
public void setDrone(ItemStack itemstack) {
this.drone = itemstack;
}
@Override
public boolean addProduct(ItemStack product, boolean all) {
return false;
}
}
@@ -0,0 +1,325 @@
/*******************************************************************************
* 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.tiles;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ITickable;
import net.minecraft.util.Vec3;
import net.minecraft.world.EnumSkyBlock;
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.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.apiculture.IHiveTile;
import forestry.api.apiculture.hives.IHiveRegistry;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorLogic;
import forestry.api.genetics.IAllele;
import forestry.apiculture.BeekeepingLogic;
import forestry.apiculture.blocks.BlockBeeHives;
import forestry.apiculture.genetics.BeeDefinition;
import forestry.apiculture.genetics.alleles.AlleleEffect;
import forestry.apiculture.network.packets.PacketActiveUpdate;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.IActivatable;
import forestry.core.utils.DamageSourceForestry;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.ItemStackUtil;
public class TileHive extends TileEntity implements ITickable, IHiveTile, IActivatable, IBeeHousing {
private static final DamageSource damageSourceBeeHive = new DamageSourceForestry("bee.hive");
@Nonnull
private final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
@Nonnull
private final HiveBeeHousingInventory inventory;
@Nonnull
private final BeekeepingLogic beeLogic;
@Nonnull
private final IErrorLogic errorLogic;
private IBee containedBee = null;
private boolean active = true;
private boolean angry = false;
private int calmTime;
/**
* 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;
public TileHive() {
inventory = new HiveBeeHousingInventory(this);
beeLogic = new BeekeepingLogic(this);
errorLogic = ForestryAPI.errorStateRegistry.createErrorLogic();
}
@Override
public void update() {
if (worldObj.isRemote) {
if (!updatedLight && worldObj.getWorldTime() % 20 == 0) {
updatedLight = worldObj.checkLightFor(EnumSkyBlock.BLOCK, getPos());
}
if (active && worldObj.rand.nextInt(4) == 0) {
if (beeLogic.canDoBeeFX()) {
beeLogic.doBeeFX();
}
}
} else {
boolean canWork = beeLogic.canWork(); // must be called every tick to stay updated
if (worldObj.rand.nextInt(angry ? 10 : 80) == 0) {
if (calmTime == 0) {
if (canWork) {
AxisAlignedBB boundingBox = AlleleEffect.getBounding(getContainedBee().getGenome(), this);
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox);
if (!entities.isEmpty()) {
Collections.shuffle(entities);
EntityLivingBase entity = entities.get(0);
attack(entity, 2);
}
beeLogic.doWork();
setActive(true);
} else {
setActive(false);
}
} else {
calmTime--;
if (calmTime == 0) {
setActive(true);
} else {
setActive(false);
}
}
}
}
}
public IBee getContainedBee() {
if (this.containedBee == null) {
IBeeGenome beeGenome = null;
ItemStack containedBee = contained.getStackInSlot(0);
if (containedBee != null) {
IBee bee = BeeManager.beeRoot.getMember(containedBee);
if (bee != null) {
beeGenome = bee.getGenome();
}
}
if (beeGenome == null) {
beeGenome = getGenomeFromBlock();
}
if (beeGenome == null) {
beeGenome = BeeDefinition.FOREST.getGenome();
}
this.containedBee = BeeManager.beeRoot.getBee(worldObj, beeGenome);
}
return this.containedBee;
}
private IBeeGenome getGenomeFromBlock() {
IBlockState blockState = worldObj.getBlockState(pos);
if (blockState != null) {
Block block = blockState.getBlock();
if (block instanceof BlockBeeHives) {
IHiveRegistry.HiveType hiveType = BlockBeeHives.getHiveType(blockState);
if (hiveType != null) {
String speciesUid = hiveType.getSpeciesUid();
IAllele[] template = BeeManager.beeRoot.getTemplate(speciesUid);
if (template != null) {
return BeeManager.beeRoot.templateAsGenome(template);
}
}
}
}
return null;
}
public void setContained(@Nonnull List<ItemStack> bees) {
for (ItemStack itemstack : bees) {
InventoryUtil.addStack(contained, itemstack, true);
}
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
contained.readFromNBT(nbttagcompound);
beeLogic.readFromNBT(nbttagcompound);
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
contained.writeToNBT(nbttagcompound);
beeLogic.writeToNBT(nbttagcompound);
}
@Override
public void calmBees() {
calmTime = 5;
angry = false;
setActive(false);
}
@Override
public void onAttack(World world, BlockPos pos, EntityPlayer player) {
if (calmTime == 0) {
angry = true;
}
}
@Override
public void onBroken(World world, BlockPos pos, EntityPlayer player, boolean canHarvest) {
if (calmTime == 0) {
attack(player, 10);
}
if (canHarvest) {
for (ItemStack beeStack : InventoryUtil.getStacks(contained)) {
if (beeStack != null) {
ItemStackUtil.dropItemStackAsEntity(beeStack, worldObj, pos);
}
}
}
}
private static void attack(EntityLivingBase entity, int maxDamage) {
double attackAmount = entity.worldObj.rand.nextDouble() / 2.0 + 0.5;
int damage = (int) (attackAmount * maxDamage);
if (damage > 0) {
// Entities are not attacked if they wear a full set of apiarist's armor.
int count = BeeManager.armorApiaristHelper.wearsItems(entity, damageSourceBeeHive.damageType, true);
damage -= (damage / 4.0f) * count;
if (damage > 0) {
entity.attackEntityFrom(damageSourceBeeHive, damage);
}
}
}
@Override
public boolean isActive() {
return active;
}
@Override
public void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
if (!worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj);
}
}
@Override
public Packet getDescriptionPacket() {
beeLogic.syncToClient();
return super.getDescriptionPacket();
}
@Override
public Iterable<IBeeModifier> getBeeModifiers() {
return Collections.emptyList();
}
@Override
public Iterable<IBeeListener> getBeeListeners() {
return Collections.emptyList();
}
@Override
public IBeeHousingInventory getBeeInventory() {
return inventory;
}
@Override
public IBeekeepingLogic getBeekeepingLogic() {
return beeLogic;
}
@Override
public EnumTemperature getTemperature() {
return EnumTemperature.getFromBiome(getBiome(), getWorld(), getPos());
}
@Override
public EnumHumidity getHumidity() {
float humidity = ForestryAPI.climateManager.getHumidity(getWorld(), getPos());
return EnumHumidity.getFromValue(humidity);
}
@Override
public int getBlockLightValue() {
return getWorld().isDaytime() ? 15 : 0; // hives may have the sky obstructed but should still be active
}
@Override
public boolean canBlockSeeTheSky() {
return true; // hives may have the sky obstructed but should still be active
}
@Override
public BiomeGenBase getBiome() {
return getWorld().getBiomeGenForCoords(getPos());
}
@Override
public GameProfile getOwner() {
return null;
}
@Override
public Vec3 getBeeFXCoordinates() {
BlockPos pos = getPos();
return new Vec3(pos.getX() + 0.5, pos.getY() + 0.25, pos.getZ() + 0.5);
}
@Nonnull
@Override
public IErrorLogic getErrorLogic() {
return errorLogic;
}
@Override
public BlockPos getCoordinates() {
return getPos();
}
}
@@ -1,68 +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.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 implements ITickable {
public final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
// 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 update() {
if (worldObj.isRemote && !updatedLight && worldObj.getWorldTime() % 20 == 0) {
updatedLight = worldObj.checkLightFor(EnumSkyBlock.BLOCK, getPos());
}
}
public TileSwarm setContained(ItemStack[] bees) {
for (ItemStack itemstack : bees) {
InventoryUtil.addStack(contained, itemstack, true);
}
return this;
}
public boolean containsBees() {
for (int i = 0; i < contained.getSizeInventory(); i++) {
if (contained.getStackInSlot(i) != null) {
return true;
}
}
return false;
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
contained.readFromNBT(nbttagcompound);
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
contained.writeToNBT(nbttagcompound);
}
}
@@ -10,13 +10,20 @@
******************************************************************************/
package forestry.apiculture.worldgen;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.IPlantable;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.hives.HiveManager;
@@ -32,11 +39,29 @@ import forestry.apiculture.genetics.BeeDefinition;
public enum HiveDescription implements IHiveDescription {
FOREST(0, 3.0f, BeeDefinition.FOREST, HiveManager.genHelper.tree()),
MEADOWS(1, 1.0f, BeeDefinition.MEADOWS, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)),
DESERT(2, 1.0f, BeeDefinition.MODEST, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.sand, Blocks.sandstone)),
JUNGLE(3, 4.0f, BeeDefinition.TROPICAL, HiveManager.genHelper.tree()),
END(4, 4.0f, BeeDefinition.ENDED, HiveManager.genHelper.ground(Blocks.end_stone)) {
FOREST(0, 3.0f, BeeDefinition.FOREST, HiveManager.genHelper.tree()) {
@Override
public void postGen(World world, BlockPos pos) {
super.postGen(world, pos);
postGenFlowers(world, pos, flowerStates);
}
},
MEADOWS(1, 1.0f, BeeDefinition.MEADOWS, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)) {
@Override
public void postGen(World world, BlockPos pos) {
super.postGen(world, pos);
postGenFlowers(world, pos, flowerStates);
}
},
DESERT(2, 1.0f, BeeDefinition.MODEST, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.sand, Blocks.sandstone)) {
@Override
public void postGen(World world, BlockPos pos) {
super.postGen(world, pos);
postGenFlowers(world, pos, cactusStates);
}
},
JUNGLE(3, 6.0f, BeeDefinition.TROPICAL, HiveManager.genHelper.tree()),
END(4, 6.0f, BeeDefinition.ENDED, HiveManager.genHelper.ground(Blocks.end_stone)) {
@Override
public boolean isGoodBiome(BiomeGenBase biome) {
return BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.END);
@@ -48,9 +73,30 @@ public enum HiveDescription implements IHiveDescription {
if (world.isAirBlock(pos.add(0, 1, 0))) {
world.setBlockState(pos.add(0, 1, 0), Blocks.snow_layer.getStateFromMeta(0), 0);
}
postGenFlowers(world, pos, flowerStates);
}
},
SWAMP(6, 2.0f, BeeDefinition.MARSHY, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)),;
SWAMP(6, 2.0f, BeeDefinition.MARSHY, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)) {
@Override
public void postGen(World world, BlockPos pos) {
super.postGen(world, pos);
postGenFlowers(world, pos, mushroomStates);
}
};
private static final IHiveGen groundGen = HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.snow, Blocks.sand, Blocks.sandstone);
private static final List<IBlockState> flowerStates = new ArrayList<>();
private static final List<IBlockState> mushroomStates = new ArrayList<>();
private static final List<IBlockState> cactusStates = Collections.singletonList(Blocks.cactus.getDefaultState());
static {
flowerStates.addAll(Blocks.red_flower.getBlockState().getValidStates());
flowerStates.addAll(Blocks.yellow_flower.getBlockState().getValidStates());
mushroomStates.add(Blocks.red_mushroom.getDefaultState());
mushroomStates.add(Blocks.brown_mushroom.getDefaultState());
}
private final int meta;
private final float genChance;
@@ -107,4 +153,46 @@ public enum HiveDescription implements IHiveDescription {
public void postGen(World world, BlockPos pos) {
}
protected static void postGenFlowers(World world, BlockPos hivePos, List<IBlockState> flowerStates) {
int plantedCount = 0;
for (int i = 0; i < 10; i++) {
int xOffset = world.rand.nextInt(8) - 4;
int zOffset = world.rand.nextInt(8) - 4;
BlockPos blockPos = hivePos.add(xOffset, 0, zOffset);
if (!world.isBlockLoaded(blockPos) || (xOffset == 0 && zOffset == 0)) {
continue;
}
int y = groundGen.getYForHive(world, blockPos.getX(), blockPos.getZ());
if (y <= 0) {
continue;
}
blockPos = new BlockPos(blockPos.getX(), y, blockPos.getZ());
IBlockState state = flowerStates.get(world.rand.nextInt(flowerStates.size()));
Block block = state.getBlock();
if (!block.canPlaceBlockAt(world, blockPos)) {
continue;
}
world.setBlockState(blockPos, state);
plantedCount++;
if (block instanceof IPlantable) {
IPlantable plantable = (IPlantable) block;
BlockPos groundPos = blockPos.down();
Block ground = world.getBlockState(groundPos).getBlock();
if (!ground.canSustainPlant(world, groundPos, EnumFacing.UP, plantable)) {
world.setBlockToAir(blockPos);
plantedCount--;
}
}
if (plantedCount >= 3) {
break;
}
}
}
}
@@ -10,6 +10,9 @@
******************************************************************************/
package forestry.apiculture.worldgen;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -23,14 +26,14 @@ import forestry.api.apiculture.hives.IHiveGen;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.tiles.TileSwarm;
import forestry.apiculture.tiles.TileHive;
public class HiveDescriptionSwarmer implements IHiveDescription {
private final ItemStack[] bees;
private final List<ItemStack> bees;
public HiveDescriptionSwarmer(ItemStack... bees) {
this.bees = bees;
this.bees = Arrays.asList(bees);
}
@Override
@@ -45,7 +48,7 @@ public class HiveDescriptionSwarmer implements IHiveDescription {
@Override
public int getMeta() {
return 8;
return 7;
}
@Override
@@ -71,8 +74,8 @@ public class HiveDescriptionSwarmer implements IHiveDescription {
@Override
public void postGen(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileSwarm) {
((TileSwarm) tile).setContained(bees);
if (tile instanceof TileHive) {
((TileHive) tile).setContained(bees);
}
}
}
@@ -68,7 +68,7 @@ public class Config {
public static boolean generateApatiteOre = true;
public static boolean generateCopperOre = true;
public static boolean generateTinOre = true;
private static float generateBeehivesAmount = 1.0f;
private static float generateBeehivesAmount = 1.5f;
public static boolean generateBeehivesDebug = false;
public static boolean enableVillagers = true;
@@ -0,0 +1,92 @@
/*******************************************************************************
* 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.core.entities;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class EntityFXSmoke extends EntityFX {
private final float ignitionParticleScale;
public EntityFXSmoke(World world, double x, double y, double z) {
super(world, x, y, z, 0, 0, 0);
this.motionX *= 0.8;
this.motionY *= 0.8;
this.motionZ *= 0.8;
this.motionY = this.rand.nextFloat() * 0.2F + 0.05F;
this.particleRed = this.particleGreen = this.particleBlue = 1.0F;
this.particleScale *= this.rand.nextFloat() / 4;
this.ignitionParticleScale = this.particleScale;
this.particleMaxAge = (int) (16.0 / (Math.random() * 0.8 + 0.2));
this.noClip = false;
this.setParticleTextureIndex(49);
}
@Override
public int getBrightnessForRender(float p_70070_1_) {
int i = super.getBrightnessForRender(p_70070_1_);
int j = i >> 16 & 255;
return 240 | j << 16;
}
/**
* Gets how bright this entity is.
*/
@Override
public float getBrightness(float p_70013_1_) {
return 1.0F;
}
@Override
public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) {
float f6 = (this.particleAge + partialTicks) / this.particleMaxAge;
this.particleScale = this.ignitionParticleScale * (1.0F - f6 * f6);
super.renderParticle(worldRendererIn, entityIn, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge) {
this.setDead();
}
float f = (float) this.particleAge / (float) this.particleMaxAge;
if (this.rand.nextFloat() > f * 2) {
this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ);
}
this.motionY -= 0.03D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.999D;
this.motionY *= 0.999D;
this.motionZ *= 0.999D;
if (this.onGround) {
this.motionX *= 0.7;
this.motionZ *= 0.7;
}
}
}
@@ -42,7 +42,7 @@ public class ErrorLogic implements IErrorLogic {
@Override
public final boolean hasErrors() {
return errorStates.size() > 0;
return !errorStates.isEmpty();
}
@Override
@@ -16,7 +16,7 @@ import forestry.api.core.Tabs;
public class ItemScoop extends ItemForestryTool implements IToolScoop {
public ItemScoop() {
super(null);
setEfficiencyOnProperMaterial(4.0f);
setEfficiencyOnProperMaterial(2.0f);
setMaxDamage(10);
setCreativeTab(Tabs.tabApiculture);
setMaxStackSize(1);
@@ -10,10 +10,10 @@
******************************************************************************/
package forestry.core.proxy;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@@ -22,8 +22,10 @@ import net.minecraft.entity.Entity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.animation.ITimeValue;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import forestry.core.fluids.Fluids;
import forestry.core.items.ItemCrated;
import forestry.core.models.BlockModelIndex;
@@ -122,6 +124,9 @@ public class ProxyRender {
public void addEntityIgnitionFX(World world, double x, double y, double z) {
}
public void addEntitySmokeFX(World world, double x, double y, double z) {
}
public void addEntityPotionFX(World world, double x, double y, double z, int color) {
}
}
@@ -10,10 +10,10 @@
******************************************************************************/
package forestry.core.proxy;
import javax.annotation.Nonnull;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@@ -39,6 +39,7 @@ import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.animation.Animation;
import net.minecraftforge.client.model.animation.ITimeValue;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import forestry.apiculture.entities.EntityFXBee;
import forestry.apiculture.render.ParticleRenderer;
import forestry.apiculture.render.TextureHabitatLocator;
@@ -46,6 +47,7 @@ import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.entities.EntityFXHoneydust;
import forestry.core.entities.EntityFXIgnition;
import forestry.core.entities.EntityFXSmoke;
import forestry.core.entities.EntityFXSnow;
import forestry.core.fluids.Fluids;
import forestry.core.items.ItemCrated;
@@ -244,6 +246,16 @@ public class ProxyRenderClient extends ProxyRender {
effectRenderer.addEffect(new EntityFXIgnition(world, x, y, z));
}
@Override
public void addEntitySmokeFX(World world, double x, double y, double z) {
if (!shouldSpawnParticle(world)) {
return;
}
EffectRenderer effectRenderer = Minecraft.getMinecraft().effectRenderer;
effectRenderer.addEffect(new EntityFXSmoke(world, x, y, z));
}
@Override
public void addEntityPotionFX(World world, double x, double y, double z, int color) {
if (!shouldSpawnParticle(world)) {