Jump to content

FIXED OreGenerating, no ore?


clowcadia

Recommended Posts

I am back, so i made an ore generator handler and i still cant find my ores

OreGenHandler

package com.clowcadia.tutorial.world;

import java.util.Random;

import com.clowcadia.tutorial.handlers.BlockHandler;
import com.google.common.base.Predicate;

import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraftforge.fml.common.IWorldGenerator;

public class WorldGenOre implements IWorldGenerator{

	@Override
	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) 
	{
		  switch(world.provider.getDimension())
		  {
		  
		  }
	}
	
	private void genSurface(World world, Random random, int chunkX, int chunkZ)
	{
		 addOreSpawn(BlockHandler.blockTutorial.getDefaultState(), world, random, chunkX, chunkZ, 16, 16, 100, 20, 74, 126, BlockMatcher.forBlock(Blocks.STONE));
	}
	
	private void addOreSpawn(IBlockState block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chance, int minY, int maxY, Predicate<IBlockState> blockToSpawnIn)
	{
		int diffMinMaxY = maxY - minY;
		for(int x = 0; x < chance; x++)
		{
		   int posX = blockXPos + random.nextInt(maxX);
		   int posY = minY + random.nextInt(diffMinMaxY);
		   int posZ = blockZPos + random.nextInt(maxZ);
		   (new WorldGenMinable(block, maxVeinSize, blockToSpawnIn)).generate(world, random, new BlockPos(posX, posY, posZ));
		}
	}

}

ClientProxy

package com.clowcadia.tutorial.proxy;

import com.clowcadia.tutorial.handlers.BlockHandler;
import com.clowcadia.tutorial.handlers.ItemHandler;
import com.clowcadia.tutorial.world.WorldGenOre;

import net.minecraftforge.fml.common.registry.GameRegistry;

//Class to put Tile Entities
public class ClientProxy extends CommonProxy
{
	public void init() 
	{
		ItemHandler.registerRenders();
		BlockHandler.registerRenders();
		GameRegistry.registerWorldGenerator(new WorldGenOre(), 0);
	}

}

 

Edited by clowcadia
Link to comment
Share on other sites

i missed something but it had no immpact

 

package com.clowcadia.tutorial.world;

import java.util.Random;

import com.clowcadia.tutorial.handlers.BlockHandler;
import com.google.common.base.Predicate;

import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraftforge.fml.common.IWorldGenerator;

public class WorldGenOre implements IWorldGenerator{

	@Override
	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) 
	{
		  switch(world.provider.getDimension())
		  {
		  case -1: genSurface(world, random, chunkX, chunkZ);
		  	break;
		  case 0: genSurface(world, random, chunkX, chunkZ);
		  	break;
		  case 1: genSurface(world, random, chunkX, chunkZ);
		  	break;
		  default: genSurface(world, random, chunkX, chunkZ);
		  	break;
		  }
	}
	
	private void genSurface(World world, Random random, int chunkX, int chunkZ)
	{
		 addOreSpawn(BlockHandler.blockTutorial.getDefaultState(), world, random, chunkX, chunkZ, 16, 16, 100, 20, 74, 126, BlockMatcher.forBlock(Blocks.STONE));
	}
	
	private void addOreSpawn(IBlockState block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chance, int minY, int maxY, Predicate<IBlockState> blockToSpawnIn)
	{
		int diffMinMaxY = maxY - minY;
		for(int x = 0; x < chance; x++)
		{
		   int posX = blockXPos + random.nextInt(maxX);
		   int posY = minY + random.nextInt(diffMinMaxY);
		   int posZ = blockZPos + random.nextInt(maxZ);
		   (new WorldGenMinable(block, maxVeinSize, blockToSpawnIn)).generate(world, random, new BlockPos(posX, posY, posZ));
		}
	}

}

 

Link to comment
Share on other sites

1 minute ago, TheSunCat said:

By the way, you can check if something is generating easily if you do a System.out.println(pos.getX() + " " + pos.getY() + " " + pos.getZ()); That is how I check if my ores and generated structures spawn...

Your very kind, but for the sake of the post and others who may have similar issues. Where would you plug that in?

Link to comment
Share on other sites

5 minutes ago, TheSunCat said:

