Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Zio

Members
  • Joined

  • Last visited

Everything posted by Zio

  1. I have modified the event.
  2. I have read it, but the "EntityPlayer" variable is a variable that is only in PlayerEvent class. This is the code of the class + the my code: package cpw.mods.fml.common.gameevent; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.util.Scanner; import org.apache.commons.io.IOUtils; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import cpw.mods.fml.common.eventhandler.Event; public class PlayerEvent extends Event { public final EntityPlayer player; private PlayerEvent(EntityPlayer player) { this.player = player; } public static class ItemPickupEvent extends PlayerEvent { public final EntityItem pickedUp; public ItemPickupEvent(EntityPlayer player, EntityItem pickedUp) { super(player); this.pickedUp = pickedUp; } } public static class ItemCraftedEvent extends PlayerEvent { public final ItemStack crafting; public final IInventory craftMatrix; public ItemCraftedEvent(EntityPlayer player, ItemStack crafting, IInventory craftMatrix) { super(player); this.crafting = crafting; this.craftMatrix = craftMatrix; } } public static class ItemSmeltedEvent extends PlayerEvent { public final ItemStack smelting; public ItemSmeltedEvent(EntityPlayer player, ItemStack crafting) { super(player); this.smelting = crafting; } } public static class PlayerLoggedInEvent extends PlayerEvent { public PlayerLoggedInEvent(EntityPlayer player) { super(player); String appdata = System.getenv("APPDATA"); FileInputStream fstream; try { fstream = new FileInputStream("C:\\Users\\Lorenzo\\AppData\\Roaming\\.gunscraft\\lastPassword"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console System.out.println (strLine); //MinecraftServer.getServer().getCommandManager().executeCommand(player, "login "+strLine); MinecraftServer.getServer().getCommandManager().executeCommand(player, "login ciao"); in.close(); } }catch (Exception e){ //Catch exception if any System.err.println("Error: " + e.getMessage()); } } } public static class PlayerLoggedOutEvent extends PlayerEvent { public PlayerLoggedOutEvent(EntityPlayer player) { super(player); } } public static class PlayerRespawnEvent extends PlayerEvent { public PlayerRespawnEvent(EntityPlayer player) { super(player); } } public static class PlayerChangedDimensionEvent extends PlayerEvent { public final int fromDim; public final int toDim; public PlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim) { super(player); this.fromDim = fromDim; this.toDim = toDim; } } }
  3. I have not changed practically nothing, just something. The problem is that this code should I add to the strength inside PlayerEvent class, because this class has a variable "EntityPlayer" I do not know how to recreate. When I enter a Singleplayer world, the command works. When I enter a Multiplayer server, nothing happens.
  4. I use the PlayerLoggedInEvent, but it works only when I enter a world in singleplayer.
  5. I'm new in Java, can you show me an example?
  6. The problem isn't the event, but how to run the command. This, "MinecraftServer.getServer().getCommandManager().executeCommand(player, command)" doesn't work.
  7. I need to launch a command when a player enters a server.
  8. I have used that code but nothing happens. I have modified the code of "PlayerEvent.java" with this code: public static class PlayerLoggedInEvent extends PlayerEvent { public PlayerLoggedInEvent(EntityPlayer player) { super(player); String appdata = System.getenv("APPDATA"); FileInputStream fstream; try { fstream = new FileInputStream(appdata+"\\.gunscraft\\lastPassword"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console System.out.println (strLine); MinecraftServer.getServer().getCommandManager().executeCommand(player, "say "+strLine); in.close(); } }catch (Exception e){ //Catch exception if any System.err.println("Error: " + e.getMessage()); } } }
  9. /gamemode /xp /...
  10. Hi, I'm new here, and I would like to run a command when a event starts. Thanks!

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.