Jump to content

Ctwx

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by Ctwx

  1. Okay, I have found the answer. I was using the wrong event bus. This seems to work: public ExampleMod() { MinecraftForge.EVENT_BUS.addListener(this::onServerStarted); } private void onServerStarted(ServerStartedEvent event) { int count = event.getServer().getPlayerCount(); LOGGER.info("onServerStarted, playCount: " + count); }
  2. Hello, I am trying to do some things after the server (dedicated server) has been started. I want to access the player data in that event. But I can't find a way to get a MinecraftServer instance. My current code is pretty simple yet: public ExampleMod() { // MinecraftForge.EVENT_BUS.register(this); IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::onDedicatedServer); } // @SubscribeEvent private void onDedicatedServer(FMLDedicatedServerSetupEvent event) { int count = 42; LOGGER.info("onDedicatedServer, playCount: " + count); } @SubscribeEvent did not work for some reason, but that is nothing I worry about right now. I could not find a way to access the MinecraftServer instance in the EventHandler. Is there any static method or something to get it? I was searching and found net.minecraftforge.event.server.ServerStartedEvent but it failed with this modEventBus.
  3. Okay, I fixed it. Thank you very much for the recommendations for Parchment and blit. The issue that I still had was this: // I had this: new ResourceLocation("sereneseasons", "sereneseasons/textures/item/ss_icon.png"); // but I needed this: new ResourceLocation("sereneseasons", "textures/item/ss_icon.png"); I checked the sereneseasons.jar and the textures where in assets/sereneseasons, so I thought I needed the extra folder name above. Now it works.
  4. My bad. I checked the additional FAQ, prefixing my parameters with "p" fixed Parchment, but not the icon issue in my answer above. Thanks
  5. Okay, Parchment works, and blit also. But still, it is black on the screen: private static final ResourceLocation SS_ICON = new ResourceLocation("sereneseasons", "sereneseasons/textures/item/ss_icon.png"); @SubscribeEvent public void onRenderGameOverlayEventPost(RenderGameOverlayEvent.Post pEvent) { if (pEvent.getType() == RenderGameOverlayEvent.ElementType.ALL) { Minecraft.getInstance().getTextureManager().bind(SS_ICON); AbstractGui.blit(pEvent.getMatrixStack(), 50, 50, 0f, 0f, 8, 8, 16, 16); } } The icon is black in game (when I make it bigger, it is this black/magenta squared texture): I also tried it with a different ResourceLocation which works fine: new ResourceLocation("textures/gui/book.png"); I am not sure why it is not able to locate the resource. I also tried to copy it in my src/resources/assets folder, but that does not seem to work either. Do I have to register the resources first?
  6. Thank you. I'll check Parchment out. What does blit do? Without Parchment I see a bunch of different Parameters but all of them just use int and float. Perhaps that will be more clear when I use Parchment.
  7. Hello, I am trying to render an icon on the screen. I've read https://forums.minecraftforge.net/topic/107635-1165-mcp-render-overlay-errorbackground-black/ and thought this should be easily appliable to my code, but I only get a black square. Furthermore, I've read https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/modification-development/1437340-drawing-texture-with-drawtexturedmodalrect-is-too where they say the icon has to be 256x256, so I increased the size of the icon from 16x16 to 256x256. My code is: private static final ResourceLocation SS_ICON = new ResourceLocation("sereneseasons", "sereneseasons/textures/item/ss_icon.png"); @SubscribeEvent public void onRenderGameOverlayEventPost(RenderGameOverlayEvent.Post event) { if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) { TextureManager textureManager = Minecraft.getInstance().getTextureManager(); textureManager.bind(SS_ICON); GuiUtils.drawTexturedModalRect(event.getMatrixStack(), 50, 50, 0, 0, 8, 8, 0); } } This is the icon This icon is from another mod, sereneseasons and it is inside its assets/sereneseasons/textures/item folder. What am I missing here? And can someone explain the 4. and 5. parameter that are 0 in my code above?
  8. Ah! That makes sense. I did not thought about that.
  9. They have a forum, but nothing about modding for it. They also don't provide and source so it is a bit harder. The only thing they provide are the docs above. But I found threads regarding Pixelmon modding here so I thought this forum might be a good place to ask. Interestingly the DropEvent (https://reforged.gg/docs/com/pixelmonmod/pixelmon/api/events/DropEvent.html) I want to listen to extends net.minecraftforge.fml.common.eventhandler.Event. This is very strange...
  10. Hello, I am trying to program a small mod that is working with Pixelmon Reforged. In the @Mod annotated class' constructor I register an EventHandler class like this: public ExampleMod() { MinecraftForge.EVENT_BUS.register(new com.example.examplemod.EventHandler()); } The EventHandler class looks like this: package com.example.examplemod; import com.pixelmonmod.pixelmon.api.events.DropEvent; import com.pixelmonmod.pixelmon.api.pokemon.PokemonSpec; import com.pixelmonmod.pixelmon.api.trading.TradePair; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.apache.logging.log4j.Logger; public class EventHandler { private Logger logger; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); logger.info("### EXAMPLE MOD LOADED"); } @SubscribeEvent public void ev(DropEvent event) { logger.info("### onEconomyEvent " + event.player); PokemonSpec exchange = PokemonSpec.from("glumanda"); PokemonSpec offer = PokemonSpec.from("mewto"); TradePair tradePair = new TradePair(offer, exchange); com.pixelmonmod.pixelmon.api.trading.NPCTrades.showTrade(event.player, tradePair); } @SubscribeEvent public void pickupItem(EntityItemPickupEvent event) { System.out.println("### Item picked up! " + event.getItem().getName()); } } I added a test event which I found in the documentation. It gets triggered. But the DropEvent (or other Pixelmon events) does not. I checked different events but none of them are triggered. (I found them here: https://reforged.gg/docs/) I put the pixelmon jar into a "lib" folder and added the dependency like this: dependencies { provided fileTree(include: ['*.jar'], dir: 'lib') } Why aren't any of those events triggered?
×
×
  • Create New...

Important Information

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