本文整理汇总了Java中net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent.getHarvester方法的典型用法代码示例。如果您正苦于以下问题:Java HarvestDropsEvent.getHarvester方法的具体用法?Java HarvestDropsEvent.getHarvester怎么用?Java HarvestDropsEvent.getHarvester使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent
的用法示例。
在下文中一共展示了HarvestDropsEvent.getHarvester方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
}
}
}
示例3: onHarvestDrop
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDrop(HarvestDropsEvent event) {
EntityPlayer player = event.getHarvester();
if (player != null) {
Iterator<ItemStack> it = event.getDrops().iterator();
while (it.hasNext()) {
ItemStack stack = it.next();
if (ProgressionEvents.isEventCancelled(player, ActionType.HARVESTDROPWITH, player.getHeldItemMainhand(), ActionType.HARVESTDROP, stack)) {
it.remove();
}
}
}
}
示例4: onHarvestDropsEvent
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDropsEvent(HarvestDropsEvent event)
{
if (event.getHarvester() != null)
{
ItemStack stack = event.getHarvester().getHeldItemMainhand();
if (stack.isEmpty() == false && stack.getItem() instanceof ItemEnderTool)
{
((ItemEnderTool) stack.getItem()).handleHarvestDropsEvent(stack, event);
}
}
}
示例5: 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;
}
}
}
}
示例6: 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;
}
示例7: onMine
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onMine(HarvestDropsEvent event) {
if (event.getHarvester() == null) {
return;
}
EntityPlayer player = event.getHarvester();
Province inProvince = loadProvince(event.getHarvester().world, event.getPos());
if (inProvince == null || inProvince.civilization == null) {
return;
}
ItemStack tool = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
if (!tool.hasTagCompound()) {
return;
}
String questId = tool.getTagCompound().getString("mine_quest");
String provinceId = tool.getTagCompound().getString("province");
if (questId == null || provinceId == null || !provinceId.equals(inProvince.id.toString())) {
return;
}
QuestData data = getQuestById(player, questId);
if (data == null) {
return;
}
if (notCurrentDepth(event, data)) {
return;
}
if (event.getState().getBlock() != BLOCK_TYPES[getBlockType(data)]) {
return;
}
event.setDropChance(1f);
for (ItemStack drop : event.getDrops()) {
drop.setTagInfo("mine_quest", new NBTTagString(questId));
drop.setTagInfo("province", new NBTTagString(provinceId));
drop.setStackDisplayName(drop.getDisplayName() + " for " + inProvince.name);
}
}
示例8: 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;
}