net.minecraft.util.MovingObjectPosition#net.minecraft.block.state.IBlockState源码实例Demo

下面列出了net.minecraft.util.MovingObjectPosition#net.minecraft.block.state.IBlockState 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: NOVA-Core   文件: FWBlock.java
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
	Block blockInstance;

	// see onBlockHarvested for why the harvestedBlocks hack exists
	// this method will be called exactly once after destroying the block
	BlockPosition position = new BlockPosition((World) world, pos.getX(), pos.getY(), pos.getZ());
	if (harvestedBlocks.containsKey(position)) {
		blockInstance = harvestedBlocks.remove(position);
	} else {
		blockInstance = getBlockInstance(world, pos);
	}

	Block.DropEvent event = new Block.DropEvent(blockInstance);
	blockInstance.events.publish(event);

	return event.drops
		.stream()
		.map(ItemConverter.instance()::toNative)
		.collect(Collectors.toList());
}
 
源代码2 项目: EmergingTechnology   文件: Bioreactor.java
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote) {
        IBlockState north = worldIn.getBlockState(pos.north());
        IBlockState east = worldIn.getBlockState(pos.east());
        IBlockState south = worldIn.getBlockState(pos.south());
        IBlockState west = worldIn.getBlockState(pos.west());

        EnumFacing face = (EnumFacing) state.getValue(FACING);

        if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) {
            face = EnumFacing.SOUTH;
        } else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) {
            face = EnumFacing.NORTH;
        } else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) {
            face = EnumFacing.WEST;
        } else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) {
            face = EnumFacing.EAST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, face));
    }
}
 
源代码3 项目: GT-Classic   文件: GTItemJackHammer.java
public boolean shouldBreak(EntityPlayer playerIn, World worldIn, BlockPos originalPos, BlockPos pos) {
	if (originalPos.equals(pos)) {
		return false;
	}
	IBlockState blockState = worldIn.getBlockState(pos);
	if (blockState.getMaterial() == Material.AIR) {
		return false;
	}
	if (blockState.getMaterial().isLiquid()) {
		return false;
	}
	float blockHardness = blockState.getPlayerRelativeBlockHardness(playerIn, worldIn, pos);
	if (blockHardness == -1.0F) {
		return false;
	}
	float originalHardness = worldIn.getBlockState(originalPos).getPlayerRelativeBlockHardness(playerIn, worldIn, originalPos);
	if ((originalHardness / blockHardness) > 10.0F) {
		return false;
	}
	return true;
}
 
源代码4 项目: OpenModsLib   文件: OpenBlock.java
@SuppressWarnings("deprecation") // TODO review
@Override
public boolean eventReceived(IBlockState state, World world, BlockPos blockPos, int eventId, int eventParam) {
	if (eventId < 0 && !world.isRemote) {
		switch (eventId) {
			case EVENT_ADDED:
				return onBlockAddedNextTick(world, blockPos, state);
		}

		return false;
	}
	if (hasTileEntity) {
		super.eventReceived(state, world, blockPos, eventId, eventParam);
		TileEntity te = world.getTileEntity(blockPos);
		return te != null? te.receiveClientEvent(eventId, eventParam) : false;
	} else {
		return super.eventReceived(state, world, blockPos, eventId, eventParam);
	}
}
 
源代码5 项目: NOVA-Core   文件: FWBlock.java
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity entity) {
	Block blockInstance = getBlockInstance(world, VectorConverter.instance().toNova(pos));
	blockInstance.components.getOp(Collider.class).ifPresent(
		collider -> {
			Set<Cuboid> boxes = collider.occlusionBoxes.apply(Optional.ofNullable(entity != null ? EntityConverter.instance().toNova(entity) : null));

			list.addAll(
				boxes
					.stream()
					.map(c -> c.add(VectorConverter.instance().toNova(pos)))
					.filter(c -> c.intersects(CuboidConverter.instance().toNova(mask)))
					.map(CuboidConverter.instance()::toNative)
					.collect(Collectors.toList())
			);
		}
	);
}
 
