Jump to content

Lumby

Members
  • Posts

    50
  • Joined

  • Last visited

Everything posted by Lumby

  1. I found it, thank you for your help! EntityPlayer seems to be extended by EntityPlayerMP and AbstractClientPlayer, the latter I'm guessing is the one that handles client side code. The AbstractClientPlayer is instantiated by EntityPlayerSP, which is where I found the other openBook() implementation. My question now is, how do I emulate this approach on my item? Do I simply have two if conditions like so, where the conditions check whether world.isRemote to execute client side or server side specific code?: @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (!worldIn.isRemote){ //emulate EntityPlayerMP code by doing a bunch of packet stuff }else if(worldIn.isRemote){ //emulate ENtityPlayerSP code like so this.mc.displayGuiScreen(new myCustomItemGUI(this, stack, true)); } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); }
  2. Hi, I want to create a letter item where if you use it the item opens a GUI for you to type in, which then adds that string to the NBTTagcompound of the item, just like ItemWritableBook. ItemWritableBook, however, simply called player.openBook() which leads to an empty method with no code, so I don't understand how the entire process should be undertaken. Are there any possible resources or mods that have a similar functionality that someone can point me towards as an example? Thanks in advance!
  3. ItemBase is the class you extended for your fishing rod class, can you post what your ItemBase class looks like so we can see what's wrong with it?
  4. Hi, in one of my slots I want to check if all the items in a shulker box are the same before allowing it to be placed in the container slot. I am however running into some trouble with navigating the NBTTagCompound. From my understanding, the items are listed in the NBTBase BlockEntityTag of the tag compound, but I don't understand how to get the "Items" tag list out of the BlockEntityTag. I tried converting it to a string, but it would take a lot of difficult parsing to go through the whole string to see if all the items are the same. Is there any way to iterate through every item within the NBTTagCompound or is my current solution with parsing strings the best there is? Thanks in advance! Working in version 1.12.2 Below is what I have so far in case it may help: public boolean isItemValid(ItemStack stack) { if(stack.getItem() == Item.getItemFromBlock(Blocks.PURPLE_SHULKER_BOX)) { NBTTagCompound tags = stack.getTagCompound(); if(tags.hasKey("BlockEntityTag", 10)){ NBTBase blockEntityTag = tags.getTag("BlockEntityTag"); String tagString = blockEntityTag.toString(); } return true; } return false; }
  5. Figured it out, the forge version that I was running was also 1.12.2, but just slightly behind the one I developed my mod in. (1.12.2 - 14.21.1.2387 instead of 1.12.2 - 14.23.5.2768). Updated and issue was resolved
  6. Didn't really follow any tutorial, more of a hobbled attempt on any and everything I can find on the internet As for final step of exporting the mod itself, I just followed the docs. Edited build.gradle, ran the command in cmd, then copied the file in build/libs to the mods folder in minecraft.
  7. Hi, I just built my mod using gradlew.bat but it won't run in minecraft. When I start up it gives me the error: "The mods listed below can't run in Minecraft 1.12, *My mod name* (my modid) requires Minecraft 1.12.2, try to find an update or remove *My mod name*" I am able to run it fine in eclipse, but as soon as I try to run the built version in Minecraft it gives me this error. Any ideas what might be the cause? Thanks! below is my fml-client-latest.log
  8. My goal is to basically be able to place down a special modded block and create an area that only spawns my custom mob
  9. Hi, I want to make a mod in 1.12 where you can create a structure in game (like creating a village) that spawns specific mobs within the structure (like a witch hut). I cannot however, find the code that governs these processes, can anyone point me in the right direction to look? For example a class name that contains the relevant code, a mod previously created that does something similar, or really any advice would be greatly appreciated. Thanks in advance!
  10. I was making my crop block when I realized that the updateTick() method for vanilla BlockCrops doesn't have any checks for whether it's currently server-side or client-side. Nonetheless, the resulting block I made which extended BlockCrops and overrides said method seems to work perfectly. Why is that? Is updateTick() only called from the server-side, hence I do not need to worry about sides when dealing with updateTick()?
  11. Thanks for the help! Is there any case where the objects are not singletons that I should look out for then? I'm guessing players obviously aren't, but is there anything else?
  12. Try using a normal character like "S" instead of "/", as / is an escape character in java.
  13. Hi, after a bit of time I've realized that minecraft mods involve a lot of checking whether two objects are equal or not, be it items, blocks, biomes, etc. Since my mod performs so many of these checks, I'm starting to worry that if these comparisons are not coded efficiently, it would start slowing down minecraft a lot. Most of the time, I just use the good ol' Object#equals() method to check whether an object is the same (same as in #getBlock() is Blocks.DIRT or something like that). Is this the most efficient method? Or is there a better way to do things like this, specifically for checking Items, Blocks, and Biomes? Thanks in advance for the help.
  14. Turns out I didn't set the light level of the dimension low enough that hostile mobs can spawn. As soon as I lowered the light level, they started to spawn like crazy
  15. I've created a custom dimension and added my custom biome into it successfully. The Biome is able to correctly affect the day/night cycle and the water color, yet I am unable to get it to spawn any mobs naturally. As far as I'm aware, the biome is the one handling which mobs get to spawn via the spawnableCreatureList/spawnableMonsterList. I've tried adding entities (My custom demon entity, cows, and enderman) to both lists and neither worked. Any ideas what might be the problem? Custom Biome Class: public class BiomeNightmare extends Biome{ public BiomeNightmare() { super(new BiomeProperties("Nightmare").setBaseBiome("sky").setWaterColor(12255232).setRainDisabled()); topBlock = ModBlocks.NightmareBlock.getDefaultState(); fillerBlock = ModBlocks.NightmareBlock.getDefaultState(); this.spawnableCaveCreatureList.clear(); this.spawnableCreatureList.clear(); this.spawnableMonsterList.clear(); this.spawnableWaterCreatureList.clear(); this.spawnableMonsterList.add(new SpawnListEntry(EntityDemon.class, 10, 4, 4)); } }
  16. My bad, sorry that was a dumb move on my part -.- I keep forgetting to register my tile entities. Thanks for helping and tolerating my ignorance lol. For my purposes it doesn't matter since I'll only have one of these portals in my world. I did however, also think about using capabilities to handle this beforehand, but I read somewhere that whenever a player respawns or dies custom capabilities added by forge are cleared and need to be readded through a player clone. I didn't want to bother with that if all players are going to teleport to the same place any way. I'm still curious though, is that true?
  17. I've successfully created a dimension and a block that teleports the player to said dimension's 0, y, 0 position (y being the top most block in the world given the x z value). My problem, however, is getting the player to teleport back. My goal is to create the same type of teleport block in the other dimension, which holds a tileEntity that will store where in the overworld the player teleported from. When I did this, however, the game threw a runtime exception saying my tileEntity is missing a mapping and crashed spectacularly. My guess is this because my tileEntity isn't created until my player has finished teleporting to the other dimension, but I don't really know any other way of giving the block in the other dimension a BlockPos. Any suggestions on how to fix this, or just a overall better approach would be more than welcome. Thanks in advance! Block code: public class NightmareObelisk extends BlockBase{ public NightmareObelisk(String name, Material material) { super(name, material); setSoundType(SoundType.STONE); setResistance(18000000.0F); setBlockUnbreakable(); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(worldIn.provider.getDimension() == 0) { if (!worldIn.isRemote && !playerIn.isRiding() && !playerIn.isBeingRidden()) { BlockPos nightmareSpawn = getAndCreateSpawn(playerIn.getServer().getWorld(Reference.NIGHTMARE), playerIn.getPosition()); CustomTeleporter.teleportToDimension(playerIn, Reference.NIGHTMARE, nightmareSpawn.getX(), nightmareSpawn.getY(), nightmareSpawn.getZ() ); return true; } }else if(worldIn.provider.getDimension() == Reference.NIGHTMARE) { if (!worldIn.isRemote && !playerIn.isRiding() && !playerIn.isBeingRidden()) { if(worldIn.getTileEntity(pos) instanceof TileEntityNightmareObelisk){ BlockPos respawnPos = ((TileEntityNightmareObelisk)worldIn.getTileEntity(pos)).getTargetPos(); CustomTeleporter.teleportToDimension(playerIn, 0, respawnPos.getX(), respawnPos.getY(), respawnPos.getZ()); } return true; } } return false; } private BlockPos getAndCreateSpawn(World world, BlockPos overworldPos) { BlockPos outputPos = world.getTopSolidOrLiquidBlock(new BlockPos(0,0,0)).up(); world.setBlockState(outputPos, ModBlocks.BedrockBrick.getDefaultState()); world.setBlockState(outputPos.east(), ModBlocks.BedrockBrick.getDefaultState()); world.setBlockState(outputPos.west(), ModBlocks.BedrockBrick.getDefaultState()); world.setBlockState(outputPos.north(), ModBlocks.BedrockBrick.getDefaultState()); world.setBlockState(outputPos.north().east(), ModBlocks.BedrockBrick.getDefaultState()); world.setBlockState(outputPos.north().west(), ModBlocks.BedrockBrick.getDefaultState()); world.setBlockState(outputPos.south(), ModBlocks.BedrockBrick.getDefaultState()); world.setBlockState(outputPos.south().east(), ModBlocks.BedrockBrick.getDefaultState()); world.setBlockState(outputPos.south().west(), ModBlocks.BedrockBrick.getDefaultState()); world.setBlockState(outputPos.up().north(), ModBlocks.NightmareObelisk.getDefaultState()); world.setBlockState(outputPos.up().north().up(), Blocks.STONE_SLAB.getDefaultState()); world.setBlockState(outputPos.up(), Blocks.TORCH.getDefaultState()); if(world.getTileEntity(outputPos.up().north()) instanceof TileEntityNightmareObelisk) { ((TileEntityNightmareObelisk)world.getTileEntity(outputPos.up().north())).setTargetPos(overworldPos.getX(), overworldPos.getY(), overworldPos.getZ()); } outputPos = outputPos.up(); return outputPos; } @Override public TileEntity createTileEntity(World world, IBlockState state) { TileEntityNightmareObelisk tileEntityNightmareObelisk = new TileEntityNightmareObelisk(); return tileEntityNightmareObelisk; } @Override public boolean hasTileEntity(IBlockState state) { return true; } } The CustomTeleporter code: public class CustomTeleporter extends Teleporter{ private final WorldServer world; private double x,y,z; public CustomTeleporter(WorldServer world, double x, double y, double z) { super(world); this.world = world; this.x = x; this.y = y; this.z = z; } public void placeInPortal(Entity entity, float rotationYaw) { this.world.getBlockState(new BlockPos((int)this.x, (int)this.y, (int)this.z)); entity.setPosition(x, y, z); entity.motionX = 0F; entity.motionY = 0F; entity.motionZ = 0F; } public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) { int oldDimension = player.getEntityWorld().provider.getDimension(); EntityPlayerMP entityPlayerMP = (EntityPlayerMP)player; MinecraftServer server = player.getEntityWorld().getMinecraftServer(); WorldServer worldServer = server.getWorld(dimension); if(worldServer == null || server == null) { throw new IllegalArgumentException("Dimension: " +dimension + " doesn't exist"); } worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new CustomTeleporter(worldServer, x,y,z)); player.setPositionAndUpdate(x, y, z); } } TileEntity code: public class TileEntityNightmareObelisk extends TileEntity{ private int x,y,z; public TileEntityNightmareObelisk() { this.x = 0; this.y = 0; this.z = 0; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("x") && compound.hasKey("y") && compound.hasKey("z")) { x = compound.getInteger("x"); y = compound.getInteger("y"); z = compound.getInteger("z"); }else { x=0; y=0; z=0; } } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("x", x); compound.setInteger("y", y); compound.setInteger("z", z); return compound; } public BlockPos getTargetPos() { return new BlockPos(this.x, this.y, this.z); } public void setTargetPos(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } }
  18. Yeah I found the post, was literally typing out the last sentence when you replied haha. Thanks again for the tip!
  19. Nvm, I got it, sorry I'm new to using data tags in JSON. Found out if I add "data": 32767 as the data tag it'll accept any type of log since 32767 is the wildcard value
  20. Thanks for the help! Is there any way where I can make the recipe so that it takes in any type of logs (oak, birch, jg) or do I have to make an individual json for every log type?
  21. I am trying to add a crafting table recipe via JSON { "type": "minecraft:crafting_shaped", "pattern": [ "AAA", "ALA", "AAA" ], "key": { "A": { "item": "crumblemod:arcana_shards" }, "L": { "item": "minecraft:oak_log" } }, "result": { "item": "crumblemod:magic_logs_block", "count": 1 } } All my other recipes work just fine, yet with this JSON recipe for some reason it throws the exception: As in it cannot find the vanilla item oak logs. If I swap out oak logs with something like glass, however, the recipe would work again. What might be causing this?
  22. Thanks for the response. My goal is to get the nbt data of a shulker box in its item form and pass it to a custom tileEntity. From my understanding all I have to do is call that line and add these lines into my packet: in #toBytes ByteBufUtils.writeTag(buf, nbt); and #fromBytes nbt = ByteBufUtils.readTag(buf); I feel like the Shulker box with its many items holding their own nbt data, however, would cause the packet to be over the limit? Is there a way to know the size of the packet when I'm sending it somehow?
  23. Hi, I want to send the nbt data of an item block to the server through a packet. From my understanding, NBTTagCompounds are already converted to byte streams since the way I accessed it was: NBTTagCompound nbt = this.inventorySlots.inventorySlots.get(0).getStack().serializeNBT(); hence I can send it through my packet. However, I read somewhere that there is a limit to how much data you can send to the server through a packet. Is this still true as of the 1.12.2? If so, what is the size, and how do I make sure I don't go over the limit? Thanks in advance
  24. I see, thanks for the tip! I feel like the main problem, however, is the fact that there is still an extra overlay present. What segment of the code causes minecraft to render two boxes on top of the players head, hence creating the extra overlay?
×
×
  • Create New...

Important Information

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