本文整理汇总了Java中net.minecraft.entity.item.EntityMinecart类的典型用法代码示例。如果您正苦于以下问题:Java EntityMinecart类的具体用法?Java EntityMinecart怎么用?Java EntityMinecart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityMinecart类属于net.minecraft.entity.item包,在下文中一共展示了EntityMinecart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getComparatorInputOverride
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
if (((Boolean)worldIn.getBlockState(pos).getValue(POWERED)).booleanValue())
{
List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);
if (!list.isEmpty())
{
return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
}
List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.selectInventories});
if (!list1.isEmpty())
{
return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
}
}
return 0;
}
示例2: WeightedRandomMinecart
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
private WeightedRandomMinecart(NBTTagCompound tagCompound, String type, int weight)
{
super(weight);
if (type.equals("Minecart"))
{
if (tagCompound != null)
{
type = EntityMinecart.EnumMinecartType.byNetworkID(tagCompound.getInteger("Type")).getName();
}
else
{
type = "MinecartRideable";
}
}
this.nbtData = tagCompound;
this.entityType = type;
}
示例3: spawnEntityInWorld
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
/**
* Called when an entity is spawned in the world. This includes players.
*/
public boolean spawnEntityInWorld(Entity entityIn)
{
boolean flag = super.spawnEntityInWorld(entityIn);
this.entityList.add(entityIn);
if (!flag)
{
this.entitySpawnQueue.add(entityIn);
}
else if (entityIn instanceof EntityMinecart)
{
this.mc.getSoundHandler().playSound(new MovingSoundMinecart((EntityMinecart)entityIn));
}
return flag;
}
示例4: startRiding
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
public boolean startRiding(Entity entityIn, boolean force)
{
if (!super.startRiding(entityIn, force))
{
return false;
}
else
{
if (entityIn instanceof EntityMinecart)
{
this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart)entityIn));
}
if (entityIn instanceof EntityBoat)
{
this.prevRotationYaw = entityIn.rotationYaw;
this.rotationYaw = entityIn.rotationYaw;
this.setRotationYawHead(entityIn.rotationYaw);
}
return true;
}
}
示例5: getComparatorInputOverride
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
if (((Boolean)blockState.getValue(POWERED)).booleanValue())
{
List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);
if (!list.isEmpty())
{
return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
}
List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.HAS_INVENTORY});
if (!list1.isEmpty())
{
return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
}
}
return 0;
}
示例6: spawnEntityInWorld
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
/**
* Called when an entity is spawned in the world. This includes players.
*/
public boolean spawnEntityInWorld(Entity entityIn)
{
boolean flag = super.spawnEntityInWorld(entityIn);
this.entityList.add(entityIn);
if (flag)
{
if (entityIn instanceof EntityMinecart)
{
this.mc.getSoundHandler().playSound(new MovingSoundMinecart((EntityMinecart)entityIn));
}
}
else
{
this.entitySpawnQueue.add(entityIn);
}
return flag;
}
示例7: isEntityValidForName
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
private static boolean isEntityValidForName(String filter, Entity entity) throws IllegalArgumentException {
if (filter.equals("")) {
return true;
} else if (filter.startsWith("@")) {//entity type selection
filter = filter.substring(1); //cut off the '@'.
Class typeClass = null;
if (filter.equals("mob")) {
typeClass = EntityMob.class;
} else if (filter.equals("animal")) {
typeClass = EntityAnimal.class;
} else if (filter.equals("living")) {
typeClass = EntityLivingBase.class;
} else if (filter.equals("player")) {
typeClass = EntityPlayer.class;
} else if (filter.equals("item")) {
typeClass = EntityItem.class;
} else if (filter.equals("minecart")) {
typeClass = EntityMinecart.class;
} else if (filter.equals("drone")) {
typeClass = EntityDrone.class;
}
if (typeClass != null) {
return typeClass.isAssignableFrom(entity.getClass());
} else {
throw new IllegalArgumentException(filter + " is not a valid entity type.");
}
} else {
try {
String regex = filter.toLowerCase().replaceAll(".", "[$0]").replace("[*]", ".*");//Wildcard regex
return entity.getName().toLowerCase().matches(regex);//TODO when player, check if entity is tamed by the player (see EntityAIAvoidEntity for example)
} catch (PatternSyntaxException e) {
return entity.getName().toLowerCase().equals(filter.toLowerCase());
}
}
}
示例8: createEntityFromNBT
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
/**
* create a new instance of an entity from NBT store
*/
public static Entity createEntityFromNBT(NBTTagCompound nbt, World worldIn)
{
Entity entity = null;
if ("Minecart".equals(nbt.getString("id")))
{
nbt.setString("id", EntityMinecart.EnumMinecartType.byNetworkID(nbt.getInteger("Type")).getName());
nbt.removeTag("Type");
}
try
{
Class <? extends Entity > oclass = (Class)stringToClassMapping.get(nbt.getString("id"));
if (oclass != null)
{
entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {worldIn});
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
if (entity != null)
{
entity.readFromNBT(nbt);
}
else
{
logger.warn("Skipping Entity with id " + nbt.getString("id"));
}
return entity;
}
示例9: addMountedMovementStat
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
/**
* Adds a value to a mounted movement statistic field - by minecart, boat, or pig.
*/
private void addMountedMovementStat(double p_71015_1_, double p_71015_3_, double p_71015_5_)
{
if (this.ridingEntity != null)
{
int i = Math.round(MathHelper.sqrt_double(p_71015_1_ * p_71015_1_ + p_71015_3_ * p_71015_3_ + p_71015_5_ * p_71015_5_) * 100.0F);
if (i > 0)
{
if (this.ridingEntity instanceof EntityMinecart)
{
this.addStat(StatList.distanceByMinecartStat, i);
if (this.startMinecartRidingCoordinate == null)
{
this.startMinecartRidingCoordinate = new BlockPos(this);
}
else if (this.startMinecartRidingCoordinate.distanceSq((double)MathHelper.floor_double(this.posX), (double)MathHelper.floor_double(this.posY), (double)MathHelper.floor_double(this.posZ)) >= 1000000.0D)
{
this.triggerAchievement(AchievementList.onARail);
}
}
else if (this.ridingEntity instanceof EntityBoat)
{
this.addStat(StatList.distanceByBoatStat, i);
}
else if (this.ridingEntity instanceof EntityPig)
{
this.addStat(StatList.distanceByPigStat, i);
}
else if (this.ridingEntity instanceof EntityHorse)
{
this.addStat(StatList.distanceByHorseStat, i);
}
}
}
}
示例10: ItemMinecart
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
public ItemMinecart(EntityMinecart.EnumMinecartType type)
{
this.maxStackSize = 1;
this.minecartType = type;
this.setCreativeTab(CreativeTabs.tabTransport);
BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserMinecartBehavior);
}
示例11: onItemUse
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (BlockRailBase.isRailBlock(iblockstate))
{
if (!worldIn.isRemote)
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.isAscending())
{
d0 = 0.5D;
}
EntityMinecart entityminecart = EntityMinecart.func_180458_a(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);
if (stack.hasDisplayName())
{
entityminecart.setCustomNameTag(stack.getDisplayName());
}
worldIn.spawnEntityInWorld(entityminecart);
}
--stack.stackSize;
return true;
}
else
{
return false;
}
}
示例12: updatePoweredState
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
private void updatePoweredState(World worldIn, BlockPos pos, IBlockState state)
{
boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
boolean flag1 = false;
List<EntityMinecart> list = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[0]);
if (!list.isEmpty())
{
flag1 = true;
}
if (flag1 && !flag)
{
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
worldIn.notifyNeighborsOfStateChange(pos, this);
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
}
if (!flag1 && flag)
{
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 3);
worldIn.notifyNeighborsOfStateChange(pos, this);
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
}
if (flag1)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
worldIn.updateComparatorOutputLevel(pos, this);
}
示例13: mountEntity
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
/**
* Called when a player mounts an entity. e.g. mounts a pig, mounts a boat.
*/
public void mountEntity(Entity entityIn)
{
super.mountEntity(entityIn);
if (entityIn instanceof EntityMinecart)
{
this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart)entityIn));
}
}
示例14: MovingSoundMinecartRiding
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
public MovingSoundMinecartRiding(EntityPlayer playerRiding, EntityMinecart minecart)
{
super(new ResourceLocation("minecraft:minecart.inside"));
this.player = playerRiding;
this.minecart = minecart;
this.attenuationType = ISound.AttenuationType.NONE;
this.repeat = true;
this.repeatDelay = 0;
}
示例15: MovingSoundMinecart
import net.minecraft.entity.item.EntityMinecart; //导入依赖的package包/类
public MovingSoundMinecart(EntityMinecart minecartIn)
{
super(new ResourceLocation("minecraft:minecart.base"));
this.minecart = minecartIn;
this.repeat = true;
this.repeatDelay = 0;
}