Jump to content

Seynox

Members
  • Posts

    44
  • Joined

  • Last visited

Posts posted by Seynox

  1. 5 minutes ago, V0idWa1k3r said:

    Thins means that the ItemBlock holds a different instance of the Block compared to the one you've registered.

    Spoiler
    
    @EventBusSubscriber
    public class ModBlocks
    {
    	
    	/*
    	 *   REGISTER BLOCKS
    	 */
    	@SubscribeEvent
    	public static void onBlockRegister(RegistryEvent.Register<Block> event)
    	{
    		event.getRegistry().registerAll
    		(
    				new BlockExemple0(Material.ROCK),
    				new BlockExemple1(Material.ROCK)
    			
    		);
    	}
    	
    	/*
    	 *   REGISTER ITEM BLOCKS
    	 */
    	@SubscribeEvent
    	public static void onItemBlockRegister(RegistryEvent.Register<Item> event)
    	{
    		event.getRegistry().registerAll
    		(
    				new ItemBlock(new BlockExemple0(Material.ROCK)).setRegistryName(new BlockExemple0(Material.ROCK).getRegistryName()),
    				new ItemBlock(new BlockExemple1(Material.ROCK)).setRegistryName(new BlockExemple1(Material.ROCK).getRegistryName())
    				
    		);
    	}
    }

     

    That's how i register the blocks

  2. So everything is working except the blocks that are really weird

    I have 2 custom blocks and both have the same problem : When i place the block, the block doesnt have any textures/sounds/particles, but still have the effects and properties i have set in their class, but if they are placed with a command or a structure, the block is working perfectly (When i try to pick the working block (With the middle click), nothing happen, but when i do it on the glitchy one, i get the item)

     

    EDIT : Forgot to mention that they appear normal in hand and in inventory

  3. 7 minutes ago, V0idWa1k3r said:

    I don't really know hpw to explain this, but basically

    new ItemExemple("item_exemple") != new ItemExemple("item_exemple"). These are two separate objects.

    So you are registering the items correctly, and those are the items that are in the game and are interacted with. 

    Then you have these lines

    that now define a new item that isn't registered and thus isn't actually in game.

    So as a result using this

    Will crash the game.

    However since you MUST use the instance you've registered this

    Will also crash the game.

     

    If you need a reference to your item instances use an ObjectHolder annotation.

    So, for example, if i make an item like this, it's not gonna work?

    @Override
    public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
    {
    	ItemStack itemstack = player.getHeldItem(hand);
      
    	world.spawnEntity(new EntityItem(world, posX, posY, posZ, new ItemStack(new ExempleItem())));
      
    	return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
    }

     

  4. Okay, so i registered everything like this (The string after is just to set the unlocalized name) :

    	@SubscribeEvent
    	public static void onItemRegister(RegistryEvent.Register<Item> event)
    	{
    		event.getRegistry().registerAll
    		(
    				
    				new ItemExemple0("item_exemple0"),
    				new ItemExemple1("item_exemple1"),
    				new ItemExemple2("item_exemple2")
              );
        }

    Everything is working, and i still have those lines

    public static final Item ITEM_EXEMPLE = new ItemExemple("item_exemple");

    Is it problematic if i use them? Not for the registering of course, but in general? For exemple :

    ItemStack stack = new ItemStack(ITEM_EXEMPLE);

    instead of

    ItemStack stack = new ItemStack(new ItemExemple("item_exemple"));

     

  5. Okay so now that the Items and blocks are registered, i need to find a way to register the models, so here's what i did :

    @SubscribeEvent
    public static void onModelRegister(ModelRegistryEvent event)
    {
    	
    	for(Item item : Item.REGISTRY)
    	{
    		if(item.getRegistryName().getResourceDomain().equals(Reference.MODID))
    		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    	}
    	
    }

    Is it fine if i use the Resource Domain to register the model like this? (It's working perfectly but i don't know if that's a great way to do it)

  6. Hello!

    I saw on different posts that registering items like this i not the best way to do it

    @SubscribeEvent
    public static void onItemRegister(RegistryEvent.Register<Item> event)
    {
    	event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
    }

    I saw how VoidWalker was registering his items, and it seems more complicated and to be adding more code than what i currently have

    What are the downsides of doing what i do and how can i optimize it?

  7. 23 minutes ago, V0idWa1k3r said:

    The sneaking speed is just a multiplier over the original player's spead(I think) you should just be able to apply an attribute modifier to the player's speed attribute if they are sneaking with your armour.

    I just retried the AttributeModifier, and yeah its working (but i have to put some crazy amounts) but the FOV go waaayy too high

    Is there a way to fix this?

  8. Hi!

    Im trying to make an armor piece that allow the player to move at normal speed when sneaking (The code im trying to make is inside a Tick Event)

    I already tried few things like PotionEffect, Attributes and Capabilities and any of them change the sneak walking speed

    I looked at the sneak cheat of few hacked clients and i can't find how they do

    Can anyone help me?

  9. Hello!

    Im trying to get Baubles as a dependency, i already tried so i have the bauble api in my workspace, and the mod installed when i launch with Eclipse (I didnt manually downloaded Bauble, it installed itself after adding few things in my build.gradle (see below)) so i thought that was it, but when i build my mod and i add it to my minecraft, it's not installing Bauble by itself so i have to do it myself (I put Baubles in the mod folder with my mod).

    Is there a way to have the Bauble mod automatically installed?

     

    The things i added to build.gradle :

    Spoiler
    
    repositories {
        
        maven { url 'https://jitpack.io' }
    }
    
    dependencies {
        
        deobfCompile "com.github.azanor:Baubles:${baubles_version}"
    
    }

     

     

  10. 5 minutes ago, diesieben07 said:

    Why do you check the side in onMessage? Your messages should usually only go one way.

    You cannot access client-only classes from common code (such as your IMessageHandler). You need to encapsulate such access using the @SidedProxy system

    Can you give me an exemple? I have no idea how i can do this

     

  11. 3 minutes ago, Cadiboo said:

    Post your packet class

     

    PacketHandler :

    Spoiler
    
    public class PacketHandler {
    	
    	public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID.toLowerCase());
    	
    	public static void init() {
    		registerMessage(PacketJump.class, PacketJump.JumpMessage.class);
    	}
    	
    	private static int nextPacketId = 0;
    	  
    	  private static void registerMessage(Class packet, Class message)
    	  {
    	    INSTANCE.registerMessage(packet, message, nextPacketId, Side.CLIENT);
    	    INSTANCE.registerMessage(packet, message, nextPacketId, Side.SERVER);
    	    nextPacketId++;
    	}
    
    }

     

     

    JumpPacket :

    Spoiler
    
    public class PacketJump implements IMessageHandler<PacketJump.JumpMessage, IMessage>
    {
    	  @Override
    		public IMessage onMessage(JumpMessage message, MessageContext ctx)
    		{
    		  EntityPlayer playerID = (ctx.side.isClient() ? Minecraft.getMinecraft().player : ctx.getServerHandler().player);
    		  EntityPlayer player = (EntityPlayer)playerID.world.getEntityByID(message.playerid);
    		  
    		  boolean usedDoubleJump = false;
    		  
    		  ItemStack belt = BaublesApi.getBaublesHandler(player).getStackInSlot(3);
    		  if(!belt.isEmpty() && belt.getItem() instanceof CloudInJar && !usedDoubleJump) {
    			    usedDoubleJump = true;
    				player.fallDistance = 0;
    		  }
    		  
    		return null;
    		}
    	  
    	  public static class JumpMessage implements IMessage
    	  {
    	    int playerid;
    	    
    	    public JumpMessage() {}
    	    
    	    public JumpMessage(int playerid)
    	    {
    	      this.playerid = playerid;
    	    }
    	    
    	    @Override
    	    public void fromBytes(ByteBuf buf)
    	    {
    	      this.playerid = ByteBufUtils.readVarInt(buf, 4);
    	    }
    	    
    	    @Override
    	    public void toBytes(ByteBuf buf)
    	    {
    	    	ByteBufUtils.writeVarInt(buf, playerid, 4);
    	    }
    	}
    	  
    	  
    }

     

     

  12. I just tried the mod on server, and it's crashing about the EntityPlayerSP

    Spoiler
    
    Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/entity/EntityPlayerSP
    	at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:1.8.0_211]
    	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) ~[?:1.8.0_211]
    	at java.lang.Class.getConstructor0(Unknown Source) ~[?:1.8.0_211]
    	at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_211]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:166) ~[SimpleNetworkWrapper.class:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:159) ~[SimpleNetworkWrapper.class:?]
    	at com.seynox.adventum.network.PacketHandler.registerMessage(PacketHandler.java:21) ~[PacketHandler.class:?]
    	at com.seynox.adventum.network.PacketHandler.init(PacketHandler.java:14) ~[PacketHandler.class:?]
    	at com.seynox.adventum.Adventum.init(Adventum.java:42) ~[Adventum.class:?]

     

    How can i make this thread-safe?

  13. Okay so here's what i did. Every println are showing up in the console, which mean everything is working, but the player.motionY = 0.42D; (Inside PacketJump) is not happening, and i don't have any errors. I think it might be a side problem, but i don't see how i can fix it

     

    ClientProxy :

    Spoiler
    
    @Override
        public void preInit(FMLPreInitializationEvent event) {
    
            MinecraftForge.EVENT_BUS.register(new KeyPressHandler());
    
    }

     

     

    KeyPressHandler :

    Spoiler
    
    @SideOnly(Side.CLIENT)
    public class KeyPressHandler {
        
        @SubscribeEvent
        public void onKeyPress(InputEvent.KeyInputEvent event) {
            
            EntityPlayerSP player = Minecraft.getMinecraft().player;
            World world = player.world;
    
            if (Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed() && !player.onGround) {
                IMessage jumpmsg = new PacketJump.JumpMessage(player.getEntityId());
                PacketHandler.INSTANCE.sendToServer(jumpmsg);
                System.out.println("Jump Packet sent. Player : " + player);
                return;
            }
        }
    
    }

     

     

    PacketHandler :

    Spoiler
    
    public class PacketHandler {
    	
    	public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MOD_ID.toLowerCase());
    	
    	public static void init() {
    		registerMessage(PacketJump.class, PacketJump.JumpMessage.class);
    	}
    	
    	private static int nextPacketId = 0;
    	  
    	  private static void registerMessage(Class packet, Class message)
    	  {
    	    INSTANCE.registerMessage(packet, message, nextPacketId, Side.CLIENT);
    	    INSTANCE.registerMessage(packet, message, nextPacketId, Side.SERVER);
    	    nextPacketId++;
    	}
    
    }

     

     

    PacketJump :

    Spoiler
    
    public class PacketJump implements IMessageHandler<PacketJump.JumpMessage, IMessage>
    {
    	  @Override
    		public IMessage onMessage(JumpMessage message, MessageContext ctx)
    		{
    		  EntityPlayer playerID = (ctx.side.isClient() ? Minecraft.getMinecraft().player : ctx.getServerHandler().player);
    		  EntityPlayer player = (EntityPlayer)playerID.world.getEntityByID(message.playerid);
    		  
    		  boolean usedDoubleJump = false;
    		  
    		  ItemStack belt = BaublesApi.getBaublesHandler(player).getStackInSlot(3);
    		  if(!belt.isEmpty() && belt.getItem() instanceof CloudInJar && !usedDoubleJump) {
    			    usedDoubleJump = true;
    				player.motionY = 0.42D;
    				player.fallDistance = 0;
    				System.out.println("Added motionY to " + player);
    		  }
    		  
    		return null;
    		}
    	  
    	  public static class JumpMessage implements IMessage
    	  {
    	    int playerid;
    	    
    	    public JumpMessage() {}
    	    
    	    public JumpMessage(int playerid)
    	    {
    	      this.playerid = playerid;
    	    }
    	    
    	    @Override
    	    public void fromBytes(ByteBuf buf)
    	    {
    	      this.playerid = ByteBufUtils.readVarInt(buf, 4);
    	    }
    	    
    	    @Override
    	    public void toBytes(ByteBuf buf)
    	    {
    	    	ByteBufUtils.writeVarInt(buf, playerid, 4);
    	    }
    	}
    	  
    	  
    }

     

     

    The console output when i press space while in the air :

    Spoiler

    [15:23:06] [main/INFO] [STDOUT]: [com.seynox.seynoxstuffmod.util.handlers.KeyPressHandler:onKeyPress:28]: Jump Packet sent. Player : EntityPlayerSP['Player644'/79, l='MpServer', x=601.12, y=83.25, z=648.43]
    [15:23:06] [Netty Server IO #1/INFO] [STDOUT]: [com.seynox.seynoxstuffmod.network.PacketJump:onMessage:33]: Added motionY to EntityPlayerMP['Player644'/79, l='border', x=601.12, y=83.25, z=648.43]

     

×
×
  • Create New...

Important Information

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