Fixed saving of alfalfa crops

This commit is contained in:
Sollace 2019-01-09 15:27:50 +02:00
parent e8206a16e7
commit c89ac2419f
6 changed files with 35 additions and 13 deletions

View file

@ -24,7 +24,7 @@ import net.minecraftforge.common.ForgeHooks;
public class BlockAlfalfa extends BlockCrops {
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 5);
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 4);
public static final PropertyEnum<Half> HALF = PropertyEnum.create("half", Half.class);
private static final AxisAlignedBB[] BOUNDS = new AxisAlignedBB[] {
@ -65,7 +65,7 @@ public class BlockAlfalfa extends BlockCrops {
@Override
public int getMaxAge() {
return 5;
return 4;
}
@Override
@ -276,6 +276,38 @@ public class BlockAlfalfa extends BlockCrops {
return EnumPlantType.Crop;
}
@Override
public IBlockState getStateFromMeta(int meta) {
int age = meta % (getMaxAge() + 1);
int half = (int)Math.floor(meta / (getMaxAge() + 1)) % Half.values().length;
return withAge(age).withProperty(HALF, Half.values()[half]);
}
// 0: age:0, half:0
// 1: age:1, half:0
// 2: age:2, half:0
// 3: age:3, half:0
// 4: age:4, half:0
// 5: age:0, half:1
// 6: age:1, half:1
// 7: age:2, half:1
// 8: age:3, half:1
// 9: age:4, half:1
//10: age:0, half:2
//11: age:1, half:2
//12: age:2, half:2
//13: age:3, half:2
//14: age:4, half:2
@Override
public int getMetaFromState(IBlockState state) {
int age = getAge(state);
int half = getHalf(state).ordinal();
return (half * (getMaxAge() + 1)) + age;
}
public static enum Half implements IStringSerializable {
TOP,
MIDDLE,

View file

@ -5,19 +5,15 @@
"age=2,half=top": { "model": "unicopia:alfalfa/stage2" },
"age=3,half=top": { "model": "unicopia:alfalfa/stage3" },
"age=4,half=top": { "model": "unicopia:alfalfa/stage4" },
"age=5,half=top": { "model": "unicopia:alfalfa/stage5" },
"age=0,half=middle": { "model": "unicopia:alfalfa/shaft" },
"age=1,half=middle": { "model": "unicopia:alfalfa/shaft" },
"age=2,half=middle": { "model": "unicopia:alfalfa/shaft" },
"age=3,half=middle": { "model": "unicopia:alfalfa/shaft" },
"age=4,half=middle": { "model": "unicopia:alfalfa/shaft" },
"age=5,half=middle": { "model": "unicopia:alfalfa/shaft" },
"age=0,half=bottom": { "model": "unicopia:alfalfa/stage0" },
"age=1,half=bottom": { "model": "unicopia:alfalfa/stage1" },
"age=2,half=bottom": { "model": "unicopia:alfalfa/stage2" },
"age=3,half=bottom": { "model": "unicopia:alfalfa/stage3" },
"age=4,half=bottom": { "model": "unicopia:alfalfa/stage4" },
"age=5,half=bottom": { "model": "unicopia:alfalfa/stage5" },
"age=5,half=bottom": { "model": "unicopia:alfalfa/shaft" }
"age=4,half=bottom": { "model": "unicopia:alfalfa/shaft" }
}
}

View file

@ -1,6 +0,0 @@
{
"parent": "block/crop",
"textures": {
"crop": "unicopia:blocks/alfalfa/stage_5"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 B