Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

fr0st

Forge Modder
  • Posts

    116
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    Italy
  • Personal Text
    I used to be new!

fr0st's Achievements

Creeper Killer

Creeper Killer (4/8)

8

Reputation

  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.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.