
_p1nero
Members-
Posts
6 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
_p1nero's Achievements

Tree Puncher (2/8)
0
Reputation
-
_p1nero started following Level.setBlock doesn't work on client and Can datapack be used in mod?
-
I want to create a custom village, but it's difficult to program... I found some datapack tutorials that made it. So if I copy the json file and nbt file from the datapack to my mod's data folder, will it work?
-
I try to use the WorldEdit API follow https://worldedit.enginehub.org/en/latest/api/, but failed to setup environment.When I runClient, there is an error Caused by: java.lang.ClassNotFoundException: com.sk89q.worldedit.extension.platform.Platform but I can access the class Platform in my code. build.gradle buildscript { repositories { maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } } } plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' // id 'org.parchmentmc.librarian.forgegradle' version '1.+' id 'org.spongepowered.mixin' version '0.7.+' } version = mod_version group = mod_group_id base { archivesName = mod_id } java.toolchain.languageVersion = JavaLanguageVersion.of(17) println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=hdl.mixins.json" mods { "${mod_id}" { source sourceSets.main } } } client { property 'forge.enabledGameTestNamespaces', mod_id arg "-mixin.config=hdl.mixins.json" } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { maven { name = 'GeckoLib' url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' } maven { // name = 'worldedit-forge-mc1.20.1' url "https://maven.enginehub.org/repo/" } } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' implementation fg.deobf('software.bernie.geckolib:geckolib-forge-1.20.1:4.2.2') implementation fg.deobf('com.sk89q.worldedit:worldedit-forge-mc1.20:7.2.15') implementation fg.deobf('com.sk89q.worldedit:worldedit-core:7.2.15') } mixin { add sourceSets.main, 'hdl.mixin-refmap.json' config 'hdl.mixins.json' } tasks.named('processResources', ProcessResources).configure { var replaceProperties = [ minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, forge_version: forge_version, forge_version_range: forge_version_range, loader_version_range: loader_version_range, mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, mod_authors: mod_authors, mod_description: mod_description, ] inputs.properties replaceProperties filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { expand replaceProperties + [project: project] } } tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "MixinConfigs": "hdl.mixins.json" ]) } // This is the preferred method to reobfuscate your jar file finalizedBy 'reobfJar' } publishing { publications { register('mavenJava', MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' } the key part: repositories { maven { name = 'GeckoLib' url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' } maven { // name = 'worldedit-forge-mc1.20.1' url "https://maven.enginehub.org/repo/" } } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' implementation fg.deobf('software.bernie.geckolib:geckolib-forge-1.20.1:4.2.2') implementation fg.deobf('com.sk89q.worldedit:worldedit-forge-mc1.20:7.2.15') implementation fg.deobf('com.sk89q.worldedit:worldedit-core:7.2.15') }
-
Thanks bro, It work well now! I found that it's due to my island generate algorithm. It's possible to generated an island with a height of 0 lol
-
Sorry for my poor English lol I meant an invisible "barrier" not "barrel".
-
Thanks bro, I add the check side code and now when I right click it just give me a hand animation and generate nothing, even an invisible barrier... @Override public InteractionResult useOn(UseOnContext context) { Level level = context.getLevel(); if(!level.isClientSide){ SkyIslandGenerator skyIslandGenerator = new SkyIslandGenerator(); skyIslandGenerator.printSkyIsland(context.getClickedPos(),context.getLevel()); } return InteractionResult.sidedSuccess(level.isClientSide); } } public void printSkyIsland(BlockPos bottom, Level level) { double[][] skyIsland = generateSkyIsland(width, length, scale, octaves, persistence, lacunarity, seed, maxHeight*10); int maxHeight = -1; int max_x = 0, max_z = 0; for (int x = 0; x < width; x++) { for (int z = 0; z < length; z++) { if (skyIsland[x][z] > maxHeight) { maxHeight = (int)skyIsland[x][z]; max_x = x; max_z = z; } System.out.print("("+x+','+z+"):"+(int)skyIsland[x][z]+" "); } System.out.println(); } BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(0,0,0); for (int x = 0; x < width; x++) { for (int z = 0; z < length; z++) { for(int y = bottom.getY()+maxHeight ; y>bottom.getY()+maxHeight-skyIsland[x][z] ; y--){ blockPos.set(bottom.getX()+x-max_x,y,bottom.getZ()+z-max_z); level.setBlock(blockPos, Blocks.DIRT.defaultBlockState(), 3); } } } }
-
I created a item when you click on block it will generate a skyisland. But it just generate one dirt on where I click. I'm sure it generated because there is an invisible barrel in which the dirt should be. And when I restart the game, the invisible dirt appear. level.setBlockAndUpdate() is the same. Item.java package net.p1nero.skyislandbuilder.item; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.p1nero.skyislandbuilder.utils.SkyIslandGenerator; public class PerlinSkyIslandBuilderItem extends Item { public PerlinSkyIslandBuilderItem(Properties properties) { super(properties); } @Override public InteractionResultHolder<ItemStack> use(Level p_41432_, Player p_41433_, InteractionHand p_41434_) { //TODO: Open setting window return super.use(p_41432_, p_41433_, p_41434_); } @Override public InteractionResult useOn(UseOnContext context) { SkyIslandGenerator skyIslandGenerator = new SkyIslandGenerator(context.getClickedPos(),context.getLevel()); skyIslandGenerator.printSkyIsland(); return super.useOn(context); } } SkyIslandGenerator.java public void printSkyIsland() { double[][] skyIsland = generateSkyIsland(width, height, scale, octaves, persistence, lacunarity, seed, maxHeight*10); int maxHeight = -1; int max_x = 0, max_z = 0; for (int x = 0; x < width; x++) { for (int z = 0; z < height; z++) { if (skyIsland[x][z] > maxHeight) { maxHeight = (int)skyIsland[x][z]; max_x = x; max_z = z; } System.out.print("("+x+','+z+"):"+(int)skyIsland[x][z]+" "); } System.out.println(); } for (int x = 0; x < width; x++) { for (int z = 0; z < height; z++) { for(int y = bottom.getY()+maxHeight ; y>bottom.getY()+maxHeight-skyIsland[x][z] ; y--){ level.setBlock(new BlockPos(bottom.getX()+x-max_x,y,bottom.getZ()+z-max_z), Blocks.DIRT.defaultBlockState(),3); } } } }