Jump to content

BlockyPenguin

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by BlockyPenguin

  1. I've got my workspace laid out as such: [workspace root] | |-- LabKore | | | |-- build.gradle | |-- src, etc.. | |-- PowerKit | | | |-- build.gradle | |-- src, etc.. | |-- build.gradle |-- settings.gradle |-- etc.. PowerKit and LabKore are two individual mods. I wish for PowerKit to have a dependency on LabKore, and although everything looks fine in Eclipse, when I run runClient, Minecraft crashes with a InvocationTargetException. Looking in the logs, I see the following lines of interest: Exception message: java.lang.NoSuchMethodError: 'net.minecraft.world.item.Item$Properties net.minecraft.world.item.Item$Properties.m_41491_(net.minecraft.world.item.CreativeModeTab)' Cannot deobfuscate dependency of type DefaultProjectDependency_Decorated, using obfuscated version! In PowerKit's build.gradle, I have added LabKore as a dependency like so: dependencies { implementation fg.deobf(project(':labkore')) } Why can ForgeGradle not deobfuscate LabKore? How can I fix it? Thanks
  2. So, I need to be able to read custom json files stored in a mod's modid/data folder, or in a datapack, like recipes or models. How would I go about doing this? Thanks
  3. Modifying vanilla with Mixins, no Forge, no Fabric, just plain old vanilla. I know, it's not recommended, but it's a personal project of mine, just to see where it could lead. I have no intentions of making anything fancy, i.e. "real" modified servers like paper or sponge, it's more of a testing ground. Any ideas as to how to fix this?
  4. I'm attempting to use FG to download the vanilla Minecraft server. Gradle throws this massive error: hastebin build.gradle:
  5. Okay, so what would I set the seed to? I already have a public static final Random instance in my main class, would that do the job?
  6. That's strange, because I'm definitely calling it on a World object, unless World implements IWorldReader. So this is what I've got: @Override public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { IChunk ichunk = world.getChunk(player.getPosition()); if(ichunk instanceof Chunk) { Chunk chunk = (Chunk)ichunk; long seed = MathHelper.getCoordinateRandom(player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ()); seed += chunk.getInhabitedTime() * Config.RIFT_MULTIPLICATION_FACTOR.get(); player.sendStatusMessage(new StringTextComponent(seed + ""), false); } return ActionResult.resultSuccess(player.getHeldItem(hand)); } But how would I turn that into value between 0 and 1? or at least 0 and 100, or some other easily measurable number. Then I've also got to worry about the boolean dictating whether or not a chunk is a rift or not.
  7. Okay, thanks Here is the source code of World#getChunk: default IChunk getChunk(BlockPos pos) { return this.getChunk(pos.getX() >> 4, pos.getZ() >> 4); } So what do you suggest I do then?
  8. Because World#getChunk() returns an IChunk. Ah, thanks. TBH, I'm a little concerned about changing over to Mojang mappings, I know there are a few legality issues still. What would be the right place to ask about this?
  9. Okay, so, let's say that I want to get this data when an item is right clicked, it would be something like this, right? @Override public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { ItemStack stack = player.getHeldItem(hand); Chunk c = (Chunk)world.getChunk(player.getPosition()); c.getInhabitedTime(); return ActionResult.resultSuccess(stack); } But MathHelper.getSeed doesn't seem to exist...
  10. Okay... so how would i get the chunk then? Would it help if i uploaded my code to github?
  11. But wouldn't it be incremented at a different rate? I think I forgot to mention as well, that I have the float set to a random value between 0.0 and 0.2 in the capability's default implementation's constructor.
  12. Okay, I'm thinking we're not quite on the same page here, so I'll start again: I've made a capability for chunks, which contains a float value. I would like the float to increase by 0.1 every x amount of time. My thought is that if I get all the loaded chunks, I can iterate over them and increase this value. As to how I would implement a timer without a tick() method, I am at a loss, but one problem at a time.
  13. Every loaded chunk, I guess...
  14. Yes, but how do I get the instance of Chunk? That's what's confusing me...
  15. Oh, ok... but my question still remains as to how to get the inhabited time.
  16. So this is my capability: public class RiftCapability implements IRift { private boolean isRift; private float riftActivityPercent; public RiftCapability() { this.isRift = Rifts.RAND.nextInt(100) < 5; this.riftActivityPercent = isRift ? Utils.randomFloatBounds(0.15f) : 0.0f; } public RiftCapability(boolean isRift, float riftActivityPercent) { this.isRift = isRift; this.riftActivityPercent = riftActivityPercent; } @Override public boolean isRift() { return isRift; } @Override public float getRiftActivityPercent() { return riftActivityPercent; } @Override public void setRiftActivityPercent(float riftActivityPercent) { if(riftActivityPercent < 0 || riftActivityPercent > 1) throw new IndexOutOfBoundsException("Rift Activity Percent cannot be less than 0 or greater than 1!"); else this.riftActivityPercent = riftActivityPercent; } @Override public void openRift() { this.isRift = true; } @Override public void closeRift() { this.isRift = false; } @Override public void riftEvent() { //TODO: Fire a rift event. } } This is my provider: public class RiftCapabilityProvider implements ICapabilitySerializable<INBT> { @CapabilityInject(IRift.class) public static final Capability<IRift> RIFT_CAPABILITY = null; private LazyOptional<IRift> instance = LazyOptional.of(RIFT_CAPABILITY::getDefaultInstance); @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return cap == RIFT_CAPABILITY ? instance.cast() : LazyOptional.empty(); } @Override public INBT serializeNBT() { return RIFT_CAPABILITY.getStorage().writeNBT( RIFT_CAPABILITY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null ); } @Override public void deserializeNBT(INBT nbt) { RIFT_CAPABILITY.getStorage().readNBT( RIFT_CAPABILITY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt ); } } And I attach it like so: public static void attachRiftCapability(AttachCapabilitiesEvent<Chunk> event) { World world = event.getObject().getWorld(); if(!world.isRemote) event.addCapability(new ResourceLocation(Rifts.MODID, "rift_capability"), new RiftCapabilityProvider()); } Does this help?
  17. So, my capability has a getter for the float, yes, but how would I get the instance of Chunk?
  18. Thanks, I think I'll use Chunk#getInhabitedTime. Where should I put my code though? Is there an event or something?
  19. So I have made a capability for chunks, and it has a float field in it. I would like the float to tick up by 0.1 every x amount of ticks (configurable by user). How would I go about doing this? Thanks!
  20. I got it working! Thank you
  21. It's worth noting that you'll need to find "Different Mod"'s gradle repository (in my case jitpack), and add it to your dependencies. (If you haven't removed them already, there will be a bunch of comments here with examples too.) Here I am importing a (currently unreleased) mod of mine called LabKore on version 1.3.0-SNAPSHOT from GitHub. repositories { maven { url 'https://jitpack.io' } } dependencies { minecraft 'net.minecraftforge:forge:1.16.5-36.0.54' implementation fg.deobf('com.github.ThatBlockyPenguin:LabKore:v1.3.0-SNAPSHOT') } I hope that helps!
  22. Hi, I'm trying to save some additional data to chunks, and have figured out that Capabilities are probably the way to go. After looking around the internet for a bit I think I got the gist and I set to coding. However, the AttachCapabilitiesEvent#addCapability() method seems to require an ICapabilityProvider, which I don't remember seeing anything on. Here's what I've got so far: IRift class: public interface IRift { boolean isRift(); float getRiftActivityPercent(); void setRiftActivityPercent(float riftActivityPercent); void makeRift(); void closeRift(); void riftEvent(); } RiftStorage class: public class RiftStorage implements Capability.IStorage<IRift> { @Override public INBT writeNBT(Capability<IRift> capability, IRift instance, Direction side) { CompoundNBT nbt = new CompoundNBT(); if(instance.isRift()) { nbt.putBoolean("isRift", instance.isRift()); nbt.putFloat("riftActivityPercent", instance.getRiftActivityPercent()); } return nbt; } @Override public void readNBT(Capability<IRift> capability, IRift instance, Direction side, INBT nbt) { CompoundNBT cnbt = ((CompoundNBT)nbt); if(cnbt.getBoolean("isRift")) { instance.makeRift(); instance.setRiftActivityPercent(cnbt.getFloat("riftActivityPercent")); } } } RiftCapability class: public class RiftCapability implements IRift { private boolean isRift = false; private float riftActivityPercent = 0.0f; @Override public boolean isRift() { return isRift; } @Override public float getRiftActivityPercent() { return riftActivityPercent; } @Override public void setRiftActivityPercent(float riftActivityPercent) { if(riftActivityPercent < 0 || riftActivityPercent > 1) throw new IndexOutOfBoundsException("Rift Activity Percent cannot be less than 0 or greater than 1!"); else this.riftActivityPercent = riftActivityPercent; } @Override public void makeRift() { this.isRift = true; } @Override public void closeRift() { this.isRift = false; } @Override public void riftEvent() { //TODO: Fire a rift event. } } Advice much appreciated. Thanks
×
×
  • Create New...

Important Information

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