Removed null parameter

This commit is contained in:
marcin212 committed 2017-06-14 15:18:09 +02:00
1 parent 24fd7e89d3
commit e0ab7a89cc
7 files changed
+49 -38

No files matched your search

@@ -1,6 +1,6 @@
package binnie.extratrees.gen;
import binnie.extratrees.worldgen.BlockType;
import binnie.extratrees.worldgen.WorldGenBlockType;
import binnie.extratrees.worldgen.BlockTypeLog;
import forestry.api.world.ITreeGenData;
@@ -26,7 +26,7 @@ public class WorldGenDefault extends WorldGenTree {
}
@Override
public BlockType getWood() {
public WorldGenBlockType getWood() {
return new BlockTypeLog(this.treeGen);
}
}
@@ -5,6 +5,7 @@ import binnie.extratrees.worldgen.BlockType;
import binnie.extratrees.worldgen.BlockTypeLeaf;
import binnie.extratrees.worldgen.BlockTypeLog;
import binnie.extratrees.worldgen.BlockTypeVoid;
import binnie.extratrees.worldgen.WorldGenBlockType;
import com.mojang.authlib.GameProfile;
import forestry.api.world.ITreeGenData;
import forestry.arboriculture.tiles.TileTreeContainer;
@@ -29,10 +30,10 @@ public class WorldGenTree extends WorldGenerator {
protected int maxHeight;
protected boolean spawnPods;
protected int minPodHeight;
BlockType leaf;
BlockType wood;
BlockType vine;
BlockType air;
WorldGenBlockType leaf;
WorldGenBlockType wood;
WorldGenBlockType vine;
WorldGenBlockType air;
float bushiness;
public WorldGenTree(ITreeGenData tree) {
@@ -40,7 +41,7 @@ public class WorldGenTree extends WorldGenerator {
this.maxHeight = 80;
this.spawnPods = false;
this.minPodHeight = 3;
this.vine = new BlockType(Blocks.VINE, 0);
this.vine = new BlockType(Blocks.VINE.getDefaultState());
this.air = new BlockTypeVoid();
this.bushiness = 0.0f;
this.spawnPods = tree.allowsFruitBlocks();
@@ -87,11 +88,11 @@ public class WorldGenTree extends WorldGenerator {
return (determined < this.minHeight) ? this.minHeight : ((determined > this.maxHeight) ? this.maxHeight : determined);
}
public BlockType getLeaf() {
return leaf!=null?leaf:(leaf=new BlockTypeLeaf(null));
public WorldGenBlockType getLeaf() {
return leaf != null ? leaf : (leaf = new BlockTypeLeaf(null));
}
public BlockType getWood() {
public WorldGenBlockType getWood() {
return new BlockTypeLog(treeGen);
}
@@ -203,7 +204,7 @@ public class WorldGenTree extends WorldGenerator {
this.air.setBlock(this.world, this.treeGen, new BlockPos(this.startX + x, this.startY + y, this.startZ + z));
}
protected final void addBlock(final int x, final int y, final int z, final BlockType type, final boolean doReplace) {
protected final void addBlock(final int x, final int y, final int z, final WorldGenBlockType type, final boolean doReplace) {
if (doReplace || this.world.isAirBlock(new BlockPos(this.startX + x, this.startY + y, this.startZ + z))) {
type.setBlock(this.world, this.treeGen, new BlockPos(this.startX + x, this.startY + y, this.startZ + z));
}
@@ -221,7 +222,7 @@ public class WorldGenTree extends WorldGenerator {
this.addBlock(x, y, z, this.vine, false);
}
protected final void generateCuboid(final Vector start, final Vector area, final BlockType block, final boolean doReplace) {
protected final void generateCuboid(final Vector start, final Vector area, final WorldGenBlockType block, final boolean doReplace) {
for (int x = (int) start.x; x < (int) start.x + area.x; ++x) {
for (int y = (int) start.y; y < (int) start.y + area.y; ++y) {
for (int z = (int) start.z; z < (int) start.z + area.z; ++z) {
@@ -231,7 +232,7 @@ public class WorldGenTree extends WorldGenerator {
}
}
protected final void generateCylinder(final Vector center2, final float radius, final int height, final BlockType block, final boolean doReplace) {
protected final void generateCylinder(final Vector center2, final float radius, final int height, final WorldGenBlockType block, final boolean doReplace) {
final float centerOffset = (this.girth - 1) / 2.0f;
final Vector center3 = new Vector(center2.x + centerOffset, center2.y, center2.z + centerOffset);
final Vector start = new Vector(center3.x - radius, center3.y, center3.z - radius);
@@ -249,11 +250,11 @@ public class WorldGenTree extends WorldGenerator {
}
}
protected final void generateCircle(final Vector center, final float radius, final int width, final int height, final BlockType block, final boolean doReplace) {
protected final void generateCircle(final Vector center, final float radius, final int width, final int height, final WorldGenBlockType block, final boolean doReplace) {
this.generateCircle(center, radius, width, height, block, 1.0f, doReplace);
}
protected final void generateCircle(final Vector center2, final float radius, final int width, final int height, final BlockType block, final float chance, final boolean doReplace) {
protected final void generateCircle(final Vector center2, final float radius, final int width, final int height, final WorldGenBlockType block, final float chance, final boolean doReplace) {
final float centerOffset = (this.girth % 2 == 0) ? 0.5f : 0.0f;
final Vector center3 = new Vector(center2.x + centerOffset, center2.y, center2.z + centerOffset);
final Vector start = new Vector(center3.x - radius, center3.y, center3.z - radius);
@@ -272,7 +273,7 @@ public class WorldGenTree extends WorldGenerator {
}
}
protected final void generateSphere(final Vector center2, final int radius, final BlockType block, final boolean doReplace) {
protected final void generateSphere(final Vector center2, final int radius, final WorldGenBlockType block, final boolean doReplace) {
final float centerOffset = (this.girth - 1) / 2.0f;
final Vector center3 = new Vector(center2.x + centerOffset, center2.y, center2.z + centerOffset);
final Vector start = new Vector(center3.x - radius, center3.y - radius, center3.z - radius);
@@ -1,23 +1,19 @@
package binnie.extratrees.worldgen;
import forestry.api.world.ITreeGenData;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockType {
int meta;
Block block;
public class BlockType implements WorldGenBlockType {
IBlockState blockState;
public BlockType(final Block block, final int meta) {
this.block = block;
this.meta = meta;
public BlockType(IBlockState blockState) {
this.blockState = blockState;
}
public void setBlock(final World world, final ITreeGenData tree, final BlockPos pos) {
world.setBlockState(pos, this.block.getDefaultState(), 2);
if (world.getTileEntity(pos) != null) {
world.removeTileEntity(pos);
}
@Override
public void setBlock(World world, ITreeGenData tree, BlockPos pos) {
world.setBlockState(pos, blockState, 2);
}
}
@@ -1,6 +1,5 @@
package binnie.extratrees.worldgen;
import binnie.core.Mods;
import com.mojang.authlib.GameProfile;
import forestry.api.world.ITreeGenData;
import net.minecraft.util.math.BlockPos;
@@ -8,11 +7,10 @@ import net.minecraft.world.World;
import javax.annotation.Nullable;
public class BlockTypeLeaf extends BlockType {
public class BlockTypeLeaf implements WorldGenBlockType {
GameProfile owner;
public BlockTypeLeaf(@Nullable GameProfile owner) {
super(Mods.Forestry.block("leaves"), 0);
public BlockTypeLeaf(@Nullable GameProfile owner) {
this.owner = owner;
}
@@ -5,12 +5,10 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockTypeLog extends BlockType {
public class BlockTypeLog implements WorldGenBlockType {
ITreeGenData treeGenData;
public BlockTypeLog(ITreeGenData treeGenData) {
// TODO why is block param null here?
super(null, 0);
this.treeGenData = treeGenData;
}
@@ -1,9 +1,17 @@
package binnie.extratrees.worldgen;
import forestry.api.world.ITreeGenData;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockTypeVoid extends BlockType {
public BlockTypeVoid() {
super(Blocks.AIR, 0);
public class BlockTypeVoid implements WorldGenBlockType {
@Override
public void setBlock(World world, ITreeGenData tree, BlockPos pos) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
if (world.getTileEntity(pos) != null) {
world.removeTileEntity(pos);
}
}
}
@@ -0,0 +1,10 @@
package binnie.extratrees.worldgen;
import forestry.api.world.ITreeGenData;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface WorldGenBlockType {
void setBlock(final World world, final ITreeGenData tree, final BlockPos pos);
}