Jump to content

[forge-1.8-11.14.1.1334] CleanRoom Generator


longlostbro

Recommended Posts

I am attempting to create a mod similar to the SkyBlocks bukkit plugin. My first step is to make a CleanRoom Generator (create a world with no block generation).

 

Which is the best method of creating a world with no blocks in it? (so I can have islands in the sky with no ground below)

  • Implement IWorldGenerator?
  • Extend world provider?
  • Implement IChunkProvider?
  • Extend BiomeGenBase?
  • Some better method?

Link to comment
Share on other sites

The best method would be your own 'clean room' WorldType, which provides the IChunkProvider.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

I am getting a NullPointerException for some reason and I can't pinpoint where or why. Can someone give me a hand?

ERROR

---- Minecraft Crash Report ----
// Ouch. That hurt 

Time: 5/24/15 6:51 PM
Description: Exception ticking world

java.lang.NullPointerException: Exception ticking world
at net.minecraft.world.biome.WorldChunkManager.getRainfall(WorldChunkManager.java:90)
at net.minecraft.world.biome.BiomeCache$Block.<init>(BiomeCache.java:105)
at net.minecraft.world.biome.BiomeCache.getBiomeCacheBlock(BiomeCache.java:37)
at net.minecraft.world.biome.BiomeCache.func_180284_a(BiomeCache.java:48)
at net.minecraft.world.biome.WorldChunkManager.func_180300_a(WorldChunkManager.java:75)
at net.minecraft.world.World.getBiomeGenForCoordsBody(World.java:215)
at net.minecraft.world.WorldProvider.getBiomeGenForCoords(WorldProvider.java:429)
at net.minecraft.world.World.getBiomeGenForCoords(World.java:185)
at net.minecraft.world.World.canBlockFreezeBody(World.java:2880)
at net.minecraft.world.WorldProvider.canBlockFreeze(WorldProvider.java:508)
at net.minecraft.world.World.canBlockFreeze(World.java:2875)
at net.minecraft.world.World.func_175662_w(World.java:2863)
at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:422)
at net.minecraft.world.WorldServer.tick(WorldServer.java:228)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)
at java.lang.Thread.run(Thread.java:745)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at net.minecraft.world.biome.WorldChunkManager.getRainfall(WorldChunkManager.java:90)
at net.minecraft.world.biome.BiomeCache$Block.<init>(BiomeCache.java:105)
at net.minecraft.world.biome.BiomeCache.getBiomeCacheBlock(BiomeCache.java:37)
at net.minecraft.world.biome.BiomeCache.func_180284_a(BiomeCache.java:48)
at net.minecraft.world.biome.WorldChunkManager.func_180300_a(WorldChunkManager.java:75)
at net.minecraft.world.World.getBiomeGenForCoordsBody(World.java:215)
at net.minecraft.world.WorldProvider.getBiomeGenForCoords(WorldProvider.java:429)
at net.minecraft.world.World.getBiomeGenForCoords(World.java:185)
at net.minecraft.world.World.canBlockFreezeBody(World.java:2880)
at net.minecraft.world.WorldProvider.canBlockFreeze(WorldProvider.java:508)
at net.minecraft.world.World.canBlockFreeze(World.java:2875)
at net.minecraft.world.World.func_175662_w(World.java:2863)
at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:422)
at net.minecraft.world.WorldServer.tick(WorldServer.java:228)

-- Affected level --
Details:
Level name: New World
All players: 1 total; [EntityPlayerMP['Player357'/0, l='New World', x=1.50, y=64.00, z=0.50]]
Chunk stats: ServerChunkCache: 625 Drop: 0
Level seed: -4952892408551608451
Level generator: ID 06 - CleanRoom, ver 0. Features enabled: true
Level generator options: 
Level spawn location: 7.00,64.00,7.00 - World: (7,64,7), Chunk: (at 7,4,7 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 10 game time, 10 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 81862 (now: false), thunder time: 127519 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)
at java.lang.Thread.run(Thread.java:745)

