Jump to content

Koolade446

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by Koolade446

  1. This is exactly what I needed I couldn't find the name of the method anywhere thank you so much.
  2. I am creating a custom portal and I want it to act similar to a nether portal. I have created an overlay that is painted on screen when you stand in the portal but I need to create the camera warp that happens when you are standing in a portal and I cant figure out how to do this. Any help is appreciated!
  3. Yeah, see I had the same thought but then I tried to load a single-player world and the game crashed on the Joining World screen with Null Pointer. I think there's a split second where the player hasn't technically logged on but is still ticking idk its weird.
  4. I’m facepalming so hard at myself right now cause I was totally about to tell you how you were wrong and then I realized oh tickRem would get refreshed every tick. So then my thought is to use while loops however I tend to try and avoid while loops because they lock up threads. Here’s a major question I have about forge. Is a separate instance of each class instantiated for each player or is it more like spigot where I need to make sure my code is accounting for multiple players? Because my next thought for a solution here would be to use an instance variable or a HashMap with player name or uuid:tickRem that clears as soon as they step off the saw. Also I tested the code doing damage every tick and it works fine but I am worried about system resources on a server with many people running checks every 1/20 of a second could get be too much on a server with many people.
  5. This isn't true HOWEVER its super complicated to do and you have to change the command every time. Below is a code snippet from a custom minecraft launcher I'm working on so there may be some unnecessary steps focus mainly on the HTTP connections, request types, and request bodys/url endpoints. Forewarning this is incredibly complicated and i would advise against it. If you need to test your mod on a server just put it in offline mode.
  6. This isn't what crashed your game and pertains in no way to your mod. There are no references in the stack trace to your mod's namespace or any of its classes so this error is on Minecraft's end. Please post the WHOLE crash report.
  7. the issue with this is if a player gets on a saw and player.tickCount % 20 is 14 the player could have 19 ticks or almost a whole second to get off the saw before a tick of damage would be delt so if they like ran across it they may not take damage. Would something like this work instead: @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) public class EventListener { @SubscribeEvent public static void checkStance(TickEvent.PlayerTickEvent e) { if (e.player != null) { //I realised checking if the level was null was a mute point because if the player wasn't null then the level couldn't be either final int tickRem = e.player.tickCount % 20; if (e.player.level.getBlockState(e.player.getOnPos()).getBlock() instanceof StonecutterBlock && e.player.tickCount % 20 == tickRem) { e.player.hurt(DamageSource.OUT_OF_WORLD, 30f); } } } } To make sure the player always takes damage on the first tick they stand on the saw for or am I misunderstanding something about how ticks work.
  8. Ok, thanks. I haven't ever really done anything server-side mostly client side until mods and mostly 1.8 so sorry for my lack of knowledge of both server-side behavior and current forge events. Thanks for that so Possibly use PlayerTickEvent? How does LivingUpdateEvent fire is it just a tick thing or does the player have to do some kind of action? thanks for your help. Edit: Ok heres my now working code @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) public class EventListener { @SubscribeEvent public static void checkStance(TickEvent.PlayerTickEvent e) { if (e.player != null && e.player.level != null) { if (e.player.level.getBlockState(e.player.getOnPos()).getBlock() instanceof StonecutterBlock) { HyperIon.getLOGGER().info("Player is on saw"); e.player.hurt(DamageSource.OUT_OF_WORLD, 1.5f); } } } } Any other advice? I plan to eventually implement a custom DamageSource btw the OUT_OF_WORLD source was just for testing
  9. So I'm trying to add a piece to my mod to make Stonecutters hurt players. So im listening for WorldTickEvent and if the player is standing on a stone cutter im using Player.hurt(DamageSource.OUT_OF_WORLD, 0.4f) Heres my code: @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) public class EventListener { @SubscribeEvent public static void checkStance(TickEvent.WorldTickEvent e) { if (Minecraft.getInstance().player != null) { if (Minecraft.getInstance().player.level.getBlockState(Minecraft.getInstance().player.getOnPos()).getBlock() instanceof StonecutterBlock) { HyperIon.getLOGGER().info("Player is on saw"); Minecraft.getInstance().player.hurt(DamageSource.OUT_OF_WORLD, 0.4f); } } } } The console prints out "player is on saw" whenever I stand on a saw but it just doesn't hurt me and I can't figure out why.
  10. I tried adding those to both my render and init methods and no dice. is there a way to register a GUI in 1.18? I'm doing this one a little different from how I would do GUI's in the past because 1.18 changed everything and the docs are pitiful. In the past, I would register and open a GUI like this //Register FMLModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, ...) //Open NetworkHooks.openGui. But FMLModLoadingContext doesn't exist anymore in 1.18 so instead, I'm using the open method so I never registered it? also never used the RenderSystem and Mojang insists on being annoying and naming their variables stupid things like p_98389 so i have no clue what the ints and floats in the method you gave me represent. Thanks for any help.
  11. The title lays it out. I'm pretty new to forge and 1.18 changed everything i know so yeah here goes I created a menu GUI and bound it to a key all works well but the GUI just uses the default missing GUI texture from Minecraft even though i have a texture set. Here's my code: public class MenuUI extends Screen { private static final int WIDTH = 179; private static final int HEIGHT = 151; private final ResourceLocation Texture = new ResourceLocation(NoLifeSmpMod.ModID, "textures/gui/menu.png"); protected MenuUI() { super(new TranslatableComponent("screen." + NoLifeSmpMod.ModID + ".Menu")); } @Override protected void init() { int relX = (this.width - WIDTH) / 2; int relY = (this.height - HEIGHT) / 2; addRenderableWidget(new Button(relX + 10, relY + 10, 160, 20, new TextComponent("Button test"), button -> sendMessage("Press recived"))); } @Override public boolean isPauseScreen() { return false; } @Override public void render(@NotNull PoseStack poseStack, int mouseX, int mouseY, float partialTicks) { int relX = (this.width - WIDTH) / 2; int relY = (this.height - HEIGHT) / 2; assert this.minecraft != null; this.minecraft.getTextureManager().bindForSetup(Texture); this.blit(poseStack, relX, relY, 0, 0, WIDTH, HEIGHT); super.render(poseStack, mouseX, mouseY, partialTicks); } public static void open() { Minecraft.getInstance().setScreen(new MenuUI()); } } in the past I used this.minecraft.getTextureManager().bind(texture) but that doesn't exist anymore so I assumed it had been replaced by this.minecraft.getTextureManager().bindForSetup() Am I wrong? IDK please help me.
  12. Sorry if this is necroposting but I have the keybind set up (mind you this is on .1.18 so I'm using the new KeyMapping rather than KeyBinding) But I don't quite understand how to make it be changeable in the Minecraft settings menu? I assumed it would be changeable after registering it but it's not and I don't get how to set it to be there. Code (sorry it's sloppy I'm just testing proof of concept, for now, I plan to clean it up later) @Mod.EventBusSubscriber public class KeyBindHandler { private static final KeyMapping MenuKey = new KeyMapping("key.menu", KeyConflictContext.UNIVERSAL, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_H, KeyMapping.CATEGORY_GAMEPLAY); @SubscribeEvent public static void registerKeyBinds (FMLClientSetupEvent e) { ClientRegistry.registerKeyBinding(MenuKey); } @SubscribeEvent public static void onKeyPress (InputEvent.KeyInputEvent e) { if (MenuKey.isDown()) { MenuUI.open(); } } } to be clear everything works, I can press h and open my GUI and use it the only thing is it cant be changed in the menu. Edit: lol I'm an idiot ignore me. Turns out i have to use the right event bus weird how that works huh *facepalm* so anyways I used a nested class and changed the event busses so that the ClientSetupEvent was under a MOD event bus and the KeyInputEvent was under a FORGE event bus and problem solved.
  13. I know how to use generics my friend. My question was how I can make my entity able to render the item in hand
  14. Okay I'm new to modding so whats a better way to do this?
  15. Hi, so I'm trying to add a custom boss who holds a sword. I made a model in blockbench and imported it and coded a renderer. the entity renders fine but as soon as I give it the sword the game crashes Model: Renderer: Crash Log:
  16. well then where the heck do I get vanilla source code? I've tried using a decompiler on the vanilla Jar but thier file naming scheme makes no sense at all its like $q87634576auyfgiatf.class
  17. Hi i am trying to give players a lore book the first time they log in so far i have this: @SubscribeEvent public void onPlayerJoin(EntityJoinWorldEvent e) { if (e.getEntity() instanceof PlayerEntity) { PlayerEntity pe = (PlayerEntity) e.getEntity(); if (!pe.getPersistentData().getBoolean("hasLoggedIn")) { pe.addItemStackToInventory(new ItemStack(RegistryHandler.BOOK.get())); pe.getPersistentData().putBoolean("hasLoggedIn", true); } } } this does give the item on log in and also only works once but it also gives the player the item when they respawn I don't want this how do I fix it.
  18. My bad for late reply forge decided not to notify me that’s you replied I will send you code in a bit.
  19. So I'm trying to add custom armor but whenever I apply it and go into f5 mode the game crashes. I'm pretty sure the error comes from not having a model for the armor but i cant figure out how to set the model. Crash report: https://pastebin.com/CXLivSLz
  20. 1. I know that’s why the listener is added in CommenSetup 2. Thank you for the information I will use this method in the future
  21. So I spent forever trying to figure this out so hopefully this solves the problem for those of you in the same situation. So we use the BiomeLoadingEvent to catch when biomes are loading and add our ConfiguredFeature. Ore Generation like so: public class WorldGen { public static final ConfiguredFeature<?, ?> yourOre = Feature.ORE.withConfiguration( new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, YourRegistryHandler.YOUR_ORE.get().getDefaultState(), 4)) //vein size .range(12).square() //maximum y level where ore can spawn .count(3); //how many veins maximum per chunck public static void generateOre(final BiomeLoadingEvent event) { BiomeGenerationSettingsBuilder generation = event.getGeneration(); if (event.getCategory().equals(Biome.Category.ICY)) { //OPTIONAL IF STATMENT allows you to generate ores in specfifc biome types for exmaple icy biomes generation.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, yourOre); } } } Now we need to know where to register this event do NOT use EventBus it will crash your mod on startup by trying to register generation before registering your ore block instead we register this in our main class like so: //if you use the mdk this function will be pre generated so we only add our refrence here private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, WorldGen::generateOre); //our refrence } ALTERNITIVE use if you are generating a bunch of ores in the same way
×
×
  • Create New...

Important Information

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