Jump to content

fr0st

Forge Modder
  • Posts

    116
  • Joined

  • Last visited

Everything posted by fr0st

  1. Are you looking for ChunkProviderSettings ? There are hardcoded defaults of world generation settings. (The gui when you choose to make a custom world)
  2. fr0st

    Solved

    That was my best guess anyways. Aah, alright, no point in this thread anymore!
  3. fr0st

    Solved

    I seem to have solved my issues with some random seed trickery; I still have a question for you. The only "problem" left is the slight lag that my (?) world gen causes. Even though I am just generating one ore, it sometimes says Can't keep up! Did the system time change ... in the console. The amount of ticks skipped is not too large, but still quite substantial (peaking at 173 ticks skipped). Does this happen even on vanilla worlds? I could understand if the whole minecraft world generation would be causing this, not just my mod's. (as such errors are prompted when flying through the sky, and on world creation)
  4. fr0st

    Solved

    Hi. Not too long ago I made a thread about my WorldGen system's odd behaviour. I am not porting, but entirely rewriting my mod for 1.10.2. This is to ensure better code quality. Anyways, I now need to remake the WorldGen system. I have a few problems and questions about this. The main issues/questions I have are these: My ores spawn very far away from the spawn. How are chunk coordinates chosen? Completely randomly, or based on player's position? Can't keep up! Did the system time change... is my system not efficient? The main issue. To spawn my copper ore, I practically use iron's settings (count, vein size, min/max Y coords), but my ore is basically extremely common. It spawns in exponentially larger veins than iron does. Of course, I could just tune the settings down, but why does this happen, if I mostly use adapted vanilla code, and iron ore generation settings? Now, explained what my issues are, here is the code. [spoiler=ModWorldGen.java] public class ModWorldGen { private final static int NETHER = -1, OVERWORLD = 0, END = 1; public static void register() { registerFeature(new FeatureOre(ModOres.Ore.COPPER, Blocks.STONE, 20, 8, 8, 0, 64), OVERWORLD); //registerFeature(new FeatureOre(ModOres.Ore.TIN, Blocks.STONE, 16, 6, 6, 0, 64), OVERWORLD); } private static void registerFeature(Feature feature, int... dimensions) { GameRegistry.registerWorldGenerator(new WorldGenFeature(feature, dimensions), 0); } } [spoiler=WorldGenFeature.java] public class WorldGenFeature implements IWorldGenerator { private final Feature feature; private final int[] dimensions; public WorldGenFeature(Feature feature, int... dimensions) { this.feature = feature; this.dimensions = dimensions; } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if (ArrayUtils.contains(dimensions, world.provider.getDimension())) { feature.generate(new Random(), world, chunkZ, chunkZ); } } } [spoiler=Feature.java] public abstract class Feature { protected int count, minY, maxY; public Feature(int count, int minY, int maxY) { this.count = count; this.minY = minY; this.maxY = maxY; } public abstract void generate(Random random, World world, int chunkX, int chunkZ); } [spoiler=FeatureOre.java] public class FeatureOre extends Feature { private IBlockState blockOre, blockStone; private int minSize, maxSize; public FeatureOre(IVariant ore, IBlockState blockStone, int count, int minSize, int maxSize, int minY, int maxY) { super(count, minY, maxY); this.blockOre = Block.getBlockFromItem(ore.toItemStack(1).getItem()).getStateFromMeta(ore.getMetadata()); this.blockStone = blockStone; this.minSize = minSize; this.maxSize = maxSize; } public FeatureOre(IVariant ore, Block blockStone, int count, int minSize, int maxSize, int minY, int maxY) { this(ore, blockStone.getDefaultState(), count, minSize, maxSize, minY, maxY); } @Override public void generate(Random random, World world, int chunkX, int chunkZ) { final BlockPos chunkPos = new BlockPos(chunkX * 16, minY, chunkZ * 16); //Copper's size is 8 (both min and max being , like iron. int oreVeinSize = minSize + random.nextInt(Math.max(maxSize - minSize, 1)); //Copper's count is 20, like iron. for (int i = 0; i < count; i++) { new WorldGenMinable(blockOre, oreVeinSize, BlockMatcher.forBlock(blockStone.getBlock())).generate(world, random, chunkPos.add(random.nextInt(16), random.nextInt(Math.max(maxY - minY, 0)), random.nextInt(16))); } } } Edit: Something went wrong. Adding the code now. Here you go.
  5. Nailed it. Thanks a lot. I'll let this thread open in case I'll need anything else, until I'm done porting. Edit: Anything about Item>getColorFromItemStack ?
  6. Thanks a lot, choon! Oh, and another small thing: what about onBlockEventReceived ? Couldn't find anything on the issue tracker. Edit: Is it now eventReceived ? It's shown as deprecated, though.
  7. Hey. I am in the tedious progress of porting a mod. 1.8 -> current latest 1.10.2 (12.18.1.2046). I have had some success up to now, but I can't find anything about World#markBlockForUpdate . I saw that TGG uses it in his MBE github repo, but won't show up for me. Was it renamed? Was it removed? Was it reworked? I'd like to know! P.S: Oh, and I found myself quite often in this kind of situation, where I blindly google for alternatives. But, can some of you share the secret to knowing which changes Forge underwent? (The changelog doesn't help the smallest bit. I tried.)
  8. So all I have to do is create the blockstate json and place the model files in models/block ? And what do you mean by "normal" item model? I will post my attempt later, thank you guys. Edit: I am working on it (currently rewriting my model registry), and I just realized that I should have told you I'm working with 1.8, not 1.8.9, if that makes any difference.
  9. Hi. After playing a bit with the new JSON systems introduced in 1.8, I have been wondering.. Since a BlockState JSON file can be used (with the forge syntax) to reduce a lot the number of useless and redundant Block Model files, can something similar be done with items? Is there a way to use BlockState files for items, or to dynamically define the texture of an item, using one simple model, just editing some texture values for each variant the item has? Thanks to anyone who can provide any information about this.
  10. I was totally sure I had. Sorry. I'll try to double-check next time. Have a good evening!
  11. Hi everyone. Coding quite tired at the moment, and I have run into an error. I have a Coal Generator block with facing and on-off variants. I currently have implemented everything and it works fairly well, altough the blockstate/model JSONs aren't working as intended. Can any of you give a look at it, since I am fairly new to 1.8 and still unfamiliar with such errors? [spoiler=BlockCoalGenerator.java] package projectcoal.common.block.energy; import com.google.common.base.Predicate; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import projectcoal.api.energy.Energy; import projectcoal.api.energy.block.prefab.BlockEnergySourcePC; import projectcoal.client.Gui; import projectcoal.client.helper.GuiHelper; import projectcoal.common.tileentity.energy.TileCoalGenerator; @SuppressWarnings("rawtypes") public class BlockCoalGenerator extends BlockEnergySourcePC { public static final PropertyDirection FACING = PropertyDirection.create("facing", (Predicate) EnumFacing.Plane.HORIZONTAL); public static final PropertyBool BURNING = PropertyBool.create("burning"); public BlockCoalGenerator() { super(Energy.ELECTRICITY, Material.iron, 1.5F, 1.5F); setDefaultState(blockState.getBaseState().withProperty(BURNING, false).withProperty(FACING, EnumFacing.NORTH)); } @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public IBlockState getStateFromMeta(int meta) { boolean isBurning = (meta >> 2) != 0; return getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta & 3)).withProperty(BURNING, isBurning); } @Override public int getMetaFromState(IBlockState blockState) { int rotationBit = ((EnumFacing) blockState.getValue(FACING)).getHorizontalIndex(); int burningBit = ((Boolean) blockState.getValue(BURNING)).booleanValue() ? 1 : 0; return burningBit << 2 | rotationBit; } @Override protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { BURNING, FACING }); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileCoalGenerator(); } @Override public boolean useCustomRender() { return false; } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { if (!player.isSneaking()) { GuiHelper.openGui(Gui.COAL_GENERATOR, world, pos, player); } else { rotateBlock(world, pos, side); } return !player.isSneaking(); } public static void setState(boolean isBurning, World world, BlockPos pos) { IBlockState blockState = world.getBlockState(pos); world.setBlockState(pos, blockState.withProperty(BURNING, isBurning), 3); } } [spoiler=BlockState JSON] { "defaults": { "model": "projectcoal:block_coal_generator" }, variants: { "burning" : {- "true": { "textures": { "front": "projectcoal:blocks/coal_generator_front", } }, "false": { "textures": { "front": "projectcoal:blocks/coal_generator_front_on", } } }, "facing": { "north": { }, "south": { "y": 180 }, "east": { "y": 90 }, "west": { "y": 270 } } } } [spoiler=Block Model JSON] { "parent": "block/orientable", "textures": { "top": "projectcoal:blocks/machine_connection", "bottom": "projectcoal:blocks/machine_side", "front": "projectcoal:blocks/coal_generator_front", "side": "projectcoal:blocks/machine_side" } } I suppose that's everything needed. Let me know if you need any more files or info. Going to rest a while now, thanks in advance if you happen to spot any issue, as I really couldn't. By the way, the console tells me that it couldn't load the model definition for projectcoal:block_coal_generator#burning=someValue,facing=someValue Oh, about to forget: [spoiler=BlockRegistry.java] public class BlockRegistry { private static Map<String, ItemStack> blockMap = new HashMap<String, ItemStack>(); public static void registerBlocks() { registerBlock(new BlockWorktable().setUnlocalizedName("block_worktable")); registerBlock(new BlockSieve().setUnlocalizedName("block_sieve")); registerBlock(new BlockNetherLog().setUnlocalizedName("block_log_nether")); registerBlock(new BlockNetherLeaves().setUnlocalizedName("block_leaves_nether")); registerBlockWithVariants(new BlockOre().setUnlocalizedName("block_ore"), ItemBlockOre.class, BlockOre.EnumType.class); registerBlock(new BlockCoalGenerator().setUnlocalizedName("block_coal_generator")); registerBlock(new BlockElectricConduit().setUnlocalizedName("block_electric_conduit")); } public static void registerTiles() { registerTile(TileWorktable.class, "tile_worktable"); registerTile(TileSieve.class, "tile_sieve"); registerTile(TileCoalGenerator.class, "tile_coal_generator"); } public static void registerBlockModels() { Iterator<Entry<String, ItemStack>> iterator = blockMap.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, ItemStack> entry = (Entry<String, ItemStack>) iterator.next(); registerBlockModel(entry.getValue().getItem(), entry.getValue().getMetadata(), entry.getKey()); } } public static void registerBlock(Block block) { GameRegistry.registerBlock(block, block.getUnlocalizedName().replace("tile.", "")); blockMap.put(block.getUnlocalizedName().replace("tile.", ""), new ItemStack(block, 1, 0)); } public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass) { GameRegistry.registerBlock(block, itemclass, block.getUnlocalizedName().replace("tile.", "")); blockMap.put(block.getUnlocalizedName().replace("tile.", ""), new ItemStack(block, 1, 0)); } public static void registerTile(Class<? extends TileEntity> tileEntityClass, String id) { GameRegistry.registerTileEntity(tileEntityClass, id); } public static void registerBlockWithVariants(Block block, Class<? extends ItemBlock> itemclass, Class<? extends IMetadataItem> metadataClass) { GameRegistry.registerBlock(block, itemclass, block.getUnlocalizedName().replace("tile.", "")); String[] variants = new String[metadataClass.getEnumConstants().length]; for (IMetadataItem variant : metadataClass.getEnumConstants()) { variants[variant.getMetadata()] = ProjectCoal.RESOURCE_PREFIX + variant.getUnlocalizedName(); blockMap.put(variant.getUnlocalizedName(), new ItemStack(block, 1, variant.getMetadata())); } ModelBakery.addVariantName(Item.getItemFromBlock(block), variants); } public static void registerBlockModel(Item block, int meta, String name) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(block, meta, new ModelResourceLocation(ProjectCoal.RESOURCE_PREFIX + name, "inventory")); } public static Block getBlock(String name) { return GameRegistry.findBlock(ProjectCoal.MODID, name); } public static ItemStack getItemStack(String name, int amount, int meta) { return new ItemStack(getBlock(name), amount, meta); } public static Block getBlockFromMap(String name) { return Block.getBlockFromItem(blockMap.get(name).getItem()); } public static ItemStack getItemStackFromMap(String name, int amount, int meta) { return new ItemStack(getBlockFromMap(name), amount, meta); } } Sorry if it's so easy I couldn't even see the issue, but I am not feeling so well and I still want to keep coding. Have a good one!
  12. And that is exactly what came to my mind, jeffryfisher, so I have just debugged the FeatureOre#[b]generateOre[/b] calls, and they always use the same BlockPos', so the randomness is shared across all 5 FeatureOre s. Any idea on how to go about this? Thanks again. Edit: I might try one thing out. I'll let you know in a few minutes. Okay. Using a new Random instance for every time WorldGenFeature#generate is called instead of the Random argument,fixes my issue. Now I still have a slow world gen and densely packed ores, but there is no way these should be a problem. Thanks a bunch everyone, have a good evening!
  13. Good point. I now have. WorldGenFeature#[b]generate[/b] is called by GameRegistry#[b]generateWorld[/b] 5 consecutive times per chunk (chunkX and chunkZ changing after 5 times) in the order Copper-Silver-Lithium-Tin-Lead during world init, and it's copper that gets generated. We might be a step closer now..
  14. The static section runs after the enum's constructor, and everything runs as one would expect. The constructor gets called 5 times with the right arguments, and then the META_LOOKUP array is filled with the correct values. Thanks for the heads up, but still nothing useful came up from the debugging.
  15. Alright, I have carried out a few more tests, but nothing came up. I got to generate every type of ore at least once, except for silver, which has never been picked by the generator so far. The generated ore doesn't change each world created, nor every time the client is run from Eclipse, so I still don't get how the ore is chosen. May the generators be conflicting? This is a mystery that just goes beyond me, I am clueless. Any bit of help would be greatly appreciated.
  16. Hmm the FeatureOre constructor works just as expected. [spoiler=Variants]projectcoal:block_ore[variant=copper] projectcoal:block_ore[variant=lithium] projectcoal:block_ore[variant=tin] projectcoal:block_ore[variant=silver] projectcoal:block_ore[variant=lead] All of them are passed (IMetadataItem oreBlock argument), but the problem resides in the generateOre function. I am currently debugging it, and now only the TIN variant is used, so it isn't just copper. I'll further debug it and let you all know. In the meantime, thanks. Edit: Another test, another ore. This time lithium. By the way, it seems that only copper, tin and lithium generate. (Each for every new world). Pretty odd.
  17. Hi. I have a world generation system that mostly works. The problem is that with my system, I register 5 different ore generators, but odd things happen. The ores (and other features) generate fine, but it seems that for each world, one ore is "chosen" and that's the only ore that is generated. It's usually the first one in the list, so copper. I have added a few placeholder ores to test it further, but the issue still occurs. [spoiler=WorldGenRegistry.java (getInstance().registerFeatures() called during Init)] package projectcoal.common.registry; import net.minecraft.init.Blocks; import net.minecraftforge.fml.common.registry.GameRegistry; import projectcoal.common.block.BlockOre; import projectcoal.common.world.gen.WorldGenFeature; import projectcoal.common.world.gen.feature.*; public class WorldGenRegistry { private static WorldGenRegistry instance; private final static int NETHER = -1, OVERWORLD = 0, END = 1; public static WorldGenRegistry getInstance(){ return instance == null ? new WorldGenRegistry() : instance; } public void registerFeatures() { registerFeature(new FeatureOre(BlockOre.EnumType.COPPER, Blocks.air, 18, 6, 6, 96, 256, false), OVERWORLD); registerFeature(new FeatureOre(BlockOre.EnumType.LITHIUM, Blocks.air, 18, 6, 6, 96, 256, false), OVERWORLD); registerFeature(new FeatureOre(BlockOre.EnumType.TIN, Blocks.air, 18, 6, 6, 96, 256, false), OVERWORLD); registerFeature(new FeatureOre(BlockOre.EnumType.SILVER, Blocks.air, 18, 6, 6, 96, 256, false), OVERWORLD); registerFeature(new FeatureOre(BlockOre.EnumType.LEAD, Blocks.air, 18, 6, 6, 96, 256, false), OVERWORLD); //registerFeature(new FeatureTree(BlockRegistry.getBlockFromMap("block_log_nether").getDefaultState(), BlockRegistry.getBlockFromMap("block_leaves_nether").getDefaultState(), true, 6, 4, Blocks.soul_sand.getDefaultState()), NETHER); } public void registerFeature(Feature feature, int... dimensions) { GameRegistry.registerWorldGenerator(new WorldGenFeature(feature, dimensions), 1000); } } [spoiler=WorldGenFeature.java] package projectcoal.common.world.gen; import java.util.Random; import projectcoal.common.world.gen.feature.Feature; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.fml.common.IWorldGenerator; public class WorldGenFeature implements IWorldGenerator { private final Feature feature; private int[] dimensions = { 0 }; public WorldGenFeature(Feature feature, int... dimensions) { this.feature = feature; this.dimensions = dimensions; } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { for (int dimension : dimensions) { if (dimension == world.provider.getDimensionId()) { feature.tryGenerate(world, chunkX, chunkZ, random); } } } } [spoiler=Feature.java] package projectcoal.common.world.gen.feature; import java.util.Random; import net.minecraft.block.state.IBlockState; import net.minecraft.util.BlockPos; import net.minecraft.world.World; public abstract class Feature { public boolean notifyBlocks; public int count, minYCoord, maxYCoord; public Feature(int count, int minY, int maxY, boolean notifyBlocks) { this.count = count; this.minYCoord = minY; this.maxYCoord = maxY; this.notifyBlocks = notifyBlocks; } public boolean tryGenerate(World world, int chunkX, int chunkZ, Random random) { generate(world, chunkX, chunkZ, random); world.getChunkFromChunkCoords(chunkX, chunkZ).setChunkModified(); return true; } public abstract void generate(World world, int chunkX, int chunkZ, Random random); protected void setBlock(World worldIn, BlockPos pos, IBlockState blockState) { if (this.notifyBlocks) { worldIn.setBlockState(pos, blockState, 3); } else { worldIn.setBlockState(pos, blockState, 2); } } } [spoiler=FeatureOre.java] package projectcoal.common.world.gen.feature; import java.util.Random; import projectcoal.common.IMetadataItem; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.pattern.BlockHelper; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenMinable; public class FeatureOre extends Feature { private final IBlockState oreBlock, stoneBlock; private final int minVeinSize, maxVeinSize; public FeatureOre(IMetadataItem oreBlock, Block stoneBlock, int count, int minVeinSize, int maxVeinSize, int minY, int maxY, boolean notifyBlocks) { super(count, minY, maxY, notifyBlocks); this.oreBlock = Block.getBlockFromItem(oreBlock.toItemStack(1).getItem()).getStateFromMeta(oreBlock.getMetadata()); this.stoneBlock = stoneBlock.getDefaultState(); this.minVeinSize = minVeinSize; this.maxVeinSize = maxVeinSize; } public FeatureOre(Block oreBlock, int oreMeta, Block stoneBlock, int stoneMeta, int count, int minVeinSize, int maxVeinSize, int minY, int maxY, boolean notifyBlocks) { super(count, minY, maxY, notifyBlocks); this.oreBlock = oreBlock.getStateFromMeta(oreMeta); this.stoneBlock = stoneBlock.getStateFromMeta(stoneMeta); this.minVeinSize = minVeinSize; this.maxVeinSize = maxVeinSize; } @Override public void generate(World world, int chunkX, int chunkZ, Random random) { for (int i = 0; i < this.count; i++) { int x = (chunkX * 16) + random.nextInt(16); int y = minYCoord + random.nextInt(Math.max(maxYCoord - minYCoord, 0)); int z = (chunkZ * 16) + random.nextInt(16); generateOre(world, random, new BlockPos(x, y, z)); } } public void generateOre(World world, Random random, BlockPos pos) { int veinSize = minVeinSize + random.nextInt(Math.max(maxVeinSize - minVeinSize + 1, 0)); new WorldGenMinable(oreBlock, veinSize, BlockHelper.forBlock(stoneBlock.getBlock())).generate(world, random, pos); } } [spoiler=BlockOre.java (IMetadataItem is an interface that defines metadata blocks/items via enums)] package projectcoal.common.block; import java.util.List; import org.apache.commons.lang3.text.WordUtils; import projectcoal.common.IMetadataItem; import projectcoal.common.block.prefab.BlockMultiPC; import projectcoal.common.registry.BlockRegistry; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IStringSerializable; @SuppressWarnings({ "unchecked", "rawtypes" }) public class BlockOre extends BlockMultiPC { public static final PropertyEnum VARIANT = PropertyEnum.create("variant", BlockOre.EnumType.class); public BlockOre() { super(Material.rock); setResistance(6000000.0F); setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockOre.EnumType.COPPER)); } public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(VARIANT, BlockOre.EnumType.get(meta)); } public int getMetaFromState(IBlockState state) { return ((BlockOre.EnumType) state.getValue(VARIANT)).getMetadata(); } protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { VARIANT }); } @Override public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { for (BlockOre.EnumType variant : BlockOre.EnumType.values()) { list.add(new ItemStack(itemIn, 1, variant.getMetadata())); } } @Override public boolean useCustomRender() { return false; } public static enum EnumType implements IMetadataItem, IStringSerializable { COPPER(0, "copper"), LITHIUM(1, "lithium"), TIN(2, "tin"), SILVER(3, "silver"), LEAD(4, "lead"); private final String typeName; private final int metadata; private static final EnumType[] META_LOOKUP = new EnumType[values().length]; static { for (EnumType variant : values()) { META_LOOKUP[variant.getMetadata()] = variant; } } private EnumType(int meta, String oreName) { typeName = oreName; metadata = meta; } @Override public String getUnlocalizedName() { return "block_ore_" + typeName; } @Override public ItemStack toItemStack(int amount) { return BlockRegistry.getItemStackFromMap(getUnlocalizedName(), amount, ordinal()); } public static EnumType get(int ordinal) { return EnumType.values()[ordinal]; } public static EnumType byMetadata(int meta) { if (meta < 0 || meta >= META_LOOKUP.length) { meta = 0; } return META_LOOKUP[meta]; } @Override public String getName() { return typeName; } @Override public String toString() { return getName(); } @Override public int getMetadata() { return metadata; } @Override public String getGenericName() { return "block_ore"; } @Override public String getOreDictionaryName() { return "ore" + WordUtils.capitalize(typeName); } } } I really can't find an issue with this system, I have debugged and all of the ores appear to be registered, but WorldGenMinable (called in FeatureOre) is always called with a copper ore block argument. That is what I don't get. Thanks in advance. PS: Please, do not mind the arguments passed during registration, they are just for the sake of testing.
  18. Yes, I noticed I had used a new instance afterwards. Anyway I have removed the MinecraftForge.EVENT_BUS.register(new EventHandler()); line of code, so I guess it won't be a problem for the time being. Thank you for that, too.
  19. Alright, thanks for clearing that up for me. Cheers!
  20. Hi. Simple question I'm not sure about. MinecraftForge.EVENT_BUS.register(new EventHandler()); FMLCommonHandler.instance().bus().register(new EventHandler()); Would registering the same EventHandler on two buses (for different types of events) have any consequences? If so, could you explain why? Thanks.
  21. Hi. I have just checked TheGrayGhost's MinecraftByExample, and I have noticed that he has used a model builder which exports the model into a vertex array. I would just like to know what programs can do such a thing, if you know any, as I could not find anything. Thanks in advance.
  22. Hi everyone, It's been quite a bit of time.. I just started playing around with 1.8, and I have encountered an error with the new model system. I have already looked the forums, but still got the issue.. Here's the crash: CoalPower.java package coalpower; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.*; import coalpower.common.CommonProxy; import coalpower.registry.BlockRegistry; @Mod(modid = CoalPower.MODID, name = CoalPower.NAME) public class CoalPower { public static final String MODID = "coalpower"; public static final String NAME = "CoalPower"; public static final String RESOURCE_PREFIX = MODID.concat(":"); @Mod.Instance("coalpower") public static CoalPower instance; @SidedProxy(serverSide = "coalpower.common.CommonProxy", clientSide = "coalpower.client.ClientProxy") public static CommonProxy proxy; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } @Mod.EventHandler public void init(FMLInitializationEvent event) { proxy.init(event); } @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { proxy.postInit(event); } } ClientProxy.java package coalpower.client; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import coalpower.client.render.block.RenderTileEntityCrushingTable; import coalpower.common.CommonProxy; import coalpower.common.tileentity.TileEntityCrushingTable; public class ClientProxy extends CommonProxy{ @Override public void preInit(FMLPreInitializationEvent event) { super.preInit(event); } @Override public void init(FMLInitializationEvent event) { super.init(event); registerBlockRenders(); registerItemRenders(); } @Override public void postInit(FMLPostInitializationEvent event) { super.postInit(event); } public void registerBlockRenders(){ ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrushingTable.class, new RenderTileEntityCrushingTable()); } public void registerItemRenders(){ } } CommonProxy.java package coalpower.common; import coalpower.registry.BlockRegistry; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class CommonProxy { public void preInit(FMLPreInitializationEvent event) { BlockRegistry.registerBlocks(); BlockRegistry.registerTiles(); } public void init(FMLInitializationEvent event) { } public void postInit(FMLPostInitializationEvent event) { } } BlockRegistry.java package coalpower.registry; import java.util.HashMap; import java.util.Map; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fml.common.registry.GameRegistry; import coalpower.CoalPower; import coalpower.common.block.*; import coalpower.common.tileentity.*; public class BlockRegistry { private static Map<String, Block> blockMap = new HashMap<String, Block>(); public static void registerBlocks() { registerBlock(new BlockCrushingTable().setUnlocalizedName("block_crushing_table")); } public static void registerTiles() { registerTile(TileEntityCrushingTable.class, "tile_crushing_table"); } public static void registerBlock(Block block) { GameRegistry.registerBlock(block, block.getUnlocalizedName().replace("tile.", "")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(CoalPower.RESOURCE_PREFIX + block.getUnlocalizedName().substring(5), "inventory")); } public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass) { GameRegistry.registerBlock(block, itemclass, block.getUnlocalizedName().replace("tile.", "")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(CoalPower.RESOURCE_PREFIX + block.getUnlocalizedName().substring(5), "inventory")); } public static void registerTile(Class<? extends TileEntity> tileEntityClass, String id) { GameRegistry.registerTileEntity(tileEntityClass, id); } public static Block get(String name) { return GameRegistry.findBlock(CoalPower.MODID, name); } public static ItemStack get(String name, int meta) { return new ItemStack(get(name), 0, meta); } public static Block fromMap(String name) { return blockMap.get(name); } public static ItemStack fromMap(String name, int meta) { return new ItemStack(fromMap(name), 0, meta); } } Already debugged, block is not null. Everything works by commenting that line out. I feel there's something right under my nose, but I can't figure it out for the life of me.. Any help is appreciated. -NINJA EDIT- Just realized what I have done, give me a second to try and fix it. Ah well, I was sure I didn't put that in preInit... alright, fixed.
  23. If you want I could pm you my skype account, as I don't have that thing you mentioned earlier. Just for chatting though, don't expect any calls to be answered. Pm me if you agree, let's stop bumping the thread here. EDIT: Forget it, I just noticed that gitter is a part of Github, and I do have an account there, pm me for details.
  24. Glad to help out, but please... write your own version of that alright? Mine was only for you to get my concept..
  25. Mine is a bit more complex than this. Might aswell just produce some code right now, give me a few minutes.. Ok, sorry for the delay. Be advised, this is a bad written snippet of code, don't copy it, it's only a general idea.. Sorry if you see something obviously stupid in there..
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.