-- System Details --
Details:
Minecraft Version: 1.8
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.8.0_45, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 433081584 bytes (413 MB) / 780664832 bytes (744 MB) up to 3791650816 bytes (3616 MB)
JVM Flags: 0 total; 
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.10 FML v8.0.37.1334 Minecraft Forge 11.14.1.1334 4 mods loaded, 4 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{8.0.37.1334} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{11.14.1.1334} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
SkyBlocks{1.0} [skyBlocks] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Loaded coremods (and transformers): 
Profiler Position: N/A (disabled)
Player Count: 1 / 8; [EntityPlayerMP['Player357'/0, l='New World', x=1.50, y=64.00, z=0.50]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'

SOURCE

 

@Mod(modid = SkyBlocks.MODID, version = SkyBlocks.VERSION)
public class SkyBlocks
{
    public static final String MODID = "SkyBlocks";
    public static final String VERSION = "1.0";
    public static WorldType cleanRoom = new CleanRoomWorldType("CleanRoom");

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
    	
    }
    
    @EventHandler
    public void Load(FMLInitializationEvent event){
    	LanguageRegistry.instance().addStringLocalization("generator.CleanRoom", "CleanRoom");
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {
            
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
        
    }
    
}

 

public class CleanRoomWorldType extends WorldType {
    public CleanRoomWorldType(String name) {
    	super(name);      
    }

    @Override
    public WorldChunkManager getChunkManager(World world) {
        // This is our ChunkManager class, it controls rain, temp, biomes, and spawn location
        return new CleanRoomChunkManager(world);
    }

    @Override
    public IChunkProvider getChunkGenerator(World world, String generatorOptions) {
        // This is our ChunkProvider, this generates the world terrain.
        return new CleanRoomChunkProvider(world);
    }

    public boolean hasVoidParticles(boolean flag) {
        return flag; // Are their void particles?
    }

    public int getSeaLevel(World world) {
        // Sets the Average Ground Level, be careful with this one, it controls the Y value of your spawn point.
        return 64;
    }

    public double voidFadeMagnitude() {
        return 0.0D; // Sets the void fade, play with it to see which values work for you.
    }
}

 

public class CleanRoomChunkProvider implements IChunkProvider {
    private World world;
    private Random random;
    
    public CleanRoomChunkProvider(World world) {
        // Save the passed values for later use.
        this.world = world;
        random = new Random(world.getSeed());
    }    
    
@Override
public boolean chunkExists(int x, int z) {
	return true; // Of course it does, it's all air though...
}

public Chunk loadChunk(int chunkX, int chunkZ) {
        // Setting the random seed this way allows for the same seed to generate the same chunk
        // every time, even though we don't use it in this tutorial.
        random.setSeed((long)chunkX * 341873128712L + (long)chunkZ * 132897987541L);
        // Create an empty chunk
        Chunk chunk = new Chunk(world, chunkX, chunkZ);
        if (chunkX!=0 || chunkZ!=0) { // Only generate the 0,0 chunk.
            return chunk;
        }
        // Generate extended block storage
        for (int y=0; y<16; y++) {
            chunk.getBlockStorageArray()[y] = new ExtendedBlockStorage(y << 4, true);
        }
        // Generate 16x16 square of grass blocks at y value of 63.
        for (int x=0; x<16; x++) {
            for (int z=0; z<16; z++) {
                chunk.getBlockStorageArray()[3].set(x, 15/*y*/, z, Blocks.air.getDefaultState());
            }
        }
        chunk.generateSkylightMap();
        return chunk;
    }

@Override
public Chunk provideChunk(int x, int z) {
	return loadChunk(x, z);
}
@Override
public Chunk provideChunk(BlockPos blockPosIn) {
	return loadChunk(blockPosIn.getX(), blockPosIn.getY());
}
@Override
public void populate(IChunkProvider p_73153_1_, int p_73153_2_,
		int p_73153_3_) {
	//populate with ore or whatever
}
@Override
public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_,
		int p_177460_3_, int p_177460_4_) {
	// TODO Auto-generated method stub
	return false;
}
@Override
public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_) {
	// TODO Auto-generated method stub
	return false;
}
@Override
public boolean unloadQueuedChunks() {
	// TODO Auto-generated method stub
	return false;
}
@Override
public boolean canSave() {
	return true;
}
@Override
public String makeString() {
	// TODO Auto-generated method stub
	return "CleanRoom";
}
@Override //getPossibleCreatures
public List func_177458_a(EnumCreatureType p_177458_1_, BlockPos p_177458_2_) {
	return null;
}
@Override
public BlockPos getStrongholdGen(World worldIn, String p_180513_2_,
		BlockPos p_180513_3_) {
	return null;
}
@Override
public int getLoadedChunkCount() {
	return 0;
}
@Override
public void recreateStructures(Chunk p_180514_1_, int p_180514_2_,
		int p_180514_3_) {

}
@Override
public void saveExtraData() {

}

}

 

public class CleanRoomChunkManager extends WorldChunkManager {
    private World world;
    private List<BiomeGenBase> biomesToSpawnIn;

    public CleanRoomChunkManager() {
        biomesToSpawnIn = new ArrayList<BiomeGenBase>();
        biomesToSpawnIn.add(BiomeGenBase.plains); // Which biomes can you spawn in?
    }

    public CleanRoomChunkManager(World world) {
        this();
        this.world = world; // save the world value if you need it later.
    }

    // Gets the list of valid biomes for the player to spawn in.
    public List getBiomesToSpawnIn() {
        return biomesToSpawnIn;
    }

