Jump to content

Recommended Posts

Posted (edited)

I am trying to make a mod with rifts, which are vaguely like Thaumcraft's aura nodes. One block which will interact with the rifts is a destabilizer, which will allow multiblock-like crafting. This block should draw a sphere of particles above itself when powered, but when it is unpowered, just a tiny ball at the center, and drop some items, depending on the area around it. Currently, I am testing this with the fire particle when unpowered. Any code that is commented out I have tried both with and without in every combination. No particles are displayed.

 

package zane49er.VolkiharEchoes.features;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class Destabilizer extends Block {

	public Destabilizer(String registryName) {
		super(Material.PISTON);
		setRegistryName(registryName);
		setUnlocalizedName(getRegistryName().toString());
		setHardness(3.0f);
	}

	//@Override
	@SideOnly(Side.CLIENT)
	public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
		//if(!worldIn.isBlockPowered(pos)){
			worldIn.spawnParticle(EnumParticleTypes.FLAME, (double)pos.getX(), (double)pos.getY()+5, (double)pos.getZ(), 0, 0, 0, new int[0]);
		//}
	}
	
	//@Override
	@SideOnly(Side.CLIENT)
	public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
		//if(!worldIn.isBlockPowered(pos)){
			worldIn.spawnParticle(EnumParticleTypes.FLAME, (double)pos.getX(), (double)pos.getY()+5, (double)pos.getZ(), 0, 0, 0, new int[0]);
		//}
	}
	
}

It seems that the randomDisplayTick is never being called.

 

Also, I want to make the (fullbright) rifts change color based on their contents, but that's a future problem...

 

Finally, creative tabs are not being created, and I don't understand why.

Edited by Zane49er
  • Like 1

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted

Are you definitely registering an instance of this class?

 

Post your registration code and the class that calls it. Also post the code where you create your creative tabs.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
package zane49er.VolkiharEchoes.init;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import zane49er.VolkiharEchoes.features.Destabilizer;
import zane49er.VolkiharEchoes.features.Rift;
import zane49er.VolkiharEchoes.features.Stabilizer;
import zane49er.VolkiharEchoes.main.References;

public class ModBlocks {
	
	public static Block destabilizer;
	
	public static void init() {
		destabilizer = new Destabilizer("destabilizer");
	}

	public static void register() {
		registerBlock(destabilizer);
	}
	
	private static void registerBlock(Block block) {
		GameRegistry.register(block);
		ItemBlock item = new ItemBlock (block);
		item.setRegistryName(block.getRegistryName());
		GameRegistry.register(item);
	}

	public static void registerRenders() {
		registerRender(destabilizer);
	}
	
	public static void registerRender(Block block) {
		//Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(References.MODID + ":" + item.getUnlocalizedName().substring(5),"inventory"));
		//ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(new ResourceLocation(References.MODID, block.getUnlocalizedName().substring(5)), "inventory"));
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
	}

}

Unless I have to initialize the updatetick separately, I don't know how I could mess that up. The block Is working fine, it just won't make particles. I also recently tried literally copy + pasting the code from torches, still no result.

 

package zane49er.VolkiharEchoes.features;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import zane49er.VolkiharEchoes.init.ModItems;

public class ModTabUseful extends CreativeTabs{

	public ModTabUseful(String name) {
		super("TabUseful");
	}
	
	@Override
	public Item getTabIconItem() {
		return ModItems.riftReader;
	}

}


package zane49er.VolkiharEchoes.init;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import zane49er.VolkiharEchoes.features.ModTabUseful;

public class ModTabs {
	
	public static CreativeTabs useful;

	public static void init() {
		useful = new ModTabUseful("TabUseful");
	}
}

This one has been giving me trouble since 1.7.

  • Like 1

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted

I'm not seeing any obvious issues that would stop the particles from working. Create a Git repository for your mod, push it to a site like GitHub (if you haven't already) and link it here; I'll need to debug this locally to locate the issue.

 

I did notice that you have model registration code in a common class, which has the potential to crash the dedicated server. Model registration should be done in a dedicated client-only class.

 

I also recommend moving your Block/Item registration to the corresponding registry events and your model registration to ModelRegistryEvent. This will make it easier to update to 1.12+, where GameRegistry.register is private.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

https://github.com/zane49er2/Volkihar-for-MineCraft-Mod

 

Sorry this is so confusing on GitHub, this project folder includes previous versions so that I can pull models, textures, or planning from them,

  • Like 1

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted

The root of your repository should be the root directory of your mod, i.e. where build.gradle is. The repository should include the buildscript (build.gradle and gradle.properties [if you have it]), the Gradle Wrapper (gradlew, gradlew.bat and the gradle directory) and your source code/resources (the src directory).

 

Look at my mod and its .gitignore file  for an example of the repository structure to use and which files to include.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

https://github.com/zane49er2/VMC

Thanks, I've (probably obviously) never actually used git repositories. The new one still has the confusion, but maybe less.

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted

The creative tab and particles are working on my machine:

 

kOeA2eA.png

 