@Override
public IBlockState getExtendedState(IBlockState oldState, IBlockAccess world, BlockPos pos)
{
    if (this.isCamoBlock())
    {
        TileEntityEnderUtilities te = getTileEntitySafely(world, pos, TileEntityEnderUtilities.class);

        if (te != null)
        {
            IExtendedBlockState state = (IExtendedBlockState) oldState;
            state = state.withProperty(CAMOBLOCKSTATE, te.getCamoState());
            state = state.withProperty(CAMOBLOCKSTATEEXTENDED, te.getCamoExtendedState());
            return state;
        }
    }

    return oldState;
}
 
源代码7 项目: BaseMetals   文件: ItemMetalCrackHammer.java
@Override
public boolean onBlockDestroyed(final ItemStack tool, final World world, 
		final IBlockState target, final BlockPos coord, final EntityLivingBase player) {
	if(!world.isRemote && this.canHarvestBlock(target)){
		IBlockState bs = world.getBlockState(coord);
		ICrusherRecipe recipe = getCrusherRecipe(bs);
		if(recipe != null){
			ItemStack output = recipe.getOutput().copy();
			world.setBlockToAir(coord);
			if(output != null){
				int num = output.stackSize;
				output.stackSize = 1;
				for(int i = 0; i < num; i++){
					world.spawnEntityInWorld(new EntityItem(world, coord.getX()+0.5, coord.getY()+0.5, coord.getZ()+0.5, output.copy()));
				}
			}
		}
	}
	return super.onBlockDestroyed(tool, world, target, coord, player);
	
}
 
源代码8 项目: enderutilities   文件: BlockStorage.java
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
    if (state.getValue(TYPE).retainsContents())
    {
        world.updateComparatorOutputLevel(pos, this);
        world.removeTileEntity(pos);
    }
    else
    {
        super.breakBlock(world, pos, state);
    }
}
 
源代码9 项目: Sakura_mod   文件: TileEntityShoji.java
public void setFacing(EnumFacing facing) {
    this.facing = facing;
    markDirty(); 
    if (world != null) {
        IBlockState state = world.getBlockState(getPos());
        world.notifyBlockUpdate(getPos(), state, state, 3);
    }
}
 
源代码10 项目: Production-Line   文件: ItemPLTreetap.java
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xOffset, float yOffset, float zOffset) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    if (block == BlockName.rubber_wood.getInstance()) {
        attemptExtract(player, world, pos, side, state, null);
        if (!world.isRemote) {
            stack.damageItem(1, player);
        }

        return EnumActionResult.SUCCESS;
    } else {
        return EnumActionResult.PASS;
    }
}
 
源代码11 项目: Sakura_mod   文件: BlockStoneMortar.java
@Override
  public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
      if (world.isRemote) {
          return true;
      }
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof TileEntityStoneMortar) {
    player.openGui(SakuraMain.instance, SakuraGuiHandler.ID_STONEMORTAR, world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
  }
 
@Override
public boolean shouldSideBeRendered(IBlockState blockState,
		IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
	
	if(side.getFrontOffsetY() != 0) {
		if(blockAccess.getBlockState(pos).getBlock() == this)
		return true;
	}
	
	return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
}
 
源代码13 项目: ExNihiloAdscensio   文件: BlockInfestedLeaves.java
@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world,
		IBlockState blockState, IProbeHitData data) {

	TileInfestedLeaves tile = (TileInfestedLeaves) world.getTileEntity(data.getPos());

	if (tile.getProgress() >= 1.0F) {
		probeInfo.text("Progress: Done");
	} else {
		probeInfo.progress((int) (tile.getProgress()*100), 100);
	}

}
 
