当前位置: 首页>>代码示例>>Java>>正文


Java PropertyInteger类代码示例

本文整理汇总了Java中net.minecraft.block.properties.PropertyInteger的典型用法代码示例。如果您正苦于以下问题:Java PropertyInteger类的具体用法?Java PropertyInteger怎么用?Java PropertyInteger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PropertyInteger类属于net.minecraft.block.properties包,在下文中一共展示了PropertyInteger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readFromNBT

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);

    if (compound.hasKey("plantDomain") && compound.hasKey("plantPath")) {
        ResourceLocation location = new ResourceLocation(
                compound.getString("plantDomain"),
                compound.getString("plantPath"));
        Block block = Block.REGISTRY.getObject(location);
        if (block != null) {
            this.plantedThing = block.getDefaultState();
            this.onPlantedThingChanged();
        }
    }

    if (compound.hasKey("plantAge") && (this.plantedThing != null)) {
        int age = compound.getInteger("plantAge");
        PropertyInteger ageProperty = this.getAgeProperty(this.plantedThing);
        if (ageProperty != null) {
            this.plantedThing = this.plantedThing.withProperty(ageProperty, age);
            this.onPlantedThingChanged();
        }
    }
}
 
开发者ID:faceofcat,项目名称:Mekfarm,代码行数:25,代码来源:CropClonerEntity.java

示例2: writeToNBT

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    compound = super.writeToNBT(compound);

    if (this.plantedThing != null) {
        ResourceLocation resource = this.plantedThing.getBlock().getRegistryName();
        compound.setString("plantDomain", resource.getResourceDomain());
        compound.setString("plantPath", resource.getResourcePath());
        PropertyInteger ageProperty = this.getAgeProperty(this.plantedThing);
        if (ageProperty != null) {
            compound.setInteger("plantAge", this.plantedThing.getValue(ageProperty));
        }
    }

    return compound;
}
 
开发者ID:faceofcat,项目名称:Mekfarm,代码行数:17,代码来源:CropClonerEntity.java

示例3: getHUDLines

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
public List<HudInfoLine> getHUDLines() {
    List<HudInfoLine> list = super.getHUDLines();
    if (list == null)
        list = Lists.newArrayList();

    if (this.plantedThing == null) {
        list.add(new HudInfoLine(new Color(255, 159, 51),
                new Color(255, 159, 51, 42),
                "no seed")
                .setTextAlignment(HudInfoLine.TextAlignment.CENTER));
    } else /*if (this.plantedThing != null)*/ {
        list.add(new HudInfoLine(Color.WHITE, this.plantedThing.getBlock().getLocalizedName())
                .setTextAlignment(HudInfoLine.TextAlignment.CENTER));
        PropertyInteger age = this.getAgeProperty(this.plantedThing);
        if (age != null) {
            int percent = (this.plantedThing.getValue(age) * 100) / age.getAllowedValues().size();
            list.add(new HudInfoLine(Color.CYAN,
                    new Color(Color.GRAY.getRed(), Color.GRAY.getGreen(), Color.GRAY.getBlue(), 192),
                    new Color(Color.CYAN.getRed(), Color.CYAN.getGreen(), Color.CYAN.getBlue(), 192),
                    "growth: " + percent + "%")
                    .setProgress((float)percent / 100.0f, new Color(Color.CYAN.getRed(), Color.CYAN.getGreen(), Color.CYAN.getBlue(), 50)));
        }
    }

    return list;
}
 
开发者ID:faceofcat,项目名称:Mekfarm,代码行数:27,代码来源:CropClonerEntity.java

