当前位置: 首页>>代码示例>>Java>>正文


Java MinecartInteractEvent类代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.minecart.MinecartInteractEvent的典型用法代码示例。如果您正苦于以下问题:Java MinecartInteractEvent类的具体用法?Java MinecartInteractEvent怎么用?Java MinecartInteractEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MinecartInteractEvent类属于net.minecraftforge.event.entity.minecart包,在下文中一共展示了MinecartInteractEvent类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
@Override
public boolean interactFirst(EntityPlayer player) {
    if (MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player))) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != player) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity != player) {
        return false;
    } else {
        if (player != null) {
            ItemStack stack = player.getCurrentEquippedItem();
            if (stack != null) {
                if (stack.getItem() instanceof Item1N4148 ||
                        stack.getItem() instanceof ItemTrainController8Bit ||
                        stack.getItem() instanceof ItemTrainController32Bit) {
                    return true;
                }
                if (stack.getItem() instanceof ItemMinecart) return true;
            }
            if (!this.worldObj.isRemote) {
                player.mountEntity(this);
            }
        }
        return true;
    }
}
 
开发者ID:NSDN,项目名称:NyaSamaRailway,代码行数:27,代码来源:MinecartBase.java

示例2: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
@Override
public boolean interactFirst(EntityPlayer player) {
    if (MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player))) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != player) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity != player) {
        return false;
    } else {
        if (player != null) {
            ItemStack stack = player.getCurrentEquippedItem();
            if (stack != null) {
                if (stack.getItem() instanceof Item1N4148 ||
                    stack.getItem() instanceof ItemTrainController8Bit ||
                    stack.getItem() instanceof ItemTrainController32Bit) {
                    return true;
                }
                if (stack.getItem() instanceof ItemMinecart) return true;
            }
            if (!this.worldObj.isRemote) {
                player.mountEntity(this);
            }
        }
        return true;
    }
}
 
开发者ID:NSDN,项目名称:NyaSamaRailway,代码行数:27,代码来源:NSPCT8J.java

示例3: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
/**
 * First layer of player interaction
 */
public boolean interactFirst(EntityPlayer par1EntityPlayer)
{
    if(MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, par1EntityPlayer))) 
    {
        return true;
    }
    ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

    if (itemstack != null && itemstack.itemID == Item.coal.itemID)
    {
        if (!par1EntityPlayer.capabilities.isCreativeMode && --itemstack.stackSize == 0)
        {
            par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
        }

        this.fuel += 3600;
    }

    this.pushX = this.posX - par1EntityPlayer.posX;
    this.pushZ = this.posZ - par1EntityPlayer.posZ;
    return true;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:26,代码来源:EntityMinecartFurnace.java

示例4: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
/**
 * First layer of player interaction
 */
public boolean interactFirst(EntityPlayer par1EntityPlayer)
{
    if(MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, par1EntityPlayer))) 
    {
        return true;
    }
    if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer)
    {
        return true;
    }
    else if (this.riddenByEntity != null && this.riddenByEntity != par1EntityPlayer)
    {
        return false;
    }
    else
    {
        if (!this.worldObj.isRemote)
        {
            par1EntityPlayer.mountEntity(this);
        }

        return true;
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:28,代码来源:EntityMinecartEmpty.java

示例5: onMinecartInteraction

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
@SubscribeEvent
public void onMinecartInteraction(MinecartInteractEvent event){
    if(!event.getMinecart().world.isRemote) {
        ItemStack heldItem = event.getPlayer().getHeldItemMainhand();
        if(!heldItem.isEmpty()) {
            CapabilityMinecartDestination cap = event.getMinecart().getCapability(CapabilityMinecartDestination.INSTANCE, null);
            if(cap != null) {
                if(heldItem.getItem() == ModItems.CART_ENGINE && !cap.isMotorized()) {
                    if(!event.getPlayer().isCreative()) {
                        heldItem.shrink(1);
                        if(heldItem.isEmpty()) event.getPlayer().setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
                    }
                    cap.setMotorized();
                    event.getPlayer().sendMessage(new TextComponentTranslation("signals.message.cart_engine_installed"));
                    event.setCanceled(true);
                } else if(heldItem.getItem() == ModItems.RAIL_CONFIGURATOR) {
                    RailCacheManager.syncStationNames((EntityPlayerMP)event.getPlayer());
                    event.getPlayer().openGui(Signals.instance, CommonProxy.EnumGuiId.MINECART_DESTINATION.ordinal(), ((EntityPlayerMP)event.getPlayer()).world, event.getMinecart().getEntityId(), -1, cap.isMotorized() ? 1 : 0);
                    event.setCanceled(true);
                } else if(heldItem.getItem() == ModItems.TICKET) {
                    if(event.getPlayer().isSneaking()) {
                        ItemTicket.setDestinations(heldItem, Arrays.asList(cap.getDestinations()));
                        event.getPlayer().sendMessage(new TextComponentTranslation("signals.message.destinations_saved", TextFormatting.GOLD + ItemTicket.getConcattedDestinations(heldItem) + TextFormatting.WHITE));
                    } else {
                        ItemTicket.applyDestinations(event.getMinecart(), heldItem);
                        event.getPlayer().sendMessage(new TextComponentTranslation("signals.message.destinations_set", TextFormatting.GOLD + ItemTicket.getConcattedDestinations(heldItem) + TextFormatting.WHITE));
                    }
                    event.setCanceled(true);
                }
            }
        }
    }
}
 
开发者ID:MineMaarten,项目名称:Signals,代码行数:34,代码来源:EventHandler.java

示例6: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
@Override
public boolean interactFirst(EntityPlayer player)
{
	if(!MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player)))
	{
		this.sendUpdateToAllAround();
		EntityPlayer fakePlayer = new FakePlayer(player, this, this.shouldAccessPlayerInventory());
		boolean blockActivated = this.getCartBlock()
				.onBlockActivated(this.getFakeWorld(), ORIGIN_POS, this.getDisplayTile(), fakePlayer,
						EnumFacing.NORTH, 0, 0, 0);
		this.sendUpdateToAllAround();
		return blockActivated;
	}
	return true;
}
 