By the way, you can check if something is generating easily if you do a System.out.println(pos.getX() + " " + pos.getY() + " " + pos.getZ()); That is how I check if my ores and generated structures spawn...

That's a neat way to check that. I will do this in the future too. :D

Link to comment
Share on other sites

Or use the logger that Forge gives you during the event lifecycle....

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm trying to make my own modpack, but sometimes, in certain areas of the world, the game just says "server closed". Minecraft doesn't close, it just returns to the menu. When I tried to figure it out on my own and understand the logs, I didn't understand anything (English is not my native language, so it's difficult for me). I've been trying to solve the problem for the third month. So I ask if anyone is good at this and it's not difficult for you, to help me with this. If you need details, ask. I'll describe everything. What it looks like Logs
    • Hi i installed modpack to my server, it starts but when i join it crashes everytime, im running 1.20.1 forge version, all client mods are deleted from the server.   java.lang.NoClassDefFoundError: Could not initialize class sun.security.ssl.SSLContextImpl$DefaultSSLContext at java.lang.Class.forName0(Native Method) ~[?:?] {re:mixin} at java.lang.Class.forName(Class.java:390) ~[?:?] {re:mixin} at java.lang.Class.forName(Class.java:381) ~[?:?] {re:mixin} at java.security.Provider$Service.getImplClass(Provider.java:1967) ~[?:?] {} at java.security.Provider$Service.getDefaultConstructor(Provider.java:1998) ~[?:?] {} at java.security.Provider$Service.newInstanceOf(Provider.java:1912) ~[?:?] {} at java.security.Provider$Service.newInstanceUtil(Provider.java:1920) ~[?:?] {} at java.security.Provider$Service.newInstance(Provider.java:1895) ~[?:?] {} at sun.security.jca.GetInstance.getInstance(GetInstance.java:236) ~[?:?] {} at sun.security.jca.GetInstance.getInstance(GetInstance.java:164) ~[?:?] {} at javax.net.ssl.SSLContext.getInstance(SSLContext.java:185) ~[?:?] {} at javax.net.ssl.SSLContext.getDefault(SSLContext.java:110) ~[?:?] {} at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:83) ~[?:?] {} at javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(HttpsURLConnection.java:336) ~[?:?] {} at javax.net.ssl.HttpsURLConnection.<init>(HttpsURLConnection.java:292) ~[?:?] {} at sun.net.www.protocol.https.HttpsURLConnectionImpl.&lt;init&gt;(HttpsURLConnectionImpl.java:81) ~[?:?] {} at sun.net.www.protocol.https.Handler.openConnection(Handler.java:62) ~[?:?] {} at sun.net.www.protocol.https.Handler.openConnection(Handler.java:57) ~[?:?] {} at java.net.URL.openConnection(URL.java:1095) ~[?:?] {re:mixin} at java.net.URL.openStream(URL.java:1162) ~[?:?] {re:mixin} at xxrexraptorxx.additionalstructures.utils.Events.SupporterCheck(Events.java:129) ~[AdditionalStructures-1.20.x-(v.4.2.2).jar%23401!/:4.2.2] {re:classloading} at xxrexraptorxx.additionalstructures.utils.Events.SupporterRewards(Events.java:86) ~[AdditionalStructures-1.20.x-(v.4.2.2).jar%23401!/:4.2.2] {re:classloading} at xxrexraptorxx.additionalstructures.utils.__Events_SupporterRewards_PlayerLoggedInEvent.invoke(.dynamic) ~[AdditionalStructures-1.20.x-(v.4.2.2).jar%23401!/:4.2.2] {re:classloading,pl:eventbus:B} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {} at net.minecraftforge.event.ForgeEventFactory.firePlayerLoggedIn(ForgeEventFactory.java:875) ~[forge-1.20.1-47.3.0-universal.jar%23694!/:?] {re:mixin,re:classloading,pl:mixin:A} at net.minecraft.server.players.PlayerList.m_11261_(PlayerList.java:261) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:A} at net.minecraft.server.network.ServerLoginPacketListenerImpl.m_143699_(ServerLoginPacketListenerImpl.java:139) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:krypton.mixins.json:shared.network.pipeline.encryption.ServerLoginNetworkHandlerMixin,pl:mixin:APP:connectivity.mixins.json:ServerLoginNetHandlerMixin,pl:mixin:A} at net.minecraft.server.network.ServerLoginPacketListenerImpl.m_10055_(ServerLoginPacketListenerImpl.java:126) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:krypton.mixins.json:shared.network.pipeline.encryption.ServerLoginNetworkHandlerMixin,pl:mixin:APP:connectivity.mixins.json:ServerLoginNetHandlerMixin,pl:mixin:A} at net.minecraft.server.network.ServerLoginPacketListenerImpl.m_9933_(ServerLoginPacketListenerImpl.java:70) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:krypton.mixins.json:shared.network.pipeline.encryption.ServerLoginNetworkHandlerMixin,pl:mixin:APP:connectivity.mixins.json:ServerLoginNetHandlerMixin,pl:mixin:A} at net.minecraft.network.Connection.m_129483_(Connection.java:263) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,re:classloading,pl:mixin:APP:connectivity.mixins.json:AdvancedPacketErrorLogging,pl:mixin:APP:krypton.mixins.json:shared.network.flushconsolidation.ClientConnectionMixin,pl:mixin:APP:krypton.mixins.json:shared.network.pipeline.compression.ClientConnectionMixin,pl:mixin:APP:krypton.mixins.json:shared.network.pipeline.encryption.ClientConnectionMixin,pl:mixin:APP:connectivity.mixins.json:ConnectionErrorMixin,pl:mixin:APP:connectivity.mixins.json:NetworkManagerMixin,pl:mixin:A} at net.minecraft.server.network.ServerConnectionListener.m_9721_(ServerConnectionListener.java:142) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,re:classloading} at net.minecraft.server.MinecraftServer.m_5703_(MinecraftServer.java:907) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:modernfix-common.mixins.json:core.MinecraftServerMixin,pl:mixin:APP:modernfix-common.mixins.json:perf.dedicated_reload_executor.MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:neruina.mixins.json:MinecraftServerMixin,pl:mixin:A} at net.minecraft.server.dedicated.DedicatedServer.m_5703_(DedicatedServer.java:283) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:lithostitched.mixins.json:server.DedicatedServerMixin,pl:mixin:APP:mixins/common/nochatreports.mixins.json:server.MixinDedicatedServer,pl:mixin:APP:tombstone.mixins.json:DedicatedServerMixin,pl:mixin:A} at net.minecraft.server.MinecraftServer.m_5705_(MinecraftServer.java:814) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:modernfix-common.mixins.json:core.MinecraftServerMixin,pl:mixin:APP:modernfix-common.mixins.json:perf.dedicated_reload_executor.MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:neruina.mixins.json:MinecraftServerMixin,pl:mixin:A} at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:661) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:modernfix-common.mixins.json:core.MinecraftServerMixin,pl:mixin:APP:modernfix-common.mixins.json:perf.dedicated_reload_executor.MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:neruina.mixins.json:MinecraftServerMixin,pl:mixin:A} at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23689!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:modernfix-common.mixins.json:core.MinecraftServerMixin,pl:mixin:APP:modernfix-common.mixins.json:perf.dedicated_reload_executor.MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:neruina.mixins.json:MinecraftServerMixin,pl:mixin:A} at java.lang.Thread.run(Thread.java:1589) ~[?:?] {re:mixin} Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.ExceptionInInitializerError [in thread " Iron Furnaces Update Checker"] at javax.crypto.Cipher.getInstance(Cipher.java:548) ~[?:?] {re:mixin} at sun.security.ssl.SSLCipher.isTransformationAvailable(SSLCipher.java:523) ~[?:?] {} at sun.security.ssl.SSLCipher.<init>(SSLCipher.java:512) ~[?:?] {} at sun.security.ssl.SSLCipher.<clinit>(SSLCipher.java:93) ~[?:?] {} at sun.security.ssl.CipherSuite.<clinit>(CipherSuite.java:65) ~[?:?] {} at sun.security.ssl.SSLContextImpl.getApplicableSupportedCipherSuites(SSLContextImpl.java:343) ~[?:?] {} at sun.security.ssl.SSLContextImpl$AbstractTLSContext.<clinit>(SSLContextImpl.java:556) ~[?:?] {} at java.lang.Class.forName0(Native Method) ~[?:?] {re:mixin} at java.lang.Class.forName(Class.java:390) ~[?:?] {re:mixin} at java.lang.Class.forName(Class.java:381) ~[?:?] {re:mixin} at java.security.Provider$Service.getImplClass(Provider.java:1967) ~[?:?] {} at java.security.Provider$Service.getDefaultConstructor(Provider.java:1998) ~[?:?] {} at java.security.Provider$Service.newInstanceOf(Provider.java:1912) ~[?:?] {} at java.security.Provider$Service.newInstanceUtil(Provider.java:1920) ~[?:?] {} at java.security.Provider$Service.newInstance(Provider.java:1895) ~[?:?] {} at sun.security.jca.GetInstance.getInstance(GetInstance.java:236) ~[?:?] {} at sun.security.jca.GetInstance.getInstance(GetInstance.java:164) ~[?:?] {} at javax.net.ssl.SSLContext.getInstance(SSLContext.java:185) ~[?:?] {} at javax.net.ssl.SSLContext.getDefault(SSLContext.java:110) ~[?:?] {} at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:83) ~[?:?] {} at javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(HttpsURLConnection.java:336) ~[?:?] {} at javax.net.ssl.HttpsURLConnection.<init>(HttpsURLConnection.java:292) ~[?:?] {} at sun.net.www.protocol.https.HttpsURLConnectionImpl.&lt;init&gt;(HttpsURLConnectionImpl.java:81) ~[?:?] {} at sun.net.www.protocol.https.Handler.openConnection(Handler.java:62) ~[?:?] {} at sun.net.www.protocol.https.Handler.openConnection(Handler.java:57) ~[?:?] {} at java.net.URL.openConnection(URL.java:1095) ~[?:?] {re:mixin} at java.net.URL.openStream(URL.java:1162) ~[?:?] {re:mixin} at ironfurnaces.update.ThreadUpdateChecker.run(ThreadUpdateChecker.java:30) ~[ironfurnaces-1.20.1-4.1.6.jar%23534!/:4.1.6] {re:classloading}
    • If anyone is wanting to know, the solution looked like this:   // Helper method to check sunlight conditions (including daylight) private static boolean isSufficientSunlight(Level world, BlockPos pos) { int skyLight = world.getBrightness(LightLayer.SKY, pos); long dayTime = world.getDayTime() % 24000; // Check if it's daytime and if there is enough sunlight return dayTime < 12000 && skyLight >= 5; } @SubscribeEvent public static void onCropGrow(BlockEvent.CropGrowEvent.Post event) { Level world = (Level) event.getLevel(); if (world.isClientSide) return; // Don't run logic on the client side BlockPos pos = event.getPos(); // Check if the block is a glowberry vine, skip destruction if it is if (event.getState().getBlock() == Blocks.CAVE_VINES || event.getState().getBlock() == Blocks.CAVE_VINES_PLANT) { // Skip glowberry vines return; } // Check sunlight and time restrictions if (world.getBrightness(LightLayer.SKY, pos) < 13) { // Destroy the crop (turn it into air) if there is not strong sunlight world.removeBlock(pos, false); } } // Doesn't let animals breed if there is no sunlight @SubscribeEvent public static void onAnimalBreed(BabyEntitySpawnEvent event) { Level world = event.getParentA().getCommandSenderWorld(); if (world.isClientSide) return; // Don't run logic on the client side if (!(event.getParentA() instanceof Animal) || !(event.getParentB() instanceof Animal)) { return; // Ensure it is animals breeding } Animal parentA = (Animal) event.getParentA(); Animal parentB = (Animal) event.getParentB(); // Doesn't let chicken breed if (parentA instanceof Chicken || parentB instanceof Chicken){ event.setCanceled(true); return; } if (!isSufficientSunlight(world, parentA.blockPosition())) { // Cancel the breeding event event.setCanceled(true); return; } if (!isSufficientSunlight(world, parentB.blockPosition())) { // Cancel the breeding event event.setCanceled(true); } }  
  • Topics

×
×
  • Create New...

Important Information

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