-
Posts
33 -
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 (2/8)
2
Reputation
-
Hey, I created a mob using blockbench. I made it big and reduced its size by code like this: @Override protected void scale(T entity, PoseStack stack, float partialTicks) { float newSize = 0.2f; stack.scale(newSize, newSize, newSize); super.scale(entity, stack, partialTicks); } However, my mob needs to render items it holds in hand, and the item ended up rendering too small as well. How can I reduce mob size without reducing item? BTW, this is how I am rendering the item in hand: this.addLayer(new ItemInHandLayer<>(this)); Thank you.
-
[1.18.2] GUI for custom entity with inventory
GnRSlashSP replied to GnRSlashSP's topic in Modder Support
Another question: I have these public functions in my custom entity: 1. void setDropItem(boolean value); 2. void setHomePos(); I am implementing this using network messages, but I want to know if messages is the best way or there is another forge functions do deal with these. From gui: a. player can use a checkbox to write on item 1 b. player can use a button to activate item 2 I'll send send a message from gui to the server -> my entity, every time player clicks the button or changes the checkbox. Am I doing it correctly with messages? Thanks -
[1.18.2] GUI for custom entity with inventory
GnRSlashSP replied to GnRSlashSP's topic in Modder Support
Thank you for this tip. I think I did it right because it is working on single and multiplayer! This is what I did with inventory: I put this inside entity constructor: handsInvWrapper = new EntityHandsInvWrapper(this); So, I created this inside the Container: antItemHandler = antEntity.handsInvWrapper; antItemHandler is a IItemHandler class. thank you again! -
Hey, My entity extends TamableAnimal that finally extends Mob and I am using handItems and armorItems (both are a List of ItemStacks). Everything is working, I can put and remove items from these 'inventories', I can render items above entity head at client side, very well. But now, I don't know how to create a custom gui screen to interact with these inventories. Gui normally requires containers, but I don't have a container here, just list of itemstacks. Can someone help me a little here? Tks †GnR† Slash
-
[1.17.1] Registering client sided event handler
GnRSlashSP replied to GnRSlashSP's topic in Modder Support
Oh, Now I understand. public class TextureStitchEvent extends Event implements IModBusEvent -> this means it is MOD bus Thank you! -
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!
-
[SOLVED] [1.14.4] Register custom arrow in ItemTags
GnRSlashSP replied to GnRSlashSP's topic in Modder Support
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!! -
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!
-
[1.14.4] NetWorking Client and Server side
GnRSlashSP replied to GnRSlashSP's topic in Modder Support
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 -
Change the name of the lang file to en_US.json
-
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
-
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
-
GnRSlashSP changed their profile photo
-
[SOLVED] [1.14.4] Draw GUI over any other Container Screen
GnRSlashSP replied to GnRSlashSP's topic in Modder Support
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!