本文整理汇总了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));
}
示例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());
}
示例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();
}
示例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());
}
示例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();
}
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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();
}
}
示例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);
}