add force trees
leaves still render incorrectly
This commit is contained in:
parent
c7aff74bcf
commit
92ea162380
|
@ -6,6 +6,10 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import ley.modding.dartcraft.block.BlockForceLeaves;
|
||||
import ley.modding.dartcraft.block.BlockForceLog;
|
||||
import ley.modding.dartcraft.block.BlockForceSapling;
|
||||
import ley.modding.dartcraft.block.BlockPowerOre;
|
||||
import ley.modding.dartcraft.block.Blocks;
|
||||
import ley.modding.dartcraft.entity.*;
|
||||
|
@ -45,6 +49,7 @@ public class Dartcraft {
|
|||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent e) {
|
||||
// TODO: wtf is this?! this belongs into the Items and Blocks classes!
|
||||
registry = new Registry();
|
||||
Items.forcegem = registry.registerItem(new BaseItem("forcegem"));
|
||||
Items.forceingot = registry.registerItem(new BaseItem("forceingot"));
|
||||
|
@ -56,8 +61,14 @@ public class Dartcraft {
|
|||
Items.forceshears = registry.registerItem(new ItemForceShears());
|
||||
Items.forceflask = registry.registerItem(new ItemForceFlask());
|
||||
Items.entitybottle = registry.registerItem(new ItemEntityBottle());
|
||||
|
||||
Blocks.forcesapling = registry.registerBlock(new BlockForceSapling());
|
||||
Blocks.powerore = registry.registerBlock(new BlockPowerOre());
|
||||
Blocks.forcelog = registry.registerBlock(new BlockForceLog());
|
||||
Blocks.forceleaves = registry.registerBlock(new BlockForceLeaves());
|
||||
|
||||
proxy.init();
|
||||
|
||||
int entityId = 0;
|
||||
EntityRegistry.registerModEntity(EntityColdChicken.class, "coldChicken", entityId++, Dartcraft.instance, 40, 1, true);
|
||||
EntityRegistry.registerModEntity(EntityColdCow.class, "coldCow", entityId++, Dartcraft.instance, 40, 1, true);
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package ley.modding.dartcraft.block;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ley.modding.dartcraft.Dartcraft;
|
||||
import ley.modding.dartcraft.util.Util;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockForceLeaves extends BlockLeaves {
|
||||
private IIcon icon;
|
||||
|
||||
public BlockForceLeaves() {
|
||||
Util.configureBlock(this, "forceleaves");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
this.icon = register.registerIcon(Dartcraft.MODID + ":leaves");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
// this seems to be getting the variants or something...
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public String[] func_150125_e() {
|
||||
return new String[]{"force"};
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getBlockColor()
|
||||
{
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderColor(int p_149741_1_)
|
||||
{
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) {
|
||||
return 0xffffff;
|
||||
}
|
||||
}
|
32
src/main/java/ley/modding/dartcraft/block/BlockForceLog.java
Normal file
32
src/main/java/ley/modding/dartcraft/block/BlockForceLog.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package ley.modding.dartcraft.block;
|
||||
|
||||
import ley.modding.dartcraft.Dartcraft;
|
||||
import ley.modding.dartcraft.util.Util;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockForceLog extends BlockLog {
|
||||
private IIcon sideIcon;
|
||||
private IIcon topIcon;
|
||||
|
||||
public BlockForceLog() {
|
||||
Util.configureBlock(this, "forcelog");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
this.sideIcon = register.registerIcon(Dartcraft.MODID + ":logSide");
|
||||
this.topIcon = register.registerIcon(Dartcraft.MODID + ":logTop");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getTopIcon(int p_150161_1_) {
|
||||
return this.topIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getSideIcon(int p_150163_1_) {
|
||||
return this.sideIcon;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package ley.modding.dartcraft.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import ley.modding.dartcraft.Dartcraft;
|
||||
import ley.modding.dartcraft.util.Util;
|
||||
import ley.modding.dartcraft.worldgen.GenForceTree;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.terraingen.TerrainGen;
|
||||
|
||||
public class BlockForceSapling extends BlockSapling {
|
||||
IIcon icon;
|
||||
|
||||
public BlockForceSapling() {
|
||||
Util.configureBlock(this, "forcesapling");
|
||||
setBlockTextureName(Dartcraft.MODID + ":sapling");
|
||||
}
|
||||
|
||||
// generate tree
|
||||
@Override
|
||||
public void func_149878_d(World world, int x, int y, int z, Random rand) {
|
||||
if (!TerrainGen.saplingGrowTree(world, rand, x, y, z)) return;
|
||||
world.setBlockToAir(x, y, z);
|
||||
new GenForceTree(true).generate(world, rand, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
list.add(new ItemStack(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
this.icon = register.registerIcon(Dartcraft.MODID + ":sapling");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
return this.icon;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package ley.modding.dartcraft.block;
|
|||
|
||||
import ley.modding.dartcraft.Dartcraft;
|
||||
import ley.modding.dartcraft.item.Items;
|
||||
import ley.modding.dartcraft.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -12,12 +13,11 @@ public class BlockPowerOre extends Block {
|
|||
|
||||
public BlockPowerOre() {
|
||||
super(Material.rock);
|
||||
setBlockName("powerore");
|
||||
Util.configureBlock(this, "powerore");
|
||||
setHardness(3.0F);
|
||||
setResistance(10.0F);
|
||||
setStepSound(soundTypeStone);
|
||||
setBlockTextureName(Dartcraft.MODID + ":powerore");
|
||||
setCreativeTab(Dartcraft.tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,5 +5,8 @@ import net.minecraft.block.Block;
|
|||
public class Blocks {
|
||||
|
||||
public static Block powerore;
|
||||
public static Block forcesapling;
|
||||
public static Block forcelog;
|
||||
public static Block forceleaves;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ley.modding.dartcraft.util;
|
||||
|
||||
import ley.modding.dartcraft.Dartcraft;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class Util {
|
||||
|
@ -9,4 +10,9 @@ public class Util {
|
|||
item.setTextureName(Dartcraft.MODID + ":" + id);
|
||||
item.setCreativeTab(Dartcraft.tab);
|
||||
}
|
||||
|
||||
public static void configureBlock(Block block, String id) {
|
||||
block.setBlockName(id);
|
||||
block.setCreativeTab(Dartcraft.tab);
|
||||
}
|
||||
}
|
||||
|
|
125
src/main/java/ley/modding/dartcraft/worldgen/GenForceTree.java
Normal file
125
src/main/java/ley/modding/dartcraft/worldgen/GenForceTree.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package ley.modding.dartcraft.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import ley.modding.dartcraft.block.Blocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class GenForceTree extends WorldGenAbstractTree {
|
||||
/** The minimum height of a generated tree. */
|
||||
private final int minTreeHeight;
|
||||
/** The metadata value of the wood to use in tree generation. */
|
||||
private final int metaWood;
|
||||
/** The metadata value of the leaves to use in tree generation. */
|
||||
private final int metaLeaves;
|
||||
|
||||
public GenForceTree(boolean doBlockNotify) {
|
||||
this(doBlockNotify, 4, 0, 0);
|
||||
}
|
||||
|
||||
public GenForceTree(boolean doBlockNotify, int minTreeHeight, int metaWood, int metaLeaves) {
|
||||
super(doBlockNotify);
|
||||
this.minTreeHeight = minTreeHeight;
|
||||
this.metaWood = metaWood;
|
||||
this.metaLeaves = metaLeaves;
|
||||
}
|
||||
|
||||
public boolean generate(World world, Random rand, int x, int y, int z) {
|
||||
int treeHeight = rand.nextInt(3) + this.minTreeHeight;
|
||||
boolean flag = true;
|
||||
|
||||
// check if inside build limit
|
||||
if (y >= 1 && y + treeHeight + 1 <= 256) {
|
||||
byte b0;
|
||||
int k1;
|
||||
Block block;
|
||||
|
||||
for (int currentLogY = y; currentLogY <= y + 1 + treeHeight; ++currentLogY) {
|
||||
b0 = 1;
|
||||
|
||||
if (currentLogY == y) {
|
||||
b0 = 0;
|
||||
}
|
||||
|
||||
if (currentLogY >= y + 1 + treeHeight - 2) {
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
for (int j1 = x - b0; j1 <= x + b0 && flag; ++j1) {
|
||||
for (k1 = z - b0; k1 <= z + b0 && flag; ++k1) {
|
||||
if (currentLogY >= 0 && currentLogY < 256) {
|
||||
block = world.getBlock(j1, currentLogY, k1);
|
||||
|
||||
if (!this.isReplaceable(world, j1, currentLogY, k1)) {
|
||||
flag = false;
|
||||
}
|
||||
} else {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
return false;
|
||||
} else {
|
||||
Block block2 = world.getBlock(x, y - 1, z);
|
||||
|
||||
boolean isSoil =
|
||||
block2.canSustainPlant(
|
||||
|
||||
world, x, y - 1, z, ForgeDirection.UP, (BlockSapling) Blocks.forcesapling);
|
||||
if (isSoil && y < 256 - treeHeight - 1) {
|
||||
block2.onPlantGrow(world, x, y - 1, z, x, y, z);
|
||||
b0 = 3;
|
||||
byte b1 = 0;
|
||||
int l1;
|
||||
int i2;
|
||||
int j2;
|
||||
int i3;
|
||||
|
||||
for (k1 = y - b0 + treeHeight; k1 <= y + treeHeight; ++k1) {
|
||||
i3 = k1 - (y + treeHeight);
|
||||
l1 = b1 + 1 - i3 / 2;
|
||||
|
||||
for (i2 = x - l1; i2 <= x + l1; ++i2) {
|
||||
j2 = i2 - x;
|
||||
|
||||
for (int k2 = z - l1; k2 <= z + l1; ++k2) {
|
||||
int l2 = k2 - z;
|
||||
|
||||
if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || rand.nextInt(2) != 0 && i3 != 0) {
|
||||
Block block1 = world.getBlock(i2, k1, k2);
|
||||
|
||||
if (block1.isAir(world, i2, k1, k2) || block1.isLeaves(world, i2, k1, k2)) {
|
||||
this.setBlockAndNotifyAdequately(
|
||||
world, i2, k1, k2, Blocks.forceleaves, this.metaLeaves);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (k1 = 0; k1 < treeHeight; ++k1) {
|
||||
block = world.getBlock(x, y + k1, z);
|
||||
|
||||
if (block.isAir(world, x, y + k1, z) || block.isLeaves(world, x, y + k1, z)) {
|
||||
this.setBlockAndNotifyAdequately(world, x, y + k1, z, Blocks.forcelog, this.metaWood);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,5 +11,10 @@ item.forceflask_potion_force.name=Liquid Force Flask
|
|||
item.forceflask_potion_green.name=Green Liquid Flask
|
||||
item.forceflask_potion_blue.name=Blue Liquid Flask
|
||||
item.forceflask_potion_red.name=Red Liquid Flask
|
||||
tile.powerore.name=Power Ore
|
||||
tile.forcelog.name=Force Log
|
||||
tile.forceleaves.name=Force Leaves
|
||||
tile.forcesapling.name=Force Sapling
|
||||
tile.forcepickaxe.name=Force Pickaxe
|
||||
|
||||
itemGroup.dartcraft=Dartcraft
|
||||
|
|
BIN
src/main/resources/assets/dartcraft/textures/blocks/leaves.png
Normal file
BIN
src/main/resources/assets/dartcraft/textures/blocks/leaves.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
src/main/resources/assets/dartcraft/textures/blocks/logSide.png
Normal file
BIN
src/main/resources/assets/dartcraft/textures/blocks/logSide.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
src/main/resources/assets/dartcraft/textures/blocks/logTop.png
Normal file
BIN
src/main/resources/assets/dartcraft/textures/blocks/logTop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
src/main/resources/assets/dartcraft/textures/blocks/sapling.png
Normal file
BIN
src/main/resources/assets/dartcraft/textures/blocks/sapling.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Loading…
Reference in a new issue