Jump to content

Recommended Posts

Posted

So I was working on adding my custom dimension, didn't get any errors, and found a command that let me change dimensions. Everything was going well. But then I realized that I needed to add my custom biome, the Ice Sheets, to that dimension and I had no idea to do that. I've spent an hour today looking at the forums for how to do that, but I had no luck. I'm on Forge version 1.12.2 and all help would be appreciated. Any further questions, just reply. Thank you!

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted (edited)

What version of Minecraft is this?

Edited by lyghtningwither

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted

I don't have "DimensionManager.addBiome()."

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted

I copied your entire "build.gradle" file from your repository, tried it again and it still didn't work. See attached photo.

Capture.JPG

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted

Yeah, I do that in BiomeInit. Yet it's still not appearing in my dimension.

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted
16 hours ago, diesieben07 said:

DimensionManager has never had an addBiome method. addBiome is a method of BiomeManager, I assume this is a typo in the article.

Yeah, that is a typo. I actually have it in two places in the article and in one place is it correct other it isn't thanks.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Thanks, I did what the tutorial said, and it worked! Just one more thing. I can't get it to have a day/night cycle. It's just endless blackness. Do you have any ideas on how to do this? You know, the Ice age would still have a Sun and a moon and stars and everything like that.

Here's my code for the dimension world provider:

 

package com.lyghtningwither.honeyfunmods.world.dimensions;

import com.lyghtningwither.honeyfunmods.init.DimensionInit;

import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.DimensionType;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class IceWorldProvider extends WorldProvider {

	@Override
	protected void init() {
		// TODO Auto-generated method stub
		super.init();
		this.hasSkyLight = true;
		
	}
	
	@Override
	public float calculateCelestialAngle(long worldTime, float partialTicks) {
		// TODO Auto-generated method stub
		return 0.50f;
	}
	
	@Override
	protected void generateLightBrightnessTable() {
		
		float f = 0.0f;
		for(int i = 0; i<= 15; i++) {
			
			float f1 = 1.0f - (float) i / 15.0f;
			this.lightBrightnessTable[i] = (1.0f - f1) / (f1 * 3.0f + 1.0f) * 1.0f + 0.0f;
			this.lightBrightnessTable[i] *= 0.3f;
		}
	}
	
	@Override
	public DimensionType getDimensionType() {
		
		return DimensionInit.iceDimensionType;
	}
	
	@Override
	public double getMovementFactor() {
		
		return 30.0D;
	}
	
	@Override
	public IChunkGenerator createChunkGenerator() {
		
		return new ChunkGeneratorIce(world);
	}
	
	@Override
	public boolean isSurfaceWorld() {
		
		return false;
	}
	
	@Override
	public boolean canRespawnHere() {
		
		return false;
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public Vec3d getFogColor(float par1, float par2) {
		
		return new Vec3d(0.0D, 0.0D, 0.0D);
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public boolean doesXZShowFog(int x, int z) {
		
		return true;
	}
	
	@Override
	public boolean canDoLightning(Chunk chunk) {
		
		return true;
	}
	
	@Override
	public boolean canBlockFreeze(BlockPos pos, boolean byWater) {
		
		return false;
	}
	
	@Override
	public boolean canDoRainSnowIce(Chunk chunk) {
		
		return true;
	}
	
	@Override
	public boolean canSnowAt(BlockPos pos, boolean checkLight) {

		return true;
	}
}

Again, if you have any further questions, please respond to this. Thanks!

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted

Aaaaand here's the dimension. See, no sunlight!

I do "this.hasSkyLight = true" in the script above. Still not doing the day/night cycle! Please help. Thank you!

2018-03-14_19.33.40.png

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted

Thanks, that worked. But there still are problems. First of all, the dimension is stuck on midnight. The moon isn't moving at all. Second, when I try using the command "/time set day," the game crashes after a few moments. Attached is the crash report.

 

 

Thank you!

crash-2018-03-15_16.15.41-server.txt

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted

Wait, oops, sorry, it was an "exception generating a new chunk." Sorry. I was just confused because the crash happened right after I had entered a "/time set day" command. Sorry!

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted

How do you make it actually go around? Do I remove calculateCelestialAngle(), or do I do something with the parameters of calculateCelestialAngle()?

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted

Look at how the overworld handles it.

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.

Posted (edited)

Where is the code for the overworld? How do you get to it? (i'm a big noob to Eclipse)

Edited by lyghtningwither

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted
15 hours ago, lyghtningwither said:

Where is the code for the overworld? How do you get to it? (i'm a big noob to Eclipse)

Assuming you ran the full gradlew setupDecompWorkspace when you were setting up your workspace, then you should have all the source available as a Referenced Library in your project. So if you go to the Package Explorer pane you can navigate to the referenced libraries and find one (usually the first in the list) there should be one called forgeSrc and you can go into that to find all the net.minecraft and net.minecraftforge packages with code.

 

That is for generally browsing the code. However, you can also find specific stuff. For example, your code extends WorldProvider. So if you want to see the code for that, you just click somewhere in the word or select it and then right-click and select Open Declaration. That will open up the source for that.

 

Now the overworld probably extends WorldProvider so to find all the code that extends that, select the word and right-click and select Open Type Hierarchy. That will open up a pane that will show you all the classes derived from it, and also all the methods in it and inherited by it. You can then double-click on one of the derived classes to open up its source.

 

So specifically for this case I would:

1) Open up your world provider class

2) Go to top of the class where you extend WorldProvider, right click on the world "WorldProvider" and select Open Type Hierarchy.

3) A pane will pop up that shows that there are derived classes and one of them is called WorldProviderSurface. You can guess that that is probably the overrworld. So double-click that in the hierarchy window, and that will open the source.

4) You'll find that the WorldProviderSurface doesn't override very many methods. You're interested in the celestial angle, which isn't overridden. So you will want to go up the hierarchy. So double-click the WorldProvider class in the hierarchy window.

