Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

The method func_178845_a() is undefined for the type loadedPlayer


AngelNour
 Share

Recommended Posts

package com.example.examplemod;

import java.util.Collection;

import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

@Mod(modid = "PartyAll", name = "PartyAll", version = "1.0", acceptedMinecraftVersions = "[1.16.X]")
public class ExampleMod extends CommandBase {
  @EventHandler
  public void init(FMLPostInitializationEvent event) {
    MinecraftForge.EVENT_BUS.register(this);
    ClientCommandHandler.instance.func_71560_a((ICommand)this);
  }
  
  public int func_82362_a() {
    return 0;
  }
  
  public String func_71517_b() {
    return "pall";
  }
  
  public String func_71518_a(ICommandSender sender) {
    return null;
  }
  
  public void func_71515_b(ICommandSender sender, String[] args) throws CommandException {
    (new Thread(() -> myRun(sender))).start();
  }
  
  public void myRun(ICommandSender sender) {
    Collection<NetworkPlayerInfo> playersC = Minecraft.func_71410_x().func_147114_u().func_175106_d();
    playersC.forEach(loadedPlayer -> {
          String loadedPlayerName = loadedPlayer.func_178845_a().getName();
          (Minecraft.func_71410_x()).field_71439_g.func_71165_d("/p " + loadedPlayerName);
          try {
            Thread.sleep(150L);
          } catch (InterruptedException e) {
            e.printStackTrace();
          } 
        });
  }

@Override
public String getCommandName() {
    // TODO Auto-generated method stub
    return null;
}

@Override
public String getCommandUsage(ICommandSender sender) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    // TODO Auto-generated method stub
    
}
}
 

Link to comment
Share on other sites

37 minutes ago, AngelNour said:

package com.example.examplemod;

import java.util.Collection;

import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

@Mod(modid = "PartyAll", name = "PartyAll", version = "1.0", acceptedMinecraftVersions = "[1.16.X]")
public class ExampleMod extends CommandBase {
  @EventHandler
  public void init(FMLPostInitializationEvent event) {
    MinecraftForge.EVENT_BUS.register(this);
    ClientCommandHandler.instance.func_71560_a((ICommand)this);
  }
  
  public int func_82362_a() {
    return 0;
  }
  
  public String func_71517_b() {
    return "pall";
  }
  
  public String func_71518_a(ICommandSender sender) {
    return null;
  }
  
  public void func_71515_b(ICommandSender sender, String[] args) throws CommandException {
    (new Thread(() -> myRun(sender))).start();
  }
  
  public void myRun(ICommandSender sender) {
    Collection<NetworkPlayerInfo> playersC = Minecraft.func_71410_x().func_147114_u().func_175106_d();
    playersC.forEach(loadedPlayer -> {
          String loadedPlayerName = loadedPlayer.func_178845_a().getName();
          (Minecraft.func_71410_x()).field_71439_g.func_71165_d("/p " + loadedPlayerName);
          try {
            Thread.sleep(150L);
          } catch (InterruptedException e) {
            e.printStackTrace();
          } 
        });
  }

@Override
public String getCommandName() {
    // TODO Auto-generated method stub
    return null;
}

@Override
public String getCommandUsage(ICommandSender sender) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    // TODO Auto-generated method stub
    
}
}
 

The method has probably been remapped to something else

Link to comment
Share on other sites

23 hours ago, AngelNour said:

Now that i'm using 1.16

 

23 hours ago, AngelNour said:

@Mod(modid = "PartyAll", name = "PartyAll", version = "1.0", acceptedMinecraftVersions = "[1.16.X]")

 

23 hours ago, AngelNour said:

public void init(FMLPostInitializationEvent event)

dont lie plz

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I am trying to create a custom anvil for my mod and the approach i am trying is to create a normal vanilla anvil with custom recipe container - i tried creating the block and passing a custom container to it but i do feel a bit stuck and confused on how to do this. Some explanation and guidence would be great! Thanks in advance. package com.vassdeniss.makoru.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.inventory.container.SimpleNamedContainerProvider; import net.minecraft.stats.Stats; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.IWorldPosCallable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; public class AngelAnvilBlock extends Block { private static final ITextComponent AngelAnvilContainer = new TranslationTextComponent("container.crafting"); public AngelAnvilBlock() { super(Block.Properties.create()); } @Override public ActionResultType onBlockActivated(BlockState p_225533_1_, World worldIn, BlockPos p_225533_3_, PlayerEntity player, Hand p_225533_5_, BlockRayTraceResult p_225533_6_) { if (worldIn.isRemote) { return ActionResultType.SUCCESS; } else { NetworkHooks.openGui(player, ); player.addStat(Stats.INTERACT_WITH_ANVIL); return ActionResultType.CONSUME; } } @Override public INamedContainerProvider getContainer(BlockState state, World world, BlockPos pos) { return new SimpleNamedContainerProvider((id, inventory, player) -> new AngelAnvilContainer(id, inventory, IWorldPosCallable.of(world, pos)), AngelAnvilContainer); } } package com.vassdeniss.makoru.blocks; import com.vassdeniss.makoru.util.RegistryHandler; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.RepairContainer; import net.minecraft.util.IWorldPosCallable; public class AngelAnvilContainer extends RepairContainer { private final IWorldPosCallable field_217070_e; public AngelAnvilContainer(int id, PlayerInventory playerInventory, IWorldPosCallable p_i50102_3_) { super(id, playerInventory, p_i50102_3_); this.field_217070_e = p_i50102_3_; } @Override public boolean canInteractWith(PlayerEntity player) { return isWithinUsableDistance(this.field_217070_e, player, RegistryHandler.ANGEL_ANVIL.get()); } }  
    • I'm making some tools and I'm using a Set of type Block to specify on what blocks the tools would work. This is all in my ItemInit class which I use to register items. See below. private static Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.ANDESITE); This works fine with minecraft blocks. Problems occur when I want to use mod blocks like this: private static Set<Block> EFFECTIVE_ON = Sets.newHashSet(BlockInit.AMBER_BLOCK.get());   I get an error while loading the game, which is a NullPointerException.  Exception message: java.lang.NullPointerException: Registry Object not present: extinctioncraft:amber_block   It seems my block can't be found by this set despite the block working fine in the game itself.    I already tried the following without success: - Checked if the BlockInit is registered in the main class. ( BlockInit.BLOCKS.register(bus); ) - Checked if the block is registered in the BlockInit class. 
    • As the name implies I am trying to make a block with a "condition" value. I am doing this because I will be adding future features where a very strong type of block would be useful. I have started out with making a simple custom blockstate property (1-4) which determines the model (Polished, Un-polished, scuffed, cracked). However, I want those 4 states to then be determined by a larger number (more wiggle room with how much damage a certain event can do to this type of block). I was thinking 3000-5000, which I can then say "oh the block durability has to be at 200 to be cracked, but 750 for scuffed". I think the large health number think could be done with a tile entity I also want certain states to be maintained even after it has been picked up such as the larger number (maybe not the 1-4 since I think I would have to do something funky with datagen for my 90 items to have 360 item models), so perhaps NBT (which I have never done before). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I could probably figure this out on my own given a good bit of time, but dual-enrollment does not allow much time in a day. So, basically just looking either for a github repos that shows persistent data & some funky tile entities (if that is the best route for the block health thing), or suggestions.    
    • ObfuscationReflectionHelper methods always take SRG names, even in the development environment. In development, the SRG name is automatically remapped to the corresponding MCP name.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.