From 308f24378c2bbdee96393b11c41a7b6e23446ab3 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Fri, 10 Apr 2015 23:54:00 +1000 Subject: [PATCH] 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) --- .../generation/GeneratorWeightedEntry.java | 2 +- .../common/block/BlockBOPFlower1.java | 9 -------- .../common/block/BlockBOPFlower2.java | 9 -------- .../common/block/BlockBOPMushroom.java | 9 -------- .../common/block/BlockBOPSapling.java | 9 +++++++- .../common/block/BlockBamboo.java | 9 ++++++++ .../common/block/BlockCoral.java | 9 -------- .../common/block/BlockDecoration.java | 11 ++++++++-- .../common/block/BlockFoliage.java | 2 -- .../common/util/biome/GeneratorUtils.java | 22 ------------------- 10 files changed, 27 insertions(+), 64 deletions(-) diff --git a/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeightedEntry.java b/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeightedEntry.java index 5b2571b3f..ed564c2b5 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeightedEntry.java +++ b/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeightedEntry.java @@ -67,7 +67,7 @@ public final class GeneratorWeightedEntry extends WeightedRandom.Item implements public void readFromJson(JsonObject json, JsonDeserializationContext context) { 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 diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPFlower1.java b/src/main/java/biomesoplenty/common/block/BlockBOPFlower1.java index 76bb9382f..f6589509d 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPFlower1.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPFlower1.java @@ -88,15 +88,6 @@ public class BlockBOPFlower1 extends BlockDecoration { 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 @Override public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPFlower2.java b/src/main/java/biomesoplenty/common/block/BlockBOPFlower2.java index f6a8a012b..cce87347a 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPFlower2.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPFlower2.java @@ -77,15 +77,6 @@ public class BlockBOPFlower2 extends BlockDecoration { 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 @Override public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPMushroom.java b/src/main/java/biomesoplenty/common/block/BlockBOPMushroom.java index 58d8550b6..094bb7f23 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPMushroom.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPMushroom.java @@ -82,15 +82,6 @@ public class BlockBOPMushroom extends BlockDecoration 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 @Override public int getLightValue(IBlockAccess world, BlockPos pos) diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPSapling.java b/src/main/java/biomesoplenty/common/block/BlockBOPSapling.java index 44259d1b1..0392a5cc0 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPSapling.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPSapling.java @@ -26,6 +26,8 @@ import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraft.world.gen.feature.WorldGenTrees; 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 { @@ -139,7 +141,12 @@ public abstract class BlockBOPSapling extends BlockDecoration implements IGrowab return 0; } - + @Override + @SideOnly(Side.CLIENT) + public Block.EnumOffsetType getOffsetType() + { + return Block.EnumOffsetType.NONE; + } diff --git a/src/main/java/biomesoplenty/common/block/BlockBamboo.java b/src/main/java/biomesoplenty/common/block/BlockBamboo.java index 6be16ecb7..1e13fc21b 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBamboo.java +++ b/src/main/java/biomesoplenty/common/block/BlockBamboo.java @@ -20,6 +20,8 @@ import net.minecraft.init.Blocks; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; 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; + } + } diff --git a/src/main/java/biomesoplenty/common/block/BlockCoral.java b/src/main/java/biomesoplenty/common/block/BlockCoral.java index ed6df9931..e1728df20 100644 --- a/src/main/java/biomesoplenty/common/block/BlockCoral.java +++ b/src/main/java/biomesoplenty/common/block/BlockCoral.java @@ -89,15 +89,6 @@ public class BlockCoral extends BlockDecoration { 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 @Override diff --git a/src/main/java/biomesoplenty/common/block/BlockDecoration.java b/src/main/java/biomesoplenty/common/block/BlockDecoration.java index 2658a99da..e71cf3bba 100644 --- a/src/main/java/biomesoplenty/common/block/BlockDecoration.java +++ b/src/main/java/biomesoplenty/common/block/BlockDecoration.java @@ -54,7 +54,7 @@ public class BlockDecoration extends Block implements IBOPBlock // set some defaults this.setTickRandomly(true); this.setHardness(0.0F); - this.setStepSound(Block.soundTypePiston); + this.setStepSound(Block.soundTypeGrass); this.setBlockBoundsByRadiusAndHeight(0.3F, 0.6F); this.setDefaultState(this.blockState.getBaseState()); @@ -141,6 +141,13 @@ public class BlockDecoration extends Block implements IBOPBlock return EnumWorldBlockLayer.CUTOUT; } - + //decoration should be randomly offset by default + @Override + @SideOnly(Side.CLIENT) + public Block.EnumOffsetType getOffsetType() + { + return Block.EnumOffsetType.XZ; + } + } diff --git a/src/main/java/biomesoplenty/common/block/BlockFoliage.java b/src/main/java/biomesoplenty/common/block/BlockFoliage.java index d3b07a80b..8d6456507 100644 --- a/src/main/java/biomesoplenty/common/block/BlockFoliage.java +++ b/src/main/java/biomesoplenty/common/block/BlockFoliage.java @@ -185,8 +185,6 @@ public class BlockFoliage extends BlockDecoration implements IShearable return this.getRenderColor(state); } } - - // different variants have different sizes @Override diff --git a/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java b/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java index 5310fb27e..3c8c01f8d 100644 --- a/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java +++ b/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java @@ -72,28 +72,6 @@ public class GeneratorUtils return state; } - - public static IGenerator deserializeGenerator(JsonObject json, String memberName, JsonDeserializationContext context) - { - return deserializeGeneratorOfType(json, memberName, context, IGenerator.class); - } - - public static T deserializeGeneratorOfType(JsonObject json, String memberName, JsonDeserializationContext context, Class 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) {