    // Returns the BiomeGenBase related to the x, z position on the world.
    public BiomeGenBase getBiomeGenAt(int x, int z) {
        return BiomeGenBase.plains; // Always plains here
    }

    // checks given Chunk's Biomes against List of allowed ones
    public boolean areBiomesViable(int par1, int par2, int par3, List par4List) {
        return true;
    }

    // Finds a valid position within a range, that is one of the listed biomes.
    public BlockPos findBiomePosition(int i, int j, int k, List list, Random random) {
        // With the integration of the server into the client, the spawn location is randomized a bit.
        // EntityPlayerMP will adjust the location you give here randomly in the range of -10 to +9
        // This is done to both the X and Z locations.
        // The Y location is ideally just above the top solid block at that location.
        // NOTE:  If the location given does not have a grass block, the location will be further randomized.
        return new BlockPos(7, 0, 7);
    }
}

Link to comment
Share on other sites

1. What is your minecraft and forge version?

2. I think you should make it so that there is no chunk on the world.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

11.14.1.1334 the latest recommended

 

In which class would i do that? Im new to world generation..

So is that 1.7 or 2.8?

And surely, on public boolean chunkExists(int x, int z)

 

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

1.8 returning fals for chunk exists still causes the same error

I inspected it and only found out that the exception is impossible..