源代码14 项目: seppuku   文件: BlockHighlightModule.java
@Listener
public void render3D(EventRender3D event) {
    final Minecraft mc = Minecraft.getMinecraft();
    final RayTraceResult ray = mc.objectMouseOver;
    if(ray.typeOfHit == RayTraceResult.Type.BLOCK) {

        final BlockPos blockpos = ray.getBlockPos();
        final IBlockState iblockstate = mc.world.getBlockState(blockpos);

        if (iblockstate.getMaterial() != Material.AIR && mc.world.getWorldBorder().contains(blockpos)) {
            final Vec3d interp = MathUtil.interpolateEntity(mc.player, mc.getRenderPartialTicks());
            RenderUtil.drawBoundingBox(iblockstate.getSelectedBoundingBox(mc.world, blockpos).grow(0.0020000000949949026D).offset(-interp.x, -interp.y, -interp.z), 1.5f, 0xFF9900EE);
        }
    }
}
 
源代码15 项目: NOVA-Core   文件: FWBlock.java
@Override
@Deprecated
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) {
	Block blockInstance = getBlockInstance(world, pos);

	if (blockInstance.components.has(Collider.class)) {
		Collider collider = blockInstance.components.get(Collider.class);
		Set<Cuboid> cuboids = collider.selectionBoxes.apply(Optional.empty());
		Cuboid cuboid = cuboids.stream().reduce(collider.boundingBox.get(),
			(c1, c2) -> new Cuboid(Vector3DUtil.min(c1.min, c2.min), Vector3DUtil.max(c1.max, c2.max)));
		return CuboidConverter.instance().toNative(cuboid.add(VectorConverter.instance().toNova(pos)));
	}
	return super.getSelectedBoundingBox(state, world, pos);
}
 
源代码16 项目: litematica   文件: ItemUtils.java
public static ItemStack getStateToItemOverride(IBlockState state)
{
    if (state.getBlock() == Blocks.LAVA || state.getBlock() == Blocks.FLOWING_LAVA)
    {
        return new ItemStack(Items.LAVA_BUCKET);
    }
    else if (state.getBlock() == Blocks.WATER || state.getBlock() == Blocks.FLOWING_WATER)
    {
        return new ItemStack(Items.WATER_BUCKET);
    }

    return ItemStack.EMPTY;
}
 
源代码17 项目: GT-Classic   文件: GTTileMagicEnergyAbsorber.java
@SideOnly(Side.CLIENT)
@Override
public void randomTickDisplay(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
	if (this.isActive && this.portalMode
			&& worldIn.getBlockState(this.pos.offset(EnumFacing.DOWN)).getBlock() == Blocks.END_PORTAL) {
		for (EnumFacing facing : EnumFacing.HORIZONTALS) {
			BlockPos sidePos = pos.offset(facing);
			if (world.getBlockState(sidePos).isFullBlock()) {
				continue;
			}
			for (int k = 3; k > 0; --k) {
				ParticleManager er = Minecraft.getMinecraft().effectRenderer;
				float multPos = (float) (.1 * 2) + 0.9F;
				double x = (double) ((float) sidePos.getX() + 0.05F + rand.nextFloat() * multPos);
				double y = (double) ((float) sidePos.getY() + 0.0F + rand.nextFloat() * 0.5F);
				double z = (double) ((float) sidePos.getZ() + 0.05F + rand.nextFloat() * multPos);
				double[] velocity = new double[] { 0.0D, 7.6D, 0.0D };
				if (k < 4) {
					velocity[2] *= 0.55D;
				}
				float foo = rand.nextFloat() * .25F;
				float[] colour = new float[] { 0.0F, foo, foo };
				er.addEffect(new EntityChargePadAuraFX(this.world, x, y, z, 8, velocity, colour, false));
			}
		}
	}
}
 
源代码18 项目: EmergingTechnology   文件: Harvester.java
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    playerIn.openGui(EmergingTechnology.instance, Reference.GUI_HARVESTER, worldIn, pos.getX(), pos.getY(),
            pos.getZ());

    return true;
}
 
源代码19 项目: TFC2   文件: Core.java
public static IBlockState getNaturalLog(WoodType w)
{
	if(w == WoodType.Palm)
		return TFCBlocks.LogNaturalPalm.getDefaultState();
	if(w.getMeta() >= 16)
		return TFCBlocks.LogNatural2.getDefaultState().withProperty(BlockLogNatural2.WOOD, w);
	return TFCBlocks.LogNatural.getDefaultState().withProperty(BlockLogNatural.WOOD, w);
}
 
