當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockFactory類代碼示例

本文整理匯總了Java中nova.core.block.BlockFactory的典型用法代碼示例。如果您正苦於以下問題:Java BlockFactory類的具體用法?Java BlockFactory怎麽用?Java BlockFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BlockFactory類屬於nova.core.block包,在下文中一共展示了BlockFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerNOVAToMinecraft

import nova.core.block.BlockFactory; //導入依賴的package包/類
private void registerNOVAToMinecraft() {
	BlockManager blockManager = Game.blocks();

	//Register air block
	BlockFactory airBlock = new BlockFactory("air", () -> new BWBlock(Blocks.air) {
		@Override
		public boolean canReplace() {
			return true;
		}
	}, evt -> {});

	blockManager.register(airBlock);

	//NOTE: There should NEVER be blocks already registered in preInit() stage of a NativeConverter.
	Game.events().on(BlockEvent.Register.class).bind(evt -> registerNovaBlock(evt.blockFactory));
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:17,代碼來源:BlockConverter.java

示例2: registerNovaBlock

import nova.core.block.BlockFactory; //導入依賴的package包/類
private void registerNovaBlock(BlockFactory blockFactory) {
	FWBlock blockWrapper = new FWBlock(blockFactory);
	blockFactoryMap.put(blockFactory, blockWrapper);
	String blockId = blockFactory.getID();
	if (!blockId.contains(":"))
		blockId = NovaLauncher.instance().flatMap(NovaLauncher::getCurrentMod).map(Mod::id).orElse("nova") + ':' + blockId;
	GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId);
	NovaMinecraft.proxy.postRegisterBlock(blockWrapper);

	if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) {
		//Add into creative tab
		Category category = blockWrapper.dummy.components.get(Category.class);
		blockWrapper.setCreativeTab(CategoryConverter.instance().toNative(category, blockWrapper));
	}

	Game.logger().info("Registered block: {}", blockFactory.getID());
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:18,代碼來源:BlockConverter.java

示例3: FWBlock

import nova.core.block.BlockFactory; //導入依賴的package包/類
public FWBlock(BlockFactory factory) {
	//TODO: Hack build() method
	super(getMcMaterial(factory));
	this.factory = factory;
	this.dummy = factory.build();
	if (dummy.components.has(BlockProperty.BlockSound.class)) {
		this.stepSound = new FWBlockSound(dummy.components.get(BlockProperty.BlockSound.class));
	} else {
		BlockProperty.BlockSound properties = dummy.components.add(new BlockProperty.BlockSound());
		properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound("", soundTypeStone.getBreakSound()));
		properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", soundTypeStone.getPlaceSound()));
		properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound("", soundTypeStone.getStepSound()));
		this.stepSound = soundTypeStone;
	}
	this.blockClass = dummy.getClass();

	// Recalculate super constructor things after loading the block properly
	this.fullBlock = isOpaqueCube();
	this.lightOpacity = isOpaqueCube() ? 255 : 0;
	this.translucent = !isOpaqueCube();
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:22,代碼來源:FWBlock.java

示例4: registerNovaBlock

import nova.core.block.BlockFactory; //導入依賴的package包/類
private void registerNovaBlock(BlockFactory blockFactory) {
	FWBlock blockWrapper = new FWBlock(blockFactory);
	blockFactoryMap.put(blockFactory, blockWrapper);
	NovaMinecraft.proxy.registerBlock(blockWrapper);
	String blockId = blockFactory.getID();
	if (!blockId.contains(":"))
		blockId = NovaLauncher.instance().flatMap(NovaLauncher::getCurrentMod).map(Mod::id).orElse("nova") + ':' + blockId;
	GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId);

	if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) {
		//Add into creative tab
		Category category = blockWrapper.dummy.components.get(Category.class);
		blockWrapper.setCreativeTab(CategoryConverter.instance().toNative(category, blockWrapper));
	}

	Game.logger().info("Registered block: {}", blockFactory.getID());
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:18,代碼來源:BlockConverter.java

示例5: FWBlock

