本文整理汇总了Java中net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent.getWorld方法的典型用法代码示例。如果您正苦于以下问题:Java HarvestDropsEvent.getWorld方法的具体用法?Java HarvestDropsEvent.getWorld怎么用?Java HarvestDropsEvent.getWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent
的用法示例。
在下文中一共展示了HarvestDropsEvent.getWorld方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
}
示例3: 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());
}
}
}
}
示例4: 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
}
}
示例5: onHarvestDrops
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
/** Harvest the drops and call sub-events */
@SubscribeEvent
public void onHarvestDrops(HarvestDropsEvent e) {
tool = null; // always reset this
if(!e.getWorld().isRemote) {
if(!onBlockDropSmelt(e)) {
mysticFortuneIncrease(e);
}
}
}
示例6: onHarvestDropsEvent
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDropsEvent(HarvestDropsEvent event) {
if (event.getState() != null && event.getState().getBlock() instanceof BlockDimensionOre) {
//then try spawning mob
//EntityPlayer player = event.getPlayer();
BlockPos pos = event.getPos();
World world = event.getWorld();
BlockDimensionOre block = (BlockDimensionOre) event.getState().getBlock();
block.trySpawnTriggeredEntity(world, pos);
}
}
示例7: onBlockHarvest
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockHarvest(HarvestDropsEvent event) {
if (!Config.direSlimeEnabled || event.isCanceled() || event.getWorld() == null || event.getWorld().isRemote) {
return;
}
if (event.getHarvester() == null || event.getHarvester().capabilities.isCreativeMode) {
return;
}
if (!(event.getState().getBlock() instanceof BlockDirt || event.getState().getBlock() instanceof BlockGrass)) {
return;
}
if (!isToolEffective(event.getState(), event.getHarvester().getHeldItemMainhand())) {
if (Config.direSlimeChance < event.getWorld().rand.nextFloat()) {
return;
}
EntityDireSlime direSlime = new EntityDireSlime(event.getWorld());
direSlime.setPosition(event.getPos().getX() + 0.5, event.getPos().getY() + 0.0, event.getPos().getZ() + 0.5);
event.getWorld().spawnEntity(direSlime);
direSlime.playLivingSound();
for (ItemStack drop : event.getDrops()) {
if (drop != null && drop.getItem() != null && drop.getItem() == Item.getItemFromBlock(Blocks.DIRT)) {
if (drop.getCount() > 1) {
drop.shrink(1);
} else if (event.getDrops().size() == 1) {
event.getDrops().clear();
} else {
event.getDrops().remove(drop);
}
return;
}
}
}
}
示例8: thisToolWasUsed
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
private boolean thisToolWasUsed(HarvestDropsEvent event) {
return event.getHarvester() != null && event.getHarvester().getHeldItemMainhand() != null
&& event.getHarvester().getHeldItemMainhand().getItem() == INSTANCE && !event.getWorld().isRemote;
}
示例9: onBlockDropSmelt
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
/** Auto-smelt blocks when using a skyfather tool */
private boolean onBlockDropSmelt(HarvestDropsEvent e) {
if(e.getHarvester() != null && LCConfig.autoSmelt) {
int fortuneLevel = e.getFortuneLevel() + defBonus;
// get the held item and make sure it isn't null!
// 1.1.2 fix
tool = e.getHarvester().inventory.getCurrentItem();
if(e.getHarvester().inventory.getCurrentItem() == null) {
return false;
}
Item itool = tool.getItem();
// auto smelt with the pick, axe, and shovel
// but not when sneaking! Also, not with silk touch
if((itool instanceof ItemSkyAxe || itool instanceof ItemSkyPick || itool instanceof ItemSkySpade)
&& !e.isSilkTouching() && !e.getHarvester().isSneaking()) {
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(
new ItemStack(e.getState().getBlock(), 1, e.getState().getBlock().getMetaFromState(e.getState())));
if (result != null) {
// depending on fortune, release smelted ores
// 1.4.1 fix: no fortune on block items!
int nItems;
int nParticles = 2;
if(fortuneLevel > 0 && !(result.getItem() instanceof ItemBlock)) {
nItems = 1 + random.nextInt(fortuneLevel + (itool instanceof IMysticGear ? 1 : 0)); // only Mystic has Luck
} else {
nItems = 1;
}
for(int i = 0; i < nItems; i++) {
float f = random.nextFloat() * 0.6F + 0.1F;
float f1 = random.nextFloat() * 0.6F + 0.1F;
float f2 = random.nextFloat() * 0.6F + 0.1F;
float f3 = 0.025F;
EntityItem eitem = new EntityItem(e.getWorld(),
e.getPos().getX() + f, e.getPos().getY() + f1, e.getPos().getZ() + f2, result.copy());
eitem.motionX = random.nextGaussian() * f3;
eitem.motionY = random.nextGaussian() * f3 + 0.2F;
eitem.motionZ = random.nextGaussian() * f3;
e.getWorld().spawnEntityInWorld(eitem);
tool.damageItem(1, e.getHarvester()); // +1 damage per ore obtained
// spawn particles at this position
for(int j = 0; j < nParticles; j++) {
double rx = eitem.posX + random.nextFloat() - 0.5;
double ry = eitem.posY + (random.nextFloat() + 0.5) * 0.15;
double rz = eitem.posZ + random.nextFloat() - 0.5;
LCNetwork.net.sendToAll(new MessageSpawnParticle("flame", rx, ry, rz, 0, 0, 0));
}
}
// cancel the default drops
e.setDropChance(0);
return true;
}
}
}
return false;
}