-
Posts
867 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JimiIT92
-
[SOLVED][1.10.2] Gui open when the event is cancelled
JimiIT92 replied to JimiIT92's topic in Modder Support
That way the GUI won't open at all, even not checking for anything -
[SOLVED][1.10.2] Gui open when the event is cancelled
JimiIT92 replied to JimiIT92's topic in Modder Support
I can't also do that call because i'll need to implement IInteractionObject into my GUI, wich is not what i want since is just a simple GUI with no inventory or container -
[SOLVED][1.10.2] Gui open when the event is cancelled
JimiIT92 replied to JimiIT92's topic in Modder Support
That what was i thought on first but if possibile i want to avoid handling packets. But i guess is the only possible solution -
I have a block that when right-clicked will open a GUI, but only if the player has some requirements. I've managed how to check this requirements using the PlayerInteractEvent (since all the stuff i have to control is stored server side but the gui is client side so that checks will fail), but if it turns that the player can't open the gui i get a chat message that warn the player but the gui still opens. Here is a picture of what i mean In this case the player was not allowed to open the GUI, infact there is a chat message that says that. But the GUI is opened too. So how can i prevent the GUI to open? This is my block code package com.cf.blocks; import java.util.Random; import javax.annotation.Nullable; import com.cf.CoreFaction; import com.cf.entities.TileEntityBuyer; import com.cf.entities.TileEntityCore; import com.cf.faction.Faction; import com.cf.faction.Territory; import com.cf.proxy.GuiHandler; import com.cf.utils.TerritoryUtils; import com.cf.utils.Utils; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockCore extends BlockContainer { public BlockCore() { super(Material.IRON); this.setCreativeTab(CreativeTabs.MISC); this.setHardness(100.0F); this.setResistance(2000.0F); } public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT_MIPPED; } public boolean isOpaqueCube(IBlockState state) { return false; } public boolean isFullCube(IBlockState state) { return false; } @Override public EnumPushReaction getMobilityFlag(IBlockState state) { return EnumPushReaction.BLOCK; } @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { for (int i = 0; i < 1; ++i) { int j = rand.nextInt(2) * 2 - 1; int k = rand.nextInt(2) * 2 - 1; double d0 = (double) pos.getX() + 0.5D + 0.25D * (double) j; double d1 = (double) ((float) pos.getY() + rand.nextFloat()); double d2 = (double) pos.getZ() + 0.5D + 0.25D * (double) k; worldIn.spawnParticle(EnumParticleTypes.END_ROD, d0, d1, d2, rand.nextGaussian() * 0.003D, rand.nextGaussian() * 0.003D, rand.nextGaussian() * 0.003D, new int[0]); } } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random random) { return 0; } /** * Get the Item that this Block should drop when harvested. */ @Nullable public Item getItemDropped(IBlockState state, Random rand, int fortune) { return null; } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(worldIn.isRemote) playerIn.openGui(CoreFaction.INSTANCE, GuiHandler.CORE_GUI_ID, worldIn, pos.getX(), pos.getY(), pos.getZ()); return worldIn.isRemote; } @Override public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) { // TODO super.onBlockDestroyedByExplosion(worldIn, pos, explosionIn); } @Override public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState state) { // TODO super.onBlockDestroyedByPlayer(worldIn, pos, state); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityCore(); } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { TileEntity te = worldIn.getTileEntity(pos); if (te != null && te instanceof TileEntityCore) { Territory t = TerritoryUtils.getTerritoryByPos(pos, worldIn.provider.getDimension()); if (t != null) { Faction f = TerritoryUtils.getFaction(t); if (f != null) { ((TileEntityCore) te).setName(f.getName()); ((TileEntityCore) te).setOpen(false); } } } } } } This is the PlayerInteractEvent package com.cf.events; import com.cf.blocks.BlockCore; import com.cf.core.CFBlocks; import com.cf.faction.Faction; import com.cf.faction.Territory; import com.cf.utils.FactionUtils; import com.cf.utils.TerritoryUtils; import com.cf.utils.Utils; import net.minecraft.block.Block; import net.minecraft.block.BlockBrewingStand; import net.minecraft.block.BlockButton; import net.minecraft.block.BlockChest; import net.minecraft.block.BlockDispenser; import net.minecraft.block.BlockDoor; import net.minecraft.block.BlockDropper; import net.minecraft.block.BlockFenceGate; import net.minecraft.block.BlockFurnace; import net.minecraft.block.BlockHopper; import net.minecraft.block.BlockLever; import net.minecraft.block.BlockNote; import net.minecraft.block.BlockRedstoneComparator; import net.minecraft.block.BlockRedstoneRepeater; import net.minecraft.block.BlockTrapDoor; import net.minecraft.init.Blocks; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class EventBlockInteract { @SubscribeEvent public void onInteract(PlayerInteractEvent.RightClickBlock event) { Territory t = TerritoryUtils.getTerritoryByPos(event.getPos(), event.getEntityPlayer().dimension); if (t != null) { Faction f = TerritoryUtils.getFaction(t); if (event.getWorld().getBlockState(event.getPos()).getBlock() == CFBlocks.core) { if (f == null) event.setCanceled(true); else if (f.getMembers().contains(event.getEntityPlayer().getUniqueID())) { if(!f.getOwner().equals(event.getEntityPlayer().getUniqueID())) { event.setCanceled(true); Utils.sendMessage(event.getEntityPlayer(), Utils.getTranslation("block.core.nopermission", TextFormatting.RED)); } } else { event.setCanceled(true); Utils.sendMessage(event.getEntityPlayer(), Utils.getTranslation("block.core.fail", TextFormatting.RED)); //THIS IS THE CHAT MESSAGE THAT APPEARS IN THE IMAGE } } } } } This is my GuiHandler package com.cf.proxy; import com.cf.entities.TileEntityCore; import com.cf.gui.GuiCore; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { public static int CORE_GUI_ID = 0; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == CORE_GUI_ID) { BlockPos pos = new BlockPos(x, y, z); TileEntity tileEntity = world.getTileEntity(pos); if(tileEntity instanceof TileEntityCore) { return new GuiCore((TileEntityCore)tileEntity); } } return null; } } and this is how i register it in the ClientProxy public void init() { NetworkRegistry.INSTANCE.registerGuiHandler(CoreFaction.INSTANCE, new GuiHandler()); }
-
Thank you, overriding that method like this @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { this.setName(pkt.getNbtCompound().getString("name")); this.setCost(pkt.getNbtCompound().getInteger("cost")); super.onDataPacket(net, pkt); } has solved the problem :)
-
I have a block with a Tile Entity that, using a Tile Entity Special Render, have some floating text above it. The text rendering works as well, however i need to reload the world to see them. Here's a video showing what i mean. So what happen is this: i launch a command where i set the position of the block, the name and the cost. Name and cost are stored into the tile entity to being displayed as floating text. Then the block is placed but no text appear until i rejoin the world, then i can see the texts. What i want is that i see the texts as the block is placed, without rejoining the world. How can i do that? This is the code of the Tile Entity package com.cf.entities; import javax.annotation.Nullable; import com.cf.faction.Territory; import com.cf.utils.TerritoryUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ITickable; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; public class TileEntityBuyer extends TileEntity{ private String name; private int cost; public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setString("name", this.name); compound.setInteger("cost", this.cost); return compound; } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.setName(compound.getString("name")); this.setCost(compound.getInteger("cost")); } @Nullable public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(this.pos, 7, this.getUpdateTag()); } public NBTTagCompound getUpdateTag() { return this.writeToNBT(new NBTTagCompound()); } public void setName(String n) { this.name = n; } public String getName() { return this.name; } public void setCost(int c) { this.cost = c; } public int getCost() { return this.cost; } } This is the code for the Rendering package com.cf.renderer; import javax.annotation.Nullable; import org.lwjgl.opengl.GL11; import com.cf.entities.TileEntityBuyer; import com.cf.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntityStructure; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class TileEntityBuyerRenderer extends TileEntitySpecialRenderer<TileEntityBuyer> { private RenderManager renderManager; public TileEntityBuyerRenderer(RenderManager r) { this.renderManager = r; } public void renderTileEntityAt(TileEntityBuyer te, double x, double y, double z, float partialTicks, int destroyStage) { if (te.getName() != null && this.rendererDispatcher.cameraHitResult != null && te.getPos().equals(this.rendererDispatcher.cameraHitResult.getBlockPos())) { this.setLightmapDisabled(true); this.drawNameplate(te, Utils.getTranslation("block.buyer.click", TextFormatting.RED), x, y + 0.5D, z, 16); this.drawNameplate(te, Utils.getTranslation("block.buyer.name", TextFormatting.GREEN) + ": " + te.getName(), x, y + 0.25D, z, 16); this.drawNameplate(te, Utils.getTranslation("block.buyer.cost", TextFormatting.GOLD) + ": " + te.getCost() + "G", x, y, z, 16); this.setLightmapDisabled(false); } } public boolean isGlobalRenderer(TileEntityBuyer te) { return true; } } And this is the code for the Block package com.cf.blocks; import java.util.Random; import javax.annotation.Nullable; import com.cf.core.CFBlocks; import com.cf.entities.TileEntityBuyer; import com.cf.faction.Faction; import com.cf.faction.Territory; import com.cf.utils.FactionUtils; import com.cf.utils.Settings; import com.cf.utils.TerritoryUtils; import com.cf.utils.Utils; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockBuyer extends BlockContainer { public BlockBuyer() { super(Material.IRON); this.setCreativeTab(CreativeTabs.MISC); this.setBlockUnbreakable(); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { if(FactionUtils.hasFaction(playerIn.getUniqueID())) { Faction f = FactionUtils.getFaction(playerIn.getUniqueID()); Territory t = TerritoryUtils.getTerritoryByPos(pos, playerIn.dimension); if(t != null) { if(f.getTerritories().size() >= Settings.maxTerritories) { Utils.sendMessage(playerIn, Utils.getTranslation("faction.buy.full", TextFormatting.RED)); } else if(Utils.getGolds(playerIn) >= t.getCost()) { Utils.pay(playerIn, t.getCost(), 0, 0); FactionUtils.broadcast(f, Utils.getTranslation("faction.buy.territory", TextFormatting.GOLD) + " " + t.getName()); worldIn.setBlockState(pos, CFBlocks.core.getDefaultState()); f.addTerritory(t.getName()); FactionUtils.saveFaction(f); } else Utils.sendMessage(playerIn, Utils.getTranslation("faction.buy.golds", TextFormatting.RED)); } } else Utils.sendMessage(playerIn, Utils.getTranslation("faction.buy.nofaction", TextFormatting.RED)); } return true; } public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT_MIPPED; } public boolean isOpaqueCube(IBlockState state) { return false; } public boolean isFullCube(IBlockState state) { return false; } @Override public EnumPushReaction getMobilityFlag(IBlockState state) { return EnumPushReaction.BLOCK; } @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { for (int i = 0; i < 1; ++i) { int j = rand.nextInt(2) * 2 - 1; int k = rand.nextInt(2) * 2 - 1; double d0 = (double)pos.getX() + 0.5D + 0.25D * (double)j; double d1 = (double)((float)pos.getY() + 0.2D + rand.nextFloat()); double d2 = (double)pos.getZ() + 0.5D + 0.25D * (double)k; worldIn.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, d0, d1, d2, rand.nextGaussian() * 0.003D, rand.nextGaussian() * 0.003D, rand.nextGaussian() * 0.003D, new int[0]); } } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if(!worldIn.isRemote) { TileEntity te = worldIn.getTileEntity(pos); if(te != null && te instanceof TileEntityBuyer) { Territory t = TerritoryUtils.getTerritoryByPos(pos, worldIn.provider.getDimension()); if(t != null) { ((TileEntityBuyer)te).setName(t.getName()); ((TileEntityBuyer)te).setCost(t.getCost()); } } } } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random random) { return 0; } /** * Get the Item that this Block should drop when harvested. */ @Nullable public Item getItemDropped(IBlockState state, Random rand, int fortune) { return null; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityBuyer(); } }
-
[1.10.2] Exporting a library with the mod's jar
JimiIT92 replied to JimiIT92's topic in Modder Support
Thanks, i will look at it -
[1.10.2] Exporting a library with the mod's jar
JimiIT92 replied to JimiIT92's topic in Modder Support
I know that putting the library into the mod folder works, but this is exactly what i want to know if can be avoided. I want to know if i can put just 1 jar file into the mod folder that will load both mod and library to avoid some errors from users (they could forget about the second jar) -
[1.10.2] Exporting a library with the mod's jar
JimiIT92 replied to JimiIT92's topic in Modder Support
Dind't know that. But in general is it possible to bundle any external library into the jar? -
In my mod i use an external library (Json.simple). Now, in order to use the mod you need to add the Json.simple jar inside the mod folder too, but what i want is to have a single jar file that contains both the mod and the library. Is this possible? And if so how can i tell gradle to export the library too into the generated jar file?
-
[SOLVED][1.10.2] onBlockActivated called twice
JimiIT92 replied to JimiIT92's topic in Modder Support
Thank you, changing that to true solved the problem -
[SOLVED][1.10.2] onBlockActivated called twice
JimiIT92 replied to JimiIT92's topic in Modder Support
Then why this code runs twice? @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { Faction f = FactionUtils.getFaction(playerIn.getUniqueID()); if(f != null) { if(Utils.samePos(pos, f.getCore()) && f.getCoreDimension() == playerIn.dimension) { if(f.getOwner().equals(playerIn.getUniqueID())) { int money = f.getMoney(); int level = f.getCoreLevel(); if(level == CoreFaction.coreMaxLevel) { Utils.sendMessage(playerIn, Utils.getTranslation("faction.upgrade.maxlevel", TextFormatting.RED)); } else if(money >= (CoreFaction.coreCost * (level + 1))) { f.setCoreLevel(level + 1); f.setMoney(f.getMoney() - (CoreFaction.coreCost * (level + 1))); Utils.sendMessage(playerIn, Utils.getTranslation("faction.upgrade", TextFormatting.GREEN)); FactionUtils.saveFaction(f); } else Utils.sendMessage(playerIn, Utils.getTranslation("faction.upgrade.nomoney", TextFormatting.GREEN)); } else Utils.sendMessage(playerIn, Utils.getTranslation("faction.upgrade.nopermission", TextFormatting.RED)); } else Utils.sendMessage(playerIn, Utils.getTranslation("faction.upgrade.noowner", TextFormatting.RED)); } else { Utils.sendMessage(playerIn, Utils.getTranslation("faction.upgrade.noowner", TextFormatting.RED)); } } return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ); } What should i check to make sure it runs only once? -
I know this method is called once per hand (so twice) but how can i do so it's called only once, when the player right clicks the block without checking for a specific item in hand?
-
[1.10.2] Spawning structures using Structure Blocks files
JimiIT92 replied to JimiIT92's topic in Modder Support
@TheRPGAdventurer the benefit of this is that you can use whatever you want. You can use a class that implements an IWorldGenerator and in the generate method call this code, or you can create a simple class without IWorldGenerator and call it where you want (from example from the biome generator or the WorldGenMinable class). You can even spawn the structure at a specific location (for example you want a structure that is unique per world and is always generated at 0,0. With this type of generation you can do it pretty easy), you can randomize the inside using the Data structure blocks and check for them during the generation of the structure, and more. BUt to answer your question: no, you don't necessairly need an IWorldGenerator. As i said you can use it of course, for instance to avoid some errors if you want to port your structures to this system -
[1.10.2] Spawning structures using Structure Blocks files
JimiIT92 replied to JimiIT92's topic in Modder Support
Mmmm, then i have no clue why this is not working for you I'll post here an example of working class i'm using that spawns an obelisk in the world public class WorldGenObelisk { private int mirror; private int rotation; public WorldGenObelisk(BlockPos pos, World world) { mirror = MW.rand.nextInt(Mirror.values().length); rotation = MW.rand.nextInt(Rotation.values().length); this.loadStructure(pos, world, "obelisk", true); } public void loadStructure(BlockPos pos, World world, String name, boolean check) { boolean flag = false; if (!world.isRemote) { WorldServer worldserver = (WorldServer) world; MinecraftServer minecraftserver = world.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); ResourceLocation loc = new ResourceLocation(MW.MODID, name); Template template = templatemanager.func_189942_b(minecraftserver, loc); if (template != null) { IBlockState iblockstate = world.getBlockState(pos); world.notifyBlockUpdate(pos, iblockstate, iblockstate, 3); flag = true; if (check) { for (int i = 0; i < template.getSize().getX(); i++) { for (int j = 0; j < template.getSize().getZ(); j++) { BlockPos down = pos.add(i, -1, j); Block b = world.getBlockState(down).getBlock(); if (!b.equals(Blocks.SAND)) { flag = false; } } } } if (flag) { PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.values()[mirror]) .setRotation(Rotation.values()[rotation]).setIgnoreEntities(false).setChunk((ChunkPos) null) .setReplacedBlock((Block) null).setIgnoreStructureBlock(true); template.addBlocksToWorldChunk(world, pos.down(), placementsettings); } } } } } This class is called from the WorldGenMinable class, in the generateOverworld method (so where you put the code to spawn ores) by doing this if (world.getBiomeGenForCoords(new BlockPos(x, 60, z)).equals(Biomes.DESERT) && random.nextInt(70) == 1) { int randPosX = x + random.nextInt(35); int randPosZ = z + random.nextInt(35); int randPosY = 60 + random.nextInt(255 - 64); BlockPos position = new BlockPos(randPosX, randPosY, randPosZ); if (!(world.getBlockState(world.getTopSolidOrLiquidBlock(position)).getBlock().equals(Blocks.WATER))) new WorldGenObelisk(world.getTopSolidOrLiquidBlock(position), world); } Notice that in the structure class it will also check if the spawn area is a valid area, you can remove that if you want. I hope this help, if not you can try looking at how Structure Blocks load structures and edit that code (since is exactly what i've done, maybe some small changes has been made but since is still 1.10.2 i don't think so) -
[1.10.2] Spawning structures using Structure Blocks files
JimiIT92 replied to JimiIT92's topic in Modder Support
The reason could be that you are searching for this resource new ResourceLocation(Reference.MOD_ID,"structures/test2.nbt") This will actually search for the file in structures/structures/test2.nbt, wich i believe doesn't exist. So you should just type the name of the structure in your structures folder (if is not in a sub folder). Searching for this resource instead will mostly solve your issue. That was my bad that i didn't specified earlier and i'm sorry for this. Let me know if it works after this change new ResourceLocation(Reference.MOD_ID,"test2.nbt") -
Don't know why but i've rewrote the file (not a big deal, 5 lines) and now it works. Maybe there was some undesired character previously. Thank you anyway
-
1.10.2 how to make your structure spawn in underground caves.
JimiIT92 replied to TheRPGAdventurer's topic in Modder Support
Just check before calling the generate method that the Y level is below something (for example below 50 or 40) -
Yes other things like item or block names works as well
-
I want to display a translated message using the TextComponentTranslation, but when i print the message it shows the key used and not the translated string itself. For instance, if i do this player.addChatMessage(new TextComponentTranslation("faction.already.name", new Object[0])); then this is showed In the en_US.lang file there is the translated string, so how can i actually display that string instead of the key?
-
Yes, i want that file to exist on a dedicated server and using FMLCommonHandler::getSide has solve the issue Thank you for your help
-
I've done this try { event.getSuggestedConfigurationFile().createNewFile(); } catch (IOException e) { e.printStackTrace(); } But the config file has been created in the .minecraft folder and in the server config folder too. How can i do so only in the server folder this file (or anything else) is created?
-
I forgot to mention that i store them in the world folder just to be more organized, but what if i want to save them generically in the server folder (like config files for example)? For instance, i want to create a subfolder into the server folder, but of course this has to be created only on the server, not on the client (in the .minecraft folder). How can i point directly to that? Is there a way to get the path to the server folder located on another pc?
-
Is not what i'm looking for just because i need something to be edited easy outside of the game (for example a server admin want to change the informations of one of these files but he wants to do it from the console, without logging into the game). That's why i need to save text files of some form, just to help the server managing
-
Doesn't that save informations into a world data nbt file? Because if so is not what i'm looking for. Also i can't get it work, i've done this package com.cf.utils; import com.cf.CoreFaction; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import net.minecraft.world.storage.MapStorage; public class ExampleWorldSavedData extends WorldSavedData { private static final String DATA_NAME = CoreFaction.MODID + "_ExampleData"; public ExampleWorldSavedData() { super(DATA_NAME); } public ExampleWorldSavedData(String s) { super(s); } @Override public void readFromNBT(NBTTagCompound nbt) { System.out.println(nbt.getString("test")); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setString("test", "prova"); return compound; } public static ExampleWorldSavedData get(World world) { MapStorage storage = world.getPerWorldStorage(); ExampleWorldSavedData instance = (ExampleWorldSavedData) storage.getOrLoadData(ExampleWorldSavedData.class, DATA_NAME); if (instance == null) { instance = new ExampleWorldSavedData(); storage.setData(DATA_NAME, instance); } return instance; } } But if i call the get method nothing happens and there is no new file in the world folder