Having trouble with Random ore generation for minecraft 1.15.2 - minecraft

So I am trying to make a minecraft mod that has a randomly generated ore. I have run into a problem in this part of the code.
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;
public class ModOreGen {
public static void generateOre() {
for (Biome biome : ForgeRegistries.BIOMES) {
if (biome == Biomes.BAMBOO_JUNGLE) {
ConfiguredPlacement<CountRangeConfig> customConfig = Placement.COUNT_RANGE
.func_227446_a_(new CountRangeConfig(9, 10, 10, 0));
biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES,Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, blockinit.chocolate_ore.getDefaultState(), 10)).withPlacement(customConfig));
}
}
}
}
Where it says .withConfiguration it gives me the error:
The method withConfiguration(OreFeatureConfig) is undefined for the type Feature<OreFeatureConfig>
I have already tried updating my mappings and such, but nothing helped. This has been a problem that has really irritated me for days now. What is happening?

I just had this same problem with my code and finally fixed it. Try this out!
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;
public class ModOreGen {
public static void generateOre() {
for (Biome biome : ForgeRegistries.BIOMES) {
if(biome == Biomes.BAMBOO_JUNGLE) {
ConfiguredPlacement<?> customConfig = Placement.COUNT_RANGE
.configure(new CountRangeConfig(9, 10, 10, 0));
biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(newOreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,BlockInit.chocolate_ore.getDefaultState(), 10)).withPlacement(customConfig));
}
}
}
}

The obvious thing Sammerson did was to remove the strong typing for CountRangeConfig:
ConfiguredPlacement<?> , but that doesn't matter.
What you can't see is updating Forge to 1.15.2.
This is most likely your best fix. In your build.gradle, somewhere near the top (mine is line 28) you've probably already updated your mappings to:
mappings channel: 'snapshot', version: '20200409-1.15.1'
But you also want to go down and update the Forge version also (this is around line 90 for me).
dependencies {
minecraft 'net.minecraftforge:forge:1.15.2-31.1.0'
}
You need to do the same
gradlew genEclipseRuns
gradlew eclipse
just like updating the mappings.
(You can check the Forge page, there may be a newer version than 1.15.2 by the time someone else reads this. And I hope anyone using IntelliJ can figure out how to update your own mappings/forge.))

Related

Cannot use Duration.seconds method from kotlin.time

I'm trying to use the Duration class from kotlin.time package like this:
Duration.seconds(5)
But I see Expression 'seconds' cannot be invoked as a function. The function 'invoke()' is not found in my intelliJ.
Not sure, how should I call this function then? Or is there something I'm missing?
For time being I have to use 5.toDuration(DurationUnit.SECONDS)
Snippet:
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
#ExperimentalTime
class Temp {
fun test() {
println(Duration.seconds(5))
}
}
I have kotlin ref in build.gradle.kts file
plugins {
id("org.jetbrains.kotlin.jvm") version "1.5.21"
}
Using it with kotest.
Here are my project dependencies.
dependencies {
testImplementation(kotlin("test-junit5"))
testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
testImplementation("io.kotest:kotest-runner-junit5-jvm:$kotestVersion")
testImplementation("io.rest-assured:kotlin-extensions:4.3.0")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.+")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.+")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.+")
implementation("io.kotest.extensions:kotest-extensions-allure:1.0.1")
}
Make sure you are importing the correct Duration
import kotlin.time.Duration
as there are other Durations.
You can also use the extension function on Int,
import kotlin.time.toDuration
5.toDuration(DurationUnit.SECONDS)
For those looking to use Java Duration, you can do this using #Francesc answer and the information in the link below is (1.toDuration(DurationUnit.SECONDS)).toJavaDuration()
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.time/to-java-duration.html

Can not resolve JavaParser

