Decoration by default now uses grass sounds and a random offset, fixed an issue with weighted generators causing config files to not load (they're being a pain)

This commit is contained in:
Adubbz 2015-04-10 23:54:00 +10:00
parent 9c9037e6d3
commit 308f24378c
10 changed files with 27 additions and 64 deletions

View file

@ -67,7 +67,7 @@ public final class GeneratorWeightedEntry extends WeightedRandom.Item implements
public void readFromJson(JsonObject json, JsonDeserializationContext context) public void readFromJson(JsonObject json, JsonDeserializationContext context)
{ {
this.itemWeight = json.get("weight").getAsInt(); this.itemWeight = json.get("weight").getAsInt();
this.wrappedGenerator = GeneratorUtils.deserializeGenerator(json, "wrapped_generator", context); this.wrappedGenerator = context.deserialize(json.get("wrapped_generator"), IGenerator.class);
} }
@Override @Override

View file

@ -88,15 +88,6 @@ public class BlockBOPFlower1 extends BlockDecoration {
return ((FlowerType) state.getValue(VARIANT)).ordinal(); return ((FlowerType) state.getValue(VARIANT)).ordinal();
} }
// give the flowers a random XZ offset so they're not spaced in a perfect grid
@Override
@SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.XZ;
}
// set the size of the different flowers' bounding boxes // set the size of the different flowers' bounding boxes
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)

View file

@ -77,15 +77,6 @@ public class BlockBOPFlower2 extends BlockDecoration {
return ((FlowerType) state.getValue(VARIANT)).ordinal(); return ((FlowerType) state.getValue(VARIANT)).ordinal();
} }
// give the flowers a random XZ offset so they're not spaced in a perfect grid
@Override
@SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.XZ;
}
// set the size of the different flowers' bounding boxes // set the size of the different flowers' bounding boxes
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)

View file

@ -82,15 +82,6 @@ public class BlockBOPMushroom extends BlockDecoration
return ((MushroomType) state.getValue(VARIANT)).ordinal(); return ((MushroomType) state.getValue(VARIANT)).ordinal();
} }
// give the mushrooms a random XZ offset so they're not spaced in a perfect grid
@Override
@SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.XZ;
}
// glowshrooms emit light // glowshrooms emit light
@Override @Override
public int getLightValue(IBlockAccess world, BlockPos pos) public int getLightValue(IBlockAccess world, BlockPos pos)

View file

@ -26,6 +26,8 @@ import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraft.world.gen.feature.WorldGenTrees; import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public abstract class BlockBOPSapling extends BlockDecoration implements IGrowable { public abstract class BlockBOPSapling extends BlockDecoration implements IGrowable {
@ -139,7 +141,12 @@ public abstract class BlockBOPSapling extends BlockDecoration implements IGrowab
return 0; return 0;
} }
@Override
@SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.NONE;
}

View file

@ -20,6 +20,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockBamboo extends BlockDecoration public class BlockBamboo extends BlockDecoration
{ {
@ -117,4 +119,11 @@ public class BlockBamboo extends BlockDecoration
} }
} }
@Override
@SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.NONE;
}
} }

View file

@ -90,15 +90,6 @@ public class BlockCoral extends BlockDecoration
return ((CoralType) state.getValue(VARIANT)).ordinal(); return ((CoralType) state.getValue(VARIANT)).ordinal();
} }
// give the corals a random XZ offset so they're not spaced in a perfect grid
@Override
@SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.XZ;
}
// glowing_coral emits light // glowing_coral emits light
@Override @Override
public int getLightValue(IBlockAccess world, BlockPos pos) public int getLightValue(IBlockAccess world, BlockPos pos)

View file

@ -54,7 +54,7 @@ public class BlockDecoration extends Block implements IBOPBlock
// set some defaults // set some defaults
this.setTickRandomly(true); this.setTickRandomly(true);
this.setHardness(0.0F); this.setHardness(0.0F);
this.setStepSound(Block.soundTypePiston); this.setStepSound(Block.soundTypeGrass);
this.setBlockBoundsByRadiusAndHeight(0.3F, 0.6F); this.setBlockBoundsByRadiusAndHeight(0.3F, 0.6F);
this.setDefaultState(this.blockState.getBaseState()); this.setDefaultState(this.blockState.getBaseState());
@ -141,6 +141,13 @@ public class BlockDecoration extends Block implements IBOPBlock
return EnumWorldBlockLayer.CUTOUT; return EnumWorldBlockLayer.CUTOUT;
} }
//decoration should be randomly offset by default
@Override
@SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.XZ;
}
} }

View file

@ -186,8 +186,6 @@ public class BlockFoliage extends BlockDecoration implements IShearable
} }
} }
// different variants have different sizes // different variants have different sizes
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)

View file

@ -73,28 +73,6 @@ public class GeneratorUtils
return state; return state;
} }
public static IGenerator deserializeGenerator(JsonObject json, String memberName, JsonDeserializationContext context)
{
return deserializeGeneratorOfType(json, memberName, context, IGenerator.class);
}
public static <T extends IGenerator> T deserializeGeneratorOfType(JsonObject json, String memberName, JsonDeserializationContext context, Class<T> type)
{
T generator = context.deserialize(json.get(memberName), type);
if (generator == null)
{
throw new JsonSyntaxException("Property " + memberName + " doesn't exist");
}
if (!(generator.getClass().isAssignableFrom(type)))
{
throw new JsonSyntaxException("Property " + memberName + " is of an invalid type");
}
return generator;
}
public static boolean isBlockTreeReplacable(Block block) public static boolean isBlockTreeReplacable(Block block)
{ {
return block.getMaterial() == Material.air || block.getMaterial() == Material.leaves || block == Blocks.grass || block == Blocks.dirt || block == Blocks.log || block == Blocks.log2 || block == Blocks.sapling || block == Blocks.vine; return block.getMaterial() == Material.air || block.getMaterial() == Material.leaves || block == Blocks.grass || block == Blocks.dirt || block == Blocks.log || block == Blocks.log2 || block == Blocks.sapling || block == Blocks.vine;