本文整理汇总了Java中net.minecraft.block.Block.spawnAsEntity方法的典型用法代码示例。如果您正苦于以下问题:Java Block.spawnAsEntity方法的具体用法?Java Block.spawnAsEntity怎么用?Java Block.spawnAsEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.block.Block
的用法示例。
在下文中一共展示了Block.spawnAsEntity方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: breakBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
// System.out.println("123");
if (!worldIn.isRemote) {
TileEntityPictureFrame te = (TileEntityPictureFrame) worldIn.getTileEntity(pos);
if (!te.imagename.equals("")) {
ItemStack picture = new ItemStack(ItemLoader.itemPicture);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("pid", te.imagename);
picture.setTagCompound(nbt);
// worldIn.spawnEntityInWorld(new EntityItem(worldIn,
// pos.getX(), pos.getY(), pos.getZ(), picture));
Block.spawnAsEntity(worldIn, pos, picture);
}
}
super.breakBlock(worldIn, pos, state);
}
示例2: onBlockActivated
import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
// System.out.println(((TileEntityPictureFrame)
// worldIn.getTileEntity(pos)).imagename);
if (heldItem != null && heldItem.getItem().equals(ItemLoader.itemPicture) && heldItem.hasTagCompound()&&heldItem.getTagCompound().hasKey("pid")) {
//System.out.println(hand);
String imagename = heldItem.getTagCompound().getString("pid");
TileEntityPictureFrame te = (TileEntityPictureFrame) worldIn.getTileEntity(pos);
if (!worldIn.isRemote && !te.imagename.equals("")) {
ItemStack picture = new ItemStack(ItemLoader.itemPicture);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("pid", te.imagename);
picture.setTagCompound(nbt);
Block.spawnAsEntity(worldIn, pos, picture);
//worldIn.spawnEntityInWorld(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), ));
}
te.imagename = imagename;
heldItem.stackSize--;
}
// playerIn.addChatComponentMessage((new
// TextComponentTranslation("test")));
return true;
}
示例3: dropBlockAsItemWithChanceImpl
import net.minecraft.block.Block; //导入方法依赖的package包/类
public static <T extends Block & IImplementableBlock> void dropBlockAsItemWithChanceImpl(T self, World world, BlockPos pos, IBlockState state, float chance, int fortune) {
if (!world.isRemote && !world.restoringBlockSnapshots) {
TileEntity entity = world.getTileEntity(pos);
if (entity != null && entity instanceof RandoresTileEntity) {
NonNullList<ItemStack> drops = NonNullList.create();
RandoresItemHelper.getRawDrop(drops, entity, state);
chance = net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, fortune, chance, false, self.getHarvester());
for (ItemStack drop : drops) {
if (world.rand.nextFloat() <= chance) {
Block.spawnAsEntity(world, pos, drop);
}
}
}
}
}
示例4: dropContents
import net.minecraft.block.Block; //导入方法依赖的package包/类
private void dropContents()
{
this.func_190773_I();
for (int i = 0; i < this.handItems.size(); ++i)
{
ItemStack itemstack = (ItemStack)this.handItems.get(i);
if (!itemstack.func_190926_b())
{
Block.spawnAsEntity(this.world, (new BlockPos(this)).up(), itemstack);
this.handItems.set(i, ItemStack.field_190927_a);
}
}
for (int j = 0; j < this.armorItems.size(); ++j)
{
ItemStack itemstack1 = (ItemStack)this.armorItems.get(j);
if (!itemstack1.func_190926_b())
{
Block.spawnAsEntity(this.world, (new BlockPos(this)).up(), itemstack1);
this.armorItems.set(j, ItemStack.field_190927_a);
}
}
}
示例5: setDead
import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public void setDead() {
//System.out.println("death and drop");
if (!this.getEntityWorld().isRemote) {
Block.spawnAsEntity(this.getEntityWorld(), this.getPosition(), new ItemStack(ItemLoader.itemTripod, 1));
// last slot useless,so= -2 !=-1
for (int i = Inventory.getSlots() - 2; i >= 0; --i) {
if (Inventory.getStackInSlot(i) != null) {
Block.spawnAsEntity(this.getEntityWorld(), this.getPosition(), Inventory.getStackInSlot(i));
((IItemHandlerModifiable) Inventory).setStackInSlot(i, null);
}
}
}
super.setDead();
}
示例6: breakBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
TileEntityPhotoProcessor te = (TileEntityPhotoProcessor) worldIn.getTileEntity(pos);
IItemHandler inv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
for (int i = inv.getSlots() - 1; i >= 0; --i) {
if (inv.getStackInSlot(i) != null) {
Block.spawnAsEntity(worldIn, pos, inv.getStackInSlot(i));
((IItemHandlerModifiable) inv).setStackInSlot(i, null);
}
}
super.breakBlock(worldIn, pos, state);
}
示例7: dropContents
import net.minecraft.block.Block; //导入方法依赖的package包/类
private void dropContents()
{
for (int i = 0; i < this.contents.length; ++i)
{
if (this.contents[i] != null && this.contents[i].stackSize > 0)
{
if (this.contents[i] != null)
{
Block.spawnAsEntity(this.worldObj, (new BlockPos(this)).up(), this.contents[i]);
}
this.contents[i] = null;
}
}
}
示例8: dropContents
import net.minecraft.block.Block; //导入方法依赖的package包/类
private void dropContents()
{
this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_ARMORSTAND_BREAK, this.getSoundCategory(), 1.0F, 1.0F);
for (int i = 0; i < this.handItems.length; ++i)
{
if (this.handItems[i] != null && this.handItems[i].stackSize > 0)
{
if (this.handItems[i] != null)
{
Block.spawnAsEntity(this.worldObj, (new BlockPos(this)).up(), this.handItems[i]);
}
this.handItems[i] = null;
}
}
for (int j = 0; j < this.armorItems.length; ++j)
{
if (this.armorItems[j] != null && this.armorItems[j].stackSize > 0)
{
if (this.armorItems[j] != null)
{
Block.spawnAsEntity(this.worldObj, (new BlockPos(this)).up(), this.armorItems[j]);
}
this.armorItems[j] = null;
}
}
}
示例9: removedByPlayer
import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player,
boolean willHarvest) {
EnumFacing facing = state.getValue(FACING).getOpposite().rotateY();
EnumFacing fatherfacing = facing.getOpposite();
if (player.isSneaking()) {
int width = 1;
int height = 1;
for (int i = 1; i < 50; i++) {
if (world.getBlockState(pos.offset(facing, i)).getBlock() instanceof BlockPictureFrameMultiple) {
width++;
world.setBlockToAir(pos.offset(facing, i));
} else {
break;
}
}
for (int i = 1; i < 50; i++) {
if (world.getBlockState(pos.up(i)).getBlock() instanceof BlockPictureFrameMultiple) {
height++;
world.setBlockToAir(pos.up(i));
} else {
break;
}
}
for (int i = 1; i < width; i++) {
for (int j = 1; j < height; j++) {
if (world.getBlockState(pos.offset(facing, i).up(j))
.getBlock() instanceof BlockPictureFrameMultiple) {
world.setBlockToAir(pos.offset(facing, i).up(j));
}
}
}
}
for (int i = 1; i < 50; i++) {
if (!(world.getBlockState(pos.offset(fatherfacing, i)).getBlock() instanceof BlockPictureFrameMultiple)) {
for (int j = 1; j < 50; j++) {
if (!(world.getBlockState(pos.offset(fatherfacing, i - 1).down(j))
.getBlock() instanceof BlockPictureFrameMultiple)) {
TileEntityPictureFrameMultiple te = (TileEntityPictureFrameMultiple) world
.getTileEntity(pos.offset(fatherfacing, i - 1).down(j - 1));
if (te != null) {
//System.out.println(pos.offset(fatherfacing, i - 1).down(j - 1));
if (!te.imagename.equals("")) {
if (!world.isRemote) {
ItemStack picture = new ItemStack(ItemLoader.itemPicture);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("pid", te.imagename);
picture.setTagCompound(nbt);
Block.spawnAsEntity(world, pos, picture);
player.addChatComponentMessage(
new TextComponentTranslation("chat.framemultiple.changeanddrowpicture"));
}
te.imagename = "";
te.shouldrender = false;
}
}
break;
}
}
break;
}
}
return super.removedByPlayer(state, world, pos, player, willHarvest);
}
示例10: onPlayerItemCrafted
import net.minecraft.block.Block; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerItemCrafted(ItemCraftedEvent event) {
if(Block.getBlockFromItem(event.crafting.getItem()) instanceof BlockPhotoProcessor &&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftprocessor)){
event.player.addStat(AchievementLoader.craftprocessor);
}
if(Block.getBlockFromItem(event.crafting.getItem()) instanceof BlockPictureFrame &&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftpictureframe)){
event.player.addStat(AchievementLoader.craftpictureframe);
}
if(Block.getBlockFromItem(event.crafting.getItem()) instanceof BlockPictureFrameMultiple &&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftpictureframe_multiple)){
event.player.addStat(AchievementLoader.craftpictureframe_multiple);
}
if(event.crafting.getItem() instanceof ItemPhotoPaper&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftphoto_paper)){
event.player.addStat(AchievementLoader.craftphoto_paper);
}
if(event.crafting.getItem() instanceof ItemGlassesHelmet&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftglasses)){
event.player.addStat(AchievementLoader.craftglasses);
}
if(event.crafting.getItem() instanceof ItemFilm&&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftfilm)){
event.player.addStat(AchievementLoader.craftfilm);
}
if(event.crafting.getItem() instanceof ItemTripod&&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.crafttripod)){
event.player.addStat(AchievementLoader.crafttripod);
}
if(event.crafting.getItem() instanceof ItemPictureBook&&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftpicture_book)){
event.player.addStat(AchievementLoader.craftpicture_book);
}
if (event.crafting.getItem() instanceof ItemCamera) {
if(!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftcamera)){
System.out.println("has no stat");
event.player.addStat(AchievementLoader.craftcamera);
}
for (int i = 0; i < 9; i++) {
if (event.craftMatrix.getStackInSlot(i) != null
&& event.craftMatrix.getStackInSlot(i).getItem() instanceof ItemTripod) {
if (!event.player.inventory.addItemStackToInventory(new ItemStack(ItemLoader.itemCamera))) {
if (!event.player.getEntityWorld().isRemote) {
Block.spawnAsEntity(event.player.getEntityWorld(), event.player.getPosition(),
new ItemStack(ItemLoader.itemCamera));
}
}
if (!event.player.inventory.addItemStackToInventory(new ItemStack(Blocks.IRON_BLOCK, 3))) {
if (!event.player.getEntityWorld().isRemote) {
Block.spawnAsEntity(event.player.getEntityWorld(), event.player.getPosition(),
new ItemStack(Blocks.IRON_BLOCK, 3));
}
}
if (!event.player.inventory.addItemStackToInventory(new ItemStack(Items.ENDER_EYE))) {
if (!event.player.getEntityWorld().isRemote) {
Block.spawnAsEntity(event.player.getEntityWorld(), event.player.getPosition(),
new ItemStack(Items.ENDER_EYE));
}
}
break;
}
}
}
}
示例11: dropBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
private void dropBlock()
{
Block.spawnAsEntity(this.worldObj, new BlockPos(this), new ItemStack(Items.armor_stand));
this.dropContents();
}
示例12: dropBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
private void dropBlock()
{
Block.spawnAsEntity(this.world, new BlockPos(this), new ItemStack(Items.ARMOR_STAND));
this.dropContents();
}
示例13: dropBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
private void dropBlock()
{
Block.spawnAsEntity(this.worldObj, new BlockPos(this), new ItemStack(Items.ARMOR_STAND));
this.dropContents();
}