Jump to content

Recommended Posts

Posted

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?

Posted

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.

Posted

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);
    }
}

Posted

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.

Posted

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.

Posted

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.

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

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

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