@Override public void readCustomNBT(NBTTagCompound nbt){ super.readCustomNBT(nbt); for(EnumFacing facing : EnumFacing.HORIZONTALS){ if(nbt.hasKey(facing.getName().toLowerCase())){ NBTTagCompound nbtFace = nbt.getCompoundTag(facing.getName().toLowerCase()); if(nbtFace.hasKey("BaseType")){ int type = nbtFace.getInteger("BaseType"); BlockPlanks.EnumType base = BlockPlanks.EnumType.byMetadata(type); setBase(facing, base); } else if(nbtFace.hasKey("HasBase")){ setBase(facing, BlockPlanks.EnumType.OAK); } else { setBase(facing, null); } //setBase(facing, nbtFace.getBoolean("HasBase")); setPost(facing, 0, nbtFace.getBoolean("HasLeftPost")); setPost(facing, 1, nbtFace.getBoolean("HasRightPost")); setPost(facing, 2, nbtFace.getBoolean("HasTopPost")); } } }
@Override protected void runTest() { final ItemStack oakLog = new ItemStack(Blocks.LOG, 1, BlockPlanks.EnumType.OAK.getMetadata()); assertRegistered(oakLog, "logWood"); assertNotRegistered(oakLog, "blahblahblah"); final ItemStack jungleLog = new ItemStack(Blocks.LOG, 1, BlockPlanks.EnumType.JUNGLE.getMetadata()); assertRegistered(jungleLog, "logWood"); final ItemStack ironIngot = new ItemStack(Items.IRON_INGOT); assertRegistered(ironIngot, "ingotIron"); final ItemStack stone = new ItemStack(Blocks.STONE, 1, BlockStone.EnumType.STONE.getMetadata()); assertRegistered(stone, "stone"); final ItemStack andesite = new ItemStack(Blocks.STONE, 1, BlockStone.EnumType.ANDESITE.getMetadata()); assertNotRegistered(andesite, "stone"); final ItemStack record13 = new ItemStack(Items.RECORD_13); assertRegistered(record13, "record"); }
private static void addWinnowingRecipes() { IWinnowingMachineHandler winnowing = CulinaryCultivationAPI.winnowing; ItemStack tallGrass = new ItemStack(Blocks.TALLGRASS, 1, BlockTallGrass.EnumType.GRASS.getMeta()); ItemStack doubleTallGrass = new ItemStack(Blocks.DOUBLE_PLANT, 1, BlockDoublePlant.EnumPlantType.GRASS.getMeta()); //Culinary Cultivation outputs winnowing.addOutput(tallGrass, new ItemStack(CROP_SEEDS, 1, ProductType.CUCUMBER.getMetadata()), 10); winnowing.addOutput(tallGrass, new ItemStack(CROP_SEEDS, 1, ProductType.TOMATO.getMetadata()), 8); winnowing.addJunk(tallGrass, new ItemStack(GENERAL, 1, ItemGeneral.Type.CHAFF_PILE.getMetadata()), 10); winnowing.addRecipe(doubleTallGrass, new ItemStack(CROP_SEEDS, 1, ProductType.BLACK_PEPPER_DRUPE.getMetadata()), 18); winnowing.addRecipe(doubleTallGrass, new ItemStack(CROP_SEEDS, 1, ProductType.CORN.getMetadata()), 8); //Vanilla outputs winnowing.addOutput(tallGrass, new ItemStack(Items.WHEAT_SEEDS), 10); winnowing.addOutput(tallGrass, new ItemStack(Items.BEETROOT_SEEDS), 2); winnowing.addOutput(tallGrass, new ItemStack(Items.PUMPKIN_SEEDS), 1); winnowing.addRecipe(new ItemStack(Blocks.SAPLING, 1, BlockPlanks.EnumType.JUNGLE.getMetadata()), new ItemStack(Items.MELON_SEEDS), 1, new ItemStack(Blocks.DEADBUSH), 10); winnowing.addRecipe(new ItemStack(Items.WHEAT), new ItemStack(Items.WHEAT_SEEDS), 15, new ItemStack(GENERAL, 1, ItemGeneral.Type.CHAFF_PILE.getMetadata()), 90); }
@SubscribeEvent public void onSaplingGrow(SaplingGrowTreeEvent ev) { IBlockState state = ev.getWorld().getBlockState(ev.getPos()); Block block = state.getBlock(); if (block == Blocks.sapling) { BlockPlanks.EnumType type = state.getValue(BlockSapling.TYPE); switch (type) { case OAK: ev.setResult(Event.Result.DENY); new BirchTreeGenerator().generateTreeAt(ev.getWorld(), ev.getPos(), ev.getRand()); break; } } }
/** * Convert the given metadata into a BlockState for this Block */ @Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = getDefaultState().withProperty(VARIANT, BlockPlanks.EnumType.byMetadata((meta & 3) + 4)); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
/** * Convert the BlockState into the correct metadata value */ @Override public int getMetaFromState(IBlockState state) { byte b0 = 0; int i = b0 | ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4; switch (BlockReinforcedNewLog.SwitchEnumAxis.AXIS_LOOKUP[((BlockLog.EnumAxis)state.getValue(LOG_AXIS)).ordinal()]) { case 1: i |= 4; break; case 2: i |= 8; break; case 3: i |= 12; } return i; }
/** * Convert the given metadata into a BlockState for this Block */ @Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = getDefaultState().withProperty(VARIANT, BlockPlanks.EnumType.byMetadata((meta & 3) % 4)); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; }
/** * Convert the BlockState into the correct metadata value */ @Override public int getMetaFromState(IBlockState state) { byte b0 = 0; int i = b0 | ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); switch (BlockReinforcedOldLog.SwitchEnumAxis.AXIS_LOOKUP[((BlockLog.EnumAxis)state.getValue(LOG_AXIS)).ordinal()]) { case 1: i |= 4; break; case 2: i |= 8; break; case 3: i |= 12; } return i; }
public BlockBambooFence(WoodMaterial wood) { //TODO maptypes super(Material.WOOD,BlockPlanks.EnumType.OAK.getMapColor()); this.setSoundType(SoundType.WOOD); this.wood = wood; this.blockHardness = wood.getPlankBlockHardness(); this.blockResistance = wood.getBlastResistance(); this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); Blocks.FIRE.setFireInfo(this, 5, 20); this.setRegistryName(wood.getName()+"_fence"); }
public BlockWoodFence(WoodMaterial wood) { //TODO maptypes super(Material.WOOD,BlockPlanks.EnumType.OAK.getMapColor()); this.setSoundType(SoundType.WOOD); this.wood = wood; this.blockHardness = wood.getPlankBlockHardness(); this.blockResistance = wood.getBlastResistance(); this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); Blocks.FIRE.setFireInfo(this, 5, 20); this.setRegistryName(wood.getName()+"_fence"); }
public BlockBambooFence(WoodMaterial wood) { super(Material.WOOD, BlockPlanks.EnumType.OAK.getMapColor()); this.setSoundType(SoundType.WOOD); this.wood = wood; this.blockHardness = wood.getPlankBlockHardness(); this.blockResistance = wood.getBlastResistance(); this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); Blocks.FIRE.setFireInfo(this, 5, 20); this.setRegistryName(wood.getName() + "_fence"); }
public BlockWoodFence(WoodMaterial wood) { super(Material.WOOD, BlockPlanks.EnumType.OAK.getMapColor()); this.setSoundType(SoundType.WOOD); this.wood = wood; this.blockHardness = wood.getPlankBlockHardness(); this.blockResistance = wood.getBlastResistance(); this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); Blocks.FIRE.setFireInfo(this, 5, 20); this.setRegistryName(wood.getName() + "_fence"); }
public BlockWoodFenceGate(WoodMaterial wood) { super(BlockPlanks.EnumType.OAK); this.setSoundType(SoundType.WOOD); this.wood = wood; this.blockHardness = wood.getPlankBlockHardness(); this.blockResistance = wood.getBlastResistance(); this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); Blocks.FIRE.setFireInfo(this, 5, 20); this.setRegistryName(wood.getName() + "_fence_gate"); }
@SubscribeEvent public static void gatherDrop(BlockEvent.HarvestDropsEvent event) { if (event.getHarvester() != null && event.getHarvester().getRNG().nextInt(100) < 15) { //Drop lotus seeds if (event.getState().getBlock() == Blocks.WATERLILY) event.getDrops().add(new ItemStack(MooncakeConstants.LOTUS_SEED, 1)); //Drop jujubes if (event.getState().getBlock() == Blocks.LEAVES && event.getState().getProperties().containsValue(BlockPlanks.EnumType.SPRUCE)) event.getDrops().add(new ItemStack(MooncakeConstants.JUJUBE, 1)); } }
@Test public void test_deserialization_propertiesAsObject() { WrappedBlockState state = gson.fromJson("{ \"block\": \"minecraft:log\", \"properties\" : { \"variant\" : \"spruce\"} }", WrappedBlockState.class); IBlockState blockState = state.createState(); assertNotNull(state); assertNotNull(blockState); assertSame(Blocks.LOG, blockState.getBlock()); assertSame(BlockPlanks.EnumType.SPRUCE, blockState.getValue(BlockOldLog.VARIANT)); }
@Test public void test_deserialization_propertiesAsString() { WrappedBlockState state = gson.fromJson("{ \"block\": \"minecraft:log\", \"properties\" : \"variant=spruce,axis=z\" }", WrappedBlockState.class); IBlockState blockState = state.createState(); assertNotNull(state); assertNotNull(blockState); assertSame(Blocks.LOG, blockState.getBlock()); assertSame(BlockPlanks.EnumType.SPRUCE, blockState.getValue(BlockOldLog.VARIANT)); assertSame(BlockLog.EnumAxis.Z, blockState.getValue(BlockLog.LOG_AXIS)); }
@SubscribeEvent public void onVillageBlocks(BiomeEvent.GetVillageBlockID event) { IBlockState original = event.getOriginal(); if (event.getBiome() == ATGBiomes.TUNDRA) { if (original.getBlock() == Blocks.LOG || original.getBlock() == Blocks.LOG2) { event.setResult(Event.Result.DENY); event.setReplacement(Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE).withProperty(BlockLog.LOG_AXIS, original.getValue(BlockLog.LOG_AXIS))); } else if (original.getBlock() == Blocks.PLANKS) { event.setResult(Event.Result.DENY); event.setReplacement(Blocks.PLANKS.getDefaultState().withProperty(BlockPlanks.VARIANT, BlockPlanks.EnumType.SPRUCE)); } else if (original.getBlock() == Blocks.OAK_STAIRS) { event.setResult(Event.Result.DENY); event.setReplacement(Blocks.SPRUCE_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, original.getValue(BlockStairs.FACING))); } else if (original.getBlock() == Blocks.OAK_FENCE) { event.setResult(Event.Result.DENY); event.setReplacement(Blocks.SPRUCE_FENCE.getDefaultState()); } } else if (event.getBiome() == ATGBiomes.SCRUBLAND) { if (original.getBlock() == Blocks.LOG || original.getBlock() == Blocks.LOG2) { event.setResult(Event.Result.DENY); event.setReplacement(Blocks.LOG2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.ACACIA).withProperty(BlockLog.LOG_AXIS, original.getValue(BlockLog.LOG_AXIS))); } else if (original.getBlock() == Blocks.PLANKS) { event.setResult(Event.Result.DENY); event.setReplacement(Blocks.PLANKS.getDefaultState().withProperty(BlockPlanks.VARIANT, BlockPlanks.EnumType.ACACIA)); } else if (original.getBlock() == Blocks.OAK_STAIRS) { event.setResult(Event.Result.DENY); event.setReplacement(Blocks.ACACIA_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, original.getValue(BlockStairs.FACING))); } else if (original.getBlock() == Blocks.OAK_FENCE) { event.setResult(Event.Result.DENY); event.setReplacement(Blocks.ACACIA_FENCE.getDefaultState()); } } }
protected IBlockState func_189917_F_() { switch (this.mineShaftType) { case NORMAL: default: return Blocks.PLANKS.getDefaultState(); case MESA: return Blocks.PLANKS.getDefaultState().withProperty(BlockPlanks.VARIANT, BlockPlanks.EnumType.DARK_OAK); } }
public FruitTreeGenerator() { MinecraftForge.TERRAIN_GEN_BUS.register(this); for (FruitType fruitType : FruitType.values()) { generatorTreeMap.put(fruitType, new BaseTreeGenerator.Builder().minHeight(4).maxHeight(7) .log(BlockPlanks.EnumType.OAK) .altLeaves(BlockPlanks.EnumType.JUNGLE).leaves(FoodCraftReloaded.getProxy().getLoaderManager().getLoader(FruitEnumLoader.class).get().getInstanceMap(BlockFruitLeaves.class).get(fruitType).getDefaultState()).build()); } }
public void setBase(EnumFacing side, BlockPlanks.EnumType type){ if(type == null){ bases.remove(side); } else{ bases.put(side, type); } }
public EnderTreeNormalGen(boolean notify) { super(notify); this.minTreeHeight = 4; this.metaWood = Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK); this.oakLeaves = Blocks.LEAVES.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK).withProperty(BlockLeaves.CHECK_DECAY, false); this.enderLeaves = IWTechBlocks.BLOCK_ENDER_LEAVES.getDefaultState(); }
private void seedMap() { // Iterate through the blockmap looking for known pattern types. // Though they probably should all be registered with Forge // dictionary it's not a requirement. final Iterator<Block> itr = Block.REGISTRY.iterator(); while (itr.hasNext()) { final Block block = itr.next(); final String blockName = MCHelper.nameOf(block); if (block instanceof BlockCrops) { final BlockCrops crop = (BlockCrops) block; if (crop.getMaxAge() == 3) { this.registerBlocks("#beets", blockName); } else if (blockName.equals("minecraft:wheat")) { this.registerBlocks("#wheat", blockName); } else if (crop.getMaxAge() == 7) { this.registerBlocks("#crop", blockName); } } else if (block instanceof BlockSapling) { this.registerBlocks("#sapling", blockName); } else if (block instanceof BlockReed) { this.registerBlocks("#reed", blockName); } else if (block instanceof BlockFence) { this.registerBlocks("#fence", blockName); } else if (block instanceof BlockFlower || block instanceof BlockMushroom) { this.registerBlocks("NOT_EMITTER", blockName); } else if (block instanceof BlockLog || block instanceof BlockPlanks) { this.registerBlocks("wood", blockName); } else if (block instanceof BlockDoor) { this.registerBlocks("bluntwood", blockName); } else if (block instanceof BlockLeaves) { this.registerBlocks("leaves", blockName); } else if (block instanceof BlockOre) { this.registerBlocks("ore", blockName); } else if (block instanceof BlockIce) { this.registerBlocks("ice", blockName); } } }
private static void registerVanillaVariantProps() { // TODO: omit similar blocks registerVariantProperty(BlockStone.VARIANT); registerVariantProperty(BlockPlanks.VARIANT); registerVariantProperty(BlockSapling.TYPE); registerVariantProperty(BlockDirt.VARIANT); registerVariantProperty(BlockSand.VARIANT); registerVariantProperty(BlockOldLog.VARIANT); registerVariantProperty(BlockNewLog.VARIANT); registerVariantProperty(BlockOldLeaf.VARIANT); registerVariantProperty(BlockNewLeaf.VARIANT); registerVariantProperty(BlockSandStone.TYPE); registerVariantProperty(BlockTallGrass.TYPE); registerVariantProperty(BlockPistonExtension.TYPE); registerVariantProperty(BlockColored.COLOR); registerVariantProperty(BlockPistonMoving.TYPE); registerVariantProperty(Blocks.YELLOW_FLOWER.getTypeProperty()); registerVariantProperty(Blocks.RED_FLOWER.getTypeProperty()); registerVariantProperty(BlockStoneSlab.VARIANT); registerVariantProperty(BlockWoodSlab.VARIANT); registerVariantProperty(BlockAnvil.DAMAGE); registerVariantProperty(BlockQuartz.VARIANT); registerVariantProperty(BlockCarpet.COLOR); registerVariantProperty(BlockDoublePlant.VARIANT); registerVariantProperty(BlockStainedGlass.COLOR); registerVariantProperty(BlockStainedGlassPane.COLOR); registerVariantProperty(BlockPrismarine.VARIANT); registerVariantProperty(BlockRedSandstone.TYPE); registerVariantProperty(BlockStoneSlabNew.VARIANT); }