import nova.core.block.BlockFactory; //導入依賴的package包/類
public FWBlock(BlockFactory factory) {
	//TODO: Hack build() method
	super(getMcMaterial(factory));
	this.factory = factory;
	this.dummy = factory.build();
	if (dummy.components.has(BlockProperty.BlockSound.class)) {
		this.stepSound = new FWBlockSound(dummy.components.get(BlockProperty.BlockSound.class));
	} else {
		BlockProperty.BlockSound properties = dummy.components.add(new BlockProperty.BlockSound());
		properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound("", soundTypeStone.getBreakSound()));
		properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", soundTypeStone.func_150496_b()));
		properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound("", soundTypeStone.getStepResourcePath()));
		this.stepSound = soundTypeStone;
	}
	this.blockClass = dummy.getClass();

	// Recalculate super constructor things after loading the block properly
	this.opaque = isOpaqueCube();
	this.lightOpacity = isOpaqueCube() ? 255 : 0;

	if (FMLCommonHandler.instance().getSide().isClient()) {
		blockRenderingID = RenderingRegistry.getNextAvailableRenderId();
	}
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:25,代碼來源:FWBlock.java

示例6: createLauncher

import nova.core.block.BlockFactory; //導入依賴的package包/類
/**
 * Creates a fake launcher to allow mods to unit test.
 * @return
 */