开发者ID:BrassGoggledCoders,项目名称:MoarCarts,代码行数:16,代码来源:EntityMinecartTEBase.java

示例7: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
@Override
public boolean interactFirst(EntityPlayer player)
{
	if(MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player)))
	{
		return true;
	}

	if (!this.worldObj.isRemote && !player.isSneaking())
	{
		FMLNetworkHandler.openGui(player, MoarCarts.instance, 2, player.worldObj, this.getEntityId(), 0, 0);
	}

	return true;
}
 
开发者ID:BrassGoggledCoders,项目名称:MoarCarts,代码行数:16,代码来源:EntityMinecartBase.java

示例8: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
@Override
public boolean interactFirst(EntityPlayer player)
{
    if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player))) {
        return true;
    }

    if (!this.worldObj.isRemote && !player.isSneaking())
    {
        FMLNetworkHandler.openGui(player, ExtraCarts.instance, 2, player.worldObj, this.getEntityId(), 0, 0);
    }

    return true;
}
 
开发者ID:ScottDTA,项目名称:ExtraCarts-1.7.10,代码行数:15,代码来源:EntityExtraCartChestMinecart.java

示例9: MinecartInteractEvent

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
@SubscribeEvent
public void MinecartInteractEvent(MinecartInteractEvent event) {
	if (event.entity instanceof EntityMinecartChest) {
		ItemStack curItem = event.player.getCurrentEquippedItem();
    	EntityMinecartChest oldCart = (EntityMinecartChest) event.entity;
    	if (curItem != null && curItem.getItem() == WoodIronUpgrade) {
    		EntityIronChestCart ironCart = new EntityIronChestCart(oldCart.worldObj);
    		ironCart.copyDataFrom(event.entity, true);
    		ironCart.setDisplayTileData(0);
 	        if (!event.entity.worldObj.isRemote) {
 	           	oldCart.worldObj.spawnEntityInWorld(ironCart);
 	        }
 	        for (int i = 0; i < oldCart.getSizeInventory(); i++) {
 	        	oldCart.setInventorySlotContents(i, null);
 	        }
    		oldCart.setDead();
    		event.player.destroyCurrentEquippedItem();
    		event.setCanceled(true);
    	} else if (curItem != null && curItem.getItem() == WoodCopperUpgrade) {	
    		EntityCopperChestCart copperCart = new EntityCopperChestCart(oldCart.worldObj);
    		copperCart.copyDataFrom(event.entity, true);
    		copperCart.setDisplayTileData(3);
 	        if (!event.entity.worldObj.isRemote) {
 	        	oldCart.worldObj.spawnEntityInWorld(copperCart);
 	        }
 	        for (int i = 0; i < oldCart.getSizeInventory(); i++) {
 	          	oldCart.setInventorySlotContents(i, null);
 	        }
    		oldCart.setDead();
    		event.player.destroyCurrentEquippedItem();
    		event.setCanceled(true);
    	}
    }
}
 
开发者ID:ScottDTA,项目名称:ExtraCarts-1.7.10,代码行数:35,代码来源:ECEventHandler.java

示例10: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
/**
 * First layer of player interaction
 */
public boolean interactFirst(EntityPlayer par1EntityPlayer)
{
    if(MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, par1EntityPlayer))) 
    {
        return true;
    }
    if (!this.worldObj.isRemote)
    {
        par1EntityPlayer.displayGUIChest(this);
    }

    return true;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:17,代码来源:EntityMinecartContainer.java

示例11: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
/**
 * First layer of player interaction
 */
public boolean interactFirst(EntityPlayer par1EntityPlayer)
{
    if(MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, par1EntityPlayer))) 
    {
        return true;
    }
    if (!this.worldObj.isRemote)
    {
        par1EntityPlayer.displayGUIHopperMinecart(this);
    }

    return true;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:17,代码来源:EntityMinecartHopper.java

示例12: onMinecartEvent

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
@SubscribeEvent
public void onMinecartEvent(MinecartInteractEvent ev){
	if(!Properties.enableMinecartTweaks)return; //ignore if turned off
	EntityMinecart cart=ev.minecart;
	if(cart instanceof EntityMinecartFurnace){
		EntityPlayer player=ev.player;
        if(player.isSneaking()){ 
        	//invert motion if player is sneaking - allows making furnace cart come
        	EntityMinecartFurnace fc=(EntityMinecartFurnace) cart;
        	fc.pushX = -(fc.posX - player.posX);
        	fc.pushZ = -(fc.posZ - player.posZ);
        	ev.setCanceled(true); //stop normal handling - we took care of it
        }
	}
}
 
开发者ID:planetguy32,项目名称:Gizmos,代码行数:16,代码来源:ForgeEventHandler.java

示例13: interactFirst

import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; //导入依赖的package包/类
@Override
public boolean interactFirst(EntityPlayer player) {
    return MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player));
}
 
开发者ID:NSDN,项目名称:NyaSamaRailway,代码行数:5,代码来源:LocoBase.java


注:本文中的net.minecraftforge.event.entity.minecart.MinecartInteractEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。