源代码20 项目: Cyberware   文件: ItemBrainUpgrade.java
@SubscribeEvent
public void handleMining(BreakSpeed event)
{
	EntityPlayer p = event.getEntityPlayer();
	
	ItemStack test = new ItemStack(this, 1, 3);
	if (CyberwareAPI.isCyberwareInstalled(p, test) && EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(p, test)) && isContextWorking(p) && !p.isSneaking())
	{
		IBlockState state = event.getState();
		ItemStack tool = p.getHeldItem(EnumHand.MAIN_HAND);
		
		if (tool != null && (tool.getItem() instanceof ItemSword || tool.getItem().getUnlocalizedName().contains("sword"))) return;
		
		if (isToolEffective(tool, state)) return;
		
		for (int i = 0; i < 10; i++)
		{
			if (i != p.inventory.currentItem)
			{
				ItemStack potentialTool = p.inventory.mainInventory[i];
				if (isToolEffective(potentialTool, state))
				{
					p.inventory.currentItem = i;
					return;
				}
			}
		}
	}
}
 
源代码21 项目: Valkyrien-Skies   文件: BlockNetworkRelay.java
/**
 * Convert the BlockState into the correct metadata value
 */
@Override
public int getMetaFromState(IBlockState state) {
    int i;

    switch (state.getValue(FACING)) {
        case EAST:
            i = 1;
            break;
        case WEST:
            i = 2;
            break;
        case SOUTH:
            i = 3;
            break;
        case NORTH:
            i = 4;
            break;
        case UP:
        default:
            i = 5;
            break;
        case DOWN:
            i = 0;
    }

    return i;
}
 
源代码22 项目: Cyberware   文件: BlockBlueprintArchive.java
@Override
public IBlockState getStateFromMeta(int meta)
{
	EnumFacing enumfacing = EnumFacing.getFront(meta);

	if (enumfacing.getAxis() == EnumFacing.Axis.Y)
	{
		enumfacing = EnumFacing.NORTH;
	}

	return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
源代码23 项目: AdvancedRocketry   文件: BlockSeal.java
public void clearBlob(World worldIn, BlockPos pos, IBlockState state) {
	AtmosphereHandler atmhandler = AtmosphereHandler.getOxygenHandler(worldIn.provider.getDimension());
	if(atmhandler == null)
		return;
	
	for(EnumFacing dir : EnumFacing.VALUES) {
		BlobHandler handler = blobList.remove(new HashedBlockPosition(pos.offset(dir)));
		if (handler != null) atmhandler.unregisterBlob(handler);
		
		//fireCheckAllDirections(worldIn, pos.offset(dir), dir);
	}
}
 
源代码24 项目: BetterChests   文件: BlockBBarrel.java
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	TileEntity te = world.getTileEntity(pos);
	if (te != null && te instanceof TileEntityBBarrel) {
		TileEntityBBarrel chest = (TileEntityBBarrel) te;
		ItemStack currentItem = player.getHeldItem(hand);
		if (currentItem.getItem() instanceof IUpgrade) {
			IUpgrade upgrade = (IUpgrade) currentItem.getItem();
			ItemStack toPut = currentItem.copy();
			toPut.setCount(1);
			if (upgrade.canBePutInChest(chest, toPut)) {
				if (InvUtil.putStackInInventoryFirst(toPut, chest.getUpgradePart(), false, false, false, null).isEmpty()) {
					currentItem.setCount(currentItem.getCount() - 1);
					chest.markDirty();
					return true;
				}
			}
		}
		if (player.isSneaking()) {
			ContainerHelper.openGui(chest, player, (short) 0);
		} else {
			ItemStack stack = player.getHeldItem(hand);
			if (stack.isEmpty()) {
				stack = chest.getChestPart().getDummy();
				for (ItemStack other : InvUtil.getFromInv(player.inventory)) {
					if (ItemUtil.areItemsSameMatchingIdDamageNbt(stack, other)) {
						ItemStack curr = InvUtil.putStackInInventoryInternal(other, chest.getChestPart(), false);
						other.setCount(curr.getCount());
						if (!other.isEmpty()) {
							break;
						}
					}
				}
			} else if (chest.getChestPart().isItemValidForSlot(0, stack)) {
				stack.setCount(InvUtil.putStackInInventoryInternal(stack, chest.getChestPart(), false).getCount());
			}
		}
	}
	return true;
}
 
