Jump to content

ZigTheHedge

Members
  • Posts

    57
  • Joined

  • Last visited

2 Followers

Recent Profile Visitors

5969 profile views

ZigTheHedge's Achievements

Stone Miner

Stone Miner (3/8)

4

Reputation

  1. There's a public constructor in SimpleSoundInstance ) Well, I've changed a code to use direct SoundInstance, big-fat Thank You for the suggestion ) Now it's time to test it in a multiplayer. I'll reply back.
  2. Hey, guys. I'm trying to play a sound in a mod, which is client-only. It works fine with single-player saves, but when trying to use in on a real multiplayer server (without installing the mod on server of course), I'm getting a crash: Here's the code: Registration: public class Sounds { public static final DeferredRegister<SoundEvent> SOUNDS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, TrovoGration.MOD_ID); public static final RegistryObject<SoundEvent> SOUND_ACTION_NEGATIVE = SOUNDS.register("negative_action", () -> new SoundEvent(new ResourceLocation(TrovoGration.MOD_ID,"negative_action"))); public static final RegistryObject<SoundEvent> SOUND_ACTION_POSITIVE = SOUNDS.register("positive_action", () -> new SoundEvent(new ResourceLocation(TrovoGration.MOD_ID,"positive_action"))); public static final RegistryObject<SoundEvent> SOUND_COOLDOWN_START = SOUNDS.register("cooldown_start", () -> new SoundEvent(new ResourceLocation(TrovoGration.MOD_ID,"cooldown_start"))); public static final RegistryObject<SoundEvent> SOUND_COOLDOWN_END = SOUNDS.register("cooldown_end", () -> new SoundEvent(new ResourceLocation(TrovoGration.MOD_ID,"cooldown_end"))); } Main class constructor: public TrovoGration(){ Sounds.SOUNDS.register(FMLJavaModLoadingContext.get().getModEventBus()); } Play code: LocalPlayer player ... ; player.playSound(Sounds.SOUND_ACTION_NEGATIVE.get(), 0.7f, 1.0f); sounds.json: { "positive_action": { "category": "record", "subtitle": "trovogration.subtitle.positive_action", "sounds": [ "trovogration:positive_action" ] }, "negative_action": { "category": "record", "subtitle": "trovogration.subtitle.negative_action", "sounds": [ "trovogration:negative_action" ] }, "cooldown_start": { "category": "record", "subtitle": "trovogration.subtitle.cooldown_start", "sounds": [ "trovogration:cooldown_start" ] }, "cooldown_end": { "category": "record", "subtitle": "trovogration.subtitle.cooldown_end", "sounds": [ "trovogration:cooldown_end" ] } } Help!!
  3. Wow that's new! And it helped! Thanks! And BTW: invalidateCaps isn't needed
  4. Hey guys! I'm porting one of my mods from 1.14.4 to 1.18.2 and got stuck with Capabilities. To ensure that I'm not making a mistake elsewhere, I've started a completely new project just for testing and faced the same issue: I cannot copy capability data to new Player instance on PlayerEvent.Clone on Player's death. My capability class SpiritCapability: public class SpiritCapability { public final ArrayList<DeathEventData> deaths = new ArrayList<>(); public void addDeath(DeathEventType reason, long tod) { deaths.add(new DeathEventData(reason, tod)); } public void copyFrom(SpiritCapability source) { deaths.clear(); deaths.addAll(source.deaths); } public void saveNBTData(CompoundTag compound) { compound.putInt("deathCount", deaths.size()); for (int i = 0; i < deaths.size(); i++) { compound.put("dth_" + i, deaths.get(i).getTag()); } } public void loadNBTData(CompoundTag compound) { deaths.clear(); int deathCount = compound.getInt("deathCount"); for (int i = 0; i < deathCount; i++) { CompoundTag death = compound.getCompound("dth_" + i); deaths.add(new DeathEventData(death)); } } } Capability Provider class SpiritCapabilityProvider: public class SpiritCapabilityProvider implements ICapabilityProvider, INBTSerializable<CompoundTag> { public static Capability<SpiritCapability> SPIRIT_CAP = CapabilityManager.get(new CapabilityToken<>(){}); private SpiritCapability spiritCapability = null; private final LazyOptional<SpiritCapability> opt = LazyOptional.of(this::createCap); @Nonnull private SpiritCapability createCap() { if (spiritCapability == null) { spiritCapability = new SpiritCapability(); } return spiritCapability; } @NotNull @Override public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) { return getCapability(cap); } @NotNull @Override public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap) { if(cap == SPIRIT_CAP) return opt.cast(); else return LazyOptional.empty(); } @Override public CompoundTag serializeNBT() { CompoundTag nbt = new CompoundTag(); createCap().saveNBTData(nbt); return nbt; } @Override public void deserializeNBT(CompoundTag nbt) { createCap().loadNBTData(nbt); } } Capability events: public class SpiritCapabilityEvents { @SubscribeEvent public void onAttachCapabilitiesPlayer(AttachCapabilitiesEvent<Entity> event){ if (event.getObject() instanceof Player) { if (!event.getObject().getCapability(SpiritCapabilityProvider.SPIRIT_CAP).isPresent()) { event.addCapability(new ResourceLocation(SinsOfDeath.MODID, "spiritcap"), new SpiritCapabilityProvider()); } } } @SubscribeEvent public void onPlayerCloned(PlayerEvent.Clone event) { if(event.getOriginal().level.isClientSide) return; if(event.isWasDeath()) { LazyOptional<SpiritCapability> loNewCap = event.getPlayer().getCapability(SpiritCapabilityProvider.SPIRIT_CAP); // loOldCap is never present! LazyOptional<SpiritCapability> loOldCap = event.getOriginal().getCapability(SpiritCapabilityProvider.SPIRIT_CAP); loNewCap.ifPresent( newCap -> { loOldCap.ifPresent( oldCap -> { newCap.copyFrom(oldCap); }); }); } } } Main class: @Mod(SinsOfDeath.MODID) public class SinsOfDeath { // Directly reference a slf4j logger public static final String MODID = "sinsofdeath"; private static final Logger LOGGER = LogUtils.getLogger(); public SinsOfDeath() { // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onRegisterCapabilities); } private void setup(final FMLCommonSetupEvent event) { MinecraftForge.EVENT_BUS.register(new DeathEvent()); MinecraftForge.EVENT_BUS.register(new CommandEvent()); MinecraftForge.EVENT_BUS.register(new SpiritCapabilityEvents()); Networking.registerMessages(); } public void onRegisterCapabilities(RegisterCapabilitiesEvent event) { event.register(SpiritCapability.class); } } When setting capability data, I use the following code server-side: // ep is ServerPlayer ... ep.getCapability(SpiritCapabilityProvider.SPIRIT_CAP).ifPresent(spiritDeath -> { spiritDeath.addDeath(finalDt, ep.deathTime); }); ... Am I forgetting something?
  5. Okay. Solved. If anyone is interested: First of all, I had to use "relocate" in shadowJar to shadow both packages like this: shadowJar { configurations = [project.configurations.embed] relocate 'org.glassfish', 'shaded.glassfish' relocate 'javax.websocket', 'shaded.websocket' classifier = '' } After that, pay close attention at your META-INF. In my case there was a direct reference to unshadowed package service called "javax.websocket.ContainerProvider", containing unshadowed path to class... So, just find a way to replace this file with one, that is referencing your shadowed configuration. In my case, file is called "shaded.websocket.ContainerProvider".
  6. Hey, guys! I'm trying to add javax.websocket in my mod. In dev environment everything is smooth, but when I build my mod and add it to modpack, I'm getting java.lang.NoClassDefFoundError. Here's my build.gradle: buildscript { repositories { maven { url = 'https://maven.minecraftforge.net' } mavenCentral() repositories { maven { url "https://plugins.gradle.org/m2/" } } } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true classpath "com.github.jengelman.gradle.plugins:shadow:4.0.4" } } apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' apply plugin: 'maven-publish' apply plugin: 'com.github.johnrengelman.shadow' version = '1.16.5-1.0.0' group = 'com.cwelth.omd' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'omd' java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8. println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) minecraft { mappings channel: 'official', version: '1.16.5' runs { client { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } server { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } data { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') mods { examplemod { source sourceSets.main } } } } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { mavenLocal() mavenCentral() maven { url = 'https://mvnrepository.com/artifact/javax' } maven { url = 'https://mvnrepository.com/artifact/org.glassfish.tyrus.bundles' } flatDir { dirs 'libs\\' } } configurations { embed compileOnly.extendsFrom(embed) } shadowJar { configurations = [project.configurations.embed] } reobf { shadowJar { dependsOn tasks.createMcpToSrg mappings = tasks.createMcpToSrg.outputs.files.singleFile } } artifacts { archives tasks.shadowJar } dependencies { minecraft 'net.minecraftforge:forge:1.16.5-36.1.30' /* compile 'javax.websocket:javax.websocket-client-api:1.1' compile 'org.glassfish.tyrus.bundles:tyrus-standalone-client:1.9' */ embed 'javax.websocket:javax.websocket-client-api:1.1' embed 'org.glassfish.tyrus.bundles:tyrus-standalone-client:1.9' } // Example for how to get properties into the manifest for reading by the runtime.. jar { manifest { attributes([ "Specification-Title": "examplemod", "Specification-Vendor": "examplemodsareus", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" :"examplemodsareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } jar.finalizedBy('reobfJar') publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } } } And I can see that needed packages are in my compiled jar:
  7. The same question. The only thing I could find is CommentedFileConfig.preserveInsertionOrder(), but either it doesn't work, or I'm doing something wrong...
  8. 125 isn't the limit. And I cannot figure out how to use datagenerators in 1.16.2: BlockStateProvider has only one meaningful method to override (act), but it is doing something already.
  9. I'm making a block which contains three different parts. Each of the parts can use one of five possible textures, leading to 125 blocks in total (due to flattening). I could make three states in block (one state per part) and just 15 models and use multipart blockstate to combine the final block, but parts can use different geometry themselves, increasing the number of possible states combination drastically. In 1.12.2 there was a way to specify texture in blockstate, and now, when forge blockstate format is gone, I cannot find a way to efficiently solve this task.
  10. Hey, guys and gals! In times of 1.12.2 there was a possibility to put normal obfuscated mod jar file in ./libs directory to make its classes accessible within dev environment. In recent versions however, that doesn't work. Yes, I know that I can (and probably should) use maven dependencies to load deobf versions of needed mods, but what to do if I want to use mod, whose maven repository doesn't exist? I've tried to use "compile fileTree(include: ['*.jar'], dir: 'libs')" which allows IDEA to see the internals of jars inside "libs" directory, but I cannot run the mod due to obfuscated names in jars, the same with local "flatDir" repo. Is it possible now at all?
  11. Well, actually, I did It seems, updatePostPlacement is my solution. But the method name is kinda misleading... I thought it is called after the block is placed, and has nothing to do with block breaking, Thanks
  12. Well, I'm struggling with getActualState absence... I have a block, which should act pretty much like fences do. It changes it's model (via BlockState) according to neighbors. I overrode updateNeighbors to set BlockStates to correct values when block is placed nearby, but this method doesn't get called when something destroys the block. What mechanic should I use to change the BlockState when nearby block is destroyed? Forge: 28.1.104
×
×
  • Create New...

Important Information

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