本文整理汇总了Java中net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent类的典型用法代码示例。如果您正苦于以下问题:Java HarvestDropsEvent类的具体用法?Java HarvestDropsEvent怎么用?Java HarvestDropsEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HarvestDropsEvent类属于net.minecraftforge.event.world.BlockEvent包,在下文中一共展示了HarvestDropsEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: harvestDrops
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void harvestDrops(HarvestDropsEvent event) {
if (!ToroQuestConfiguration.cropsAffectRep) {
return;
}
if (isCrop(event.getState().getBlock())) {
BlockPos pos = event.getPos();
AxisAlignedBB bb = new AxisAlignedBB(pos);
List<EntityPlayer> players = event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, bb);
if (players != null && players.size() > 0) {
for (EntityPlayer player : players) {
adjustPlayerRep(player, pos.getX() / 16, pos.getZ() / 16, -getFarmRepAmount(event.getWorld().rand));
}
}
}
}
示例2: limitEnderBlockDropsInTheTeletory
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void limitEnderBlockDropsInTheTeletory(HarvestDropsEvent event) {
if (!isEnderBlock(event)) {
return;
}
EntityPlayer player = event.getHarvester();
if (player == null || player.dimension != Teletory.DIMID) {
return;
}
List<ItemStack> drops = event.getDrops();
List<ItemStack> dropsToRemove = new ArrayList<ItemStack>(drops.size());
Random rand = event.getWorld().rand;
for (ItemStack drop : drops) {
if (rand.nextInt(10) > 2) {
dropsToRemove.add(drop);
}
}
drops.removeAll(dropsToRemove);
}
示例3: mysticFortuneIncrease
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
/** Apply a fortune increase to mystic tools */
private void mysticFortuneIncrease(HarvestDropsEvent e) {
if(tool != null && tool.getItem() instanceof IMysticGear) {
// override vanilla fortune handling here
int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, tool) + mysticBonus;
Block block = e.getState().getBlock();
if(!e.getWorld().restoringBlockSnapshots) {
for (ItemStack item : block.getDrops(e.getWorld(), e.getPos(), e.getState(), i)) {
if (e.getWorld().rand.nextFloat() <= e.getDropChance()) {
Block.spawnAsEntity(e.getWorld(), e.getPos(), item.copy());
}
}
}
// cancel the default drops
e.setDropChance(0);
}
}
示例4: onDrop
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDrop(HarvestDropsEvent event){
if(Config.IsToolsEnabled&&!event.getWorld().isRemote&&event.getHarvester()!=null&&isBlazonium(event.getHarvester())){
for(int i=0;i<event.getDrops().size();i++){
if(event.getDrops().get(i)!=null){
if(FurnaceRecipes.instance().getSmeltingResult(event.getDrops().get(i))!=null){
event.getDrops().set(i, FurnaceRecipes.instance().getSmeltingResult(event.getDrops().get(i)).copy());
}
}
}
}
if(Config.IsToolsEnabled&&!event.getWorld().isRemote&&event.getHarvester()!=null&&isEmerald(event.getHarvester())){
if(event.isSilkTouching()==false&&event.getFortuneLevel()<=Config.MaxGreed){
List<ItemStack> list=event.getDrops();
list.clear();
List<ItemStack> newlist=event.getState().getBlock().getDrops(event.getWorld(), event.getPos(), event.getState(), event.getFortuneLevel()+1);
for(int i=0;i<newlist.size();i++){
list.add(newlist.get(i).copy());
}
}
}
}
示例5: doBonusDrops
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
/**
* Gives a chance for bonus drops to happen depending on dropChance
*
* @param event
* @param dropChance
*/
public void doBonusDrops(HarvestDropsEvent event, float dropChance)
{
List<ItemStack> dropList = new ArrayList();
System.out.println("DropListB:"+ event.drops.size());
Iterator<ItemStack> it = event.drops.iterator();
Random rand = new Random();
ItemStack item;
while(it.hasNext())
{
item = it.next();
System.out.println("increase items:"+ item.getDisplayName());
if(rand.nextFloat() < dropChance)
{
dropList.add(item.copy());
}
}
event.drops.addAll(dropList);
System.out.println("DropListA:"+ event.drops.size());
}
示例6: onBlockHarvest
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockHarvest(HarvestDropsEvent event) {
if (event.harvester != null) {
Block block = event.state.getBlock();
if (block == Blocks.dirt || block == Blocks.grass) {
if (event.harvester.getCurrentArmor(ArmorIndex.WORN_HELM) != null && event.harvester.getCurrentArmor(ArmorIndex.WORN_HELM).getItem() == ZSSItems.maskScents && event.world.rand.nextInt(32) == 0) {
event.drops.add(event.world.rand.nextInt(4) == 0 ? new ItemStack(Blocks.red_mushroom) : new ItemStack(Blocks.brown_mushroom));
}
} else if (block == Blocks.tallgrass) {
if (PlayerUtils.isSword(event.harvester.getHeldItem()) && event.world.rand.nextFloat() < Config.getGrassDropChance()) {
event.drops.add(ZSSItems.getRandomGrassDrop(event.world.rand));
}
} else if (block == Blocks.iron_ore) {
if (event.world.rand.nextFloat() < (0.005F * event.fortuneLevel)) {
event.drops.add(new ItemStack(ZSSItems.masterOre));
event.harvester.worldObj.playSoundEffect(event.harvester.posX, event.harvester.posY, event.harvester.posZ, Sounds.SPECIAL_DROP, 1.0F, 1.0F);
}
}
}
}
示例7: onBlockDrop
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockDrop(HarvestDropsEvent event) {
if (event.block == GameRegistry.findBlock("derpyshiz", "log")) {
if (event.harvester == null)
return;
event.drops.removeAll(event.drops);
ItemStack is = event.harvester.getHeldItem();
if (is == null) {
event.drops.add(this.dropsHand[event.blockMetadata % 2].get());
} else {
int hl = is.getItem().getHarvestLevel(is, "axe");
if (hl < 0) {
event.drops.add(this.dropsHand[event.blockMetadata % 2].get());
return;
}
if (hl > 3)
hl = 3;
event.drops.add(this.dropsPerLevel[hl][event.blockMetadata % 2].get());
}
} else if (event.block == GameRegistry.findBlock("derpyshiz", "ore") && event.blockMetadata == DerpyOres.darknessIndex) {
if (event.world.getBlockLightValue(event.x, event.y, event.z) != 0) {
event.drops.clear();
}
}
}
示例8: OnBlockBreak
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void OnBlockBreak(HarvestDropsEvent event) {
if(event.harvester != null && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() != null) {
if(event.harvester.getHeldItem().getItem() instanceof ItemTool && ((ItemTool) event.harvester.getHeldItem().getItem()).func_150913_i() == ModTools.FYRESTONE && !event.isSilkTouching) {
if(FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(event.block.getItemDropped(event.blockMetadata, event.world.rand, event.fortuneLevel))) != null) {
event.drops.clear();
event.world.playSoundAtEntity(event.harvester, "random.fizz", 0.7f, 1.6f);
event.drops.add(new ItemStack(FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(event.block.getItemDropped(event.blockMetadata, event.world.rand, event.fortuneLevel))).getItem(), 1, FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(event.block.getItemDropped(event.blockMetadata, event.world.rand, event.fortuneLevel))).getItemDamage()));
} else if(event.block.isFlammable(event.world, event.x, event.y, event.z, ForgeDirection.WEST)) {
event.drops.clear();
event.world.playSoundAtEntity(event.harvester, "random.fizz", 0.7f, 1.6f);
}
} else if(event.harvester.getHeldItem().getItem() instanceof ItemTool && ((ItemTool) event.harvester.getHeldItem().getItem()).func_150913_i() == ModTools.VOIDIUM) {
event.drops.clear();
event.world.playSoundAtEntity(event.harvester, "mob.endermen.portal", 1.0f, 1.6f);
}
}
}
示例9: onHarvestDrops
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onHarvestDrops(HarvestDropsEvent event) {
if ((event.block != Blocks.gravel) || event.isSilkTouching)
return;
double chance = 0;
ItemStack holding = ((event.harvester != null) ? event.harvester.getCurrentEquippedItem() : null);
ItemTool tool = (((holding != null) && (holding.getItem() instanceof ItemTool)) ? (ItemTool)holding.getItem() : null);
if ((tool != null) && tool.getToolClasses(holding).contains("shovel")) {
chance = 0.35 - tool.getHarvestLevel(holding, "shovel") * 0.15;
if (event.fortuneLevel > 0)
chance += event.fortuneLevel * 0.15;
}
event.drops.clear();
event.drops.add(RandomUtils.getBoolean(chance)
? new ItemStack(Items.flint) : new ItemStack(Blocks.gravel));
}
示例10: onDrop
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDrop(HarvestDropsEvent event)
{
if(event.harvester == null)
return ;
ArrayList<EnchantmentModifier> modifiers = CraftMaterial.getModifiers(event.harvester.getHeldItem());
for (int i = 0; i < modifiers.size(); i++) {
modifiers.get(i).onHarvestBlockPre(event.harvester, event.world, event.x, event.y, event.z, event.blockMetadata, event.block, event.drops);
}
for (int i = 0; i < modifiers.size(); i++) {
modifiers.get(i).onHarvestBlock(event.harvester, event.world, event.x, event.y, event.z, event.blockMetadata, event.block, event.drops);
}
for (int i = 0; i < modifiers.size(); i++) {
modifiers.get(i).onHarvestBlockPost(event.harvester, event.world, event.x, event.y, event.z, event.blockMetadata, event.block, event.drops);
}
}
示例11: blockHarvestDrops
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@Override
public void blockHarvestDrops(ItemStack tool, HarvestDropsEvent event) {
if (ToolHelper.isToolEffective2(tool, event.getState())) {
ModifierNBT data = new ModifierNBT(TinkerUtil.getModifierTag(tool, name));
BlockPos pos = event.getPos();
final World world = event.getWorld();
for (Iterator<ItemStack> iterator = event.getDrops().iterator(); iterator.hasNext();) {
ItemStack next = iterator.next().copy();
if (world != null && random.nextFloat() <= event.getDropChance()) {
if (random.nextFloat() < (data.level * .21f)) {
RandomTeleportUtil.teleportSpawnItem(world, pos, next);
iterator.remove();
}
} else {
iterator.remove();
}
}
event.setDropChance(1); // we already implemented the drop chance
}
}
示例12: blockHarvestDrops
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@Override
public void blockHarvestDrops(ItemStack tool, HarvestDropsEvent event) {
if (ToolHelper.isToolEffective2(tool, event.getState())) {
for (Iterator<ItemStack> iterator = event.getDrops().iterator(); iterator.hasNext();) {
ItemStack next = iterator.next().copy();
if (random.nextFloat() <= event.getDropChance()) {
if (event.getHarvester().inventory.addItemStackToInventory(next)) {
iterator.remove();
}
} else {
iterator.remove();
}
}
event.setDropChance(1); // we already implemented the drop chance
}
}
示例13: onHarvestDropsEvent
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onHarvestDropsEvent(HarvestDropsEvent event){
// System.out.println("Block: " + event.getState().getBlock().getUnlocalizedName());
if (event.getState().getBlock() == Blocks.DIAMOND_ORE){
int random_number = (int) (Math.random() * 5);
System.out.println(random_number);
if (random_number == 4) {
event.getDrops().clear();
event.getDrops().add(new ItemStack(ModItems.crackeddiamond));
}
}
}
示例14: notCurrentDepth
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
protected boolean notCurrentDepth(HarvestDropsEvent event, QuestData data) {
int max = getMaxDepth(data);
int min = getMinDepth(data);
int y = event.getPos().getY();
if (min > 0 && y < min) {
return true;
}
if (max > 0 && y > max) {
return true;
}
return false;
}
示例15: onBlockBreak
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onBlockBreak(HarvestDropsEvent event)
{
if (!event.isSilkTouching())
{
BlockPos pos = event.getPos();
int fortuneBonus = 0;
for (int x = -16; x <= 16; x++)
for (int z = -16; z <= 16; z++)
for (int y = -8; y <= 8; y++)
if (event.getWorld().getBlockState(pos.add(x, y, z)).getBlock() == Blocks.BEACON)
{
Block block = event.getWorld().getBlockState(pos.add(x, y, z).down()).getBlock();
if (block == Blocks.IRON_BLOCK)
fortuneBonus = Math.max(fortuneBonus, 1);
else if (block == Blocks.GOLD_BLOCK)
fortuneBonus = Math.max(fortuneBonus, 2);
else if (block == Blocks.DIAMOND_BLOCK)
fortuneBonus = Math.max(fortuneBonus, 3);
else if (block == Blocks.EMERALD_BLOCK)
fortuneBonus = Math.max(fortuneBonus, 4);
}
List<ItemStack> drops = event.getDrops();
drops.clear();
drops.addAll(event.getState().getBlock().getDrops(event.getWorld(), event.getPos(), event.getState(), event.getFortuneLevel() + fortuneBonus));
}
}