Im not going to argue the point as many servers still use 1.8 over 1.12 but whatever
The commands class is working perfectly fine on multiplayer and single player servers
Thank you fixed
I'm am not very sure how to do this? From what I understand, the event triggers off 2x per tick, one at the start and once at the end. As a result this is rapid firing the message being sent, "/sell all" and getting me kicked for spam. How can i use the phase to make sure that at the instance the code only fires a single time?
Fixed and now the code is being sent properly
updated code:
Main
@Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = Reference.ACCEPTED_VERSIONS)
public class AutoSell
{
public static String planet;
@Instance
public static AutoSell instance;
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;
@Mod.EventHandler
public void onFMLInitialization(final FMLInitializationEvent event)
{
MinecraftForge.EVENT_BUS.register(new LivingEntityEventHandlers());
ClientCommandHandler.instance.registerCommand((ICommand)new Commands());
FMLCommonHandler.instance().bus().register((Object)this);
FMLCommonHandler.instance().bus().register(new AntiAfk());
}
public static void AfkForDays()
{
Minecraft.getMinecraft().thePlayer.sendChatMessage("/server " + planet + " planet");
Minecraft.getMinecraft().thePlayer.sendChatMessage("/lag");
}
public static void sellShit()
{
Minecraft.getMinecraft().thePlayer.sendChatMessage("/sell all");
}
}
Sell class:
public class LivingEntityEventHandlers
{
int maxslots;
@SubscribeEvent
public void LivingUpdateEvent(LivingEvent event)
{
if (event.entity instanceof EntityPlayerSP)
{
EntityPlayerSP player = (EntityPlayerSP) event.entity;
InventoryPlayer inventory = player.inventory;
for (int i = 0; i < inventory.mainInventory.length; ++i)
{
maxslots = i;
if (inventory.mainInventory[i] == null)
{
}
else
{
if (maxslots == 35)
{
FallingAngel.AutoSell.AutoSell.sellShit();
maxslots = 0;
break;
}
}
}
}
}
}
AntiAFK (Not Working)
public class AntiAfk {
int tick = 0;
@SubscribeEvent
public void onPlayerJoinedServer(FMLNetworkEvent.ClientConnectedToServerEvent event) {
if(tick != 6000){
tick++;
return;
}
else
{
tick = 0;
FallingAngel.AutoSell.AutoSell.AfkForDays();
}
}
Commands
public class Commands extends CommandBase
{
private final List aliases;
private String planets;
public Commands()
{
aliases = new ArrayList();
aliases.add("planet");
aliases.add("reco");
}
@Override
public int compareTo(Object o)
{
return 0;
}
@Override
public String getName()
{
return "planet";
}
@Override
public String getCommandUsage(ICommandSender var1)
{
return "planet <text>";
}
@Override
public List getAliases()
{
return this.aliases;
}
@Override
public void execute(ICommandSender sender, String[] args) throws CommandException {
if (args.length == 0)
{
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eplease enter in a planet or do '/planet list' to see the §ecurrent planet! "));
}
else if (args[0].equals("list"))
{
if(planets != null && !planets.isEmpty())
{
System.out.println(args[0]);
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eCurrent Planet: §4§l" + planets.toUpperCase()));
}
else
{
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eNo current planet!"));
}
}
else
{
FallingAngel.AutoSell.AutoSell.planet = args[0];
planets = args[0];
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eplanet has been set to: §4§l" + args[0].toUpperCase() + " §r§eplanet"));
}
}
public boolean canCommandSenderUse(ICommandSender var1)
{
return true;
}
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isUsernameIndex(String[] var1, int var2)
{
// TODO Auto-generated method stub
return false;
}
}