Started by
HerrLemming
on
Topic category: Help with MCreator software
Hey! I am currently trying to get a new Ore to only spawn in a desert. I can't figure out how! I checked the code and tried to fix it myself, but i'm not the best at coding so... help would be appreciated.. thanks!
The Code if you need it:
package mod.mcreator;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.World;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.Item;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.material.Material;
import net.minecraft.block.SoundType;
import net.minecraft.block.Block;
import java.util.Random;
public class mcreator_desertoore {
public mcreator_desertoore() {
}
public static BlockDesertoore block;
public static Item item;
public static Object instance;
public int addFuel(ItemStack fuel) {
return 0;
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
block.setRegistryName("desertoore");
ForgeRegistries.BLOCKS.register(block);
item = new ItemBlock(block).setRegistryName(block.getRegistryName());
ForgeRegistries.ITEMS.register(item);
}
public void registerRenderers() {
}
public void load(FMLInitializationEvent event) {
if (event.getSide() == Side.CLIENT) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
.register(item, 0, new ModelResourceLocation("testenvironmentmod:desertoore", "inventory"));
}
}
static {
block = (BlockDesertoore) (new BlockDesertoore().setHardness(5.0F).setResistance(10.0F).setLightLevel(0.0F).setUnlocalizedName("desertoore")
.setLightOpacity(0).setCreativeTab(CreativeTabs.BUILDING_BLOCKS));
block.setHarvestLevel("pickaxe", 6);
}
public void generateSurface(World world, java.util.Random rand, int chunkX, int chunkZ) {
for (int i = 0; i < 10; i++) {
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(79) + 16;
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mcreator_desertoore.block.getDefaultState(), 15)).generate(world, rand, new BlockPos(randPosX, randPosY, randPosZ));
}
}
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
static class BlockDesertoore extends Block {
int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
boolean red = false;
protected BlockDesertoore() {
super(Material.ROCK);
setSoundType(SoundType.STONE);
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
}
@Override
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
return red ? 15 : 0;
}
@Override
public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
return red ? 15 : 0;
}
@SideOnly(Side.CLIENT)
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.SOLID;
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
}
@Override
public int tickRate(World world) {
return 10;
}
@Override
public int quantityDropped(Random par1Random) {
return 1;
}
}
}