本文整理了Java中net.minecraft.world.World.spawnEntityInWorld()
方法的一些代码示例,展示了World.spawnEntityInWorld()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.spawnEntityInWorld()
方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:spawnEntityInWorld
暂无
代码示例来源:origin: AlgorithmX2/Chisels-and-Bits
private static void spawnItem(
World world,
EntityItem ei )
{
if ( world.isRemote ) // no spawning items on the client.
return;
world.spawnEntityInWorld( ei );
}
}
代码示例来源:origin: coolAlias/Tutorial-Demo
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (!player.capabilities.isCreativeMode) {
--stack.stackSize;
}
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote) {
world.spawnEntityInWorld(new EntityThrowingRock(world, player));
}
return stack;
}
}
代码示例来源:origin: Electrical-Age/ElectricalAge
public static void dropItem(ItemStack itemStack, int x, int y, int z, World world) {
if (itemStack == null)
return;
if (world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
float var6 = 0.7F;
double var7 = (double) (world.rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
double var9 = (double) (world.rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
double var11 = (double) (world.rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
EntityItem var13 = new EntityItem(world, (double) x + var7, (double) y + var9, (double) z + var11, itemStack);
var13.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(var13);
}
}
代码示例来源:origin: squeek502/VeganOption
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand)
{
if (!player.capabilities.isCreativeMode)
{
--itemStack.stackSize;
}
player.playSound(throwSound, 0.5F, 0.4F / (RandomHelper.random.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote)
{
EntityThrowable entity = getNewThrownEntity(world, player);
entity.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, throwSpeed, 1.0F);
world.spawnEntityInWorld(entity);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
}
代码示例来源:origin: squeek502/VeganOption
public void freeze()
{
if (!this.worldObj.isRemote)
{
EntityItem frozenBubble = new EntityItem(worldObj, posX, posY, posZ, new ItemStack(FrozenBubble.frozenBubble));
worldObj.spawnEntityInWorld(frozenBubble);
this.setDead();
}
}
代码示例来源:origin: Electrical-Age/ElectricalAge
public void dropItem(ItemStack itemStack) {
if (itemStack == null) return;
if (coordonate.world().getGameRules().getGameRuleBooleanValue("doTileDrops")) {
float var6 = 0.7F;
double var7 = (double) (coordonate.world().rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
double var9 = (double) (coordonate.world().rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
double var11 = (double) (coordonate.world().rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
EntityItem var13 = new EntityItem(coordonate.world(), (double) coordonate.x + var7, (double) coordonate.y + var9, (double) coordonate.z + var11, itemStack);
var13.delayBeforeCanPickup = 10;
coordonate.world().spawnEntityInWorld(var13);
}
}
代码示例来源:origin: Electrical-Age/ElectricalAge
@Override
protected void updateAITick() {
super.updateAITick();
//setDead();
hunger += 0.05 / hungerTime;
if (hunger > 1 && Math.random() < 0.05 / 5) {
attackEntityFrom(DamageSource.starve, 1);
}
if (hunger < 0.5 && Math.random() * 10 < 0.05) {
heal(1f);
}
if (hunger < hungerToDuplicate) {
ReplicatorEntity entityliving = new ReplicatorEntity(this.worldObj);
entityliving.setLocationAndAngles(this.posX, this.posY, this.posZ, 0f, 0f);
entityliving.rotationYawHead = entityliving.rotationYaw;
entityliving.renderYawOffset = entityliving.rotationYaw;
worldObj.spawnEntityInWorld(entityliving);
entityliving.playLivingSound();
hunger = 0;
}
}
代码示例来源:origin: portablejim/VeinMiner
private void spawnDrops() {
for(Map.Entry<ItemStackID, Integer> schedDrop : drops.entrySet()) {
ItemStackID itemStack = schedDrop.getKey();
String itemName = itemStack.getItemId();
Item foundItem = Item.getByNameOrId(itemName);
if(foundItem == null) {
continue;
}
int itemDamage = itemStack.getDamage();
int numItems = schedDrop.getValue();
while (numItems > itemStack.getMaxStackSize()) {
ItemStack newItemStack = new ItemStack(foundItem, itemStack.getMaxStackSize(), itemDamage);
EntityItem newEntityItem = new EntityItem(world, initalBlock.getX() + 0.5F, initalBlock.getY() + 0.5F, initalBlock.getZ() + 0.5F, newItemStack);
world.spawnEntityInWorld(newEntityItem);
numItems -= itemStack.getMaxStackSize();
}
ItemStack newItemStack = new ItemStack(foundItem, numItems, itemDamage);
newItemStack.setItemDamage(itemStack.getDamage());
EntityItem newEntityItem = new EntityItem(world, initalBlock.getX() + 0.5F, initalBlock.getY() + 0.5F, initalBlock.getZ() + 0.5F, newItemStack);
world.spawnEntityInWorld(newEntityItem);
}
drops.clear();
}
代码示例来源:origin: joshiejack/Mariculture
@Override
@Nonnull
@SuppressWarnings("ConstantConditions")
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, @Nonnull World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand) {
if (playerIn.fishEntity != null) {
FishingRod rod = FishingAPI.INSTANCE.getFishingRodFromStack(stack);
if (rod != null) rod.setCastStatus(false);
int damage = playerIn.fishEntity.handleHookRetraction();
for (FishingTrait trait: FishingRodHelper.getTraits(stack)) {
damage = trait.modifyDamage(worldIn.rand, damage);
}
if (damage > 0 && FishingRodHelper.isDamageable(stack)) {
stack.damageItem(damage, playerIn);
}
playerIn.swingArm(hand);
} else {
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
FishingRod rod = FishingAPI.INSTANCE.getFishingRodFromStack(stack);
if (rod != null) rod.setCastStatus(true);
if (!worldIn.isRemote) {
worldIn.spawnEntityInWorld(new EntityFishHookMC(worldIn, playerIn, null));
}
playerIn.swingArm(hand);
playerIn.addStat(StatList.getObjectUseStats(this));
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
代码示例来源:origin: squeek502/VeganOption
@Override
public ItemStack onItemUseFinish(ItemStack itemStack, World world, EntityLivingBase player)
{
if (!world.isRemote)
{
EntityBubble bubble = new EntityBubble(world, player);
bubble.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, BUBBLE_INITIAL_VELOCITY, 1.0F);
world.spawnEntityInWorld(bubble);
}
itemStack.damageItem(1, player);
if (itemStack.stackSize == 0 && getContainerItem() != null)
{
return new ItemStack(getContainerItem());
}
return super.onItemUseFinish(itemStack, world, player);
}
代码示例来源:origin: ata4/dragon-mounts
/**
* Spawns a baby animal of the same type.
*/
private void spawnBaby() {
EntityTameableDragon dragonBaby = (EntityTameableDragon) dragon.createChild(dragonMate);
if (dragonBaby != null) {
dragon.setGrowingAge(6000);
dragonMate.setGrowingAge(6000);
dragon.resetInLove();
dragonMate.resetInLove();
dragonBaby.setLocationAndAngles(dragon.posX, dragon.posY, dragon.posZ, 0, 0);
dragonBaby.getLifeStageHelper().setLifeStage(EnumDragonLifeStage.EGG);
world.spawnEntityInWorld(dragonBaby);
// TODO: particles for the clients?
}
}
}
代码示例来源:origin: Electrical-Age/ElectricalAge
@Override
public void process(double time) {
energy -= powerResistor.getP() * time;
if (inventory.getStackInSlot(EggIncubatorContainer.EggSlotId) != null) {
descriptor.setState(powerResistor, true);
if (energy <= 0) {
inventory.decrStackSize(EggIncubatorContainer.EggSlotId, 1);
EntityChicken chicken = new EntityChicken(node.coordonate.world());
chicken.setGrowingAge(-24000);
EntityLiving entityliving = (EntityLiving) chicken;
entityliving.setLocationAndAngles(node.coordonate.x + 0.5, node.coordonate.y + 0.5, node.coordonate.z + 0.5, MathHelper.wrapAngleTo180_float(node.coordonate.world().rand.nextFloat() * 360.0F), 0.0F);
entityliving.rotationYawHead = entityliving.rotationYaw;
entityliving.renderYawOffset = entityliving.rotationYaw;
//entityliving.func_110161_a((EntityLivingData)null); 1.6.4
node.coordonate.world().spawnEntityInWorld(entityliving);
entityliving.playLivingSound();
//node.coordonate.world().spawnEntityInWorld());
resetEnergy();
needPublish();
}
} else {
descriptor.setState(powerResistor, false);
resetEnergy();
}
if (Math.abs(powerLoad.getU() - lastVoltagePublish) / descriptor.nominalVoltage > 0.1) needPublish();
}
代码示例来源:origin: Electrical-Age/ElectricalAge
entityliving.rotationYawHead = entityliving.rotationYaw;
entityliving.renderYawOffset = entityliving.rotationYaw;
world.spawnEntityInWorld(entityliving);
entityliving.playLivingSound();
entityliving.isSpawnedFromWeather = true;
代码示例来源:origin: joshiejack/Mariculture
@SubscribeEvent
public void onKillChicken(LivingDeathEvent event) {
if (Debug.CHICKEN_FISHING > 0) {
EntityPlayer angler = event.getSource().getEntity() instanceof EntityPlayer ? (EntityPlayer) event.getSource().getEntity() : null;
if (angler != null && !angler.worldObj.isRemote && event.getEntityLiving() instanceof EntityChicken) {
for (int i = 0; i < Debug.CHICKEN_FISHING; i++) {
LootContext.Builder lootcontext$builder = new LootContext.Builder((WorldServer) angler.worldObj);
lootcontext$builder.withLuck((float) EnchantmentHelper.getLuckOfSeaModifier(angler) + angler.getLuck());
lootcontext$builder.withPlayer(angler); //Added by Mariculture
lootcontext$builder.withLootedEntity(event.getEntityLiving()); //Added by Mariculture
for (ItemStack itemstack : angler.worldObj.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(this.rand, lootcontext$builder.build())) {
EntityItem entityitem = new EntityItem(angler.worldObj, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, itemstack);
double d0 = angler.posX - event.getEntityLiving().posX;
double d1 = angler.posY - event.getEntityLiving().posY;
double d2 = angler.posZ - event.getEntityLiving().posZ;
double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d1 * d1 + d2 * d2);
double d4 = 0.1D;
entityitem.motionX = d0 * d4;
entityitem.motionY = d1 * d4 + (double) MathHelper.sqrt_double(d3) * 0.08D;
entityitem.motionZ = d2 * d4;
angler.worldObj.spawnEntityInWorld(entityitem);
angler.worldObj.spawnEntityInWorld(new EntityXPOrb(angler.worldObj, angler.posX, angler.posY + 0.5D, angler.posZ + 0.5D, this.rand.nextInt(6) + 1));
}
}
}
}
}
}
代码示例来源:origin: joshiejack/Mariculture
entityitem.motionY = d1 * d4 + (double) MathHelper.sqrt_double(d3) * 0.08D;
entityitem.motionZ = d2 * d4;
worldObj.spawnEntityInWorld(entityitem);
angler.worldObj.spawnEntityInWorld(new EntityXPOrb(angler.worldObj, angler.posX, angler.posY + 0.5D, angler.posZ + 0.5D, xp));
代码示例来源:origin: AlgorithmX2/Chisels-and-Bits
player.getEntityWorld().spawnEntityInWorld( ei );
代码示例来源:origin: squeek502/VeganOption
public boolean tryFillContainersInside()
{
if (worldObj == null || worldObj.isRemote || !couldFillContainers())
return false;
List<EntityItem> entityItemsWithin = WorldHelper.getItemEntitiesWithin(worldObj, ((BlockBasin) Basin.basin).getInnerBoundingBox(worldObj, pos.getX(), pos.getY(), pos.getZ()));
for (EntityItem entityItemWithin : entityItemsWithin)
{
if (!FluidContainerHelper.isEmptyContainer(entityItemWithin.getEntityItem()))
continue;
EntityItem entityItemToFill = entityItemWithin;
ItemStack containerToFill = entityItemWithin.getEntityItem().splitStack(1);
FluidContainerHelper.drainHandlerIntoContainer(fluidTank, fluidTank.getFluid(), containerToFill);
if (!FluidContainerHelper.isEmptyContainer(containerToFill))
{
entityItemToFill = new EntityItem(entityItemToFill.worldObj, entityItemToFill.posX, entityItemToFill.posY, entityItemToFill.posZ, containerToFill);
entityItemToFill.setPickupDelay(10);
entityItemToFill.worldObj.spawnEntityInWorld(entityItemToFill);
}
return true;
}
return false;
}
代码示例来源:origin: squeek502/VeganOption
public static boolean tryWash(EntityItem entityItem)
{
if (entityItem == null || entityItem.worldObj.isRemote || entityItem.getEntityItem() == null)
return false;
if (!isReadyToCook(entityItem.getEntityItem()))
{
BlockPos fluidBlockPos = new BlockPos(MathHelper.floor_double(entityItem.posX), MathHelper.floor_double(entityItem.posY), MathHelper.floor_double(entityItem.posZ));
FluidStack consumedFluid = FluidHelper.consumeExactFluid(entityItem.worldObj, fluidBlockPos, FluidRegistry.WATER, Fluid.BUCKET_VOLUME);
if (consumedFluid != null)
{
EntityItem entityItemToWash = entityItem;
ItemStack doughToWash = entityItemToWash.getEntityItem();
if (entityItemToWash.getEntityItem().stackSize > 1)
{
doughToWash = entityItem.getEntityItem().splitStack(1);
entityItemToWash = new EntityItem(entityItemToWash.worldObj, entityItemToWash.posX, entityItemToWash.posY, entityItemToWash.posZ, doughToWash);
entityItemToWash.setPickupDelay(10);
entityItemToWash.worldObj.spawnEntityInWorld(entityItemToWash);
}
ItemStack washedItemStack = wash(doughToWash, 1);
entityItemToWash.setEntityItemStack(washedItemStack);
return true;
}
}
return false;
}
代码示例来源:origin: squeek502/VeganOption
public static boolean tryFillWithRawEnderFromWorld(EntityItem entityItem)
{
if (entityItem == null || entityItem.worldObj.isRemote || entityItem.getEntityItem() == null)
return false;
if (!isFull(entityItem.getEntityItem()))
{
BlockPos fluidBlockPos = new BlockPos(MathHelper.floor_double(entityItem.posX), MathHelper.floor_double(entityItem.posY), MathHelper.floor_double(entityItem.posZ));
FluidStack consumedFluid = FluidHelper.consumeExactFluid(entityItem.worldObj, fluidBlockPos, Ender.fluidRawEnder, FluidHelper.FINITE_FLUID_MB_PER_META);
if (consumedFluid != null)
{
EntityItem entityItemToFill = entityItem;
ItemStack bubbleToFill = entityItemToFill.getEntityItem();
if (entityItemToFill.getEntityItem().stackSize > 1)
{
bubbleToFill = entityItem.getEntityItem().splitStack(1);
entityItemToFill = new EntityItem(entityItemToFill.worldObj, entityItemToFill.posX, entityItemToFill.posY, entityItemToFill.posZ, bubbleToFill);
entityItemToFill.setPickupDelay(10);
entityItemToFill.worldObj.spawnEntityInWorld(entityItemToFill);
}
ItemStack filledItemStack = fill(bubbleToFill, 1);
entityItemToFill.setEntityItemStack(filledItemStack);
return true;
}
}
return false;
}
代码示例来源:origin: ata4/dragon-mounts
world.spawnEntityInWorld(dragon);
内容来源于网络,如有侵权,请联系作者删除!