JavaParser.CallContext and JavaParser.FunctionDeclContext do not seem to be able to resolve. This is modeled after page 139 in the definitive antlr reference.
Am I missing a Lib?
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.MultiMap;
import org.antlr.v4.runtime.misc.OrderedHashSet;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.*;
import org.stringtemplate.v4.ST;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Set;
static class FunctionListener extends JavaBaseListener {
Graph graph = new Graph();
String currentFunctionName = null;
public void enterFunctionDecl(JavaParser.FunctionDeclContext ctx) {
currentFunctionName = ctx.ID().getText();
graph.nodes.add(currentFunctionName);
}
public void exitCall(JavaParser.CallContext ctx) {
String funcName = ctx.ID().getText();
// map current function to the callee
graph.edge(currentFunctionName, funcName);
}
}
I think I have seen this one, and I dont have enough points to "comment", but let me ask a question first; It looks like you are trying to produce an external version of the AST on page 137, You took the examples and renamed them to the grammar you had generated already. I'm going to assume that the rest of it is working or you would have had a lot more errors than this one ! Is that the goal ? Are you after just the calling methods/classes or are you after the full homogeneous AST ?
This depends on the grammar entry points. That's not as obvious in the book as it seems. You referenced functionDecl, which looks to be an entry in the Cymbol.g4, but doesn't exist in Java.g4 So rather than JavaParser.FunctionDeclContext I suggest JavaParser.classOrInterfaceDeclarationContext. It should should pull up the right method. I will also confess that I don't know what the exitCall would map to. I could use the illumination on that myself.
Were you after the whole AST or only the call graph ? If the whole AST, I think you can use enterEveryRule or ExitEveryRule for that as well, but confirmation would be good.
So start by regenerating your grammar, change your program to reference the rule entry point in the .g4 files, then see if it all works.
Thanks

Threads did not exit in parallel execution in karate

Here is my code snippet for parallel execution:
package examples;
import com.intuit.karate.KarateOptions;
import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
#KarateOptions(tags = {"~#ignore"})
public class ExamplesTest {
#Test
public void testParallel() {
List<String> tags = Arrays.asList("~#ignore");
List<String> features = Arrays.asList("classpath:examples/autocomment");
Results results = Runner.parallel(tags,features, 5, "target/surefire-reports");
// assertTrue(results.getErrorMessages(), results.getFailCount() == 0);
}
}
Once all feature files executed using command
mvn test -DargLine="-Dkarate.env=qa",threads did not exit and hence build never gets concluded.
Could you please let me know if I am doing anything wrong here??
`
One of your tests probably has a severe error (maybe the eval of karate-config.js). Run using the JUnit runner and see the logs.
This should be fixed in this ticket, do see if you can build from source and validate: https://github.com/intuit/karate/issues/667

Cucumber JVM cannot find the steps defined

When I run to run this test with a feature it complains it cannot find the steps. I have tried defining them in Java 8 style, and Java 7 style and using IntelliJ to generate the steps into a MyStepdefs class but it cannot find them.
I am using version 1.2.4 of cucumber-java8 and cucumber-junit.
import cucumber.api.CucumberOptions;
import cucumber.api.DataTable;
import cucumber.api.PendingException;
import cucumber.api.java8.En;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(
monochrome = true,
glue = {"com.mycom.core.agg.RunCukesTest"})
public class RunCukesTest implements En {
public RunCukesTest() {
Given("^I have PriceLevels$", (DataTable arg1) -> {
});
And("^I have a TradeRequest$", (DataTable arg1) -> {
});
Then("^I should get these LegRequests$", (DataTable arg1) -> {
});
}
}
running the test prints
Running com.mycom.core.agg.RunCukesTest
1 Scenarios (1 undefined)
3 Steps (3 undefined)
0m0.000s
You can implement missing steps with the snippets below:
Given("^I have PriceLevels$", (DataTable arg1) -> {
.. rest deleted ...
Running the feature file from IntelliJ give much the same error.
While we couldn't figure out what the cause was, create a new maven project with a minimum of dependencies "fixed" the problem. We didn't need to change the code.

Adobe Flex - mxmlc.exe and compile with dependent libraries

I have Flex SDK 4.6. I would like to work with library https://github.com/y8/websocket-as. This library needed library as3corelib (https://github.com/mikechambers/as3corelib). The problem is, that I'm not able to use/include this libraries in my HelloWorld project.
package {
import flash.display.Sprite;
import flash.text.TextField;
import y8.net.WebSocket;
public class HelloWorld extends Sprite {
public function HelloWorld() {
var display_txt:TextField = new TextField();
display_txt.text = "Hello World!";
addChild(display_txt);
}
}
}
When I compile it with mxmlc.exe -o HelloWorld.swf tuts\HelloWorld.as, I get error
HelloWorld.as(5): col: 15 Error: Definition y8.net:WebSocket could not be found.
import y8.net.WebSocket;
Please, how can I put it together (directories) and how can I compile this libraries and HelloWordl with mxmlc.exe. Thanks.
You can do it like this
mxmlc -library-path+=/myLibraries/MyRotateEffect.swc;/myLibraries/MyButtonSwc.swc c:/myFiles/app.mxml
ref: http://livedocs.adobe.com/flex/3/html/help.html?content=apparch_08.html