-
Posts
867 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JimiIT92
-
Kinda, instead of the inventory the player will open the chat, so the cursor become visibile and he can click on the notification.
-
The idea is to have something like a notification, a small GUI on screen that doesn't block the player but can also be clicked if the mouse cursor is visible. I know how to make overlay GUIs, i just can't figure out how to make the button clickable. Is it possible to do this? And if so how can i do this?
-
Thank you for the answer, i did those steps and it worked
-
In 1.10 i've added a dynamic crafting recipe so the player can craft an empty gift or e gift with an itemstack in it. To do this the recipe will check the center slot of the crafting table: if it's empty than return an empty gift, if it's not than "pack" that itemstack into the gift. Looking at how banners do this for the patterns it was simple to add something like this, but now in 1.12 i'm having issues registering all this recipes due to the new json system. The class i'm using to get a different result based on events is this package com.mw.crafting; import com.mw.core.MWBlocks; import net.minecraft.init.Blocks; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.NonNullList; import net.minecraft.world.World; public class CraftingGift { public static class RecipeGift extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe { /** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting inv, World worldIn) { boolean flag = false; int num = 0; for (int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack itemstack = inv.getStackInSlot(i); if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.WOOL) && i != 4) { if (num == 7) { flag = true; num = 0; break; } num++; } } return flag; } /** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack itemstack = ItemStack.EMPTY; ItemStack chestitem = ItemStack.EMPTY; int num = 0; for (int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack itemstack1 = inv.getStackInSlot(i); if (itemstack1 != null && itemstack1.getItem() == Item.getItemFromBlock(Blocks.WOOL) && i != 4) { if (num == 7) { itemstack = new ItemStack(MWBlocks.GIFT); itemstack.setCount(1); num = 0; chestitem = inv.getStackInSlot(4); break; } num++; } } if (chestitem != null) { NBTTagCompound nbttagcompound1 = itemstack.getSubCompound("BlockEntityTag"); NBTTagList nbttaglist; nbttaglist = new NBTTagList(); NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("Gift", (byte) 0); chestitem.writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); nbttagcompound1.setTag("Items", nbttaglist); } return itemstack; } public ItemStack getRecipeOutput() { return ItemStack.EMPTY; } public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) { NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>withSize(inv.getSizeInventory(), ItemStack.EMPTY); for (int i = 0; i < nonnulllist.size(); ++i) { ItemStack itemstack = inv.getStackInSlot(i); nonnulllist.set(i, net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack)); } return nonnulllist; } public boolean isHidden() { return true; } /** * Used to determine if this recipe can fit in a grid of the given width/height */ public boolean canFit(int width, int height) { return width >= 3 && height >= 3; } } } What i'm missing is how i can register this In 1.10 i do this CraftingManager.getInstance().addRecipe(new RecipeGift()); but now that seems to be gone So how can i register this?
-
[SOLVED][1.12] Throwable Entity not rendering
JimiIT92 replied to JimiIT92's topic in Modder Support
@admiralmattbar In the Client Proxy i've registered the render like this RenderingRegistry.registerEntityRenderingHandler(EntityGranade.class, new EntityGranadeFactory()); Then i've created the factory class public class EntityGranadeFactory implements IRenderFactory<EntityGranade>{ @Override public Render<? super EntityGranade> createRenderFor(RenderManager manager) { return new RenderSnowball<EntityGranade>(manager, MWItems.GRANADE, Minecraft.getMinecraft().getRenderItem()); } } where i call the RenderSnowball class passing it the item i want to render. -
The point is that the launcher should automatically launch a modded version of the game. If i open the regular launcher from another launcher, than what's the point? By the way i guess i'll switch to Java (unfortunately, cause i hate for this kind of projects) since there are already libraries that allows you to do this
-
This is the part i'm missing, i don't understand wich arguments should i pass to the Minecraft.exe process in order to launch the game in a specific version without opening the launcher
-
I see that point and i totally agree, perhaps making the launcher open source would prevent any suspect of malicious intents. But i guess i should skip this, i'm developing an rpg mod and would be cool if the player can see his stats without logging into the actual game, that's why i was trying to do this
-
Yes, but Choonster said it should return values between 0 and 1, wich is not
-
Actually i use that in my mod to detect when a player uses a flint and steel on an unlit torch and it returns almost the coordinates of the torch. I've done a test right now, the torch was at {x=-7, y=84, z=19}, the getHitVec returned me this {x=-6.399999976158142, y=84.39314504887278, z=19.46219003009727}. Is this a recent change or i just something that shouldn't happen? By the way you can just do this event.getWorld().getBlockState(event.getPos()).getBlock() And it will tell you what block the player has right clicked
-
BlockPos blockpos = event.getPos().offset(event.getFace()); What? I don't understand what are you trying to do there. To get the position of where the player right clicked you have the hitVec variable in the event. So to get the block you should do this Block block = event.getWorld().getBlockState(new BlockPos(event.getHitVec().x, event.getHitVec().y, event.getHitVec().z)).getBlock();
-
Why don't you catch the RightClickBlock event directly instead and check if the clicked block is a door?
-
[SOLVED] getUnformattedComponentText() throws error
JimiIT92 replied to Toinou9120's topic in Modder Support
The problem is that when you set playerName you check if getDisplayName() returns null. But when setting the name you don't check it, so if is null you are trying to get a property from a null object, wich of course will throw an error. I don't know what are you trying to do there but you have 2 options: set name = playerName do the null check, like you've done in playerName, for the name -
Why shouldn't i make a custom launcher? Are there some exploits that i should aware of? Because as far as i know Mojang allows you to do that
-
I'm trying to make a custom modded launcher using C# that will allow users to play a custom modpack. I've managed the authentication part, so premium users can now be properly authenticated, but i can't figure out how to actually start the game. I've search trhough the web but i only found some old methods that no longer works now (at least not for 1.10). Does anyone know where can i look to see how can i launch the game using C# or command line?
-
Tried with 16|3 (19), still had that error I tried with every flag and i always got this message, but only for underwater plants (i have a custom flowers generator and that never gave me an error)
-
No matter if i set the flag to 2, 16 or 16|2, it still spams that error The thing i don't unserstand is why it happens only with this, and not for example with custom flower generation
-
I've tried adding a flag to the setBlockState, by doing this worldIn.setBlockState(pos.down(), Blocks.SAND.getDefaultState(), 2); But that doesn't fixed this
-
You mean the getLookingEntity code? If yes than i guess i should get that entity trhough a packet and not through a static method, right?
-
In my WorldGenMinable i've added some code to generate some underwater plants. The code i'm using is the same code i used in 1.10 and always worked. But in 1.12 i'm giving this odd error when creating a new world or loading new chunks MineWorld loaded a new chunk (-115, -93 Dimension: 0) during chunk population, causing cascading worldgen lag. Please report this to the mod's issue tracker. This log can be disabled in the Forge config. This is the class i'm using to place the blocks underwater package com.mw.world.gen.feature; import java.util.Random; import com.mw.blocks.BlockUnderwaterPlant; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Biomes; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; public class WorldGenUnderwaterPlants extends WorldGenerator{ private IBlockState state; public WorldGenUnderwaterPlants(IBlockState stateIn) { this.state = stateIn; } @Override public boolean generate(World worldIn, Random rand, BlockPos pos) { if(worldIn.getBlockState(pos).getBlock() != Blocks.WATER || worldIn.getBlockState(pos.up()).getBlock() != Blocks.WATER) return false; if(worldIn.getBiome(pos) == Biomes.OCEAN || worldIn.getBiome(pos) == Biomes.DEEP_OCEAN) { if((worldIn.getBlockState(pos.down()).getBlock() != Blocks.SAND || worldIn.getBlockState(pos.down()).getBlock() != Blocks.DIRT || worldIn.getBlockState(pos.down()).getBlock() != Blocks.GRAVEL) && this.state.getBlock() instanceof BlockUnderwaterPlant) if(!worldIn.isAirBlock(pos)) worldIn.setBlockState(pos.down(), Blocks.SAND.getDefaultState()); worldIn.setBlockState(pos, state); return true; } return false; } }
-
@oldcheese If it can help, this is the cod ei'm using to get the entity the player is looking at Entity entity = Minecraft.getMinecraft().getRenderViewEntity(); Entity pointedEntity = null; if (entity != null) { if (Minecraft.getMinecraft().world != null) { Minecraft.getMinecraft().mcProfiler.startSection("pick"); Minecraft.getMinecraft().pointedEntity = null; double d0 = (double)Minecraft.getMinecraft().playerController.getBlockReachDistance() * 2; Minecraft.getMinecraft().objectMouseOver = entity.rayTrace(d0, 20); Vec3d vec3d = entity.getPositionEyes(20); boolean flag = false; int i = 3; double d1 = d0; if (Minecraft.getMinecraft().playerController.extendedReach()) { //d1 = 6.0D; d1 = 14.0D; d0 = d1; } else { if (d0 > 3.0D) { flag = true; } } if (Minecraft.getMinecraft().objectMouseOver != null) { d1 = Minecraft.getMinecraft().objectMouseOver.hitVec.distanceTo(vec3d); } Vec3d vec3d1 = entity.getLook(1.0F); Vec3d vec3d2 = vec3d.addVector(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0); pointedEntity = null; Vec3d vec3d3 = null; float f = 1.0F; List<Entity> list = Minecraft.getMinecraft().world.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().expand(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0).grow(1.0D, 1.0D, 1.0D), Predicates.and(EntitySelectors.NOT_SPECTATING, new Predicate<Entity>() { public boolean apply(@Nullable Entity p_apply_1_) { return p_apply_1_ != null && p_apply_1_.canBeCollidedWith(); } })); double d2 = d1; for (int j = 0; j < list.size(); ++j) { Entity entity1 = list.get(j); AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow((double)entity1.getCollisionBorderSize()); RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2); if (axisalignedbb.contains(vec3d)) { if (d2 >= 0.0D) { pointedEntity = entity1; vec3d3 = raytraceresult == null ? vec3d : raytraceresult.hitVec; d2 = 0.0D; } } else if (raytraceresult != null) { double d3 = vec3d.distanceTo(raytraceresult.hitVec); if (d3 < d2 || d2 == 0.0D) { if (entity1.getLowestRidingEntity() == entity.getLowestRidingEntity() && !entity1.canRiderInteract()) { if (d2 == 0.0D) { pointedEntity = entity1; vec3d3 = raytraceresult.hitVec; } } else { pointedEntity = entity1; vec3d3 = raytraceresult.hitVec; d2 = d3; } } } } if (pointedEntity != null && flag && vec3d.distanceTo(vec3d3) > 3.0D) { pointedEntity = null; Minecraft.getMinecraft().objectMouseOver = new RayTraceResult(RayTraceResult.Type.MISS, vec3d3, (EnumFacing)null, new BlockPos(vec3d3)); } if (pointedEntity != null && (d2 < d1 || Minecraft.getMinecraft().objectMouseOver == null)) { Minecraft.getMinecraft().objectMouseOver = new RayTraceResult(pointedEntity, vec3d3); if (pointedEntity instanceof EntityLivingBase || pointedEntity instanceof EntityItemFrame) { Minecraft.getMinecraft().pointedEntity = pointedEntity; } } Minecraft.getMinecraft().mcProfiler.endSection(); } } return pointedEntity; I've already tried to see if the entity i'm looking is correct by printing the entity's class and the effect choosen and both works as well (if i point a Cow it prints EntityCow). I will try to see if using packets will solve the problem
-
Post your block class code
-
Any suggest? If i try to do other things, like change the position of the looked entity or if i give the effect to the player it works, just giving the effect to the entity doesn't
-
I want to make a biome without flowers or tall grass. So i've done this in my biome's constructor this.flowers.clear(); this.decorator.grassPerChunk = 0; this.decorator.flowersPerChunk = 0; But both flowers and tall grass still spawns. So how can i totally get rid of this?
-
I made a sign that will act as a leaderboard, so the text in it should be set automatically. If i set the text when placing down the sign everyhting works correctly, however, if i do in the "update" method of the tile entity nothing is displayed on the sign. This is the TileEntity i'm using package com.cf.entities; import java.util.ArrayList; import com.cf.guild.Guild; import com.cf.utils.GuildUtils; import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.ITickable; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; public class TileEntityLeaderboardSign extends TileEntitySign implements ITickable { @Override public void update() { if (!this.worldObj.isRemote) { ArrayList<Guild> guilds = GuildUtils.getGuildsOrderedByBank(); if (!guilds.isEmpty()) { this.signText[0] = new TextComponentTranslation("guild.leaderboard.top", new Object[0]); this.signText[1] = new TextComponentString("#1"); this.signText[2] = new TextComponentString(guilds.get(0).getName()); this.signText[3] = new TextComponentString( new TextComponentTranslation("guild.leaderboard.golds", new Object[0]) + " " + String.valueOf(guilds.get(0).getBank().getGold())); } else this.signText[0] = new TextComponentTranslation("guild.leaderboard.noguilds", new Object[0]); } } } So i just extend the TileEntitySign and implement the ITickable interface to make the TileEntity update. But as i said on the sign no text is displayed at all. What should i do to solve this issue? EDIT: I solved this by using 2 messages. The first is sent to the server from the tile entity like this if (this.worldObj.isRemote) { CoreGuild.NETWORK.sendToServer(new LeaderboardServerMessage(this.pos.getX(), this.pos.getY(), this.pos.getZ())); } In wich i do this TileEntity te = CoreGuild.PROXY.getPlayer(ctx).worldObj.getTileEntity(message.pos); if(te != null && te instanceof TileEntityLeaderboardSign) { TileEntityLeaderboardSign sign = (TileEntityLeaderboardSign)te; ArrayList<Guild> guilds = GuildUtils.getGuildsOrderedByBank(); String text = "No guilds"; if (!guilds.isEmpty()) { text = guilds.get(0).getName(); } CoreGuild.NETWORK.sendTo(new LeaderboardClientMessage(text, message.pos.getX(), message.pos.getY(), message.pos.getZ()), (EntityPlayerMP) CoreGuild.PROXY.getPlayer(ctx)); } So i send a message to the client with what i want to display. Then on the client i set the texts :) TileEntity te = CoreGuild.PROXY.getPlayer(ctx).worldObj.getTileEntity(message.pos); if(te != null && te instanceof TileEntityLeaderboardSign) { TileEntityLeaderboardSign sign = (TileEntityLeaderboardSign)te; sign.signText[0] = new TextComponentString(message.name); }