net.minecraft.block.properties.PropertyInteger Java Examples
The following examples show how to use
net.minecraft.block.properties.PropertyInteger.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockHelper.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
/** * Gets the property for the given max age of a crop. Returns the same instance of a property for the same max age. */ @Nonnull public static PropertyInteger getCropAgeProperty(int maxAge) { checkArgument(maxAge >= 0 && maxAge <= 15, "Invalid maxAge : " + maxAge); return cropAgeProperties.computeIfAbsent(maxAge, BlockHelper::createCropAgeProperty); }
Example #2
Source File: BlockHelperTests.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@Test public void test_getCropAgeProperty() { PropertyInteger property1 = BlockHelper.getCropAgeProperty(9); assertEquals(10, property1.getAllowedValues().size()); assertTrue(property1.getAllowedValues().contains(0)); assertTrue(property1.getAllowedValues().contains(9)); }
Example #3
Source File: BlockHelperTests.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@Test public void test_getCropAgeProperty_multipleCallsReturnsSameProperty() { PropertyInteger property1 = BlockHelper.getCropAgeProperty(9); PropertyInteger property2 = BlockHelper.getCropAgeProperty(9); assertEquals(10, property1.getAllowedValues().size()); assertSame(property1, property2); }
Example #4
Source File: BlockLeekCrop.java From TofuCraftReload with MIT License | 4 votes |
protected PropertyInteger getAgeProperty() { return AGE; }
Example #5
Source File: BlockPepperCrop.java From Sakura_mod with MIT License | 4 votes |
public PropertyInteger getAgeProperty() { return AGE; }
Example #6
Source File: BlockVanillaCrop.java From Sakura_mod with MIT License | 4 votes |
protected PropertyInteger getAgeProperty() { return AGE; }
Example #7
Source File: BlockGrapeVine.java From Sakura_mod with MIT License | 4 votes |
protected PropertyInteger getAgeProperty() { return AGE; }
Example #8
Source File: BlockGrapeLeaves.java From Sakura_mod with MIT License | 4 votes |
protected PropertyInteger getAgeProperty() { return AGE; }
Example #9
Source File: BlockNoodle.java From Sakura_mod with MIT License | 4 votes |
protected PropertyInteger getAgeProperty() { return CUTTING; }
Example #10
Source File: BlockChestnut.java From Sakura_mod with MIT License | 4 votes |
protected PropertyInteger getAgeProperty() { return AGE; }
Example #11
Source File: BlockTataraSmelting.java From Sakura_mod with MIT License | 4 votes |
public PropertyInteger getTimerProperty(){ return Timer; }
Example #12
Source File: PlantHelper.java From EmergingTechnology with MIT License | 4 votes |
public static int getPlantGrowthAtPosition(World world, BlockPos position) { IBlockState state = world.getBlockState(position); if (state == null) return 0; Block block = state.getBlock(); if (block instanceof BlockReed || block instanceof BlockCactus) { int growth = 0; Block[] aboveBlocks = new Block[] { world.getBlockState(position.add(0, 1, 0)).getBlock(), world.getBlockState(position.add(0, 2, 0)).getBlock(), world.getBlockState(position.add(0, 3, 0)).getBlock() }; for (Block aboveBlock : aboveBlocks) { if (aboveBlock instanceof BlockReed || block instanceof BlockCactus) { growth++; } else { return growth; } ; } return growth; } ; if (block instanceof BlockCrops) { // int maxAge = 0; int age = 0; // tnx draco Iterator<IProperty<?>> properties = state.getPropertyKeys().iterator(); while (properties.hasNext()) { IProperty<?> p = properties.next(); if (p instanceof PropertyInteger && p.getName().toLowerCase().equals("age")) { PropertyInteger ageProperty = (PropertyInteger) p; // maxAge = Iterables.getLast(ageProperty.getAllowedValues()); age = state.getValue(ageProperty); } } return age; } return 0; }
Example #13
Source File: PlantHelper.java From EmergingTechnology with MIT License | 4 votes |
public static boolean isCropAtPositionReadyForHarvest(World world, BlockPos position) { IBlockState state = world.getBlockState(position); if (state == null) return false; Block block = state.getBlock(); if (isStackableCropReady(world, block, position)) { return true; } if (block instanceof BlockCrops) { int maxAge = 0; int age = 0; // tnx draco Iterator<IProperty<?>> properties = state.getPropertyKeys().iterator(); while (properties.hasNext()) { IProperty<?> p = properties.next(); if (p instanceof PropertyInteger && p.getName().toLowerCase().equals("age")) { PropertyInteger ageProperty = (PropertyInteger) p; maxAge = Iterables.getLast(ageProperty.getAllowedValues()); age = state.getValue(ageProperty); } } if (maxAge == 0) { return false; } if (age == maxAge) { return true; } } return false; }
Example #14
Source File: BlockHelper.java From customstuff4 with GNU General Public License v3.0 | 4 votes |
private static PropertyInteger createCropAgeProperty(int maxAge) { return PropertyInteger.create("age", 0, maxAge); }
Example #15
Source File: BlockCrops.java From customstuff4 with GNU General Public License v3.0 | 4 votes |
@Override protected PropertyInteger getAgeProperty() { return ageProperty; }