Jump to content

Recommended Posts

Posted

I have created a custom feature which should generate my custom ore in the world,
my ore should only generate in certain chunks with certain biomes,
and this in a 5x5 chunk area (80x80 blocks), but after a lot of testing and fixing bugs,
that's me noticed that my ore is only generated in a 3x3 chunk area, outside the area no chunk seems to exist.

So is this intentional,
or do I have to overwrite a method in my feature,
or is this due to the "settings" of the ConfiguredFeature,
or somewhere else?

Posted
10 hours ago, ChampionAsh5357 said:

there is a dependency on each chunk to be able to load an eight chunk radius around that for feature generation.

This is also the case, if I specify a position that is outside of these 8 chunks,
there is an error on the console, but if I try to place a block outside of a 3 chunk radius,
no block is placed, as already said outside the area no chunk seems to exist

 

10 hours ago, ChampionAsh5357 said:

What does your feature look like?

this is my feature:

public class HardDeepslateFeature extends Feature<NoFeatureConfig> {

	public HardDeepslateFeature() {
		super(NoFeatureConfig.CODEC);
	}

	@Override
	public boolean place(ISeedReader seedReader, ChunkGenerator chunkGenerator, Random rng, BlockPos pos, NoFeatureConfig config) {
		Chunk chunk = (Chunk) seedReader.getChunk(pos);
		if (chunk.getPos().x % 20 == 0 && chunk.getPos().z % 20 == 0) {
			this.placeOre(seedReader, rng, pos);
		}
		return true;
	}
	
	protected void placeOre(ISeedReader seedReader, Random rng, BlockPos pos) {
		// Main Ore
		int y = MathHelper.nextInt(rng, 32, 128);
		this.generateOreVine(seedReader, rng, this.getNextPos(pos, 8, 8), y, 10);
		// Ore in chunk +1 +1
		this.generateOreVine(seedReader, rng, this.getNextPos(pos, 24, 24), y, 20);
		// Ore in chunk +1 -1
		this.generateOreVine(seedReader, rng, this.getNextPos(pos, 24, -24), y, 20);
		// Ore in chunk -1 +1
		this.generateOreVine(seedReader, rng, this.getNextPos(pos, -24, 24), y, 20);
		// Ore in chunk -1 -1
		this.generateOreVine(seedReader, rng, this.getNextPos(pos, -24, -24), y, 20);
		
		// Ore in chunk +5 +5
		this.generateOreVine(seedReader, rng, this.getNextPos(pos, 88, 88), y, 40);
		// Ore in chunk +5 -5
		this.generateOreVine(seedReader, rng, this.getNextPos(pos, 88, -88), y, 40);
		// Ore in chunk -5 +5
		this.generateOreVine(seedReader, rng, this.getNextPos(pos, -88, 88), y, 40);
		// Ore in chunk -5 -5
		this.generateOreVine(seedReader, rng, this.getNextPos(pos, -88, -88), y, 40);
	}
	
	protected BlockPos getNextPos(BlockPos pos, int x, int z) {
		return new BlockPos(z, pos.getY(), z);
	}
	
	// generate horizontal vine
	protected void generateOreVine(ISeedReader seedReader, Random rng, BlockPos pos, int y, int count) {
		int x = MathHelper.nextInt(rng, 0, 15);
		int z = MathHelper.nextInt(rng, 0, 15);
		for (int i = y; i < y + count; i++) {
			seedReader.setBlock(new BlockPos(pos.getX() + x, i, pos.getZ() + z), ModBlocks.HARD_DEEPSLATE.get().defaultBlockState(), i);
		}
	}

}

 

Posted

The entire purpose of this feature is incorrect. You're mixing in a placement with the feature.  All this feature would do is spawn the block at the specified position passed with maybe the count coming into effect. The placement would determine whether a chunk was valid to spawn in and the height of the feature to start setting.

Posted (edited)
1 hour ago, ChampionAsh5357 said:

The entire purpose of this feature is incorrect. You're mixing in a placement with the feature.

so i am not allowed to change the position in the feature
makes sense after looking at the vanilla features

1 hour ago, ChampionAsh5357 said:

The placement would determine whether a chunk was valid to spawn in and the height of the feature to start setting.

so i have to create a placement for my feature, which then handle the position of the feature?
But how do I put the bigger features? because my created feature is actually only a small part of what I want to generate.

is there a vanilla example for a placement/feature of a larger feature,
since the MonsterRoom feature is probably not suitable as an example for my purposes,
or does it make more sense to create a structure for larger features
and if so, how do I create these randomly because the structures are fixed, village houses, igloos, etc. ?

 

Edited by Luis_ST
Posted
31 minutes ago, Luis_ST said:

But how do I put the bigger features? because my created feature is actually only a small part of what I want to generate.

So what do you want to generate? You seem to either be combining multiple features into one feature based on what I'm seeing.

34 minutes ago, Luis_ST said:

and if so, how do I create these randomly because the structures are fixed, village houses, igloos, etc. ?

Structures are perfectly capable of being randomized using pools. Currently out of what I've seen though, you don't really have any dynamic data.

Posted
15 hours ago, ChampionAsh5357 said:

So what do you want to generate? You seem to either be combining multiple features into one feature based on what I'm seeing.

my goal would be to generate a large main room with a lot of my custom ore,
and to generate these several small rooms with less ore, the ore should be generated in the middle of the room,
the rooms should also be connected with a kind of tunnel system.

if I think about what I want to generate, it would be smartest to generate a structure instead of a featrure
two more questions about structures:

it is possible to generate structures in the code and not via nbt file
and is there a vanilla structure that i can use as an example

Posted
3 hours ago, Luis_ST said:

it is possible to generate structures in the code and not via nbt file

Sure, although based on what I'm hearing, there's nothing that you can't do via nbt.

3 hours ago, Luis_ST said:

and is there a vanilla structure that i can use as an example

There's a bunch like the desert pyramid iirc.

Posted
1 hour ago, ChampionAsh5357 said:

Sure, although based on what I'm hearing, there's nothing that you can't do via nbt.

There's a bunch like the desert pyramid iirc

thanks i try that

Posted
On 5/17/2021 at 4:01 PM, ChampionAsh5357 said:

There's a bunch like the desert pyramid iirc.

the structure works almost perfectly there are a few small things that i have to change, only optically

one more little thing, I'm currently trying to understand the world generating, here I tried to generate a custom cave,
but I have again the problem that chunks not or not complete load. looks like this:

2021-05-23_19_17_14.thumb.png.aa535f88688e1c12e14b34e08e8f236f.png

this is the code:
https://github.com/Luis-st/Forge-1.16.5-Industry/blob/main/src/main/java/net/luis/industry/common/world/carver/ocean/OceanWorldCarver.java


I hope you can help me again

 

  • 2 weeks later...
Posted
On 5/24/2021 at 3:45 PM, ChampionAsh5357 said:

Your carvers seem to be working as intended from what I glance. I would suggest looking at the existing CaveWorldCarver since that most likely has what you're looking for.

the problem has been fixed, unfortunately i still have a problem with my structure because i had to recreate it (because my hard drive crashed and destroyed many files).
unfortunately i can't remember how i fixed the problem last time. The error is probably due to the fact that the structure is not correctly registered,
because the game is always chrashed when I want to create a new world or i load a old world:

This is the log:
log.log

I hope you can help me one last time

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.