public NovaLauncher createLauncher(Class<?>... modClasses) {
	DependencyInjectionEntryPoint diep = new DependencyInjectionEntryPoint();

	getModules().forEach(diep::install);

	NovaLauncher launcher = new NovaLauncher(diep, new HashSet<>(Arrays.asList(modClasses)));

	Game.inject(diep);

	/**
	 * Register fake air block
	 */
	Game.blocks().register(new BlockFactory("air", Block::new, evt -> {}));

	launcher.generateDependencies();
	launcher.load();

	//Handle all content loads
	Game.language().init();
	Game.render().init();
	Game.blocks().init();
	Game.items().init();
	Game.entities().init();
	Game.recipes().init();

	return launcher;
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:32,代碼來源:NovaLauncherTestFactory.java

示例7: setBlock

import nova.core.block.BlockFactory; //導入依賴的package包/類
@Override
public boolean setBlock(Vector3D position, BlockFactory factory) {
	Block newBlock = factory.build();
	BlockTransform component = new BlockTransform();
	component.setPosition(position);
	component.setWorld(this);
	newBlock.components.add(component);
	blockMap.put(position, newBlock);
	return true;
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:11,代碼來源:FakeWorld.java

示例8: testForBlock

import nova.core.block.BlockFactory; //導入依賴的package包/類
@Test
public void testForBlock() {
	BlockFactory block = Game.blocks().register("test:block", Block::new);
	ItemFactory itemBlock = Game.items().getItemFromBlock(block);

	assertThat(ItemIngredient.forBlock(block).getPossibleItemIds()).hasSize(1).containsExactly(block.getID());
	assertThat(ItemIngredient.forBlock(block).getExampleItems()).hasSize(1).containsExactly(itemBlock.build());

	assertThat(ItemIngredient.forBlock(block).matches(itemBlock.build())).isTrue();
	assertThat(ItemIngredient.forBlock(block).isSubsetOf(ItemIngredient.forItem(itemBlock))).isTrue();

	assertThat(ItemIngredient.forBlock(block)).isEqualTo(ItemIngredient.forItem(itemBlock));
	assertThat(ItemIngredient.forBlock(block).toString()).isEqualTo("SpecificItemIngredient[test:block]");
	assertThat(ItemIngredient.forBlock(block).hashCode()).isEqualTo(ItemIngredient.forItem(itemBlock).hashCode());
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:16,代碼來源:SpecificItemIngredientTest.java

示例9: registerNOVAItem

import nova.core.block.BlockFactory; //導入依賴的package包/類
private void registerNOVAItem(ItemFactory itemFactory) {
	if (map.containsKey(itemFactory)) {
		// just a safeguard - don't map stuff twice
		return;
	}

	net.minecraft.item.Item itemWrapper;

	Item dummy = itemFactory.build();
	if (dummy instanceof ItemBlock) {
		BlockFactory blockFactory = ((ItemBlock) dummy).blockFactory;
		net.minecraft.block.Block mcBlock = BlockConverter.instance().toNative(blockFactory);
		itemWrapper = net.minecraft.item.Item.getItemFromBlock(mcBlock);
		if (itemWrapper == null) {
			throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID());
		}
	} else {
		itemWrapper = new FWItem(itemFactory);
	}

	MinecraftItemMapping minecraftItemMapping = new MinecraftItemMapping(itemWrapper, 0);
	map.put(itemFactory, minecraftItemMapping);

	// Don't register ItemBlocks twice
	if (!(dummy instanceof ItemBlock)) {
		NovaMinecraft.proxy.registerItem((FWItem) itemWrapper);
		String itemId = itemFactory.getID();
		if (!itemId.contains(":"))
			itemId = NovaLauncher.instance().flatMap(NovaLauncher::getCurrentMod).map(Mod::id).orElse("nova") + ':' + itemId;
		GameRegistry.registerItem(itemWrapper, itemId);

		if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) {
			//Add into creative tab
			Category category = dummy.components.get(Category.class);
			itemWrapper.setCreativeTab(CategoryConverter.instance().toNative(category, itemWrapper));
		}

		Game.logger().info("Registered item: {}", itemFactory.getID());
	}
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:41,代碼來源:ItemConverter.java

示例10: setBlock

import nova.core.block.BlockFactory; //導入依賴的package包/類
@Override
public boolean setBlock(Vector3D position, BlockFactory blockFactory) {
	net.minecraft.block.Block mcBlock = BlockConverter.instance().toNative(blockFactory);
	BlockPos pos = VectorConverter.instance().toNative(position);
	net.minecraft.block.Block actualBlock = mcBlock != null ? mcBlock : Blocks.air;
	IBlockState defaultState = actualBlock.getDefaultState();
	IBlockState extendedState = actualBlock.getExtendedState(defaultState, world(), pos);
	return world().setBlockState(pos, extendedState);
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:10,代碼來源:BWWorld.java

示例11: toNova

import nova.core.block.BlockFactory; //導入依賴的package包/類
@Override
public BlockFactory toNova(net.minecraft.block.Block nativeBlock) {
	//Prevent recursive wrapping
	if (nativeBlock instanceof FWBlock) {
		return ((FWBlock) nativeBlock).getFactory();
	}

	if (nativeBlock == Blocks.air) {
		return Game.blocks().getAirBlock();
	}

	return blockFactoryMap.inverse().get(nativeBlock);
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:14,代碼來源:BlockConverter.java

示例12: createBlock

import nova.core.block.BlockFactory; //導入依賴的package包/類
private static Block createBlock(String blockID) {
	Optional<BlockFactory> blockFactory = Game.blocks().get(blockID);
	if (blockFactory.isPresent()) {
		return blockFactory.get().build();
	} else {
		throw new RuntimeException("Error! Invalid NOVA block ID: " + blockID);
	}
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:9,代碼來源:FWTileLoader.java

示例13: getMcMaterial

import nova.core.block.BlockFactory; //導入依賴的package包/類
private static Material getMcMaterial(BlockFactory factory) {
	Block dummy = factory.build();
	if (dummy.components.has(BlockProperty.Opacity.class) || dummy.components.has(BlockProperty.Replaceable.class)) {
		// TODO allow color selection
		return new ProxyMaterial(MapColor.grayColor,
			dummy.components.getOp(BlockProperty.Opacity.class),
			dummy.components.getOp(BlockProperty.Replaceable.class));
	} else {
		return Material.piston;
	}
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:12,代碼來源:FWBlock.java

示例14: blockRegisterEvent

import nova.core.block.BlockFactory; //導入依賴的package包/類
private void blockRegisterEvent(BlockEvent.Register evt) {
	BlockFactory blockFactory = evt.blockFactory;

	Block dummy = blockFactory.build();
	if (dummy.components.has(Microblock.class) || dummy.components.has(Multiblock.class)) {
		//Sneaky block factory replacement
		MicroblockInjectFactory microblockInjectFactory = new MicroblockInjectFactory(evt.blockFactory);
		containedIDToFactory.put(evt.blockFactory.getID(), microblockInjectFactory);
		containedFactoryToFactory.put(evt.blockFactory, microblockInjectFactory);
		evt.blockFactory = microblockInjectFactory;
		evt.cancel();
	}
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Microblock,代碼行數:14,代碼來源:NovaMicroblock.java

示例15: MicroblockInjectFactory

import nova.core.block.BlockFactory; //導入依賴的package包/類
public MicroblockInjectFactory(BlockFactory containedFactory) {
	super("blockContainer-" + containedFactory.getID(),
		BlockContainer::new,
		evt -> {
			NovaMicroblock.instance.items.register("blockContainer-" + containedFactory.getID(), () -> new ItemBlockContainer(evt.blockFactory));
		}
	);

	this.containedFactory = containedFactory;
	//Check the contained factory's dummy, and injectToContainer components.
	BlockContainer dummy = (BlockContainer) build();

	//TODO: Changes in MB injection might not work
	NovaMicroblock.instance.componentInjection.injectToContainer(containedFactory.build(), dummy);
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Microblock,代碼行數:16,代碼來源:NovaMicroblock.java


注:本文中的nova.core.block.BlockFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。