本文整理汇总了Java中net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent方法的典型用法代码示例。如果您正苦于以下问题:Java BlockEvent.HarvestDropsEvent方法的具体用法?Java BlockEvent.HarvestDropsEvent怎么用?Java BlockEvent.HarvestDropsEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.world.BlockEvent
的用法示例。
在下文中一共展示了BlockEvent.HarvestDropsEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onWitherBoneHarvestEvent
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWitherBoneHarvestEvent(BlockEvent.HarvestDropsEvent event) {
if (event.getHarvester() == null) {
return;
}
EntityPlayer player = event.getHarvester();
ItemStack stack = player.getHeldItemMainhand();
boolean flag = false;
if (stack.getItem() instanceof IHaftTool) {
if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
flag = true;
}
}
if (flag) {
if (player.dimension != DimensionType.NETHER.getId()) {
stack.damageItem(7, player);
}
}
}
示例2: HarvestDropsEvent
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void HarvestDropsEvent(BlockEvent.HarvestDropsEvent e){
try {
if (e != null && e.getHarvester() == null && !e.getDrops().isEmpty() && ((e.getState().getBlock().equals(Blocks.LEAVES))
|| e.getState().getBlock().equals(Blocks.LEAVES2)) && !e.getWorld().isRemote) {
Block block = Block.getBlockFromItem(e.getDrops().get(0).getItem());
int meta = e.getDrops().get(0).getMetadata();
BlockPos pos = findGround(e.getWorld(), e.getPos());
if (pos != null && e.getWorld() != null) {
e.getWorld().setBlockState(pos, block.getStateFromMeta(meta));
deleteCopySapling(e.getWorld(), pos, Item.getItemFromBlock(block));
}
}
}catch(Throwable throwable){
System.out.println(" EXCEPTION FOUND IN EVENT TWEAKS FOREST REPLANTING: PLEASE REPORT LOGS TO EVENT TWEAKS WITH INFORMATION ON REPRODUCING");
throwable.printStackTrace();
}
}
示例3: blockHarvestDrops
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@Override
public void blockHarvestDrops(ItemStack tool, BlockEvent.HarvestDropsEvent event) {
if (!event.getWorld().isRemote && random.nextFloat() < 0.05) {
List<IBlockState> blockstates = Lists.newArrayList(Blocks.STONE.getDefaultState(), Blocks.NETHERRACK.getDefaultState(), Blocks.END_STONE.getDefaultState(), Blocks.AIR.getDefaultState(), Blocks.DIRT.getDefaultState());
IBlockState mainstate = event.getState();
if (blockstates.contains(mainstate)) return;
for (int i = 0; i < chance; i++) {
int x = event.getPos().getX() + Utils.nextInt(random, -distance, distance);
int y = event.getPos().getY() + Utils.nextInt(random, -distance, distance);
int z = event.getPos().getZ() + Utils.nextInt(random, -distance, distance);
BlockPos cPos = new BlockPos(x, y, z);
IBlockState state = event.getWorld().getBlockState(cPos);
if (blockstates.contains(state)) {
event.getDrops().clear();
event.getWorld().setBlockState(cPos, mainstate);
event.getHarvester().playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
event.getHarvester().sendStatusMessage(new TextComponentString("Teleported to: " + x + " " + y + " " + z), false);
return;
}
}
}
}
示例4: suppressClayDrops
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void suppressClayDrops(BlockEvent.HarvestDropsEvent event) {
List<ItemStack> drops = event.getDrops();
if (drops.stream().noneMatch(this::isClay)) {
return;
}
EntityPlayer harvester = event.getHarvester();
if (harvester != null && ModItems.getInstance().isValidClayHarvester(harvester.getHeldItemMainhand())) {
return;
}
drops.clear();
}
示例5: harvestDrops
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
public void harvestDrops(BlockEvent.HarvestDropsEvent event) {
for (ItemStack stack : event.getDrops()) {
ItemHandlerHelper.insertItem(outItems, stack, false);
sludge.fill(new FluidStack(FluidsRegistry.SLUDGE, 10 * stack.getCount()), true);
}
event.getDrops().clear();
hasWorked = true;
}
示例6: onHarvest
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvest(BlockEvent.HarvestDropsEvent event) {
for (PlantInteractorTile tile : PlantInteractorTile.WORKING_TILES) {
if (tile.getWorld().equals(event.getWorld()) && BlockUtils.getBlockPosInAABB(tile.getWorkingArea()).contains(event.getPos())) {
tile.harvestDrops(event);
return;
}
}
}
示例7: onHarvestAllium
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestAllium(BlockEvent.HarvestDropsEvent harvest) {
if (harvest.getState().getBlock() == Blocks.RED_FLOWER && harvest.getState().getBlock().getMetaFromState(harvest.getState()) == 2 && harvest.getWorld().rand.nextInt(5) == 0) {
harvest.getDrops().clear();
harvest.getDrops().add(new ItemStack(ModItems.seed_garlic, 1));
}
}
示例8: onHarvestDeadBush
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDeadBush(BlockEvent.HarvestDropsEvent harvest) {
if ((harvest.getState().getBlock() == Blocks.DEADBUSH && harvest.getWorld().rand.nextInt(150) < 25)) {
harvest.getDrops().clear();
harvest.getDrops().add(new ItemStack(ModItems.seed_white_sage, 1));
}
}
示例9: onHarvestOakLeaves
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestOakLeaves(BlockEvent.HarvestDropsEvent event) {
if ((event.getState().getBlock() == Blocks.LEAVES && event.getWorld().rand.nextInt(150) < 25)) {
event.getDrops().clear();
event.getDrops().add(new ItemStack(ModItems.oak_apple_gall, 1));
}
}
示例10: onScoopGravel
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onScoopGravel(BlockEvent.HarvestDropsEvent event) {
if ((event.getState().getBlock() == Blocks.GRAVEL && event.getWorld().rand.nextInt(400) < 25)) {
event.getDrops().clear();
event.getDrops().add(new ItemStack(ModItems.gem, 1, 1));
}
}
示例11: onMineCoquina
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onMineCoquina(BlockEvent.HarvestDropsEvent event) {
if ((event.getState().getBlock() == ModBlocks.coquina && event.getWorld().rand.nextInt(345) < 25)) {
event.getDrops().clear();
event.getDrops().add(new ItemStack(Blocks.GRAVEL, 1));
}
}
示例12: onHarvestWormwood
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestWormwood(BlockEvent.HarvestDropsEvent event) {
if ((event.getState().getBlock() == ModBlocks.crop_wormwood && event.getWorld().rand.nextInt(450) < 25)) {
event.getDrops().clear();
event.getDrops().add(new ItemStack(ModItems.absinthe_green, 1));
event.getDrops().add(new ItemStack(ModItems.wormwood, 3));
event.getDrops().add(new ItemStack(ModItems.seed_wormwood, 2));
}
}
示例13: modifyHarvestDrops
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void modifyHarvestDrops(BlockEvent.HarvestDropsEvent event)
{
if (event.getState().getBlock() == Blocks.GRAVEL)
{
Random rand = event.getWorld().rand;
if (rand.nextInt(100) < Config.shiny_stone_drop_rate)
{
event.getDrops().add(new ItemStack(ModItems.shiny_stone));
}
}
}
示例14: onHarvestDropsEvent
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
BlockPos pos = event.getPos();
if (harvestableBlocksToCollect.containsKey(pos)) {
Integer actionId = harvestableBlocksToCollect.get(pos);
ActionOptions options = ServerActionManager.getManager().getOptions(actionId);
if (options != null) {
options.registerDrops(pos, event.getDrops());
event.getDrops().clear();
ServerActionManager.getManager().save();
} else {
harvestableBlocksToCollect.remove(pos);
}
}
}
示例15: registerEvent
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void registerEvent(BlockEvent.HarvestDropsEvent event)
{
if (!Config.getInstance().boringSamples || event.getHarvester() == null || event.getState() == null || event.getState().getBlock() != this)
{
return;
}
String resource = Types.Modded.byMetadata(event.getState().getBlock().getMetaFromState(event.getState())).getResource();
event.getHarvester().sendStatusMessage(new TextComponentString("You break the sample to find " + resource), true);
event.getDrops().clear();
}