Jump to content

Focamacho

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by Focamacho

  1. I want to get the tool used in a BreakEvent or HarvestDropsEvent, but I'm not sure how to do this. Usually the tool used is in the main hand, so I could use getHeldItemMainhand(), but sometimes the offhand can also break blocks(Modded Items like staffs can do it). So how do I know which hand was used to break the block?
  2. https://github.com/Focamacho/MysticalCreations
  3. They are? I'm using a config file to get things like item name, etc ... so I create the item using these arguments. Everything works perfectly, the only problem is the texture of the blocks.
  4. I need to do it because I am registering blocks & items using a config file. Yes, all the blocks will have the same texture, and I'll try to change only the block color. Using ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation("modid:base_item", "inventory")); Works fine for items, but I'm not sure how to do it with blocks.
  5. Hello, I'm trying to make all of my blocks use the same .json (assets/.../blockstates/block_base.json & assets/.../models/block/block_base.json), but I have no idea how to do it.
  6. Is there any way to get the source from an open container? I would like to check if the player has an open container from a determinated block Something like: player.openContainer.getSource so I wanted to get a BlockState or BlockPos So I could check if the openContainer is from x block
  7. Please, can u make a example for "Get the value of RenderLivingBase#layerRenderers from the player renderer using reflection."?
  8. Is it possible to cancel the Renderer of the Elytra when it's equipped?
  9. I just want create something basic to get the mods installed. Something like that... https://www.curseforge.com/minecraft/mc-mods/mod-control, maybe?
  10. I would like to check the mods that the player has installed, and if he is using some mod that is not allowed on the server, disconnect the player from the server.
  11. Is it possible to get the list of mods loaded from a player as it enters the server? Like a server-side only mod to get all mods loaded and do something if a specific mod is loaded?
  12. It's possible get the time that a player is without pressing any key? Like to detect if he's AFK and do something if yes?
  13. I'm using 1.12.2. I found a way to fix my problem, I don't know if it's the best way, but it works. I create a new List<Block> for each seed, and get his values using: public static List<Block> getBlockConfig2(String config) { List<Block> allBlocks = new ArrayList<Block>(); String[] blockList = config.split(";"); if(!(blockList.length <= 0)) { for(String block : blockList) { if(block.startsWith("ore:")) { //nothing } else { String[] split = block.split(":"); if(split.length > 2) { ItemStack blockA = new ItemStack(Item.getByNameOrId(split[0] + ":" + split[1]), 1, Integer.parseInt(split[2])); if(blockA.getItem() == Items.AIR) { Block blockB = Block.getBlockFromName(split[0] + ":" + split[1]); if(blockB != null) { allBlocks.add(blockB); } } } else if(split.length == 2){ ItemStack blockA = new ItemStack(Item.getByNameOrId(split[0] + ":" + split[1])); if(blockA.getItem() == Items.AIR) { Block blockB = Block.getBlockFromName(split[0] + ":" + split[1]); if(blockB != null) { allBlocks.add(blockB); } } } } } } return allBlocks; } https://github.com/Focamacho/MysticalAdaptations/commit/f4f233d76ce057ba79b10379c571cc62cfe18522
  14. I'm trying to get a list of blocks from a configuration file, using a String: water_seeds = config.get(category, "water_seeds", "minecraft:water").getString(); wood_seeds = config.get(category, "wood_seeds", "ore:logWood").getString(); BlockCheck.java public static final List<ItemStack> Water = getBlockConfig(ModConfig.water_seeds); public static final List<ItemStack> Wood = getBlockConfig(ModConfig.wood_seeds); public static List<ItemStack> getBlockConfig(String config) { List<ItemStack> allBlocks = new ArrayList<ItemStack>(); String[] blockList = config.split(";"); if(!(blockList.length <= 0)) { for(String block : blockList) { if(block.startsWith("ore:")) { String[] split = block.split(":"); allBlocks.addAll(getBlockListFromOredict(split[1])); } else { String[] split = block.split(":"); if(split.length > 2) { ItemStack blockA = new ItemStack(Item.getByNameOrId(split[0] + ":" + split[1]), 1, Integer.parseInt(split[2])); allBlocks.add(blockA); } else if(split.length == 2){ ItemStack blockA = new ItemStack(Item.getByNameOrId(split[0] + ":" + split[1])); allBlocks.add(blockA); } } } } return allBlocks; } public static List<ItemStack> getBlockListFromOredict(String ore) { List<ItemStack> oreItems = OreDictionary.getOres(ore); return oreItems; } But, when I create a ItemStack from things like "minecraft:water" or "minecraft:lava" it returns a tile.air: And I need use the List<ItemStack> to compare a right-clicked block with the blocks in the list. SeedExtractor.java ........ ItemStack blockItem = iblockstate.getBlock().getPickBlock(iblockstate, raytraceresult, worldIn, pos, player); if(player.canPlayerEdit(pos, raytraceresult.sideHit, itemstack)) { if(checkBlockAndTier(itemstack, blockItem, BlockCheck.Wood, Type.WOOD)) seed = returnSeedItem(Type.WOOD); else if(checkBlockAndTier(itemstack, blockItem, BlockCheck.Water, Type.WATER)) seed = returnSeedItem(Type.WATER); else if(checkBlockAndTier(itemstack, blockItem, BlockCheck.Fire, Type.FIRE)) seed = returnSeedItem(Type.FIRE); ........ public boolean checkBlockAndTier(ItemStack extractor, ItemStack block, List<ItemStack> blockList, CropType.Type seed) { if(checkBlock(block, blockList) && verifyTier(seed, extractor) && seed.isEnabled()) return true; else return false; } public boolean checkBlock(ItemStack block, List<ItemStack> blockList) { if(blockList == null || blockList.isEmpty()) return false; else { for(ItemStack b : blockList) { if(OreDictionary.itemMatches(b, block, true)) { return true; } } } return false; } to result in this:
  15. I tried use ItemStacks, but a ItemStack from blocks like minecraft:water, always returns tile.air.
  16. This code only crashs with ore:logWood public static List<IBlockState> getBlockListFromOredict(String ore) { List<IBlockState> oreBlocks = new ArrayList<IBlockState>(); List<ItemStack> oreItems = OreDictionary.getOres(ore); for(ItemStack item : oreItems) { oreBlocks.add(Block.getBlockFromItem(item.getItem()).getStateFromMeta(item.getMetadata()); } return oreBlocks; }
  17. There's no BlockStateArgument. I'm using 1.12.2 - 14.23.5.2768
  18. How should I do it? public static List<IBlockState> getBlockListFromOredict(String ore) { List<IBlockState> oreBlocks = new ArrayList<IBlockState>(); List<ItemStack> oreItems = OreDictionary.getOres(ore); for(ItemStack item : oreItems) { oreBlocks.add(Block.getBlockFromItem(item.getItem()).getStateFromMeta(item.getMetadata()); } return oreBlocks; }
  19. How can I get a block from a String? Example: String config = "minecraft:water;minecraft:grass;biomesoplenty:gem_block:7;ore:logWood"; I tried: public static List<ItemStack> getBlockConfig(String config) { System.out.println(config); List<ItemStack> allBlocks = new ArrayList<Integer>(); String[] blockList = config.split(";"); if(!(blockList.length <= 0)) { for(String block : blockList) { if(block.startsWith("ore:")) { String[] split = block.split(":"); allBlocks.addAll(getBlockListFromOredict(split[1])); } else { String[] split = block.split(":"); if(split.length > 2) { ItemStack blockItem = new ItemStack(Item.getByNameOrId(split[0] + ":" + split[1]), 1, Integer.parseInt(split[2])); allBlocks.add(blockItem); } else if(split.length == 2){ ItemStack blockItem = new ItemStack(Item.getByNameOrId(split[0] + ":" + split[1])); allBlocks.add(blockItem); } } } } return allBlocks; } But for blocks like water & flowers, it returns Air. Tried using blockstate, but it don't work with oredict, because crashs in logWood using .getStateFromMeta. Crash: I need a list of blocks defined in the configuration file, for comparison with a Right-Clicked block.
  20. I could not find any way to get ResourceLocation, only: https://github.com/BlakeBr0/MysticalAgriculture/blob/master/src/main/java/com/blakebr0/mysticalagriculture/crafting/ModRecipes.java#L32-L32 https://github.com/BlakeBr0/Cucumber/blob/master/src/main/java/com/blakebr0/cucumber/helper/RecipeHelper.java#L15-L15 I tried to use "getRecipeLocation", but it does not work. Or I'm doing something wrong.
  21. I could not find anything related to the seeds https://github.com/BlakeBr0/MysticalAgriculture/tree/master/src/main/resources/assets/mysticalagriculture/recipes
  22. I'm trying to remove/disable some recipes of Mystical Agriculture, in this case, the seeds. I think I need do something like: @SubscribeEvent public static void removeRecipes(RegistryEvent.Register<IRecipe> event) { ResourceLocation seed = How can I get this?; IForgeRegistryModifiable modRegistry = (IForgeRegistryModifiable) event.getRegistry(); modRegistry.remove(seed); But how I get the Recipe ResourceLocation? Is it possible to get this from an item stack?
×
×
  • Create New...

Important Information

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