Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/09/17 in all areas

  1. Delete the coremods. And update to 1.11.2
    2 points
  2. This post also gives another example using the newer registration events and a couple simple items and blocks.
    2 points
  3. In what events do you call those other classes? It's not about which class the method is in, it's about which stage of mod loading it happens in. Edit: Posting all your up-to-date code would be the easiest solution.
    1 point
  4. That doesn't answer the question, when is it called?
    1 point
  5. Where do you call these methods? ModelLoader.setCustomModelResourceLocation needs to be in either FMLPreInitializationEvent or ModelRegistryEvent.
    1 point
  6. If you control the Block but not all the Items, it's best to handle the interactions in Block#onBlockActivated. If you control the Items but not the Block, it's best to handle the interactions in Item#onItemUse. If you control neither the Block nor the Items, you can handle the interactions using PlayerInteractEvent.RightClickBlock.
    1 point
  7. In 1.8.9 (before item properties were added), this was handled by TextureCompass rather than the IItemPropertyGetters and overrides in the model.
    1 point
  8. No, it's an instance field so you need to specify which instance to change the field's value for. If you get/set the value of a field or call a method with reflection more than once, you should use ReflectionHelper.findField/findMethod to look up the Field/Method object, store it in a private static field and then use it whenever you need to interact with the field/method. Looking up the Field/Method object is relatively slow, so you should only do it once.
    1 point
  9. You need to override isOpaqueCube and isFullCube in your block class to return false, so that it always renders the faces of adjacent blocks.
    1 point
  10. You have installed bad coremods, stop using coremods. And update to 1.11.2.
    1 point
  11. What did you see happening when you set breakpoints and used the debugger to step through the code that's trying to generate your structure?
    1 point
  12. Mmmm, then i have no clue why this is not working for you I'll post here an example of working class i'm using that spawns an obelisk in the world public class WorldGenObelisk { private int mirror; private int rotation; public WorldGenObelisk(BlockPos pos, World world) { mirror = MW.rand.nextInt(Mirror.values().length); rotation = MW.rand.nextInt(Rotation.values().length); this.loadStructure(pos, world, "obelisk", true); } public void loadStructure(BlockPos pos, World world, String name, boolean check) { boolean flag = false; if (!world.isRemote) { WorldServer worldserver = (WorldServer) world; MinecraftServer minecraftserver = world.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); ResourceLocation loc = new ResourceLocation(MW.MODID, name); Template template = templatemanager.func_189942_b(minecraftserver, loc); if (template != null) { IBlockState iblockstate = world.getBlockState(pos); world.notifyBlockUpdate(pos, iblockstate, iblockstate, 3); flag = true; if (check) { for (int i = 0; i < template.getSize().getX(); i++) { for (int j = 0; j < template.getSize().getZ(); j++) { BlockPos down = pos.add(i, -1, j); Block b = world.getBlockState(down).getBlock(); if (!b.equals(Blocks.SAND)) { flag = false; } } } } if (flag) { PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.values()[mirror]) .setRotation(Rotation.values()[rotation]).setIgnoreEntities(false).setChunk((ChunkPos) null) .setReplacedBlock((Block) null).setIgnoreStructureBlock(true); template.addBlocksToWorldChunk(world, pos.down(), placementsettings); } } } } } This class is called from the WorldGenMinable class, in the generateOverworld method (so where you put the code to spawn ores) by doing this if (world.getBiomeGenForCoords(new BlockPos(x, 60, z)).equals(Biomes.DESERT) && random.nextInt(70) == 1) { int randPosX = x + random.nextInt(35); int randPosZ = z + random.nextInt(35); int randPosY = 60 + random.nextInt(255 - 64); BlockPos position = new BlockPos(randPosX, randPosY, randPosZ); if (!(world.getBlockState(world.getTopSolidOrLiquidBlock(position)).getBlock().equals(Blocks.WATER))) new WorldGenObelisk(world.getTopSolidOrLiquidBlock(position), world); } Notice that in the structure class it will also check if the spawn area is a valid area, you can remove that if you want. I hope this help, if not you can try looking at how Structure Blocks load structures and edit that code (since is exactly what i've done, maybe some small changes has been made but since is still 1.10.2 i don't think so)
    1 point
  13. That's close, but you're trying to call the constructor like a regular method instead of using the new operator, which won't compile. You're using MinecraftServer#getEntityWorld to get the World, but this is always dimension 0, which the player may not be in. You should use the player's World instead. You're also getting the villager from the World in the constructor, which is still called on the network thread. Don't do this, it's not safe to call methods like this from the network thread. The Runnable implementation doesn't have to be a named class, it could be an anonymous class or a lambda. If you want it to be named, I suggest making it a nested class of the IMessage or the IMessageHandler. You don't get a container out of an inventory, I'm not entirely sure what you're talking about. You can have multiple Container classes that interact with the same slots of an inventory without issue. For example, almost every Container includes the same slots of the player's inventory. An IItemHandler is a persistent inventory, it's generally created once when the containing object (e.g. an Entity or TileEntity) is created and read from and written to NBT with the containing object. A Container is a temporary view of specific slots of one or more inventories, it's generally created when a player opens a GUI and released for garbage collection when the GUI is closed. Its sole purpose is to handle client/server interaction and synchronisation for a GUI.
    1 point
  14. You may benefit from a straightforward beginner's tutorial like those from ShadowFacts. https://shadowfacts.net/tutorials/forge-modding-1112/ You'll want to work through all the tutorials up through Basic Blocks to make sure you get all the pieces right.
    1 point
  15. We can't help you if we don't know what you've tried so far.
    1 point
  16. There are three events you need: https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/flowers/FlowerEventHandler.java#L101-L118 One for reading the data, one for writing the data, and one from freeing the data from RAM.
    1 point
  17. EDIT: I've looked at the Strucutre Block class and i found out how to load a structure. But for some reason if i generate a new world and (for example) try to load this structure right-clicking an item it seems like the game can't find the structure (wich is stored in the structures folder into resources). This is the dummy item class i use to "spawn" the structure public class ItemMW extends Item { public ItemMW(CreativeTabs tab) { this.setCreativeTab(tab); } @Override public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { if (!worldIn.isRemote) this.func_189714_c(playerIn.getPosition(), worldIn); return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand); } public boolean func_189714_c(BlockPos pos, World world) { WorldServer worldserver = (WorldServer) world; MinecraftServer minecraftserver = world.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); Template template = templatemanager.func_189942_b(minecraftserver, new ResourceLocation(MW.MODID + ":" + "structures/pagoda.nbt")); if(template == null) { System.out.println("NO STRUCTURE"); return false; } BlockPos blockpos2 = template.getSize(); IBlockState iblockstate = world.getBlockState(pos); world.notifyBlockUpdate(pos, iblockstate, iblockstate, 3); PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.NONE) .setRotation(Rotation.NONE).setIgnoreEntities(false).setChunk((ChunkPos) null) .setReplacedBlock((Block) null).setIgnoreStructureBlock(false); template.addBlocksToWorldChunk(world, pos.add(0, 1, 0), placementsettings); return true; } } The NBT file is stored into resources-assets-mw-structures-pagoda.nbt (mw is the mod id) EDIT 2: Found out a way to make it works. The problem was (as i suspected) in the ResourceLocation, that for some reason pointed at a wrong location. By changing that i can spawn my structure and also integrating this function into (for example) a biome class i can spawn it randomly in the world using the nbt file public void loadStructure(BlockPos pos, World world, String name) { WorldServer worldserver = (WorldServer) world; MinecraftServer minecraftserver = world.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); ResourceLocation loc = new ResourceLocation(MW.MODID, name); Template template = templatemanager.func_189942_b(minecraftserver, loc); if (template != null) { IBlockState iblockstate = world.getBlockState(pos); world.notifyBlockUpdate(pos, iblockstate, iblockstate, 3); PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.NONE) .setRotation(Rotation.NONE).setIgnoreEntities(false).setChunk((ChunkPos) null) .setReplacedBlock((Block) null).setIgnoreStructureBlock(false); template.addBlocksToWorldChunk(world, pos.add(0, 1, 0), placementsettings); } }
    1 point
×
×
  • Create New...

Important Information

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