Java 类net.minecraft.block.properties.PropertyInteger 实例源码

项目:Mekfarm    文件:CropClonerEntity.java   
@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();
        }
    }
}
项目:Mekfarm    文件:CropClonerEntity.java   
@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;
}
项目:Mekfarm    文件:CropClonerEntity.java   
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;
}
项目:Toms-Mod    文件:MaterialSlab.java   
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);
}
项目:ElectricAdvantage    文件:VirtualCrop.java   
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;
}
项目:Easy-Editors    文件:CommandSlotBlock.java   
@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);
    }
}
项目:Mekfarm    文件:CropClonerEntity.java   
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;
}
项目:shifted-snow    文件:ModEventHandler.java   
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;
}
项目:Toms-Mod    文件:BlockDuctBase.java   
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;
}
项目:Toms-Mod    文件:BlockDuctBase.java   
@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);
}
项目:Toms-Mod    文件:BlockOre.java   
@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]);
}
项目:Minecraft-Flux    文件:BlockSided.java   
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;
    }
}
项目:ElectricAdvantage    文件:VirtualCrop.java   
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;
}
项目:NeptuneCommon    文件:NeptuneBlockProperty.java   
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);
}
项目:Redux    文件:ReduxBlock.java   
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());
    }
}
项目:Redux    文件:ReduxBlock.java   
@Override
public int isProvidingWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side) {
    if (customBlockProperties.get(reduxBlock.getRedstoneOutputProperty()) != null) {
        PropertyInteger redstoneProperty = customBlockProperties.get(reduxBlock.getRedstoneOutputProperty());
        return ((Integer)state.getValue(redstoneProperty)) > 15 ? 15 : ((Integer)state.getValue(redstoneProperty));
    }
    return 0;
}
项目:Redux    文件:ReduxBlock.java   
@Override
public int isProvidingStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side) {
    if (customBlockProperties.get(reduxBlock.getRedstoneOutputProperty()) != null) {
        PropertyInteger redstoneProperty = customBlockProperties.get(reduxBlock.getRedstoneOutputProperty());
        return ((Integer)state.getValue(redstoneProperty)) > 15 ? 15 : ((Integer)state.getValue(redstoneProperty));
    }
    return 0;
}
项目:NeptuneMod    文件:NeptuneBlockProperty.java   
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);
}
项目:MrglgaghCore    文件:BlockCropsBase.java   
@Override
protected abstract PropertyInteger getAgeProperty();
项目:BaseFoods    文件:BlockCorn.java   
protected PropertyInteger getAgeProperty() {
    return CORN_AGE;
}
项目:Backmemed    文件:BlockCrops.java   
protected PropertyInteger getAgeProperty()
{
    return AGE;
}
项目:Backmemed    文件:BlockBeetroot.java   
protected PropertyInteger getAgeProperty()
{
    return BEETROOT_AGE;
}
项目:CustomWorldGen    文件:BlockCrops.java   
protected PropertyInteger getAgeProperty()
{
    return AGE;
}
项目:CustomWorldGen    文件:BlockBeetroot.java   
protected PropertyInteger getAgeProperty()
{
    return BEETROOT_AGE;
}
项目:LittleThings-old    文件:RightClickCrops.java   
public void performAction(World world, BlockPos pos, IBlockState state, PropertyInteger prop)
{
    world.setBlockState(pos, state.withProperty(prop, 0));
    state.getBlock().dropBlockAsItemWithChance(world, pos, state, 1, 0);
}
项目:PrimordialCrops    文件:CropBlocksSpecial.java   
protected PropertyInteger getAge() {
    return AGE;
}
项目:PrimordialCrops    文件:CropBlocks.java   
protected PropertyInteger getAge() {
    return AGE;
}
项目:Mekfarm    文件:CropClonerEntity.java   
@Override
    protected float performWork() {
        float result = 0.0f;
        // EnumFacing facing = super.getFacing();

        if (this.plantedThing != null) {
            PropertyInteger ageProperty = this.getAgeProperty(this.plantedThing);
            if (ageProperty != null) {
                int age = this.plantedThing.getValue(ageProperty);
                Integer[] ages = ageProperty.getAllowedValues().toArray(new Integer[0]);
                if (age == ages[ages.length - 1]) {
                    List<ItemStack> stacks = this.plantedThing.getBlock().getDrops(this.getWorld(), this.getPos(), this.plantedThing, 0);
//                    if (stacks != null) {
//                        for (ItemStack s : stacks) {
//                            ItemStack remaining = ItemHandlerHelper.insertItem(this.outStackHandler, s, false);
//                            if (!ItemStackUtil.isEmpty(remaining)) {
////                                BlockPos spawnPos = this.pos.offset(facing);
////                                world.spawnEntity(new EntityItem(this.getWorld(), spawnPos.getX(), spawnPos.getY(), spawnPos.getZ(), remaining));
//                                super.spawnOverloadedItem(remaining);
//                            }
//                        }
//                    }
                    if (super.outputItems(stacks)) {
                        this.plantedThing = null;
                        result += .85f;
                    }
                } else {
                    this.plantedThing = this.plantedThing.withProperty(ageProperty, ++age);
                    result += .85f;
                }
                this.onPlantedThingChanged();
            }
//            result += .85f;
        }

        if ((this.plantedThing == null) && (this.waterTank != null) && (this.waterTank.getFluidAmount() >= 250)) {
            ItemStack stack = this.inStackHandler.getStackInSlot(0);
            if (!ItemStackUtil.isEmpty(stack) && (stack.getItem() instanceof IPlantable)) {
                IPlantable plantable = (IPlantable) stack.getItem();
                if (plantable.getPlantType(this.getWorld(), this.getPos()) == EnumPlantType.Crop) {
                    this.plantedThing = plantable.getPlant(this.getWorld(), this.getPos());
                    this.waterTank.drain(250, true); // TODO: <-- do this better
                    this.onPlantedThingChanged();
                }
            }
            result += .15f;
        }

        return result;
    }
