Jump to content

peter1745

Members
  • Posts

    53
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by peter1745

  1. Never mind. I just realized that it's not an actual loot table but it's actually just a Resource Location... Sorry...
  2. Don't you have to register it? I want to assign the loot table to a chest in my structure generation code, it's not for a block or entity. I want to do something like this: protected void handleDataMarker(String function, BlockPos pos, IWorld worldIn, Random rand, MutableBoundingBox sbb) { if ("chest".equals(function)) { worldIn.setBlockState(pos, Blocks.CHEST.getDefaultState().with(ChestBlock.WATERLOGGED, Boolean.valueOf(worldIn.getFluidState(pos).isTagged(FluidTags.WATER))), 2); TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof ChestTileEntity) { ((ChestTileEntity)tileentity).setLootTable(this.isLarge ? LootTables.CHESTS_UNDERWATER_RUIN_BIG : LootTables.CHESTS_UNDERWATER_RUIN_SMALL, rand.nextLong()); } } } That code is taken from the Ocean Ruin Structure, as you can see they load a loot table, register it and then access it from the Ocean Ruin Structure.
  3. I'm currently working on creating my own loot table. I don't want to inject into an already existing table, I want to load my own but I haven't found any resources on it and I'm unable to figure out how to do it by looking through the code. Does anyone know how to do it? Thank you.
  4. Thanks for the tip! It seems like the easiest structure to mimic is actually the fossil structure. It's the easiest to understand at least.
  5. Hello! I'm looking for tutorials on structure generation for 1.14 or 1.15. I've found a few tutorials on the subject but none are up to date. I've tried to look at how vanilla minecraft does it, but I can't figure out how to do it myself. And I don't understand the concepts enough to do so. if anyone knows how to do this, or has any pointers to tutorials it would be very much appreciated
  6. Yeah I know vanilla isn't developed for mods, but it would still be convenient if you could easily make custom variants of certain blocks and things like effects. It's not really a big deal to have to create a brand new class, but it's still more convenient if don't have to. Especially since you might not want to add custom behavior.
  7. I was recently trying to create a custom Effect and a custom glass pane. But I had to make my own custom class that extended the Effect class since it's constructor is marked protected. I had to the same thing with my custom glass pane. I don't get why these constructors are protected? Is there actually a reason for it? Seems unnecessary to have to create empty classes just to access a constructor of a vanilla one. I mean yeah, if you're want implement some custom behavior then you obviously have to create a custom class, but I just want custom textures, not custom functionality which means that creating a brand new class is really wasteful.
  8. Managed to solve it by overriding the same functions as the AbstractGlassBlock class. Can't really say what the issue was since the function names aren't obvious.
  9. Nope. Didn't do the trick, I'll have to look into the Glass code but I think it might be a side effect of the block being water logged AND cut out. Also, in order to format actual code you can click the "<>" icon in the reply editor
  10. I'm having a strange lighting bug/issue with a block that I've added to my mod. It's a cutout block, so I've set the RenderTypeLookup for the block to cutout. I've tried overriding the methods that checks if it's a "normal" cube but that didn't solve it. Anyone know what the problem is?
  11. Yeah it is. I wasn't sure how that functionality was implemented in the game initially but water logging crops prevents water from breaking them.
  12. I would recommend taking a look at Obfuscate by MrCrayfish. I think it allows you to do things like that. But code injection and such is quite an advanced topic in modding.
  13. For 1.15? I doubt there's any tutorials of world generation yet since 1.15 is relatively new. You should take a look at how vanilla minecraft does it.
  14. I tried making a crop that could be waterlogged and that worked. I don't think blocksMovement affects whether or not water pops a crop off since things like kelp doesn't block movement. But thank you either way for the suggestion!
  15. Hello! I'm currently working on a mod that will expand upon the underwater changes 1.13 introduced, and as part of that I want to make growing crops underwater a possibility (Vanilla crops won't be able to grow under water though). I've made it so that you can till soil under water, but I'm not sure how crops breaking under water is implemented (and how to get around it). I'm wondering if crops breaking due to water is implemented in the water fluid system or if it's implemented by the parent class of all crops? I've looked around a bit but due to searge names (i think that's what they're called) it's not super clear what each function does. Anyone know roughly how it works? EDIT I'm obviously going to have to waterlog all crops that can exist under water, but I'm not sure if that will solve it.
  16. Turns out it was much simpler than I thought. I didn't realize that canceling the event reset the world state, so when I stopped canceling the event it worked. I literally just have to call World#setBlockState... Well, thank you very much for the help! I highly appreciate it, oh and I'm sorry if was a bit slow with understanding what you meant. I haven't touched modding in almost a year so I'm a bit rusty
  17. I'll try removing the block that's already there by calling World#removeBlock before I call World#setBlockState
  18. Alright, I got it to sort of works. The problem is that by the time I call setBlockState the world still thinks that the vanilla log occupies that block which means it will simply ignore the setBlockState call. I'm not sure how to solve this but I'll take a look at it.
  19. Hmm... So I've moved the event to the server side by using a proxy and only registering the class in the server proxy, I've also changed the flag to 3 instead of 2. But it still doesn't work. I'll post the code for both proxy stuff and the actual class below: package com.oceanicsurvival.common; import com.oceanicsurvival.core.ModBlocks; import com.oceanicsurvival.utils.OceanicUtils; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class CommonEvents { @SubscribeEvent public void onBlockPlaced(BlockEvent.EntityPlaceEvent event) { IWorld world = event.getWorld(); if (!world.isRemote()) { BlockPos pos = event.getPos(); if (OceanicUtils.isBelowWater(world, pos)) { if (event.getPlacedBlock().getBlock() == Blocks.OAK_LOG) { world.setBlockState(pos, ModBlocks.WET_OAK_LOG.getDefaultState(), 3); event.setCanceled(true); } } } } } package com.oceanicsurvival; import com.oceanicsurvival.core.ModBlocks; import com.oceanicsurvival.proxy.ClientProxy; import com.oceanicsurvival.proxy.CommonProxy; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod(Constants.MODID) public class OceanicSurvival { public static final Logger LOGGER = LogManager.getLogger(); public static final CommonProxy PROXY = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new); public static final ItemGroup BLOCKS_GROUP = new ItemGroup("blocks") { @Override public ItemStack createIcon() { return new ItemStack(ModBlocks.WET_OAK_LOG); } }; public OceanicSurvival() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup); } private void onCommonSetup(final FMLCommonSetupEvent event) { PROXY.onSetupCommon(); } private void onClientSetup(final FMLClientSetupEvent event) { PROXY.onSetupClient(); } } package com.oceanicsurvival.proxy; import com.oceanicsurvival.common.CommonEvents; import net.minecraftforge.common.MinecraftForge; public class CommonProxy { public void onSetupCommon() { MinecraftForge.EVENT_BUS.register(new CommonEvents()); } public void onSetupClient() {} } The ClientProxy simply overrides the CommonProxy (which I know should be called ServerProxy). I've double checked and the event only runs on the server side. I'm clueless
  20. The class is called ClientEvents because I was originally thought that those events would be detected on the client, I haven't bothered renaming it yet. So the entire event should be handled on the server? It's a bit difficult to know since forge doesn't do a great job of explaining which events are triggered on what side. I'm using 2 since that's the flag used to notify clients that a blockstate has changed? Shouldn't I be using that?
  21. @Mod.EventBusSubscriber(modid = Constants.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class ClientEvents { @SubscribeEvent public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) { IWorld world = event.getWorld(); BlockPos pos = event.getPos(); if (OceanicUtils.isBelowWater(world, pos)) { if (event.getPlacedBlock().getBlock() == Blocks.OAK_LOG) { world.setBlockState(pos, ModBlocks.WET_OAK_LOG.getDefaultState(), 2); event.setCanceled(true); } } } }
  22. Hello! I'm currently working on an aquatic update related mod, and I want to make it so that if a log is placed underwater it will be replaced with my custom "rotten" log. I've managed to *sort of* prevent the placement of logs underwater by listening for the BlockEvent.EntityPlaceEvent event and cancelling that. But when I call world.setBlockState with my custom block it doesn't actually place the block. Nothing happens, the vanilla log get's placed for like a second, then it disappears and my custom block doesn't appear.
  23. So I'm assuming it's safe to remove all other source sets? Kind of annoying to try to navigate to a certain symbol only to end up in the wrong version of the class...
  24. Yeah, not really maintaining the mod that this belongs to anymore. It was just an example, and it's not really relevant to this topic either
  25. Hello! I just saw that you referenced my old post, so I'm not sure if you've fixed this already, but I figured I would post my solution anyway: Under the data folder, I created three new folders: one called minecraft, inside that one i created one called tags, and inside that one I created one called blocks. Now, inside the tags/blocks folder I create a fences.json file with the following in it: { "replace": false, "values": [ "pme:pier_fence" ] } Unlike you I didn't create a custom Fence class, I just used Minecrafts in-built one, since I didn't need any additional functionality, so unless you're creating some "special" fence that has additional functionality, you could just use the in-built class. Hope this helped if you haven't already solved the problem! ?
×
×
  • Create New...

Important Information

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