源代码25 项目: Production-Line   文件: BlockWaterHyacinth.java
/**
 * Called When an Entity Collided with the Block
 */
@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
    super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);

    if (entityIn instanceof EntityBoat) {
        worldIn.destroyBlock(new BlockPos(pos), true);
    }
}
 
源代码26 项目: EmergingTechnology   文件: SolarGlass.java
@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos,
        EnumFacing side) {
    IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
    Block block = iblockstate.getBlock();

    if (block == this || block == ModBlocks.clearplasticblock) {
        return false;
    }

    return block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side);
}
 
源代码27 项目: AdvancedRocketry   文件: BlockAlienSapling.java
public void grow(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (((Integer)state.getValue(STAGE)).intValue() == 0)
    {
        worldIn.setBlockState(pos, state.cycleProperty(STAGE), 4);
    }
    else
    {
        this.generateTree(worldIn, pos, state, rand);
    }
}
 
源代码28 项目: AgriCraft   文件: PlayerInteractEventHandler.java
/**
 * Event handler to disable vanilla farming.
 * 
 * @param event
 */
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void vanillaSeedPlanting(PlayerInteractEvent.RightClickBlock event) {
    // If not disabled, don't bother.
    if (!AgriCraftConfig.disableVanillaFarming) {
        return;
    }

    // Fetch the event itemstack.
    final ItemStack stack = event.getItemStack();

    // If the stack is null, or otherwise invalid, who cares?
    if (!StackHelper.isValid(stack)) {
        return;
    }

    // If the item in the player's hand is not a seed, who cares?
    if (!AgriApi.getSeedRegistry().hasAdapter(stack)) {
        return;
    }

    // Fetch world information.
    final BlockPos pos = event.getPos();
    final World world = event.getWorld();
    final IBlockState state = world.getBlockState(pos);

    // Fetch the block at the location.
    final Block block = state.getBlock();

    // If clicking crop block, who cares?
    if (block instanceof IAgriCrop) {
        return;
    }

    // If the item is an instance of IPlantable we need to perfom an extra check.
    if (stack.getItem() instanceof IPlantable) {
        // If the clicked block cannot support the given plant, then who cares?
        if (!block.canSustainPlant(state, world, pos, EnumFacing.UP, (IPlantable) stack.getItem())) {
            return;
        }
    }

    // If clicking crop tile, who cares?
    if (WorldHelper.getTile(event.getWorld(), event.getPos(), IAgriCrop.class).isPresent()) {
        return;
    }

    // The player is attempting to plant a seed, which is simply unacceptable.
    // We must deny this event.
    event.setUseItem(Event.Result.DENY);

    // If we are on the client side we are done.
    if (event.getSide().isClient()) {
        return;
    }

    // Should the server notify the player that vanilla farming has been disabled?
    if (AgriCraftConfig.showDisabledVanillaFarmingWarning) {
        MessageUtil.messagePlayer(event.getEntityPlayer(), "`7Vanilla planting is disabled!`r");
    }
}
 
源代码29 项目: enderutilities   文件: BlockEnergyBridge.java
@Override
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
{
    return 15;
}
 
源代码30 项目: AdvancedRocketry   文件: BlockLaser.java
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos,
		Block blockIn, BlockPos fromPos) {
	if(blockIn != this)
		((TileSpaceLaser)worldIn.getTileEntity(pos)).checkCanRun();
}