Jump to content

Recommended Posts

Posted

It handles squares. Anything that is a square is good, because it looks up the size of the icon. So regardless of how big your icon is, it is designed to draw from the start to the end, not just 16 pixels.

The only reason it can't handle a square is because it complains about non-squares... and I don't know how to get around that.

 

True, but my point was:

 

The old spritesheets were 256x256 and held 256 sprites.  To keep that the same under the new system, you need 16x16 icon files.

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

Know how to program in Java. If you don't, start learning Java. You can probably pick it up while writing mods, but don't ask for Java help in Minecraft communication channels. There are entire books on learning Java, along with online tutorials.

"You can probably pick it up while writing mods." I am going to kick the person who wrote that.

 

Lex knows everything? Maybe we should clone him! Oh wait, that would probably be a bad idea. In many ways.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

Know how to program in Java. If you don't, start learning Java. You can probably pick it up while writing mods, but don't ask for Java help in Minecraft communication channels. There are entire books on learning Java, along with online tutorials.

"You can probably pick it up while writing mods." I am going to kick the person who wrote that.

 

It's not technically incorrect.  I didn't know Java and started writing mods.  I did, however, have prior programming experience in multiple languages (C++, C#, Javascript, Actionscript 2, Actionscript 3...).

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

Know how to program in Java. If you don't, start learning Java. You can probably pick it up while writing mods, but don't ask for Java help in Minecraft communication channels. There are entire books on learning Java, along with online tutorials.

"You can probably pick it up while writing mods." I am going to kick the person who wrote that.

 

It's not technically incorrect.  I didn't know Java and started writing mods.  I did, however, have prior programming experience in multiple languages (C++, C#, Javascript, Actionscript 2, Actionscript 3...).

Well, if you know C, then it's smooth sailing. I knew Python at the age of, like, ten, then I learned Java and GL because I wanted to write a Minecraft clone, then I decided to get into Minecraft modding. Still, I get tired of the people who think they can learn how to program and how to program in Java like this.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

Well, if you know C, then it's smooth sailing. I knew Python at the age of, like, ten, then I learned Java and GL because I wanted to write a Minecraft clone, then I decided to get into Minecraft modding. Still, I get tired of the people who think they can learn how to program and how to program in Java like this.

 

Eh.  My C* is a bit rusty.  I can't write applications from the ground up, much less one with a GUI or any rendering.  Most of what I do is either in Unity3D, Flash, or web-based.

 

As far as I'm concerned the only difference between Java and Flash is how variables are declared.

("int a;" vs. "var a:int;")

Oh, and having to deal with Floats and Doubles not being the same thing and can't convert between them implicitly.

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

So I started sorta learning Lua when I was like 8 but i didnt get far at all(played Roblox) then when I was 13 I started learning Java, but didnt get very far, made some VERY simple programs, and then I started to mod minecraft. I then kind of gave up till summer started so I had all the time in the world. And I would like my ore to spawn. So how do I make it static?

Posted

Well, if you know C, then it's smooth sailing. I knew Python at the age of, like, ten, then I learned Java and GL because I wanted to write a Minecraft clone, then I decided to get into Minecraft modding. Still, I get tired of the people who think they can learn how to program and how to program in Java like this.

 

Eh.  My C* is a bit rusty.  I can't write applications from the ground up, much less one with a GUI or any rendering.  Most of what I do is either in Unity3D, Flash, or web-based.

 

As far as I'm concerned the only difference between Java and Flash is how variables are declared.

("int a;" vs. "var a:int;")

Oh, and having to deal with Floats and Doubles not being the same thing and can't convert between them implicitly.

The largest change for me (python to java) was getting used to all the type restriction, and not just float/double. (function args, returns, variable types, casting) I don't like the way Java restricts everything. I've wanted, many times, to change something that was private/protected/package or final in a Minecraft class, but I couldn't. Making a getter and setter for one variable when you could just refer directly seems like a waste of space. I hold the belief that if you don't want something changed, it is a simple matter to *not change it*. Or, if you're writing an API or the like, make sure to write in the docs that you don't want it changed. I wrote a rant a while back to this effect.

 

Actually, the largest change was probably the eternal stupidity of Java arrays (here's another rant for you). Python's list syntax alone makes it a better language. Probably the only advantage Java has over Python that I can think of is the ternary operator. And even then you can instead use (c,a)\[b\] instead of a ? b : c. (Edit: Dammit, markdown.)

 

Or maybe the largest change would be the non-descriptive-ness of NPE's. If Python can use a NameError to say that something isn't defined, or an AttributeError to say that there's no such function or method, I don't see why Java can't.

So I started sorta learning Lua when I was like 8 but i didnt get far at all(played Roblox) then when I was 13 I started learning Java, but didnt get very far, made some VERY simple programs, and then I started to mod minecraft. I then kind of gave up till summer started so I had all the time in the world. And I would like my ore to spawn. So how do I make it static?

Just put a "static" modifier on the block.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

Well, if you know C, then it's smooth sailing. I knew Python at the age of, like, ten, then I learned Java and GL because I wanted to write a Minecraft clone, then I decided to get into Minecraft modding. Still, I get tired of the people who think they can learn how to program and how to program in Java like this.

 

Eh.  My C* is a bit rusty.  I can't write applications from the ground up, much less one with a GUI or any rendering.  Most of what I do is either in Unity3D, Flash, or web-based.

 

As far as I'm concerned the only difference between Java and Flash is how variables are declared.

("int a;" vs. "var a:int;")

Oh, and having to deal with Floats and Doubles not being the same thing and can't convert between them implicitly.

The largest change for me (python to java) was getting used to all the type restriction, and not just float/double. (function args, returns, variable types, casting) I don't like the way Java restricts everything. I've wanted, many times, to change something that was private/protected/package or final in a Minecraft class, but I couldn't. Making a getter and setter for one variable when you could just refer directly seems like a waste of space. I hold the belief that if you don't want something changed, it is a simple matter to *not change it*. Or, if you're writing an API or the like, make sure to write in the docs that you don't want it changed. I wrote a rant a while back to this effect.

 

Actually, the largest change was probably the eternal stupidity of Java arrays (here's another rant for you). Python's list syntax alone makes it a better language. Probably the only advantage Java has over Python that I can think of is the ternary operator. And even then you can instead use (c,a) instead of a ? b : c.

 

Or maybe the largest change would be the non-descriptive-ness of NPE's. If Python can use a NameError to say that something isn't defined, or an AttributeError to say that there's no such function or method, I don't see why Java can't.

So I started sorta learning Lua when I was like 8 but i didnt get far at all(played Roblox) then when I was 13 I started learning Java, but didnt get very far, made some VERY simple programs, and then I started to mod minecraft. I then kind of gave up till summer started so I had all the time in the world. And I would like my ore to spawn. So how do I make it static?

Just put a "static" modifier on the block.

How do i do that? More so i guess where do i put that?

Posted

Well, if you know C, then it's smooth sailing. I knew Python at the age of, like, ten, then I learned Java and GL because I wanted to write a Minecraft clone, then I decided to get into Minecraft modding. Still, I get tired of the people who think they can learn how to program and how to program in Java like this.

 

Eh.  My C* is a bit rusty.  I can't write applications from the ground up, much less one with a GUI or any rendering.  Most of what I do is either in Unity3D, Flash, or web-based.

 

As far as I'm concerned the only difference between Java and Flash is how variables are declared.

("int a;" vs. "var a:int;")

Oh, and having to deal with Floats and Doubles not being the same thing and can't convert between them implicitly.

The largest change for me (python to java) was getting used to all the type restriction, and not just float/double. (function args, returns, variable types, casting) I don't like the way Java restricts everything. I've wanted, many times, to change something that was private/protected/package or final in a Minecraft class, but I couldn't. Making a getter and setter for one variable when you could just refer directly seems like a waste of space. I hold the belief that if you don't want something changed, it is a simple matter to *not change it*. Or, if you're writing an API or the like, make sure to write in the docs that you don't want it changed. I wrote a rant a while back to this effect.

 

Actually, the largest change was probably the eternal stupidity of Java arrays (here's another rant for you). Python's list syntax alone makes it a better language. Probably the only advantage Java has over Python that I can think of is the ternary operator. And even then you can instead use (c,a) instead of a ? b : c.

 

Or maybe the largest change would be the non-descriptive-ness of NPE's. If Python can use a NameError to say that something isn't defined, or an AttributeError to say that there's no such function or method, I don't see why Java can't.

So I started sorta learning Lua when I was like 8 but i didnt get far at all(played Roblox) then when I was 13 I started learning Java, but didnt get very far, made some VERY simple programs, and then I started to mod minecraft. I then kind of gave up till summer started so I had all the time in the world. And I would like my ore to spawn. So how do I make it static?

Just put a "static" modifier on the block.

How do i do that? More so i guess where do i put that?

 

In the class where you declared your block ID, add static to the beginning. ie:

 public static myFirstBlockID 

(public isn't necessary, but I do use it sometimes)

Posted
The largest change for me (python to java) was getting used to all the type restriction, and not just float/double. (function args, returns, variable types, casting) I don't like the way Java restricts everything.

 

I've gotten into using type restrictions in Flash because it's faster.

Otherwise this is valid code (and not only will compile, but will run:

var i = 1.333;
i += 0x1;
i = new Object();
i.random = 2;

 

I've wanted, many times, to change something that was private/protected/package or final in a Minecraft class, but I couldn't. Making a getter and setter for one variable when you could just refer directly seems like a waste of space. I hold the belief that if you don't want something changed, it is a simple matter to *not change it*. Or, if you're writing an API or the like, make sure to write in the docs that you don't want it changed. I wrote a rant a while back to this effect.

 

There are good reasons for getters/setters.  For example if setting the property means that some other flags or variables need to get set as a result.  A good example is the setters that cause datawatchers to update.  Likewise health (forcing every effect that CAN reduce an entity to 0 hp having to manage that entity dying would be absurd, instead you can manage that inside the setter!).

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

Well, if you know C, then it's smooth sailing. I knew Python at the age of, like, ten, then I learned Java and GL because I wanted to write a Minecraft clone, then I decided to get into Minecraft modding. Still, I get tired of the people who think they can learn how to program and how to program in Java like this.

 

Eh.  My C* is a bit rusty.  I can't write applications from the ground up, much less one with a GUI or any rendering.  Most of what I do is either in Unity3D, Flash, or web-based.

 

As far as I'm concerned the only difference between Java and Flash is how variables are declared.

("int a;" vs. "var a:int;")

Oh, and having to deal with Floats and Doubles not being the same thing and can't convert between them implicitly.

The largest change for me (python to java) was getting used to all the type restriction, and not just float/double. (function args, returns, variable types, casting) I don't like the way Java restricts everything. I've wanted, many times, to change something that was private/protected/package or final in a Minecraft class, but I couldn't. Making a getter and setter for one variable when you could just refer directly seems like a waste of space. I hold the belief that if you don't want something changed, it is a simple matter to *not change it*. Or, if you're writing an API or the like, make sure to write in the docs that you don't want it changed. I wrote a rant a while back to this effect.

 

Actually, the largest change was probably the eternal stupidity of Java arrays (here's another rant for you). Python's list syntax alone makes it a better language. Probably the only advantage Java has over Python that I can think of is the ternary operator. And even then you can instead use (c,a) instead of a ? b : c.

 

Or maybe the largest change would be the non-descriptive-ness of NPE's. If Python can use a NameError to say that something isn't defined, or an AttributeError to say that there's no such function or method, I don't see why Java can't.

So I started sorta learning Lua when I was like 8 but i didnt get far at all(played Roblox) then when I was 13 I started learning Java, but didnt get very far, made some VERY simple programs, and then I started to mod minecraft. I then kind of gave up till summer started so I had all the time in the world. And I would like my ore to spawn. So how do I make it static?

Just put a "static" modifier on the block.

How do i do that? More so i guess where do i put that?

 

In the class where you declared your block ID, add static to the beginning. ie:

 public static myFirstBlockID 

(public isn't necessary, but I do use it sometimes)

Ok I cant seem to get it to work.

I declared it in my main class file, but I thought I already had it static

 

package mtshaw113.juli;

import mtshaw113.juli.client.ClientProxy;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;


@Mod(modid="Juli", name="Juli", version="0.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Juli {

    // The instance of your mod that Forge uses.
    @Instance("Juli")
    public static Juli instance;
   
    // Says where the client and server 'proxy' code is loaded.
    @SidedProxy(clientSide="mtshaw113.juli.client.ClientProxy", serverSide="mtshaw113.juli.CommonProxy")
    public static CommonProxy proxy;
    public static ClientProxy proxy1;
   
public static EventManager eventmanager = new EventManager();
public static Block oreJuli;              //<--- Isn't it static there?
public static final String modid = "Juli";
    
    @Init
    public void load(FMLInitializationEvent event) {
            proxy.registerRenderers();
            
            GameRegistry.registerWorldGenerator(eventmanager);                        
            
            oreJuli = new Block(500, Material.rock).setUnlocalizedName("oreJuli");           
            GameRegistry.registerBlock(oreJuli, modid + oreJuli.getUnlocalizedName());          
            LanguageRegistry.addName(oreJuli, "Juli's Ore");
            
            
            
  /*  ItemStack dirtStack = new ItemStack (Block.dirt);
   * ItemStack gravelStack = new ItemStack(Block.gravel);
   * ItemStack cobbleStack = new ItemStack(Block.cobblestone);     
   * 
   * GameRegistry.addSmelting(Block.stone.blockID, new ItemStack(
   *         Block.stoneBrick), 0.1f);
   *  
   * GameRegistry.addRecipe(new ItemStack(Block.stone), "xyx", "y y", "xyx",
   *         'x', dirtStack, 'y', gravelStack);
   */
    
            
    }

}

 

My Event Manager code:

 

package mtshaw113.juli;

import java.util.Random;

import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;

public class EventManager implements IWorldGenerator {

   @Override
   public void generate(Random random, int chunkX, int chunkZ, World world,
         IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
      switch(world.provider.dimensionId){
      
      case 1:
         generateNether(world, random, chunkX * 16, chunkZ * 16);
         
      case 0:
         generateSurface(world, random, chunkX * 16, chunkZ * 16);
         
      case -1:
         generateEnd(world, random, chunkX * 16, chunkZ * 16);
      }
      
   }

   private void generateEnd(World world, Random random, int chunkX, int chunkZ) {
      
      }
       


   public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
      for(int i = 0; i < 9; i++){
         int xCoord = chunkX + random.nextInt(16);
         int yCoord = random.nextInt(40);
         int zCoord = chunkZ + random.nextInt(16);
         
         (new WorldGenMinable(mtshaw113.juli.oreJuli.blockID, 5)).generate(world, random, xCoord, yCoord, zCoord);
         
      }
      
   }
   
      /**
    Here, your ore has a spawn rate of 9 (which you can change to suit your desires):
            for(int  i = 0; i < 9; i++) {
    It spawns at, or below, level 13 on the Y-Axis (also changeable):
            in yCoord = random.nextInt(13);
    And it spawns at a max of 4 blocks per vein (again, changeable):
            ...(mtshaw113.julit.oreJuli, 4) ...
     **/

   private void generateNether(World world, Random random, int chunkX,
         int chunkZ) {
      
   }

}

 

And my oreJuli class(The block im trying to spawn):

 

package mtshaw113.juli;

import net.minecraft.block.Block;
import net.minecraft.block.BlockOre;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class oreJuli extends BlockOre 
{
public oreJuli(int id, Material par2Material)
{
	super(id);
	this.setCreativeTab(CreativeTabs.tabBlock);
}{

Block oreJuli;
final String modid = "Juli";

oreJuli = new Block(500, Material.rock).setUnlocalizedName("oreJuli");           
    GameRegistry.registerBlock(oreJuli, modid + oreJuli.getUnlocalizedName());          
    LanguageRegistry.addName(oreJuli, "Juli's Ore");

}

public void updateIcons(IconRegister par1iconregister){
	this.blockIcon = par1iconregister.registerIcon("[oreJuli]");
}



/*	 @SideOnly(Side.CLIENT)
     public void registerIcons(IconRegister par1IconRegister)
  {
      this.blockIcon = par1IconRegister.registerIcon(Juli.modid + ":" + this.getUnlocalizedName2());
  }
*/
}

 

Sorry I am extremely bad at Java, I just wanted something fun and easy(easy as in like it wont take hundreds of hours of coding) to do over the summer. I promise I will start learning soon, I just want that ore to work first!

And back to the original original question, My block(from the creative menu) Has the "Missing Texture" texture

Posted

The largest change for me (python to java) was getting used to all the type restriction, and not just float/double. (function args, returns, variable types, casting) I don't like the way Java restricts everything.

 

I've gotten into using type restrictions in Flash because it's faster.

Otherwise this is valid code (and not only will compile, but will run:

var i = 1.333;
i += 0x1;
i = new Object();
i.random = 2;

I don't see a good reason why it shouldn't run. You're setting it to 1.333, then adding 1. Then you're setting it to an object, and you're giving it an attribute called "random" that you're setting to 2. Beats me as to why, but there's no good reason why you shouldn't be able to do that.

I've wanted, many times, to change something that was private/protected/package or final in a Minecraft class, but I couldn't. Making a getter and setter for one variable when you could just refer directly seems like a waste of space. I hold the belief that if you don't want something changed, it is a simple matter to *not change it*. Or, if you're writing an API or the like, make sure to write in the docs that you don't want it changed. I wrote a rant a while back to this effect.

 

There are good reasons for getters/setters.  For example if setting the property means that some other flags or variables need to get set as a result.  A good example is the setters that cause datawatchers to update.  Likewise health (forcing every effect that CAN reduce an entity to 0 hp having to manage that entity dying would be absurd, instead you can manage that inside the setter!).

True. I agree entirely. I'm referring to the getters without setters (if you don't want the variable modified, just say so!) or the like.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted
mtshaw113.juli.oreJuli.blockID

 

This is wrong.

 

You want Juli.oreJuli.blockID

 

I don't see a good reason why it shouldn't run. You're setting it to 1.333, then adding 1. Then you're setting it to an object, and you're giving it an attribute called "random" that you're setting to 2. Beats me as to why, but there's no good reason why you shouldn't be able to do that.

 

Type errors are a very good thing to check:

 

var i = new Object();
if(rand.nextBoolean()) {
     i = 3;
}
i.prop = 9;

 

That should not compile.

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

Ok finally the ore spawns. But the texture is still being "Missing Texture" Derpy.

 

Because:

 

this.blockIcon = par1iconregister.registerIcon("[oreJuli]");

 

Your registering things wrong.  It's looking for a file named "[oreJuli]" (including those brackets!) in the /mods/textures/blocks folder.

 

17th time I've posted this:

 

Capture.png

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

Ok finally the ore spawns. But the texture is still being "Missing Texture" Derpy.

 

Because:

 

this.blockIcon = par1iconregister.registerIcon("[oreJuli]");

 

Your registering things wrong.  It's looking for a file named "[oreJuli]" (including those brackets!) in the /mods/textures/blocks folder.

 

17th time I've posted this:

 

Capture.png

If I follow your setup, I get an error on 'blockIcon': Syntax error on token "blockIcon", VariableDeclaratorId expected after this token 58CqScH.png

Posted

...

 

Seriously?

 

I'm not even going to tell you what's wrong.  It should be blindingly obvious to anyone with a pair of eyeballs.

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.

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

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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