FANDOM


This Article is up to date with Custom Stuff 2 CS2
Hives
Crafthive

Maybe you have already seen the Russian folk snacks mod, there you can find Hives. I really liked this idea, so i made my own. They look the same, but use a little more coding. (Thanks again _MrRedBull_, that you allow me to use your textures)

This Hives are useless unless there are flowers nearby. The Bee's also like to get high. ;) So, if you put a fence beneath to increase their altitude, their effectiveness doubles. But put the Hives away from each other. If the bees need to share the flowers, they become less effective.

This recommend this mod as addition to mods like Pam's Harvest craft due the heavy amount of Plants there.

Uses

In vanilla it has only one use until now. Its used as alternative for slimeballs in sticky pistons. If you use Pams Mod, you can add following lines to the mod.js to make candles from honey.

var honeybottle=config.getItemId("HoneyBottleItemID");
mod.addShapelessRecipe("3909:0 4",honeybottle+":0","287:0","315:15"); // white
mod.addShapelessRecipe("3910:0 4",honeybottle+":0","287:0","315:14"); // orang
mod.addShapelessRecipe("3911:0 4",honeybottle+":0","287:0","315:13"); // magenta
mod.addShapelessRecipe("3912:0 4",honeybottle+":0","287:0","315:12"); // light blue
mod.addShapelessRecipe("3913:0 4",honeybottle+":0","287:0","315:11"); // yellow
mod.addShapelessRecipe("3914:0 4",honeybottle+":0","287:0","315:10"); // lime
mod.addShapelessRecipe("3915:0 4",honeybottle+":0","287:0","315:9"); // pink
mod.addShapelessRecipe("3916:0 4",honeybottle+":0","287:0","315:8"); // dark gray
mod.addShapelessRecipe("3917:0 4",honeybottle+":0","287:0","315:7"); // light gray
mod.addShapelessRecipe("3918:0 4",honeybottle+":0","287:0","315:6"); // cyan
mod.addShapelessRecipe("3919:0 4",honeybottle+":0","287:0","315:5"); // purple
mod.addShapelessRecipe("3920:0 4",honeybottle+":0","287:0","315:4"); // blue
mod.addShapelessRecipe("3921:0 4",honeybottle+":0","287:0","315:3"); // brown
mod.addShapelessRecipe("3922:0 4",honeybottle+":0","287:0","315:2"); // green
mod.addShapelessRecipe("3923:0 4",honeybottle+":0","287:0","315:1"); // red
mod.addShapelessRecipe("3924:0 4",honeybottle+":0","287:0","315:0"); // black

I think later i will add some edible recipes.

Some technical details

I've made the list of Flowers (or blossoming plants) configurable. config/hives_CustomStuff.cfg:

# Configuration file

####################
# block
####################
 
block {
    I:HiveBlockID=1020
}
   
####################
# general
####################
 
general {
    # Only IDs, no META
    S:blossomplants=37,38
}
 
####################
# item
####################
 
item {
    I:HoneyBottleItemID=31738
}

You 37 and 38 are the yellow and red flowers. You may add 31 (Tall Grass).


This Block is massive-use friendly. Its true, searching through the area for hives or plants could create some lag, if it's heavily used. So the hives have a high tickrate (250) and the area will only be searched if the neighbor change or on every 250th tick.


If you are interested in the code behind this magic, here is it. ^^ config/mods/hives/scripts/HiveScript.js:

function hsActivated(meta)
{
 if(player.getItemId(player.getCurrentSlot())==374) if(player.ad(config.getItemId ("HoneyBottleItemID"),1,0))
 {
  player.remove(374,1,0);
  world.setBlockMetadata(position, meta);
  hsScan(position);
 }
}
 
function hsPlace()
{
 var posX = Math.round(living.getPosX()) + 0.5;
 var posZ = Math.round(living.getPosZ()) + 0.5;
 
 if     (posX + 1 <= position.x + 0.5) world.setBlockMetadata(position, 1);
 else if(posZ + 1 <= position.z + 0.5) world.setBlockMetadata(position, 2);
 else if(posX - 1 >= position.x + 0.5) world.setBlockMetadata(position, 3);
 else if(posZ - 1 >= position.z + 0.5) world.setBlockMetadata(position, 0);
}
 
function hsUpdate(p,m)
{
 var c=world.getTileEntityIntData(p,'plants');
 var r=world.getTileEntityIntData(p,'rescan');
 if(r<1) hsScan(p);
 else world.setTileEntityIntData(p,'rescan',r-1);
 
 mod.printLine("chance "+c);
 if(c) if(Math.floor(Math.random()*25)<=c) world.setBlockMetadata(p,m);
}
 
function hsScan(p) // is also called onNeighborChange
{
 var blossomplantIDs=config.getString("blossomplants", "general");
 mod.printLine("blossomplantIDs: "+blossomplantIDs);
 blossomplantIDs = blossomplantIDs.split(",");
 var x,y,z,c,d,h;
 
 var hid=config.getBlockId("HiveBlockID");
 
 c=0;d=1;h=0;
 for(x=-3;x<=3;x++) for(y=-2;y<=2;y++) for(z=-3;z<=3;z++)
 {
  id=world.getBlockId(p.x+x,p.y+y,p.z+z);
  if(id<31) continue; // skip to increase speed
  if(y<0 && x==0 && z==0 && id==85) { d=2; continue; } // is a fence beneath ?
  if(id==hid) { h++; continue; }
  for(var plant in blossomplantIDs) if(id==blossomplantIDs[plant])
  {
   c++;
   break;
  }
 }
 world.setTileEntityIntData(p,'plants',Math.ceil(c*d/h)); // divide by the hive count
 world.setTileEntityIntData(p,'rescan',20); // scan only all 20*250 Ticks
}

If you are interested in the block script. Just download it below, but I think the only important thing is when the functions are called. As you can imagine, hsUpdate is called from onUpdate, hsPlace from onPlace and hsActivated from onActivated. The only not 100% obvious script is hsScan because it's also called from NeighborChange, but this is also written in the comment.

The Block uses an 1x1 Chest an entity. This entity is used to save 2 vars: 1. how long it should wait until next search for plants and 2. the plant count based, honey producing probability.

Its not using the chest space. Its only there to use the entity to store data. It could be changed to fill the item inside with honey. This way it would be interesting to use with buildcraft pipes.

Download

You can download the script here.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.