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

GnRSlashSP

Members
  • Posts

    28
  • Joined

  • Last visited

  • Days Won

    1

GnRSlashSP last won the day on July 22 2020

GnRSlashSP had the most liked content!

Converted

  • Gender
    Male
  • Personal Text
    I can because I am still trying hard!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

GnRSlashSP's Achievements

Tree Puncher

Tree Puncher (2/8)

2

Reputation

  1. Oh, Now I understand. public class TextureStitchEvent extends Event implements IModBusEvent -> this means it is MOD bus Thank you!
  2. Hi! I want to understand how this works. Reading Forge Documentation I made this at first: @Mod.EventBusSubscriber(modid = RedOptionsMod.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class StaticClientOnlyEventHandler { @SubscribeEvent public static void spriteAdd(TextureStitchEvent.Pre event) { if (!event.getMap().location().equals(InventoryMenu.BLOCK_ATLAS)) return; event.addSprite(Resources.FILTER); } } But this event is never fired (I don't think it should have been registered..)So, I removed the line: @Mod.EventBusSubscriber, and I did this at my mod class: if (FMLLoader.getDist().isClient()) FMLJavaModLoadingContext.get().getModEventBus().register(StaticClientOnlyEventHandler.class); And it is working (working and don't crashing at server side). Tow questions: 1. Why the first method didn't work, am I missing something? 2. Is the second way the correct way to register specific side events, using (FMLLoader.getDist().isClient()) ? Thank you!
  3. I saw this but I didn't realize that I could just create a minecraft folder inside my assets lol I was so simple, thanks!!
  4. Hi, I already create a new arrow type and it is working. StoneArrow. Everything is working including minecraft Bow and CrossBow are using my custom arrow BUT I am doing the register manually using breakpoints inside BowItem.java I am using these two lines to make my arrow be accepted by normal bow: ItemTags.getCollection().get(new ResourceLocation("arrows")).getEntries().add(new Tag.TagEntry<Item>(ModItems.ITEM_STONE_ARROW.getRegistryName())); ItemTags.getCollection().get(new ResourceLocation("arrows")).getAllElements().add(ModItems.ITEM_STONE_ARROW); I would like to know these two things: 1. Where is the right place (and time), that I can add my arrow to ItemTags 2. Is it right the code above? It seams not right for me because I used two lines... stranged thing Thank you!
  5. I think I solved this issue... GnRSharedLib has a pack.metadata and inside it has a description key. Instead of write gnrsharedlib I wrote GnRSharedLib (using caps....)
  6. Diesieben, thanks for the explanation. It's really complicated, but now I have a chance to write code the right way. So I changed the code from: PlayerEntity playerEntity = Minecraft.getInstance().player to: ClientPlayerEntity playerEntity = Minecraft.getInstance().player; and it works! But I still don't know why this do not work (even if I put all inside DistExecutor): if (ctx.get().getDirection().getReceptionSide().isClient()) { Minecraft.getInstance().displayGuiScreen(new XPTransferScreen(playerIDToTransfer, playerName)); } and this works: if (ctx.get().getDirection().getReceptionSide().isClient()) { XPTransferScreen.open(playerID, playerName); } this is inside XPTransfer class, that extends Screen: public static void open(int playerIDToTransfer, String playerName) { Minecraft.getInstance().displayGuiScreen(new XPTransferScreen(playerIDToTransfer, playerName)); } I just want to open a simple Screen, without container, just buttons, textfields
  7. Change the name of the lang file to en_US.json
  8. I am a little confused when I need to use the same message on both sides. When I want to execute client side code like Minecraft.getInstance(), I can use this: DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { // this is client side PlayerEntity playerEntity = Minecraft.getInstance().player; Entity entity = playerEntity.world.getEntityByID(entityId); .... // the rest of code here }); but this is generating an error when I try to start the server.... the error occurs while registering network messages because there is Minecraft.getInstance in message body... I don't know when to use this: Dist.DEDICATED_SERVER because I'm afraid of the code inside it only runs if the server is physical, I mean, the code inside this will not run when minecraft is running in single player mode. Another approach that I used (but again I am not sure what I am doing), was this: if (ctx.get().getDirection().getReceptionSide().isServer()) { ent = ctx.get().getSender().world.getEntityByID(playerID); if (ent instanceof PlayerEntity) { // server side code here.... } } else if (ctx.get().getDirection().getReceptionSide().isClient()) { XPTransferScreen.open(playerID, playerName); } Note that I am not using Client methods here directly, but I put the client part inside the XPTransferScreen.open method: public static void open(int playerIDToTransfer, String playerName) { Minecraft.getInstance().displayGuiScreen(new XPTransferScreen(playerIDToTransfer, playerName)); } This way the code runs without problems on single player and dedicated server. So my question is: Which method should i use? (DistExecutor or getReceptionSide) ? If your answer is DistExecutor, I have another question: How can I run it server side and single player, Dist.DEDICATED_SERVER will run like server side if I run the single player game? Thanks! โ€ GnRโ€  Slash
  9. I think this is the problem. According to documentation, you need to write it this way: ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ServerConfig.CONFIG); ServerConfig.loadConfig(ServerConfig.CONFIG, FMLPaths.CONFIGDIR.get().resolve(modid +"-server.toml")); You don't need to specify the file name, it will be your MODID name. Keep it simple and you will stay out of trouble and this: ServerConfig.loadConfig(ServerConfig.CONFIG, FMLPaths.CONFIGDIR.get().resolve("modid-server.toml").toString()); will not compile, the last parameter needs to be Path not String
  10. It is working! Of course, using this event solved my issue with drawing color but cause me issues with coordinates. Before using GuiContainerEvent: double mouseX = mc.mouseHelper.getMouseX() * (double)mc.mainWindow.getScaledWidth() / (double)mc.mainWindow.getWidth(); double mouseY = mc.mouseHelper.getMouseY() * (double)mc.mainWindow.getScaledHeight() / (double)mc.mainWindow.getHeight(); mc.fontRenderer.drawString(Resources.getMsg("item"), searchBar.x - 3 - mc.fontRenderer.getStringWidth(Resources.getMsg("item")), searchBar.y, 0x606060); mc.fontRenderer.drawString(Resources.getMsg("qty"), qtyBar.x - 3 - mc.fontRenderer.getStringWidth(Resources.getMsg("qty")), qtyBar.y, 0x606060); After using GuiContainerEvent: double mouseX = mc.mouseHelper.getMouseX() * (double)mc.mainWindow.getScaledWidth() / (double)mc.mainWindow.getWidth(); double mouseY = mc.mouseHelper.getMouseY() * (double)mc.mainWindow.getScaledHeight() / (double)mc.mainWindow.getHeight(); double newY = -(mc.mainWindow.getScaledHeight() - ((ContainerScreen) mc.currentScreen).getYSize())/2; double newX = -(mc.mainWindow.getScaledWidth() - ((ContainerScreen) mc.currentScreen).getXSize())/2; GlStateManager.translated(newX, newY, 1d); mc.fontRenderer.drawString(Resources.getMsg("item"), searchBar.x - 3 - mc.fontRenderer.getStringWidth(Resources.getMsg("item")), searchBar.y, 0x606060); mc.fontRenderer.drawString(Resources.getMsg("qty"), qtyBar.x - 3 - mc.fontRenderer.getStringWidth(Resources.getMsg("qty")), qtyBar.y, 0x606060); Another thing, after all code inside this event, I need to use this again: GlStateManager.translated(-newX, -newY, 1d); Without this, when I click a slot to drag itemstack, the item appear at wrong locations at screen lol Thank you!
  11. Hey, Lets make simple things to test complex things: Create a single player world, customized to be superflat (this way, nothing will hinder you) Enter creative mode, put your specific block anywhere (write down the block positions) Put a breakpoint somewhere in the code to stop when the mod gets the goal to that block Spawn your mob a few blocks near these block At the breakpoint, watch the variable that have the final destination position, this must be the same coords of the block! (see if rounding problems is occuring here). Good luck.
  12. I don't know what you are saying with "Spawn ItemStack", because ItemStacks can't "Spawn". If you have a ItemStack and want this item to Spawn in world right above players head, use ItemEntity (search how mobs drops its inventory and copy the code there). But if you want to put a specific ItemStack in player armor head position inventory, its simple: playerEntity.armorinventory.set(slot, itemstack) // don't remember if player head slot is 0 or 3, try it Always do these things SERVER side.
  13. Hi, I am trying to draw a gui with buttons over another screen always when player open a Screen that is instance of Container. It is working very well except the background texture. I tryed to use Forge's events like: RenderGameOverlayEvent.Post / Pre GuiScreenEvent.DrawScreenEvent.Post / Pre GuiScreenEvent.DrawScreenEvent.BackgroundDrawnEvent When I open my own custom gui, it works (the little gui at the top of screen is the GUI that I am talking about, drawned by forge events described above): https://paste.pics/e0840bd62f40d65c805edc31474ec2c8 But, if I open player inventory or crafting table or chest containers, this is what happens to my overlay gui (grayed out) https://paste.pics/65c5c355f7597296d13def7459c715c0 I tried to enable/disable GL11 lighting, blend, etc... but I am not good with grapichs parts... This is my current "working" code: @SubscribeEvent public static void onScreenRender(RenderGameOverlayEvent.Post event) { if (event.getType() == RenderGameOverlayEvent.ElementType.EXPERIENCE) { if (mc.currentScreen instanceof ContainerScreen<?> && !(mc.currentScreen instanceof CreativeScreen)) { GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderHelper.disableStandardItemLighting(); mc.getTextureManager().bindTexture(SEARCH_GUI); // SEARCH_GUI is a ResourceLocation mc.currentScreen.blit(guiLeft, guiTop, 0, 0, xSize, ySize); } } } Can anyone help me about this? Thank you!
  14. I was looking at ItemStackHandler and the difference mine is too slight, ItemHandler is missing some features like listeners, clear inventory, isEmpty, MarkDirt. So, this is reasonable if it syncs with client for me automatically. I changed from "extends Inventory" to extends "ItemHandler" and now I cant add slots because new slot needs Inventory class. Let me see ... Did I get it right? If I implement correctly, will the inventory automatically sync without having to create custom network messages or ItemHandler is just a way to writeToNBT automatically? thanks
  15. Hi, You need to override keyPressed too and put logic inside to pass the key information to textwidget if it has focus Something like this: @Override public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) { if (txtXPToTransfer.isFocused()) { txtXPToTransfer.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_); } return super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_); }
×
×
  • Create New...

Important Information

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