示例4: MaterialSlab

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
public MaterialSlab(TMResource... resources) {
	VARIANT = PropertyInteger.create("type", 0, Math.max(Math.min(resources.length - 1, 7), 1));
	half = new BlockMaterialSlab();
	full = new BlockMaterialSlab() {
		@Override
		public boolean isDouble() {
			return true;
		}
	};
	this.resources = new TMResource[Math.min(resources.length, 8)];
	for (int i = 0;i < resources.length && i < 8;i++) {
		this.resources[i] = resources[i];
		resources[i].setSlab(this);
	}
	itemBlock = new ItemSlab(half, half, full);
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:17,代码来源:MaterialSlab.java

示例5: ageToMax

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
private static IBlockState ageToMax(IBlockState startingState) {
	for(Object o : startingState.getProperties().entrySet()){
		Map.Entry e = (Map.Entry)o;
		if(e.getKey() instanceof PropertyInteger){
			PropertyInteger prop = (PropertyInteger)e.getKey();
			if("age".equals(prop.getName())){
				int max = 0;
				for(Object i : prop.getAllowedValues()){
					if((Integer)i > max){max = (Integer)i;}
				}
				return startingState.withProperty(prop, Integer.valueOf(max));
			}
		}
	}
	return startingState;
}
 
开发者ID:cyanobacterium,项目名称:ElectricAdvantage,代码行数:17,代码来源:VirtualCrop.java

示例6: createPropertyControl

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T extends Comparable<T>> IPropertyControl<T> createPropertyControl(IProperty<T> prop,
		boolean isTest) {
	if (canUseGenericPropertyControl(prop)) {
		return new PropertyControl<T>(prop, isTest);
	} else if (prop instanceof PropertyInteger) {
		int min = Integer.MIN_VALUE, max = Integer.MAX_VALUE;
		for (int allowedVal : ((PropertyInteger) prop).getAllowedValues()) {
			if (allowedVal < min) {
				min = allowedVal;
			}
			if (allowedVal > max) {
				max = allowedVal;
			}
		}
		return (IPropertyControl<T>) new IntPropertyControl((IProperty<Integer>) prop, min, max, isTest);
	} else if (prop instanceof PropertyBool) {
		if (isTest) {
			return (IPropertyControl<T>) new TestBooleanPropertyControl((IProperty<Boolean>) prop);
		} else {
			return (IPropertyControl<T>) new BooleanPropertyControl((IProperty<Boolean>) prop);
		}
	} else {
		return new PropertyControl<T>(prop, isTest);
	}
}
 
开发者ID:Earthcomputer,项目名称:Easy-Editors,代码行数:27,代码来源:CommandSlotBlock.java

示例7: getAgeProperty

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
private PropertyInteger getAgeProperty(IBlockState thing) {
    if (thing != null) {
        for (IProperty p : thing.getPropertyKeys()) {
            if ((p instanceof PropertyInteger) && (p.getName() == "age")) {
                return (PropertyInteger) p;
            }
        }
    }
    return null;
}
 
开发者ID:faceofcat,项目名称:Mekfarm,代码行数:11,代码来源:CropClonerEntity.java

示例8: handleClick

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
private boolean handleClick(BlockPos pos, BlockPos posUnder, World world) {
  IBlockState stateUnder = world.getBlockState(posUnder);
  
  EnumSnowType snowingType = ShiftedSnowApi.getSnowingType(stateUnder, world, posUnder);
  
  if (snowingType == null)
    return false;
    
  IBlockState state = world.getBlockState(pos);
  
  if (state.getBlock() instanceof IShiftedSnowBlock) {
    IShiftedSnowBlock currentSnowBlock = (IShiftedSnowBlock) state.getBlock();
    
    EnumSnowType currentSnowingType = currentSnowBlock.getSnowType(state);
    
    if (currentSnowingType == snowingType) {
      PropertyInteger heightProperty = currentSnowBlock.getHeightProperty();
      
      if (state.getValue(heightProperty) < currentSnowBlock.getMaxHeight()) {
        IBlockState newState = state.cycleProperty(heightProperty);
        
        world.setBlockState(pos, newState, 2);
        return true;
      }
    }
  } else if (world.isAirBlock(pos)) {
    IBlockState snowBlock = snowingType.getSnowBlock();
    
    world.setBlockState(pos, snowBlock, 2);
    return true;
  }
  return false;
}
 
开发者ID:Reoseah,项目名称:shifted-snow,代码行数:34,代码来源:ModEventHandler.java

示例9: PropertyList

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
public PropertyList(PropertyInteger up, PropertyInteger down, PropertyInteger north, PropertyInteger east, PropertyInteger south, PropertyInteger west) {
	UP = up;
	DOWN = down;
	NORTH = north;
	EAST = east;
	SOUTH = south;
	WEST = west;
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:9,代码来源:BlockDuctBase.java

示例10: createBlockState

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
@Override
public BlockStateContainer createBlockState() {
	if (maxStates.get() == -1) {
		maxIntValueInProperties = -1;
		propertyList = null;
	} else {
		maxIntValueInProperties = Math.min(maxStates.get(), 3);
		if (!propertyListMap.containsKey(maxIntValueInProperties)) {
			PropertyInteger UP = PropertyInteger.create("up", 0, maxIntValueInProperties);
			PropertyInteger DOWN = PropertyInteger.create("down", 0, maxIntValueInProperties);
			PropertyInteger NORTH = PropertyInteger.create("north", 0, maxIntValueInProperties);
			PropertyInteger EAST = PropertyInteger.create("east", 0, maxIntValueInProperties);
			PropertyInteger SOUTH = PropertyInteger.create("south", 0, maxIntValueInProperties);
			PropertyInteger WEST = PropertyInteger.create("west", 0, maxIntValueInProperties);
			propertyListMap.put(maxIntValueInProperties, new PropertyList(UP, DOWN, NORTH, EAST, SOUTH, WEST));
		}
		propertyList = propertyListMap.get(maxIntValueInProperties);
	}
	IProperty<?>[] properties = getProperties();
	IUnlistedProperty<?>[] unlistedProperties = getUnlistedProperties();
	if (properties == null) {
		properties = new IProperty[]{propertyList.DOWN, propertyList.UP, propertyList.NORTH, propertyList.SOUTH, propertyList.WEST, propertyList.EAST};
	}
	if (unlistedProperties != null && unlistedProperties.length > 0)
		return new ExtendedBlockState(this, properties, unlistedProperties);
	else
		return new BlockStateContainer(this, properties);
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:29,代码来源:BlockDuctBase.java

示例11: createBlockState

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
@Override
protected BlockStateContainer createBlockState() {
	if (TYPE == null) {
		Integer i = threadLocal.get();
		if (i == null)
			i = 1;
		TYPE = PropertyInteger.create("type", 0, i == 1 ? i : i - 1);
		maxStates = i;
	}
	return maxStates > 1 ? new BlockStateContainer(this, TYPE) : new BlockStateContainer(this, new IProperty[0]);
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:12,代码来源:BlockOre.java

示例12: sideFromId

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
public static PropertyInteger sideFromId(int id) {
	switch (id) {
		case 0: return DOWN;
		case 1: return UP;
		case 2: return NORTH;
		case 3: return SOUTH;
		case 4: return WEST;
		case 5: return EAST;
		default: return DOWN;
	}
}
 
开发者ID:Szewek,项目名称:Minecraft-Flux,代码行数:12,代码来源:BlockSided.java

示例13: getNumberOfGrowthStages

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
private static int getNumberOfGrowthStages(IBlockState startingState) {
	for(Object o : startingState.getProperties().entrySet()){
		Map.Entry e = (Map.Entry)o;
		if(e.getKey() instanceof PropertyInteger){
			PropertyInteger prop = (PropertyInteger)e.getKey();
			if("age".equals(prop.getName())){
				return prop.getAllowedValues().size();
			}
		}
	}
	return 8;
}
 
开发者ID:cyanobacterium,项目名称:ElectricAdvantage,代码行数:13,代码来源:VirtualCrop.java

示例14: of

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
public static BlockProperty of(IProperty property) {
    if (property instanceof PropertyBool) {
        return new NeptuneBlockBooleanProperty((PropertyBool) property);
    } else if (property instanceof PropertyDirection) {
        return new NeptuneBlockDirectionProperty((PropertyDirection) property);
    } else if (property instanceof PropertyEnum) {
        return new NeptuneBlockEnumProperty((PropertyEnum) property);
    } else if (property instanceof PropertyInteger) {
        return new NeptuneBlockIntegerProperty((PropertyInteger) property);
    }
    return new NeptuneBlockProperty(property);
}
 
开发者ID:NeptunePowered,项目名称:NeptuneCommon,代码行数:13,代码来源:NeptuneBlockProperty.java

示例15: ReduxBlock

import net.minecraft.block.properties.PropertyInteger; //导入依赖的package包/类
public ReduxBlock(Pack parentPack, Block reduxBlock) {
    super(reduxBlock.getMaterial());
    this.pack = parentPack;
    this.reduxBlock = reduxBlock;

    setUnlocalizedName(reduxBlock.getName());
    setCreativeTab(reduxBlock.getCreativeTab());

    IBlockState defaultBlockState = this.blockState.getBaseState().withProperty(SUCCESS_COUNT_META, 0);
    if (reduxBlock.shouldAddFacingProperty())
        defaultBlockState = defaultBlockState.withProperty(FACING, null);
    if (reduxBlock.getCustomProperties() != null) {
        for (Flags<String, Integer> customProperty : reduxBlock.getCustomProperties()) {
            PropertyInteger customIntegerProperty = PropertyInteger.create(customProperty.getKey(), Integer.MIN_VALUE, Integer.MAX_VALUE);
            customBlockProperties.put(customProperty.getKey(), customIntegerProperty);
            defaultBlockState = defaultBlockState.withProperty(customIntegerProperty, customProperty.getValue());
        }
    }
    this.setDefaultState(defaultBlockState);

    if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
        StateMap.Builder stateMapBuilder = (new StateMap.Builder()).addPropertiesToIgnore(SUCCESS_COUNT_META);
        if (reduxBlock.getIgnoredProperties() != null) {
            for (String s : reduxBlock.getIgnoredProperties()) {
                PropertyInteger propertyInteger = customBlockProperties.get(s);
                if (propertyInteger != null) {
                    stateMapBuilder.addPropertiesToIgnore(propertyInteger);
                }
            }
        }
        FMLClientHandler.instance().getClient().getBlockRendererDispatcher().getBlockModelShapes().registerBlockWithStateMapper(this, stateMapBuilder.build());
    }
}
 
开发者ID:Quiddity-Modding,项目名称:Redux,代码行数:34,代码来源:ReduxBlock.java


注:本文中的net.minecraft.block.properties.PropertyInteger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。