Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

epicMinecrafter666Xx

Members
  • Posts

    7
  • Joined

  • Last visited

epicMinecrafter666Xx's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. i want something that returns true only on the press action, seems that KeyBinding.isPressed() returns true on press, sets a timer of like 10 ticks and when that timer reach 0 it starts behaving like KeyBinding.isKeyDown()
  2. I tried this and its the same outcome: @SubscribeEvent public static void keyEvent(TickEvent.ClientTickEvent event) { PlayerEntity player = Minecraft.getInstance().player; GameSettings settings = Minecraft.getInstance().gameSettings; if (event.phase.equals(TickEvent.Phase.END) && Minecraft.getInstance().isGameFocused() && isWearingAntiqueArmor(player)) { while(settings.keyBindForward.isPressed()) { NetworkUtil.notifyAntiqueArmor(0); } while(settings.keyBindBack.isPressed()) { NetworkUtil.notifyAntiqueArmor(1); } while(settings.keyBindRight.isPressed()) { NetworkUtil.notifyAntiqueArmor(2); } while(settings.keyBindLeft.isPressed()) { NetworkUtil.notifyAntiqueArmor(3); } } } also, the inventory open action seems to be behaving in the same way, i think i should make my own checker for this
  3. hi, i tried this but i keep getting the same outcome @Mod.EventBusSubscriber(modid = DannysExpansion.MOD_ID, value = Dist.CLIENT) public class ModKeybinds { @SubscribeEvent(priority = EventPriority.LOW) public static void keyEvent(InputEvent.KeyInputEvent event) { PlayerEntity player = Minecraft.getInstance().player; GameSettings settings = Minecraft.getInstance().gameSettings; if (Minecraft.getInstance().isGameFocused() && isWearingAntiqueArmor(player)) { if (settings.keyBindForward.isPressed()) { NetworkUtil.notifyAntiqueArmor(0); } else if (settings.keyBindBack.isPressed()) { NetworkUtil.notifyAntiqueArmor(1); } else if (settings.keyBindRight.isPressed()) { NetworkUtil.notifyAntiqueArmor(2); } else if (settings.keyBindLeft.isPressed()) { NetworkUtil.notifyAntiqueArmor(3); } } } public static boolean isWearingAntiqueArmor(PlayerEntity player) { return player.getItemStackFromSlot(EquipmentSlotType.HEAD).getItem() == ModItems.ANTIQUE_ARMOR_HELMET.get() && player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == ModItems.ANTIQUE_ARMOR_CHESTPLATE.get() && player.getItemStackFromSlot(EquipmentSlotType.LEGS).getItem() == ModItems.ANTIQUE_ARMOR_LEGGINGS.get() && player.getItemStackFromSlot(EquipmentSlotType.FEET).getItem() == ModItems.ANTIQUE_ARMOR_BOOTS.get(); } }
  4. help, .isPressed() is not working right for me, it fires every tick, like if it was .isKeyDown() heres my code: @Mod.EventBusSubscriber(modid = DannysExpansion.MOD_ID, value = Dist.CLIENT) public class ModKeybinds { @SubscribeEvent public static void keyEvent(TickEvent.ClientTickEvent event) { PlayerEntity player = Minecraft.getInstance().player; GameSettings settings = Minecraft.getInstance().gameSettings; if (player != null) { if(event.phase.equals(TickEvent.Phase.END) && Minecraft.getInstance().isGameFocused()) { if (isWearingAntiqueArmor(player)) { if (settings.keyBindForward.isPressed()) { ClientInstance.player().sendChatMessage("asd"); NetworkUtil.notifyAntiqueArmor(0); } else if (settings.keyBindBack.isPressed()) { NetworkUtil.notifyAntiqueArmor(1); } else if (settings.keyBindRight.isPressed()) { NetworkUtil.notifyAntiqueArmor(2); } else if (settings.keyBindLeft.isPressed()) { NetworkUtil.notifyAntiqueArmor(3); } } } } } public static boolean isWearingAntiqueArmor(PlayerEntity player) { return player.getItemStackFromSlot(EquipmentSlotType.HEAD).getItem() == ModItems.ANTIQUE_ARMOR_HELMET.get() && player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == ModItems.ANTIQUE_ARMOR_CHESTPLATE.get() && player.getItemStackFromSlot(EquipmentSlotType.LEGS).getItem() == ModItems.ANTIQUE_ARMOR_LEGGINGS.get() && player.getItemStackFromSlot(EquipmentSlotType.FEET).getItem() == ModItems.ANTIQUE_ARMOR_BOOTS.get(); } }
  5. RegistryEvents is where i register the blocks, items and biomes @Mod.EventBusSubscriber( bus = Bus.MOD ) public class RegistryEvents { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MoreContent.MOD_ID); public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MoreContent.MOD_ID); public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, MoreContent.MOD_ID); @SubscribeEvent public static void onEntityRegistry(Register<EntityType<?>> event) { ModEntityTypes.register(event.getRegistry()); } public RegistryEvents() { BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); BIOMES.register(FMLJavaModLoadingContext.get().getModEventBus()); } //*************************ITEMS****************************************************************// public static final RegistryObject<Item> ENDER_BEAST_ARCHER = ITEMS.register("ender_beast_archer_spawn_egg", () -> new SpawnEggItem(ModEntityTypes.ENDERBEASTARCHER, 3286365, 4859178, (new Item.Properties()).group(ItemGroup.MISC))); //BLOCKITEMS public static final RegistryObject<Item> FIERCE_SAND_ITEM = ITEMS.register("fierce_sand", () -> new BlockItem(RegistryEvents.FIERCE_SAND.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS))); public static final RegistryObject<Item> FIERCE_SANDSTONE_ITEM = ITEMS.register("fierce_sandstone", () -> new BlockItem(RegistryEvents.FIERCE_SANDSTONE.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS))); public static final RegistryObject<Item> FOSSILS_ITEM = ITEMS.register("fossils", () -> new BlockItem(RegistryEvents.FOSSILS.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS))); public static final RegistryObject<Item> ERODED_STONE_ITEM = ITEMS.register("eroded_stone", () -> new BlockItem(RegistryEvents.ERODED_STONE.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS))); public static final RegistryObject<Item> DEAD_GRASS_ITEM = ITEMS.register("dead_grass", () -> new BlockItem(RegistryEvents.DEAD_GRASS.get(), new Item.Properties().group(ItemGroup.DECORATIONS))); public static final RegistryObject<Item> DESERTS_HOPE_ITEM = ITEMS.register("deserts_hope", () -> new BlockItem(RegistryEvents.DESERTS_HOPE.get(), new Item.Properties().group(ItemGroup.DECORATIONS))); public static final RegistryObject<Item> SPIKED_VINE_ITEM = ITEMS.register("spiked_vine", () -> new BlockItem(RegistryEvents.SPIKED_VINE.get(), new Item.Properties().group(ItemGroup.DECORATIONS))); public static final RegistryObject<Item> SPIKY_FRUIT_ITEM = ITEMS.register("spiky_fruit", () -> new Item(new Item.Properties().group(ItemGroup.FOOD).food(ModFoods.SPIKY_FRUIT))); public static final RegistryObject<Item> GOLDEN_SPIKY_FRUIT_ITEM = ITEMS.register("golden_spiky_fruit", () -> new Item(new Item.Properties().group(ItemGroup.FOOD).food(ModFoods.GOLDEN_SPIKY_FRUIT))); ///// public static final RegistryObject<Item> LARGE_ACACIA_TORCH_ITEM = ITEMS.register("large_acacia_torch", () -> new BlockItem(RegistryEvents.LARGE_ACACIA_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS))); public static final RegistryObject<Item> LARGE_BIRCH_TORCH_ITEM = ITEMS.register("large_birch_torch", () -> new BlockItem(RegistryEvents.LARGE_BIRCH_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS))); public static final RegistryObject<Item> LARGE_DARK_OAK_TORCH_ITEM = ITEMS.register("large_dark_oak_torch", () -> new BlockItem(RegistryEvents.LARGE_DARK_OAK_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS))); public static final RegistryObject<Item> LARGE_JUNGLE_TORCH_ITEM = ITEMS.register("large_jungle_torch", () -> new BlockItem(RegistryEvents.LARGE_JUNGLE_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS))); public static final RegistryObject<Item> LARGE_OAK_TORCH_ITEM = ITEMS.register("large_oak_torch", () -> new BlockItem(RegistryEvents.LARGE_OAK_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS))); public static final RegistryObject<Item> LARGE_SPRUCE_TORCH_ITEM = ITEMS.register("large_spruce_torch", () -> new BlockItem(RegistryEvents.LARGE_SPRUCE_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS))); //*************************BLOCKS***************************************************************// public static final RegistryObject<Block> FIERCE_SAND = BLOCKS.register("fierce_sand", () -> new SandBlock(16760677, Block.Properties.create(Material.SAND, MaterialColor.SAND).hardnessAndResistance(0.5F).harvestTool(ToolType.SHOVEL).sound(SoundType.SAND))); public static final RegistryObject<Block> FIERCE_SANDSTONE = BLOCKS.register("fierce_sandstone", () -> new Block(Block.Properties.create(Material.ROCK, MaterialColor.SAND).hardnessAndResistance(0.9F).harvestTool(ToolType.PICKAXE).sound(SoundType.STONE))); public static final RegistryObject<Block> FOSSILS = BLOCKS.register("fossils", () -> new Block(Block.Properties.create(Material.ROCK, MaterialColor.DIRT).hardnessAndResistance(1.0F).harvestTool(ToolType.PICKAXE).sound(SoundType.STONE))); public static final RegistryObject<Block> ERODED_STONE = BLOCKS.register("eroded_stone", () -> new Block(Block.Properties.create(Material.ROCK, MaterialColor.DIRT).hardnessAndResistance(1.0F).harvestTool(ToolType.PICKAXE).sound(SoundType.STONE))); public static final RegistryObject<Block> SPIKED_VINE = BLOCKS.register("spiked_vine", () -> new SpikedVineBlock(Block.Properties.create(Material.PLANTS, MaterialColor.GRASS).hardnessAndResistance(0.5F).harvestTool(ToolType.AXE).sound(SoundType.PLANT))); public static final RegistryObject<Block> SPIKY_FRUIT = BLOCKS.register("spiky_fruit", () -> new SpikyFruitBlock(Block.Properties.create(Material.PLANTS, MaterialColor.ORANGE_TERRACOTTA).hardnessAndResistance(0.5F).harvestTool(ToolType.AXE).sound(SoundType.PLANT))); public static final RegistryObject<Block> DEAD_GRASS = BLOCKS.register("dead_grass", () -> new DeserticBushBlock(Block.Properties.create(Material.PLANTS, MaterialColor.GOLD).zeroHardnessAndResistance().sound(SoundType.PLANT).doesNotBlockMovement())); public static final RegistryObject<Block> DESERTS_HOPE = BLOCKS.register("deserts_hope", () -> new FlowerBlock(Effects.REGENERATION, 8, Block.Properties.create(Material.PLANTS).zeroHardnessAndResistance().sound(SoundType.PLANT).doesNotBlockMovement())); //// public static final RegistryObject<Block> POTTED_DESERTS_HOPE = BLOCKS.register("potted_deserts_hope", () -> new FlowerPotBlock(RegistryEvents.DESERTS_HOPE.get(), Block.Properties.create(Material.MISCELLANEOUS).zeroHardnessAndResistance().notSolid())); public static final RegistryObject<Block> LARGE_ACACIA_TORCH = BLOCKS.register("large_acacia_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD))); public static final RegistryObject<Block> LARGE_BIRCH_TORCH = BLOCKS.register("large_birch_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD))); public static final RegistryObject<Block> LARGE_DARK_OAK_TORCH = BLOCKS.register("large_dark_oak_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD))); public static final RegistryObject<Block> LARGE_JUNGLE_TORCH = BLOCKS.register("large_jungle_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD))); public static final RegistryObject<Block> LARGE_OAK_TORCH = BLOCKS.register("large_oak_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD))); public static final RegistryObject<Block> LARGE_SPRUCE_TORCH = BLOCKS.register("large_spruce_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD))); ////////BIOMES///////// public static final RegistryObject<Biome> RAMMERS_VALLEY = BIOMES.register("rammers_valley", RammersValleyBiome::new); public static void registerBiomesToDictionary() { BiomeManager.addBiome(BiomeManager.BiomeType.WARM, new BiomeManager.BiomeEntry(RAMMERS_VALLEY.get(), 30)); } public static void addBiomeTypes() { BiomeDictionary.addTypes(RAMMERS_VALLEY.get(), BiomeDictionary.Type.DRY, BiomeDictionary.Type.SANDY, BiomeDictionary.Type.OVERWORLD); } } apparently if i delete new RegistryEvents(); Minecraft throws me this: More Content (more content) encountered an error during the load_registries event phase the other thing you pointed out were infact useless. @Mod("morecontent") @Mod.EventBusSubscriber(modid = "morecontent", bus = Mod.EventBusSubscriber.Bus.MOD) public class MoreContent { public static MoreContent INSTANCE; public static final String MOD_ID = "morecontent"; public MoreContent() { INSTANCE = this; new RegistryEvents(); } @SubscribeEvent public void setupCommon(FMLCommonSetupEvent event) { PacketHandler.register(); DeferredWorkQueue.runLater(() -> { RegistryEvents.addBiomeTypes(); RegistryEvents.registerBiomesToDictionary(); }); } @SubscribeEvent public static void clientSetup(FMLClientSetupEvent event) { RenderHandler.registerEntityRenders(); RenderHandler.registerBlockRenders(); } } i registered the packets on FMLCommonSetup and i get a crash when i use a packet along with this [19:51:22] [Server thread/ERROR] [ne.mi.fm.ne.NetworkRegistry/NETREGISTRY]: Attempted to register channel morecontent:main even though registry phase is over "[19:51:22] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception java.lang.ExceptionInInitializerError: null
  6. Updates I noticed that i had to register them in the FMLCommonSetupEvent but now when i send a packet i get a crash along with this message [19:51:22] [Server thread/ERROR] [ne.mi.fm.ne.NetworkRegistry/NETREGISTRY]: Attempted to register channel morecontent:main even though registry phase is over "[19:51:22] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception java.lang.ExceptionInInitializerError: null
  7. I keep getting this message "[19:05:18] [Render thread/WARN] [minecraft/ClientPlayNetHandler]: Unknown custom packet identifier: morecontent:main" when i send a packet instead of doing whatever that packet should do. here are the classes PacketHandler and the packet public class PacketHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel( new ResourceLocation(MoreContent.MOD_ID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void register() { int ID = 0; INSTANCE.registerMessage(++ID, AnimationPacket.class, AnimationPacket::encode, AnimationPacket::new, AnimationPacket::handle); } } public class AnimationPacket { private int entityId; private int animationIndex; AnimationPacket(final PacketBuffer packetBuffer) { this.entityId = packetBuffer.readInt(); this.animationIndex = packetBuffer.readInt(); } public AnimationPacket(int entityId, int index) { this.entityId = entityId; this.animationIndex = index; } void encode(final PacketBuffer packetBuffer) { packetBuffer.writeInt(this.entityId); packetBuffer.writeInt(this.animationIndex); } public static void handle(AnimationPacket msg, Supplier<NetworkEvent.Context> ctx) { NetworkEvent.Context context = ctx.get(); if (context.getDirection().getReceptionSide() == LogicalSide.SERVER) { ctx.get().enqueueWork(() -> { Entity entity = Objects.requireNonNull(context.getSender()).world.getEntityByID(msg.entityId); if(entity instanceof AnimatedEntity) { ((AnimatedEntity) entity).spawnExplosionParticle(); } }); ctx.get().setPacketHandled(true); } } } Main @Mod("morecontent") @Mod.EventBusSubscriber( modid = "morecontent", bus = Mod.EventBusSubscriber.Bus.MOD ) public class MoreContent { public static MoreContent INSTANCE; public static final String MOD_ID = "morecontent"; public static final Logger LOGGER = LogManager.getLogger("morecontent"); public MoreContent() { INSTANCE = this; MinecraftForge.EVENT_BUS.register(this); PacketHandler.register(); new RegistryEvents(); MinecraftForge.EVENT_BUS.register(EventHandler.class); } @SubscribeEvent public void setupCommon(FMLCommonSetupEvent event) { DeferredWorkQueue.runLater(() -> { RegistryEvents.addBiomeTypes(); RegistryEvents.registerBiomesToDictionary(); }); } @SubscribeEvent public static void clientSetup(FMLClientSetupEvent event) { RenderHandler.registerEntityRenders(); RenderHandler.registerBlockRenders(); } } this is how i send the packet: PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new AnimationPacket(this.getEntityId(), 1));
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.