项目:shifted-snow    文件:BlockSnowOverStairs.java   
@Override
public PropertyInteger getHeightProperty() {
    return HEIGHT_8;
}
项目:shifted-snow    文件:BlockSnowOverWall.java   
@Override
public PropertyInteger getHeightProperty() {
  return HEIGHT_8;
}
项目:shifted-snow    文件:BlockSnowOverTable.java   
@Override
public PropertyInteger getHeightProperty() {
    return HEIGHT_6;
}
项目:shifted-snow    文件:BlockSnowAbstract.java   
@Override
public PropertyInteger getHeightProperty() {
  return HEIGHT_8;
}
项目:Toms-Mod    文件:BlockModuleBase.java   
@Override
protected BlockStateContainer createBlockState() {
    STATE = PropertyInteger.create("state", 0, maxStates.get());
    return new BlockStateContainer(this, FACING, STATE);
}
项目:Toms-Mod    文件:TomsModUtils.java   
public static IBlockState getBlockStateFromMeta(int meta, PropertyInteger propState, PropertyDirection propDir, IBlockState defState, int max) {
    EnumFacing facing = EnumFacing.NORTH;
    int state = 0;
    switch (meta) {
    case 0:
        break;
    case 1:
        facing = EnumFacing.SOUTH;
        break;
    case 2:
        facing = EnumFacing.EAST;
        break;
    case 3:
        facing = EnumFacing.WEST;
        break;
    case 4:
        state = 1;
        break;
    case 5:
        state = 1;
        facing = EnumFacing.SOUTH;
        break;
    case 6:
        state = 1;
        facing = EnumFacing.EAST;
        break;
    case 7:
        state = 1;
        facing = EnumFacing.WEST;
        break;
    case 8:
        state = 2;
        break;
    case 9:
        state = 2;
        facing = EnumFacing.SOUTH;
        break;
    case 10:
        state = 2;
        facing = EnumFacing.EAST;
        break;
    case 11:
        state = 2;
        facing = EnumFacing.WEST;
        break;
    case 12:
        state = 3;
        break;
    case 13:
        state = 3;
        facing = EnumFacing.SOUTH;
        break;
    case 14:
        state = 3;
        facing = EnumFacing.EAST;
        break;
    case 15:
        state = 3;
        facing = EnumFacing.WEST;
        break;
    default:
        break;
    }
    return defState.withProperty(propState, Math.min(state, max)).withProperty(propDir, facing);
}
项目:Toms-Mod    文件:ItemPartTerminal.java   
@Override
protected BlockStateContainer createBlockState() {
    STATE = PropertyInteger.create("state", 0, 2);
    return new ExtendedBlockState(this, new IProperty[]{BlockTerminalBase.FACING, STATE}, new IUnlistedProperty[]{BlockTerminalBase.COLOR, BlockTerminalBase.STATE});
}
项目:Toms-Mod    文件:ItemPartPatternTerminal.java   
@Override
protected BlockStateContainer createBlockState() {
    STATE = PropertyInteger.create("state", 0, 2);
    return new ExtendedBlockState(this, new IProperty[]{BlockTerminalBase.FACING, STATE, BlockPatternTerminal.HAS_PATTERN}, new IUnlistedProperty[]{BlockTerminalBase.COLOR, BlockTerminalBase.STATE});
}
项目:LightningCraft    文件:BlockMeta.java   
/** Get the properties for this block */
protected List<IProperty> getProperties() {
    return variants = new JointList().join(PropertyInteger.create("variant", 0, nSubBlocks - 1));
}
项目:LightningCraft    文件:BlockContainerLCMeta.java   
/** Get the properties for this block */
protected List<IProperty> getProperties() {
    return variants = new JointList().join(PropertyInteger.create("variant", 0, nSubBlocks - 1));
}
项目:SimpleCorn    文件:BlockCorn.java   
@Override
protected PropertyInteger getAgeProperty()
   {
       return AGE;
   }
项目:Cyclic    文件:BlockCropMagicBean.java   
@Override
protected PropertyInteger getAgeProperty() {
  return AGE;
}