mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Added the ability to add Emeralds to the Cocoon of Caprice to influence the outcome.
This commit is contained in:
1 parent
b6738c6237
commit
85447fb6c7
4 files changed
+66
-35
No files matched your search
@@ -23,6 +23,7 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -66,6 +67,19 @@ public class BlockCocoon extends BlockModContainer implements ILexiconable {
|
||||
return LibRenderIDs.idCocoon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) {
|
||||
TileCocoon cocoon = (TileCocoon) world.getTileEntity(x, y, z);
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if(cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS && item != null && item.getItem() == Items.emerald) {
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
item.stackSize--;
|
||||
cocoon.emeraldsGiven++;
|
||||
world.playAuxSFX(2005, x, y, z, 6 + world.rand.nextInt(4));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return new ArrayList();
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityAgeable;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.passive.EntityChicken;
|
||||
@@ -20,16 +22,20 @@ import net.minecraft.entity.passive.EntityMooshroom;
|
||||
import net.minecraft.entity.passive.EntityOcelot;
|
||||
import net.minecraft.entity.passive.EntityPig;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class TileCocoon extends TileMod {
|
||||
|
||||
private static final String TAG_TIME_PASSED = "timePassed";
|
||||
|
||||
private static final String TAG_EMERALDS_GIVEN = "timePassed";
|
||||
|
||||
public static final int TOTAL_TIME = 2400;
|
||||
public static final int MAX_EMERALDS = 20;
|
||||
|
||||
public int timePassed;
|
||||
public int emeraldsGiven;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
@@ -43,39 +49,47 @@ public class TileCocoon extends TileMod {
|
||||
worldObj.playAuxSFX(2001, xCoord, yCoord, zCoord, Block.getIdFromBlock(getBlockType()));
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
|
||||
EntityAnimal entity = null;
|
||||
EntityAgeable entity = null;
|
||||
|
||||
float specialChance = 0.05F;
|
||||
if(Math.random() < specialChance) {
|
||||
int entityType = worldObj.rand.nextInt(3);
|
||||
switch(entityType) {
|
||||
case 0:
|
||||
entity = new EntityHorse(worldObj);
|
||||
break;
|
||||
case 1:
|
||||
entity = new EntityWolf(worldObj);
|
||||
break;
|
||||
case 2:
|
||||
entity = new EntityOcelot(worldObj);
|
||||
break;
|
||||
}
|
||||
float villagerChance = Math.min(1F, (float) emeraldsGiven / (float) MAX_EMERALDS);
|
||||
|
||||
if(Math.random() < villagerChance) {
|
||||
EntityVillager villager = new EntityVillager(worldObj);
|
||||
VillagerRegistry.applyRandomTrade(villager, worldObj.rand);
|
||||
entity = villager;
|
||||
} else {
|
||||
int entityType = worldObj.rand.nextInt(4);
|
||||
switch(entityType) {
|
||||
case 0:
|
||||
entity = new EntitySheep(worldObj);
|
||||
break;
|
||||
case 1:
|
||||
if(Math.random() < 0.01)
|
||||
entity = new EntityMooshroom(worldObj);
|
||||
else entity = new EntityCow(worldObj);
|
||||
break;
|
||||
case 2:
|
||||
entity = new EntityPig(worldObj);
|
||||
break;
|
||||
case 3:
|
||||
entity = new EntityChicken(worldObj);
|
||||
break;
|
||||
float specialChance = 0.05F;
|
||||
if(Math.random() < specialChance) {
|
||||
int entityType = worldObj.rand.nextInt(3);
|
||||
switch(entityType) {
|
||||
case 0:
|
||||
entity = new EntityHorse(worldObj);
|
||||
break;
|
||||
case 1:
|
||||
entity = new EntityWolf(worldObj);
|
||||
break;
|
||||
case 2:
|
||||
entity = new EntityOcelot(worldObj);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
int entityType = worldObj.rand.nextInt(4);
|
||||
switch(entityType) {
|
||||
case 0:
|
||||
entity = new EntitySheep(worldObj);
|
||||
break;
|
||||
case 1:
|
||||
if(Math.random() < 0.01)
|
||||
entity = new EntityMooshroom(worldObj);
|
||||
else entity = new EntityCow(worldObj);
|
||||
break;
|
||||
case 2:
|
||||
entity = new EntityPig(worldObj);
|
||||
break;
|
||||
case 3:
|
||||
entity = new EntityChicken(worldObj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,11 +105,13 @@ public class TileCocoon extends TileMod {
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound cmp) {
|
||||
cmp.setInteger(TAG_TIME_PASSED, timePassed);
|
||||
cmp.setInteger(TAG_EMERALDS_GIVEN, emeraldsGiven);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound cmp) {
|
||||
timePassed = cmp.getInteger(TAG_TIME_PASSED);
|
||||
emeraldsGiven = cmp.getInteger(TAG_EMERALDS_GIVEN);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -619,7 +619,7 @@ public final class LexiconData {
|
||||
canopyDrum.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCanopyDrum));
|
||||
|
||||
cocoon = Botania.gardenOfGlassLoaded ? new BLexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices) : new ALexiconEntry(LibLexicon.DEVICE_COCOON, categoryDevices);
|
||||
cocoon.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCocoon));
|
||||
cocoon.setLexiconPages(new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeCocoon));
|
||||
|
||||
manaBomb = new ALexiconEntry(LibLexicon.DEVICE_MANA_BOMB, categoryDevices);
|
||||
manaBomb.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeManaBomb));
|
||||
|
||||
Reference in new issue
Block a user