h24A8zz.png

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

It's good to know that the problems I've been having in 1.10 aren't caused by my incompetence, but I don't understand what could be wrong here... Could settings in eclipse prevent things from working that aren't being carried over in the git? If I can't get it to work by messing with build paths and project directory by tomorrow I'll try just downloading my own mod.

 

edit: that was it! after resetting the build path, everything is working, and I feel like I can actually start to get things done. Also, I think I've gotten suggestions from you 3 times to change my registry method, which I thought I did... I'll try again, though.

Edited by Zane49er

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted (edited)

Now I can see the particles, but I still don't know how to control them. this is one of the few blocks my mod will add that I don't want to have NBT or Blockdata, so I'd like to not use that, but using normal values doesn't seem to work. this may have to do with server and client. I also tried using the logic directly in the statement, which still didn't work.
 

Spoiler

 

2017-08-02_05.30.42.png

2017-08-02_05.30.37.png


 

Edited by Zane49er

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted (edited)

I just tested the sphere effect, and it seems the size Is limited. I could render a radius of 1 or 2 blocks, but any higher than that and no particles are displayed. Edit: that was me being dumb and calculating a sphere twice, and only once dynamically. Now it works.

2017-08-02_15.13.46.pngAlso, I've changed my mind about the NBT, I'll use it since there are 4 planned sizes, times 2 states is 8, times 2 possible power sources (different color fluid) is 16.

Edited by Zane49er

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted (edited)

 I've tried adding a GUI, and attaching it to the tome. Nothing happens on a right-click Edit: the game crashes if the server tries running it, else nothing happens. I feel like this is becoming less "I have a problem, what do I do?" and more "are these even real problems?" Oh well, I still have questions at least. Also, the original purpose of this post (Redstone) is still not finished.

Edited by Zane49er

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted

I think you'll need to store the powered state in the block state or the TileEntity and use that on the client instead of using World#isBlockPowered directly. Look at BlockRedstoneLight for an example of this (though it unnecessarily uses two Blocks instead of a property).

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

 Is there a way to make the particles spawn even when the player is slightly far away? I don't necesarilly need them when the nearest player is 50+ blocks away, but the point of it is that it outlines an area... I'd like them to render about 20 blocks away.

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted
10 minutes ago, Zane49er said:

 Is there a way to make the particles spawn even when the player is slightly far away? I don't necesarilly need them when the nearest player is 50+ blocks away, but the point of it is that it outlines an area... I'd like them to render about 20 blocks away.

 

Since particles only need to be spawned on the client, just check how far away the client player is from the block before spawning them.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Currently they immediately stop spawning at a certain distance from the block. I've already made the render not distance related, but the issue is spawning, I think RandomDisplayTick is the problem, but I think the only alternative is making it a TileEntity, which, as I said, are becoming an invasive element of almost everything I'm planning.

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted
13 minutes ago, Zane49er said:

Currently they immediately stop spawning at a certain distance from the block. I've already made the render not distance related, but the issue is spawning, I think RandomDisplayTick is the problem, but I think the only alternative is making it a TileEntity, which, as I said, are becoming an invasive element of almost everything I'm planning.

 

If you're spawning particles through the World/RenderGlobal methods, they'll only spawn within 32 blocks (exclusive) of the player unless you tell it to ignore the range (by using a vanilla particle type that ignores range or by calling one of the overloads with an ignoreRange parameter).

 

Block#randomDisplayTick will only be called for blocks that are within 32 blocks (exclusive) of the client player on every axis.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
2 hours ago, Choonster said:

Block#randomDisplayTick will only be called for blocks that are within 32 blocks (exclusive) of the client player on every axis.

This is what I meant - I had already set the particles to not be distance-related, but the method is called at varying rates as the player moves further away. I found that standing 20 blocks away for a minute will eventually show the sphere, but it fades again and you have to wait. I don't know of any other client-side method that occasionally gets run for every block, so I might have to use another TileEntity?

 

The gold are 5 blocks apart.

2017-08-03_14.31.07.png

2017-08-03_14.31.24.png

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Posted

A ticking TileEntity or a TileEntity with a TESR are probably your best options here.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

Alright, I think adding a tileEntity will solve all my problems with the destabilizer. I still have a problem with the GUI, and saving my new rift NBT.

The color (eventually it'll be the essences that determine color) is randomly generated, but should, for obvious reasons, only be generated once.

Instead, It seems to be determined twice, once when it is placed/generated, and one when it is loaded. This means that the first time you see one, it won't be accurate, but if you relog, no matter how many times, it will be.

Spoiler

Screenshot before relogs

2017-08-03_15.48.04.png

Screenshot after 1 relog

2017-08-03_15.49.13.png

Screenshot after a 2nd relog2017-08-03_15.56.20.png

edit: I'll prob. move this to another thread, since it is a separate and helpful topic to understand. I think the client isn't being updated about the blockata and is rendering its own randoms, but re-logging sends the correct value. This is supported by the fact that using /blockdata also causes the desync.

Edited by Zane49er

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would 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.