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.

Kokkie

Forge Modder
  • Joined

  • Last visited

Everything posted by Kokkie

  1. 1.7.10 isn't supported anymore (for like half a year) so... please update
  2. So I wondered if you could add an easy way to add a custom structure to the /locate command, I think it would be best to put it in the WorldGenerator class and then like this (using a structure from my mod, the generate method): while (worldIn.isAirBlock(position) && position.getY() > 2) { position = position.down(); } if (!IS_GRASS.apply(worldIn.getBlockState(position)) && !IS_HIGH_GRASS.apply(worldIn.getBlockState(position))) { return false; } if(IS_HIGH_GRASS.apply(worldIn.getBlockState(position))) { position = position.down(); } Random random = worldIn.getChunkFromChunkCoords(position.getX(), position.getZ()).getRandomWithSeed(987234911L); Rotation[] arotation = Rotation.values(); Rotation rotation = arotation[random.nextInt(arotation.length)]; ChunkPos chunkpos = new ChunkPos(position); StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart() - 16, 0, chunkpos.getZStart() - 16, chunkpos.getXEnd() + 16, 256, chunkpos.getZEnd() + 16); PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random); MinecraftServer minecraftserver = worldIn.getMinecraftServer(); TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager(); Template template = templatemanager.getTemplate(minecraftserver, HOUSE); template.addBlocksToWorld(worldIn, position, placementsettings, 20); *this.addStructureToLocate(position, "House");* return true; The params being: A BlockPos, obviously for where it generated, a String which is the name to use in the command It would look something like this in the WorldGenerator class: protected void addStructureToLocate(BlockPos pos, String name) { CommandLocate.STRUCTURES.add(name); CommandLocate.addStructureLocation(pos, name); } And in the CommandLocate class itself: public static String[] STRUCTURES = new String[] {"Stronghold", "Monument", "Village", "Mansion", "EndCity", "Fortress", "Temple", "Mineshaft"} public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) { return args.length == 1 ? getListOfStringsMatchingLastWord(args, STRUCTURES): Collections.<String>emptyList(); } public void addStructureLocation(BlockPos pos, String name) { don't know how to do this but you might get the idea } I don't really know how lists sets and all work but jeh... gtg
  3. How can I request it?
  4. Hello, how can I add my structures to the /locate command?
  5. So, moving the MessageHandler class to it's own class and package seems to have fixed it, thanks!
  6. It now crashes when I register them, my code: Message and message handler public class MyMessage implements IMessage { public MyMessage(){ } private boolean creative; private int amount; public MyMessage(boolean isCreative, int cookieAmount) { this.amount = cookieAmount; this.creative = isCreative; } @Override public void toBytes(ByteBuf buf) { buf.writeBoolean(creative); buf.writeInt(amount); } @Override public void fromBytes(ByteBuf buf) { creative = buf.readBoolean(); amount = buf.readInt(); } public int getAmount() { return amount; } public boolean isCreative() { return creative; } public class MyMessageHandler implements IMessageHandler<MyMessage, IMessage> { @Override public IMessage onMessage(final MyMessage message, final MessageContext ctx) { final EntityPlayerMP player = ctx.getServerHandler().playerEntity; IThreadListener mainThread = (WorldServer) player.worldObj; mainThread.addScheduledTask(new Runnable() { @Override public void run() { System.out.println(String.format("Received %s and %s from %s", message.getAmount(), message.isCreative(), player.getDisplayName())); player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, new ItemStack(Items.COOKIE, message.getAmount()))); player.addStat(Achievements.COOKIE); if(!message.isCreative()) { player.removeExperienceLevel(message.getAmount() * 3); } } }); return null; } } } PacketHandler class public class PacketHandler { public static SimpleNetworkWrapper INSTANCE; public static int ID = 0; public void registerPackets() { INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel("myChannel"); INSTANCE.registerMessage(MyMessage.MyMessageHandler.class, MyMessage.class, ID++, Side.CLIENT); } }
  7. Wait, can't I do something with the getServerGuiElement method?
  8. How do I get the client that send the packet?
  9. You don't need those
  10. How do I get the player with the packet?
  11. To what side do I send it, I guess MP
  12. I'm sorry, I'm not getting this and probably this is simple as fk but I'm not getting this
  13. I don't really get it, how can I get the EntityPlayer that has opened the gui class
  14. How can I do that, with a Tile-Entity?
  15. I know, I only check the xp on client side and change it in the block class on server side but it is with a pretty hacky way that only works if 1 player does it at a time
  16. Bump
  17. 1. Use the normal font 2. Explain
  18. I would suggest doing AxisAlignedBB bb = playerIn.getEntityBoundingBox().expand(20.0D, 20.0D, 20.0D) and for hurting them something like this: List<EntityLivingBase> entitiesInAABB = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bb); for(int i = 0; i < entitiesInAABB.size(); i++) { EntityLivingBase entityInAABB = entitiesInAABB.get(i); entityInAABB.attackEntityFrom(DamageSource.magic, 1.0F); }
  19. So, I have made a gui that will, after some texts, trade xp - cookies but I need a player instance for me to check the xp, give a cookie and take xp, I have something that works, but it won't work if multiple people use it at the same time, this is what I have come up with: The gui class: public class CookieGui extends GuiScreen { public static GuiSlider cookies; public boolean slider = false; public EntityPlayer player = Minecraft.getMinecraft().thePlayer; public static boolean cookiesC = false; public static boolean cookiesS = false; @Override public void initGui() { slider = false; cookiesC = false; cookiesS = false; buttonList.add(new GuiButtonExt(1, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Goed geopend!")); cookies = new GuiSlider(8, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Ik wil ", " koekjes", 1, 64, 1, true, true); } @Override protected void actionPerformed(GuiButton button) throws IOException { switch(button.id) { case 1 : buttonList.removeAll(buttonList); buttonList.add(new GuiButtonExt(2, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Stop!")); break; case 2 : buttonList.removeAll(buttonList); buttonList.add(new GuiButtonExt(3, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Ik zei STOP!")); break; case 3 : buttonList.removeAll(buttonList); buttonList.add(new GuiButtonExt(4, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Nooit luisteren he")); break; case 4 : buttonList.removeAll(buttonList); buttonList.add(new GuiButtonExt(5, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Wil je een koekje?")); buttonList.add(new GuiButtonExt(6, width / 2 - 100, height / 4 + 72 + -16, 75, 20, "Ja")); buttonList.add(new GuiButtonExt(7, width / 2 + 25, height / 4 + 72 + -16, 75, 20, "Nee")); break; case 5 : buttonList.removeAll(buttonList); buttonList.add(new GuiButtonExt(8, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Mahn, niet op klikken")); buttonList.add(new GuiButtonExt(9, width / 2 - 100, height / 4 + 72 + -16, 200, 20, "Terug naar koekjes")); break; case 6 : buttonList.removeAll(buttonList); buttonList.add(cookies); buttonList.add(new GuiButtonExt(10, width / 2 - 100, height / 4 + 72 + -16, 200, 20, "Ok")); slider = true; break; case 7 : buttonList.removeAll(buttonList); this.mc.displayGuiScreen((GuiScreen)null); break; case 8 : break; case 9 : buttonList.removeAll(buttonList); buttonList.add(new GuiButtonExt(5, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Wil je een koekje?")); buttonList.add(new GuiButtonExt(6, width / 2 - 100, height / 4 + 72 + -16, 75, 20, "Ja")); buttonList.add(new GuiButtonExt(7, width / 2 + 25, height / 4 + 72 + -16, 75, 20, "Nee")); break; case 10 : buttonList.removeAll(buttonList); slider = false; if(!player.isCreative()) { if(player.experienceLevel >= 3 * cookies.getValueInt()) { cookiesS = true; buttonList.add(new GuiButtonExt(11, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Alsjeblieft")); } else { buttonList.add(new GuiButtonExt(7, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Je hebt niet genoeg xp")); } } else { cookiesC = true; buttonList.add(new GuiButtonExt(11, width / 2 - 100, height / 4 + 42 + -16, 200, 20, "Alsjeblieft")); } break; case 11 : CheeseCookieBlock.remove(); cookiesC = false; cookiesS = false; this.mc.displayGuiScreen((GuiScreen)null); break; } } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { if(slider) { drawCenteredString(fontRendererObj, "Je krijgt " + String.valueOf(cookies.getValueInt()) + " koekjes, dat is " + String.valueOf(cookies.getValueInt() * 3) + " XP levels" , width / 2, height / 4 + 102 + -16, 0xFFFFFF); } super.drawScreen(mouseX, mouseY, partialTicks); } } The block class: public class CookieBlock extends Block { public static EntityPlayer player; public CookieBlock () { super(Material.ROCK); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { player = playerIn; playerIn.openGui(MainClass.Instance, GuiHandler.COOKIEGUIID, worldIn, pos.getX(), pos.getY(), pos.getZ()); return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ); } public static void remove() { if(CookieGui.cookiesC) { player.inventory.addItemStackToInventory(new ItemStack(Items.COOKIE, CookieGui.cookies.getValueInt())); player.addStat(KokkieAchievements.COOKIE); } else if(CookieGui.cookiesS) { player.inventory.addItemStackToInventory(new ItemStack(Items.COOKIE, CookieGui.cookies.getValueInt())); player.removeExperienceLevel(3 * CookieGui.cookies.getValueInt()); player.addStat(KokkieAchievements.COOKIE); } } }
  20. It works, THANKS!!!
  21. I now have this, will it work? StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart() - 16, 0, chunkpos.getZStart() - 16, chunkpos.getXEnd() + 16, 256, chunkpos.getZEnd() + 16);
  22. Hello, I have a mod and I have a biome with a structure spawning in it but when it generates it sometimes is just fine but sometimes also spawns with a lot missing, my code: public class WorldGenSimpleHouse extends WorldGenerator { private static final BlockStateMatcher IS_GRASS = BlockStateMatcher.forBlock(Blocks.GRASS); private final ResourceLocation HOUSE = new ResourceLocation(Reference.MODID + ":house"); public boolean generate(World worldIn, Random rand, BlockPos position) { while (worldIn.isAirBlock(position) && position.getY() > 2) { position = position.down(); } if (!IS_GRASS.apply(worldIn.getBlockState(position))) { return false; } Random random = worldIn.getChunkFromChunkCoords(position.getX(), position.getZ()).getRandomWithSeed(987234911L); Rotation[] arotation = Rotation.values(); Rotation rotation = arotation[random.nextInt(arotation.length)]; ChunkPos chunkpos = new ChunkPos(position); StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd()); PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).func_189950_a(random); MinecraftServer minecraftserver = worldIn.getMinecraftServer(); TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager(); Template template = templatemanager.getTemplate(minecraftserver, HOUSE); template.func_189962_a(worldIn, position, placementsettings, 2); return true; } } And my decorate method in my biome class public void decorate(World worldIn, Random rand, BlockPos pos) { double d0 = GRASS_COLOR_NOISE.getValue((double) (pos.getX() + / 200.0D, (double) (pos.getZ() + / 200.0D); final WorldGenSimpleHouse HOUSE_GENERATOR = new WorldGenSimpleHouse(); if (rand.nextInt(1500) == 0) { int i = rand.nextInt(16) + 8; int j = rand.nextInt(16) + 8; BlockPos blockpos = worldIn.getHeight(pos.add(i, 0, j)).up(); HOUSE_GENERATOR.generate(worldIn, rand, blockpos); System.out.println("House generated at: X" + blockpos.getX() + ", Z" + blockpos.getZ()); } this.theBiomeDecorator.flowersPerChunk = 4; this.theBiomeDecorator.grassPerChunk = 10; DOUBLE_PLANT_GENERATOR.setPlantType(BlockDoublePlant.EnumPlantType.GRASS); for (int i = 0; i < 7; ++i) { int j = rand.nextInt(16) + 8; int k = rand.nextInt(16) + 8; int l = rand.nextInt(worldIn.getHeight(pos.add(j, 0, k)).getY() + 32); DOUBLE_PLANT_GENERATOR.generate(worldIn, rand, pos.add(j, l, k)); } super.decorate(worldIn, rand, pos); }
  23. Oh wait, found that the credits must be 1 string, not in brackets
  24. Hello, I have a logo for my mod and put it in my mcmod.info but when I launch the game the mcmod.info is not working but without the logo it does work [ { "modid": "sm", "name": "Simple Mod", "description": "Simple mod", "version": "1.0", "mcversion": "1.10.2", "url": "", "updateUrl": "", "authorList": ["Kokkie1989"], "credits": ["Estabist","Frikandel1998"], "logoFile": "assets/sm/textures/logo.png", "screenshots": [], "dependencies": [] } ] and the error in the console: [20:39:49] [Client thread/ERROR] [FML]: The mcmod.info file in bin cannot be parsed as valid JSON. It will be ignored com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected STRING but was BEGIN_ARRAY at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176) ~[ReflectiveTypeAdapterFactory$Adapter.class:?] at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?] at com.google.gson.Gson.fromJson(Gson.java:868) ~[Gson.class:?] at com.google.gson.Gson.fromJson(Gson.java:841) ~[Gson.class:?] at net.minecraftforge.fml.common.MetadataCollection.from(MetadataCollection.java:72) [MetadataCollection.class:?] at net.minecraftforge.fml.common.discovery.DirectoryDiscoverer.exploreFileSystem(DirectoryDiscoverer.java:76) [DirectoryDiscoverer.class:?] at net.minecraftforge.fml.common.discovery.DirectoryDiscoverer.discover(DirectoryDiscoverer.java:60) [DirectoryDiscoverer.class:?] at net.minecraftforge.fml.common.discovery.ContainerType.findMods(ContainerType.java:49) [ContainerType.class:?] at net.minecraftforge.fml.common.discovery.ModCandidate.explore(ModCandidate.java:78) [ModCandidate.class:?] at net.minecraftforge.fml.common.discovery.ModDiscoverer.identifyMods(ModDiscoverer.java:141) [ModDiscoverer.class:?] at net.minecraftforge.fml.common.Loader.identifyMods(Loader.java:380) [Loader.class:?] at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:506) [Loader.class:?] at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:216) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:477) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:386) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_77] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_77] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_77] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_77] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] Caused by: java.lang.IllegalStateException: Expected STRING but was BEGIN_ARRAY at com.google.gson.internal.bind.JsonTreeReader.nextString(JsonTreeReader.java:154) ~[JsonTreeReader.class:?] at com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:358) ~[TypeAdapters$13.class:?] at com.google.gson.internal.bind.TypeAdapters$13.read(TypeAdapters.java:346) ~[TypeAdapters$13.class:?] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93) ~[ReflectiveTypeAdapterFactory$1.class:?] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172) ~[ReflectiveTypeAdapterFactory$Adapter.class:?] ... 27 more I checked jsonlint.org but it is valid json

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.