mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-22 05:02:37 +00:00
Crumbling, Transmuting bees & their (crappy) effects.
This commit is contained in:
1 parent
7513ba1255
commit
533d7d55a8
10 files changed
+289
-8
No files matched your search
@@ -0,0 +1,75 @@
|
||||
package magicbees.bees;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectCrumbling extends AlleleEffect
|
||||
{
|
||||
private HashMap<ItemStack, ItemStack> crumbleMap;
|
||||
|
||||
public AlleleEffectCrumbling(String id, boolean isDominant)
|
||||
{
|
||||
super(id, isDominant, 200);
|
||||
|
||||
crumbleMap = new HashMap<ItemStack, ItemStack>();
|
||||
|
||||
crumbleMap.put(new ItemStack(Block.stone), new ItemStack(Block.cobblestone));
|
||||
crumbleMap.put(new ItemStack(Block.cobblestone), new ItemStack(Block.cobblestoneMossy));
|
||||
crumbleMap.put(new ItemStack(Block.stoneBrick, 1, 0), new ItemStack(Block.stoneBrick, 1, 2));
|
||||
crumbleMap.put(new ItemStack(Block.stoneBrick, 1, 2), new ItemStack(Block.stoneBrick, 1, 1));
|
||||
crumbleMap.put(new ItemStack(Block.cobblestoneWall), new ItemStack(Block.cobblestoneWall, 1, 1));
|
||||
crumbleMap.put(new ItemStack(Block.gravel), new ItemStack(Block.sand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData)
|
||||
{
|
||||
if (storedData == null || !(storedData instanceof magicbees.bees.EffectData))
|
||||
{
|
||||
storedData = new magicbees.bees.EffectData(1, 0, 0);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing)
|
||||
{
|
||||
World world = housing.getWorld();
|
||||
// Get random coords within territory
|
||||
int xCoord = (int)(housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]);
|
||||
xCoord = housing.getXCoord() + world.rand.nextInt(xCoord) - xCoord / 2;
|
||||
int yCoord = (int)(housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[1]);
|
||||
yCoord = housing.getYCoord() + world.rand.nextInt(yCoord) - yCoord / 2;
|
||||
int zCoord = (int)(housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]);
|
||||
zCoord = housing.getZCoord() + world.rand.nextInt(zCoord) - zCoord / 2;
|
||||
|
||||
boolean success = false;
|
||||
Block block = Block.blocksList[world.getBlockId(xCoord, yCoord, zCoord)];
|
||||
if (block != null)
|
||||
{
|
||||
ItemStack source = new ItemStack(block, 1, world.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
for (ItemStack key : crumbleMap.keySet())
|
||||
{
|
||||
if (OreDictionary.itemMatches(source, key, false))
|
||||
{
|
||||
ItemStack target = crumbleMap.get(key);
|
||||
world.setBlock(xCoord, yCoord, zCoord, target.itemID, target.getItemDamage(), 2);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
storedData.setInteger(0, 0);
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user