
X_Khan_X
Members-
Posts
28 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
X_Khan_X's Achievements

Tree Puncher (2/8)
0
Reputation
-
Hello, I've created some .nbt files using a structure block and I use public class StructureGenHelper extends WorldGenerator implements IStructure { public String structureName; public StructureGenHelper(String name) { structureName = name; } @Override public boolean generate(World worldIn, Random rand, BlockPos position) { generateStructure(worldIn, position); return true; } public boolean generateStructure(World world, BlockPos pos) { MinecraftServer mcServer = world.getMinecraftServer(); TemplateManager manager = worldServer.getStructureTemplateManager(); ResourceLocation location = new ResourceLocation(Main.MODID, structureName); Template template = manager.get(mcServer, location); if (template == null) { Messages.serverLog(Main.logger, "The structure " + structureName + " doesn't exist!", 3); } if (template != null) { IBlockState state = world.getBlockState(pos); world.notifyBlockUpdate(pos, state, state, 3); template.addBlocksToWorldChunk(world, pos, settings); return true; } return false; } } to generate a structure but I have a problem to rotate the structure based where the player is facing, can someone help me or point me to the right direction? Thanks
-
1.12 BreakEvent and HarvestDropsEvent conflict NPE
X_Khan_X replied to X_Khan_X's topic in Modder Support
The suppress warning is useless, need to remove the state. The line 30 is the hand item Edit: System.out.print(event.getHarvester()); prints me and null at the same time -
I have an autosmelt class public class AutosmeltEvent { @SubscribeEvent(priority = EventPriority.LOW) public static void onAutosmeltUse(HarvestDropsEvent event) { EntityPlayer player = (EntityPlayer) event.getHarvester(); ItemStack hand = player.inventory.getCurrentItem(); Map<Enchantment, Integer> autosmelt = EnchantmentHelper.getEnchantments(hand); if (autosmelt.isEmpty() || !autosmelt.containsKey(InitEnchants.AUTOSMELT)) return; int autosmeltlevel = autosmelt.get(InitEnchants.AUTOSMELT); Block block = event.getState().getBlock(); @SuppressWarnings("unused") IBlockState state = event.getState(); World world = event.getWorld(); BlockPos pos = event.getPos(); ItemStack smelt = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(block)); smelt.setCount(1); ItemStack out = smelt.copy(); if (autosmeltlevel == 1) { if (smelt.getItem() == Item.getItemFromBlock(Blocks.AIR) && !player.capabilities.isCreativeMode) { world.destroyBlock(pos, true); } if (block != null) { world.setBlockToAir(pos); event.getDrops().clear(); event.getDrops().add(out); player.addExperience(1); } } } } that works with the enchant and an excavate class public class ExcavateEvent { @SubscribeEvent(priority = EventPriority.NORMAL) public static void onExcavateUse(BlockEvent.BreakEvent event) { EntityPlayer player = (EntityPlayer) event.getPlayer(); ItemStack hand = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND); Map<Enchantment, Integer> excavate = EnchantmentHelper.getEnchantments(hand); if (excavate.isEmpty() || !excavate.containsKey(InitEnchants.EXCAVATE)) return; int excavatelevel = excavate.get(InitEnchants.EXCAVATE); World world = event.getWorld(); BlockPos pos = event.getPos(); Block block = event.getState().getBlock(); if (excavatelevel > 0) { for (int i = 0; i < (excavatelevel + 1); i++) { Iterable<BlockPos> it = BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i)); for (BlockPos offset2 : it) { Block block2 = world.getBlockState(offset2).getBlock(); if (block2 == block && block2 != Blocks.AIR) { try { world.destroyBlock(offset2, true); hand.damageItem(1, player); } catch (Exception e) { e.printStackTrace(); } } } } } } } which gives me problems when I use the excavate enchant (without autosmelt on the pickaxe) java.lang.NullPointerException: null at com.mod.modcore.events.enchantment.AutosmeltEvent.onAutosmeltUse(AutosmeltEvent.java:30) ~[AutosmeltEvent.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_17_AutosmeltEvent_onAutosmeltUse_HarvestDropsEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:321) [ForgeEventFactory.class:?] at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:721) [Block.class:?] at net.minecraft.block.BlockOre.dropBlockAsItemWithChance(BlockOre.java:92) [BlockOre.class:?] at net.minecraft.block.Block.dropBlockAsItem(Block.java:710) [Block.class:?] at net.minecraft.world.World.destroyBlock(World.java:477) [World.class:?] at com.mod.modcore.events.enchantment.ExcavateEvent.onExcavateUse(ExcavateEvent.java:42) [ExcavateEvent.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_ExcavateEvent_onExcavateUse_BreakEvent.invoke(.dynamic) [?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) [ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?] at net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(ForgeHooks.java:838) [ForgeHooks.class:?] at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:309) [PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.blockRemoving(PlayerInteractionManager.java:261) [PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:732) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:56) [CPacketPlayerDigging.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:12) [CPacketPlayerDigging.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) [PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_221] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_221] at net.minecraft.util.Util.runTask(Util.java:53) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:798) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_221] I know, the solution may be very very simple but I dont know why it throw me an error when breaking blocks AutosmeltEvent line 30: ItemStack hand = player.inventory.getCurrentItem(); ExcavateEvent line 42: world.destroyBlock(offset2, true);
-
1.12 autosmelt enchant (custom made) drop random item count
X_Khan_X replied to X_Khan_X's topic in Modder Support
Solved, thanks! -
1.12 autosmelt enchant (custom made) drop random item count
X_Khan_X replied to X_Khan_X's topic in Modder Support
Tried and in a 125 blocks test (5x5x5 cube) it dropped me 64+61 iron ore which is correct but it doesn't have to drop them and 7 stacks and 56 iron ingots -
Hello, I'm trying to create a custom enchant "Autosmelt" but sometimes it drops me more than one item, this occurs more when haste is applied, giving me 2 or more items when a block is broken. I've tested it with haste 30 (only to oneshot the blocks) with a vanilla diamond pickaxe (autosmelt enchant only) and a 5x5 iron ore block, giving me like 6 stacks of iron ingots. How can I set it drop only 1 item per block? Is the smelt result correct/good? @SubscribeEvent public static void onAutosmeltUse(BlockEvent.BreakEvent event) { EntityPlayer player = (EntityPlayer) event.getPlayer(); ItemStack head = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND); Map<Enchantment, Integer> autosmelt = EnchantmentHelper.getEnchantments(head); if (autosmelt.isEmpty()) return; int autosmeltlevel = autosmelt.get(InitEnchants.AUTOSMELT); Block block = event.getState().getBlock(); World world = event.getWorld(); BlockPos pos = event.getPos(); int x = event.getPos().getX(); int y = event.getPos().getY(); int z = event.getPos().getZ(); ItemStack smelt = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(block)); if (autosmeltlevel == 1) { if (smelt.getItem() == Item.getItemFromBlock(Blocks.AIR) && !player.capabilities.isCreativeMode) { world.destroyBlock(pos, true); } if (block != null) { world.setBlockToAir(pos); player.addExperience(1); ItemStack stack = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(block)); stack.setCount(1); EntityItem it = new EntityItem(world, x, y, z, stack); world.spawnEntity(it); } } }
-
[1.12.2] Problem rendering block's item model
X_Khan_X replied to X_Khan_X's topic in Modder Support
The class is a copy of another of my blocks, and when is in my inventory I can see "testmod:reinforced_glass#inventory" I've registered it correctly and every other block's item model works except this one Edit: I'm an idiot, I forgot it.. Thanks! -
Hello, I've created a custom block with connected textures and everything works perfectly except the item in the inventory. I've tried using { "parent": "testmod:block/reinforced_glass_c0" } and the parent is: { "parent": "block/cube_all", "textures": { "all": "testmod:blocks/reinforced_glass/reinforced_glass0C" } } I render my blocks with it (and yeah is the vanilla method) trying to remove the item/reinforced_glass.json minecraft gives an error because the file doesn't exist. How can I fix it? The placed block works perfectly
-
Thanks
-
Done. Still dying
-
Then I don't understand the problem... I don't understand what I have to change
-
But I have to check if the player has this item no?
-
How to check it correctly then?
-
The code above pass the "if player has the item in the inventory" check, I mean after if (mp.inventory.hasItemStack(pixie)) { I added a System.out.println with random text and it is printed.