5) Scroll through the code, or use Control-F, to find the calculateCelestialAngle() code.

 

Basically using these techniques of selecting, using Type Hierarchy, you can quickly navigate through the parent and children classes.

 

One other tip, when you bring up the Type Hierarchy it will also list all the fields and methods in the selected class. However, there is a toggle option (one of the small icons) where you can have it list all inherited methods. If that was on, you also can find the calculateCelestialAngle() method there and immediately see if it has overrides.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

I looked in the super implementation code, and it's this:

int i = (int)(worldTime % 24000L);
        float f = ((float)i + partialTicks) / 24000.0F - 0.25F;

        if (f < 0.0F)
        {
            ++f;
        }

        if (f > 1.0F)
        {
            --f;
        }

        float f1 = 1.0F - (float)((Math.cos((double)f * Math.PI) + 1.0D) / 2.0D);
        f = f + (f1 - f) / 3.0F;
        return f;

Is this the correct code? Please respond quickly.

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted (edited)

WorldProviderSurface has no calculateCelestialAngle. By default, it says in the world provider the code above, and WorldProviderSurvace does not override it, so it is the correct code. (I just found out how to access the whole Minecraft library, so I looked in it till I found WorldProvideSurface.)

 

So when I wondered whether you had to just delete calculateCelestialAngle, I was right. But I was also right in the way that you had to change something. Weird!

 

Edited by lyghtningwither

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted
3 hours ago, jabelar said:

Assuming you ran the full gradlew setupDecompWorkspace when you were setting up your workspace, then you should have all the source available as a Referenced Library in your project. So if you go to the Package Explorer pane you can navigate to the referenced libraries and find one (usually the first in the list) there should be one called forgeSrc and you can go into that to find all the net.minecraft and net.minecraftforge packages with code.

 

That is for generally browsing the code. However, you can also find specific stuff. For example, your code extends WorldProvider. So if you want to see the code for that, you just click somewhere in the word or select it and then right-click and select Open Declaration. That will open up the source for that.

 

Now the overworld probably extends WorldProvider so to find all the code that extends that, select the word and right-click and select Open Type Hierarchy. That will open up a pane that will show you all the classes derived from it, and also all the methods in it and inherited by it. You can then double-click on one of the derived classes to open up its source.

 

So specifically for this case I would:

1) Open up your world provider class

2) Go to top of the class where you extend WorldProvider, right click on the world "WorldProvider" and select Open Type Hierarchy.

3) A pane will pop up that shows that there are derived classes and one of them is called WorldProviderSurface. You can guess that that is probably the overrworld. So double-click that in the hierarchy window, and that will open the source.

4) You'll find that the WorldProviderSurface doesn't override very many methods. You're interested in the celestial angle, which isn't overridden. So you will want to go up the hierarchy. So double-click the WorldProvider class in the hierarchy window.

5) Scroll through the code, or use Control-F, to find the calculateCelestialAngle() code.

 

Basically using these techniques of selecting, using Type Hierarchy, you can quickly navigate through the parent and children classes.

 

One other tip, when you bring up the Type Hierarchy it will also list all the fields and methods in the selected class. However, there is a toggle option (one of the small icons) where you can have it list all inherited methods. If that was on, you also can find the calculateCelestialAngle() method there and immediately see if it has overrides.

You can also hold down "control" (or "command" on Mac) in order to get the declaration of a function.

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Posted

So yeah, so as you've found the WorldProvider class already does a celestial angle implementation and the WorldProviderSurface doesn't override it. So if you don't override it, then you'll get the same implementation.

 

You should go through your other methods as well and confirm whether you really want to override them. The WorldProviderSurface really doesn't override much, so mostly you shouldn't override unless you specifically want it different than the overworld.

 

The good thing is now you've learned how to find the source code, that is really the key to learning modding -- inspecting how vanilla does things. In addition to the Type Hierarchy, I strongly suggest you learn to use the Call Hierarchy which is really useful in Eclipse. The Call Hierarchy shows you everywhere a method, field or constructor is called and so it can give you great confidence in the proper use of methods.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Thank you! Well, I think that my dimension is about finished. Thank you, everybody, for your help.

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

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.