Can you debug it with some breakpoints?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • KILAT77 : Waspada Situs Scam dengan Withdraw Yang Tidak Dibayar Di era digital saat ini, banyak orang yang mencari keberuntungan melalui situs perjudian online. Namun, dibalik gemerlap janji-janji manis kemenangan, ada bahaya yang mengintai. Salah satu situs yang patut diwaspadai adalah KILAT77. Situs ini mendapat reputasi buruk karena banyak laporan dari pengguna yang mengklaim bahwa mereka tidak bisa menarik dana kemenangan mereka. Dalam artikel ini, kita akan membahas mengapa ROTER88 dianggap sebagai situs scam dan bagaimana Anda bisa melindungi diri dari penipuan serupa. Pengalaman Pengguna: Penarikan Tidak Dibayar Beberapa pengguna telah melaporkan pengalaman buruk mereka dengan KILAT77. Mereka mengaku bahwa setelah memenangkan sejumlah uang dan mencoba menariknya, proses penarikan mereka ditolak tanpa alasan yang jelas. Bahkan, beberapa pengguna melaporkan bahwa akun mereka tiba-tiba diblokir setelah mencoba melakukan penarikan, sehingga mereka kehilangan akses ke dana mereka sama sekali.
    • It is a dupe mod issue Remove Rubidium - you are already using Embeddium which is a fork of Rubidium
    • I made a block entity in forge 1.20.1, I want to prevent hopper from taking input slot item, i tried to override the extractItem method, it prevented hopper from taking input slot item, but the player also unable to take/change the item in input slot unless the slot is empty. public class FluidSeparatorBlockEntity extends BlockEntity implements MenuProvider { private static final int INPUT_SLOT = 0; private final CustomItemHandler itemHandler = new CustomItemHandler(3){ @Override protected void onContentsChanged(int slot) { setChanged(); } @Override public boolean isItemValid(int slot, @NotNull ItemStack stack) { return slot == INPUT_SLOT; } @Override public @NotNull ItemStack extractItem(int slot, int amount, boolean simulate) { if (slot == INPUT_SLOT) { return ItemStack.EMPTY; } return super.extractItem(slot, amount, simulate); } }; private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty(); protected final ContainerData data; private int progress = 0; private int maxProgress = 78; public FluidSeparatorBlockEntity(BlockPos pPos, BlockState pBlockState) { super(ModBlockEntities.FLUID_SEPARATOR_BE.get(), pPos, pBlockState); this.data = new ContainerData() { @Override public int get(int pIndex) { return switch (pIndex) { case 0 -> FluidSeparatorBlockEntity.this.progress; case 1, 2 -> FluidSeparatorBlockEntity.this.maxProgress; default -> 0; }; } @Override public void set(int pIndex, int pValue) { switch (pIndex) { case 0 -> FluidSeparatorBlockEntity.this.progress = pValue; case 1, 2 -> FluidSeparatorBlockEntity.this.maxProgress = pValue; } } @Override public int getCount() { return 3; } }; } @Override public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) { if(cap == ForgeCapabilities.ITEM_HANDLER) { return lazyItemHandler.cast(); } return super.getCapability(cap, side); } @Override public void onLoad() { super.onLoad(); lazyItemHandler = LazyOptional.of(() -> itemHandler); } @Override public void invalidateCaps() { super.invalidateCaps(); lazyItemHandler.invalidate(); } public void drops() { SimpleContainer inventory = new SimpleContainer(itemHandler.getSlots()); for(int i = 0; i < itemHandler.getSlots(); i++) { inventory.setItem(i, itemHandler.getStackInSlot(i)); } Containers.dropContents(this.level, this.worldPosition, inventory); } @Override public Component getDisplayName() { return Component.translatable("block.chemmaster.fluid_separator"); } @Nullable @Override public AbstractContainerMenu createMenu(int pContainerId, Inventory pPlayerInventory, Player pPlayer) { return new FluidSeparatorMenu(pContainerId, pPlayerInventory, this, this.data); } @Override protected void saveAdditional(CompoundTag pTag) { pTag.put("inventory", itemHandler.serializeNBT()); pTag.putInt("fluid_separator.progress", progress); super.saveAdditional(pTag); } @Override public void load(CompoundTag pTag) { super.load(pTag); itemHandler.deserializeNBT(pTag.getCompound("inventory")); progress = pTag.getInt("fluid_separator.progress"); } public void tick(Level pLevel, BlockPos pPos, BlockState pState) { ItemStack inputStack = this.itemHandler.getStackInSlot(INPUT_SLOT); if (inputStack.getCount() < 2) { resetProgress(); return; } if(hasRecipe()) { increaseCraftingProgress(); setChanged(pLevel, pPos, pState); if(hasProgressFinished()) { craftItem(); resetProgress(); } } else { resetProgress(); } } private void resetProgress() { progress = 0; } private void craftItem() { Optional<FluidSeparatingRecipe> recipe = getCurrentRecipe(); if (recipe.isPresent()) { List<ItemStack> results = recipe.get().getOutputs(); ItemStack inputStack = this.itemHandler.getStackInSlot(INPUT_SLOT); if (inputStack.getCount() < 2) { // If there are not enough items, do not proceed with crafting return; } // Extract the input item from the input slot this.itemHandler.internalExtractItem(INPUT_SLOT, 2, false); // Loop through each result item and find suitable output slots for (ItemStack result : results) { int outputSlot = findSuitableOutputSlot(result); if (outputSlot != -1) { this.itemHandler.setStackInSlot(outputSlot, new ItemStack(result.getItem(), this.itemHandler.getStackInSlot(outputSlot).getCount() + result.getCount())); } else { // Handle the case where no suitable output slot is found // This can be logging an error, throwing an exception, or any other handling logic System.err.println("No suitable output slot found for item: " + result); } } } } private int findSuitableOutputSlot(ItemStack result) { // Implement logic to find a suitable output slot for the given result // Return the slot index or -1 if no suitable slot is found for (int i = 0; i < this.itemHandler.getSlots(); i++) { // Ensure we do not place the output item in the input slot if (i == INPUT_SLOT) { continue; } ItemStack stackInSlot = this.itemHandler.getStackInSlot(i); if (stackInSlot.isEmpty() || (stackInSlot.getItem() == result.getItem() && stackInSlot.getCount() + result.getCount() <= stackInSlot.getMaxStackSize())) { return i; } } return -1; } private boolean hasRecipe() { Optional<FluidSeparatingRecipe> recipe = getCurrentRecipe(); if (recipe.isEmpty()) { return false; } List<ItemStack> results = recipe.get().getOutputs(); for (ItemStack result : results) { if (!canInsertAmountIntoOutputSlot(result) || !canInsertItemIntoOutputSlot(result.getItem())) { return false; } } return true; } private Optional<FluidSeparatingRecipe> getCurrentRecipe(){ SimpleContainer inventory = new SimpleContainer(this.itemHandler.getSlots()); for (int i = 0; i < itemHandler.getSlots(); i++) { inventory.setItem(i, this.itemHandler.getStackInSlot(i)); } return this.level.getRecipeManager().getRecipeFor(FluidSeparatingRecipe.Type.INSTANCE, inventory, level); } private boolean canInsertAmountIntoOutputSlot(ItemStack result) { for (int i = 1; i < this.itemHandler.getSlots(); i++) { ItemStack stackInSlot = this.itemHandler.getStackInSlot(i); if (stackInSlot.isEmpty() || (stackInSlot.getItem() == result.getItem() && stackInSlot.getCount() + result.getCount() <= stackInSlot.getMaxStackSize())) { return true; } } return false; } private boolean canInsertItemIntoOutputSlot(Item item) { for (int i = 1; i < this.itemHandler.getSlots(); i++) { ItemStack stackInSlot = this.itemHandler.getStackInSlot(i); if (stackInSlot.isEmpty() || stackInSlot.getItem() == item) { return true; } } return false; } private boolean hasProgressFinished() { return progress >= maxProgress; } private void increaseCraftingProgress() { progress++; } }  
    • No dice. Unfortunately this fix didn't work, thank you though.
  • Topics

×
×
  • Create New...

Important Information

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