Search the Community
Showing results for tags 'events'.
-
Jonarchy. Join now, conquer now, grind now. Anarchy server made just for you. Unleash your creativity, explore and grind — boredom never reaches you. Version: 1.7.x - 1.30.x Java: Jonarchy.com Bedrock port: 25565 Eaglercraft: wss://8b4t.org Website: https://www.jonarchy.com Discord: https://discord.gg/T2hKRem6xV • 100% anarchy — NO BANS or MUTES. Do as you wish. That includes EVERYTHING that comes to your mind. • Super crossplay — Eaglercraft, Java, and Bedrock • No world resets, no bullshit • Online since 2019 • World generation from the first Minecraft versions up to the latest • /TPA, /HOME included • Light anti-chest for a no-lag experience • Latest AI technology in software/plugins/hardware • No pay-to-win — we keep things fair • Trying to be as vanilla as possible • Active player base and community • Weekly, monthly PVP, DUPE, or CUSTOM events • Trusted and reliable!!! 2500+ Gigabyte world size! We respect each one of our players, and every player counts!
-
Hi! I'm trying to add my custom models/textures renderer like this: public class PonyPlayerWrapperRenderer extends EntityRenderer<Player> { // wrapper class under my LivingEntityRenderer class implementation private final PonyPlayerRenderer innerRenderer; private final PonyPlayerRenderer innerSlimRenderer; public PonyPlayerWrapperRenderer(final EntityRendererProvider.Context context) { super(context); System.out.println("creating new PonyPlayerWrapperRenderer"); this.innerRenderer = new PonyPlayerRenderer(context, false); this.innerSlimRenderer = new PonyPlayerRenderer(context, true); } @Override public void render(final Player entity, final float yaw, final float partialTicks, final PoseStack poseStack, final MultiBufferSource bufferSource, final int packedLight) { System.out.println("PonyPlayerWrapperRenderer render: " + entity.toString()); if (entity instanceof AbstractClientPlayer clientPlayer) { if (clientPlayer.getModelName().contains("slim")) { innerSlimRenderer.render(clientPlayer, yaw, partialTicks, poseStack, bufferSource, packedLight); } else { innerRenderer.render(clientPlayer, yaw, partialTicks, poseStack, bufferSource, packedLight); } } } @Override public ResourceLocation getTextureLocation(final Player player) { System.out.println("PonyPlayerWrapperRenderer getTextureLocation"); if (player instanceof AbstractClientPlayer clientPlayer) { return clientPlayer.getSkinTextureLocation(); } System.out.println("player instanceof AbstractClientPlayer is false"); return getDefaultSkin(player.getUUID()); } } public class PonyPlayerRenderer extends LivingEntityRenderer<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> { private final PlayerModel<AbstractClientPlayer> earthModel; private final PlayerModel<AbstractClientPlayer> pegasusModel; private final PlayerModel<AbstractClientPlayer> unicornModel; public PonyPlayerRenderer(final EntityRendererProvider.Context context, final boolean slim) { super( context, slim ? new PonyModelSlim(context.bakeLayer(PonyModelSlim.LAYER_LOCATION)) : new PonyModel(context.bakeLayer(PonyModel.LAYER_LOCATION)), 0.5f ); System.out.println("creating new PonyPlayerRenderer"); this.earthModel = slim ? new PonyModelSlim(context.bakeLayer(PonyModelSlim.LAYER_LOCATION)) : new PonyModel(context.bakeLayer(PonyModel.LAYER_LOCATION)); this.pegasusModel = new PegasusModel(context.bakeLayer(PegasusModel.LAYER_LOCATION)); this.unicornModel = new UnicornModel(context.bakeLayer(UnicornModel.LAYER_LOCATION)); } @Override public void render(final AbstractClientPlayer player, final float entityYaw, final float partialTicks, final PoseStack poseStack, final MultiBufferSource buffer, final int packedLight) { final PonyRace race = player.getCapability(PONY_DATA) .map(data -> ofNullable(data.getRace()).orElse(PonyRace.EARTH)) .orElse(PonyRace.EARTH); this.model = switch (race) { case PEGASUS -> pegasusModel; case UNICORN -> unicornModel; case EARTH -> earthModel; }; super.render(player, entityYaw, partialTicks, poseStack, buffer, packedLight); } @Override public ResourceLocation getTextureLocation(final AbstractClientPlayer player) { final PonyRace race = player.getCapability(PONY_DATA) .map(data -> ofNullable(data.getRace()).orElse(PonyRace.EARTH)) .orElse(PonyRace.EARTH); return switch (race) { case EARTH -> fromNamespaceAndPath(MODID, "textures/entity/earth_pony.png"); case PEGASUS -> fromNamespaceAndPath(MODID, "textures/entity/pegasus.png"); case UNICORN -> fromNamespaceAndPath(MODID, "textures/entity/unicorn.png"); }; } } @Mod.EventBusSubscriber(modid = MODID, bus = MOD, value = CLIENT) public class ClientRenderers { // mod bus render registration config @SubscribeEvent public static void onRegisterLayerDefinitions(final EntityRenderersEvent.RegisterLayerDefinitions event) { event.registerLayerDefinition(PonyModel.LAYER_LOCATION, PonyModel::createBodyLayer); event.registerLayerDefinition(PonyModelSlim.LAYER_LOCATION, PonyModelSlim::createBodyLayer); event.registerLayerDefinition(PegasusModel.LAYER_LOCATION, PegasusModel::createBodyLayer); event.registerLayerDefinition(UnicornModel.LAYER_LOCATION, UnicornModel::createBodyLayer); event.registerLayerDefinition(InnerPonyArmorModel.LAYER_LOCATION, InnerPonyArmorModel::createBodyLayer); event.registerLayerDefinition(OuterPonyArmorModel.LAYER_LOCATION, OuterPonyArmorModel::createBodyLayer); } @SubscribeEvent public static void onRegisterRenderers(final EntityRenderersEvent.RegisterRenderers event) { event.registerEntityRenderer(EntityType.PLAYER, PonyPlayerWrapperRenderer::new); System.out.println("onRegisterRenderers end"); } } Method onRegisterRenderers() is called and I can see it being logged. But when I enter the world, my PonyWrapperRenderer render() method doesn't ever seem to be called. I also tried to put my renderer to EntityRenderDispatcher's playerRenderers via reflection: @Mod.EventBusSubscriber(modid = MODID, bus = MOD, value = CLIENT) public class ClientRenderers { @SubscribeEvent public static void onRegisterLayerDefinitions(final EntityRenderersEvent.RegisterLayerDefinitions event) { event.registerLayerDefinition(PonyModel.LAYER_LOCATION, PonyModel::createBodyLayer); event.registerLayerDefinition(PonyModelSlim.LAYER_LOCATION, PonyModelSlim::createBodyLayer); event.registerLayerDefinition(PegasusModel.LAYER_LOCATION, PegasusModel::createBodyLayer); event.registerLayerDefinition(UnicornModel.LAYER_LOCATION, UnicornModel::createBodyLayer); event.registerLayerDefinition(InnerPonyArmorModel.LAYER_LOCATION, InnerPonyArmorModel::createBodyLayer); event.registerLayerDefinition(OuterPonyArmorModel.LAYER_LOCATION, OuterPonyArmorModel::createBodyLayer); } @SubscribeEvent public static void onClientSetup(final FMLClientSetupEvent event) { event.enqueueWork(() -> { try { final EntityRenderDispatcher dispatcher = Minecraft.getInstance().getEntityRenderDispatcher(); final Field renderersField = getEntityRenderDispatcherField("playerRenderers"); final Field itemInHandRenderer = getEntityRenderDispatcherField("itemInHandRenderer"); @SuppressWarnings("unchecked") final Map<String, EntityRenderer<? extends Player>> playerRenderers = (Map<String, EntityRenderer<? extends Player>>)renderersField.get(dispatcher); final PonyPlayerWrapperRenderer renderer = new PonyPlayerWrapperRenderer( new EntityRendererProvider.Context( dispatcher, Minecraft.getInstance().getItemRenderer(), Minecraft.getInstance().getBlockRenderer(), (ItemInHandRenderer)itemInHandRenderer.get(dispatcher), Minecraft.getInstance().getResourceManager(), Minecraft.getInstance().getEntityModels(), Minecraft.getInstance().font ) ); playerRenderers.put("default", renderer); playerRenderers.put("slim", renderer); System.out.println("Player renderers replaced"); } catch (final Exception e) { throw new RuntimeException("Failed to replace player renderers", e); } }); } private static Field getEntityRenderDispatcherField(final String fieldName) throws NoSuchFieldException { final Field field = EntityRenderDispatcher.class.getDeclaredField(fieldName); field.setAccessible(true); return field; } } But I receive the error before Minecraft Client appears (RuntimeException: Failed to replace player renderers - from ClientRenderers onClientSetup() method - and its cause below): java.lang.IllegalArgumentException: No model for layer anotherlittlepony:earth_pony#main at net.minecraft.client.model.geom.EntityModelSet.bakeLayer(EntityModelSet.java:18) ~[forge-1.20.1-47.4.0_mapped_official_1.20.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.entity.EntityRendererProvider$Context.bakeLayer(EntityRendererProvider.java:69) ~[forge-1.20.1-47.4.0_mapped_official_1.20.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at com.thuggeelya.anotherlittlepony.client.renderer.pony.PonyPlayerRenderer.<init>(PonyPlayerRenderer.java:32) ~[main/:?] {re:classloading} at com.thuggeelya.anotherlittlepony.client.renderer.pony.PonyPlayerWrapperRenderer.<init>(PonyPlayerWrapperRenderer.java:24) ~[main/:?] {re:classloading} at com.thuggeelya.anotherlittlepony.client.renderer.ClientRenderers.lambda$onClientSetup$0(ClientRenderers.java:79) ~[main/:?] {re:classloading} ... 33 more Problem appears when EntityRendererProvider context tries to bakeLayer with my model layer location: new PonyModel(context.bakeLayer(PonyModel.LAYER_LOCATION)); // PonyPlayerRenderer.java:32 public class PonyModel extends PlayerModel<AbstractClientPlayer> { // the model class itself public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation( ResourceLocation.fromNamespaceAndPath(MODID, "earth_pony"), "main" ); public PonyModel(final ModelPart root) { super(root, false); } public static LayerDefinition createBodyLayer() { // some CubeListBuilder stuff for model appearance } } Textures PNGs are placed at: resources/assets/[my mod id]/textures/entity. My forge version is 1.20.1. Would appreciate any help.
-
I think it would be useful to have a LightningStrikeEvent for when lightning strikes a block. In the event it would have data for the block struck, the lightning entity, and maybe the source of the lightning (either from weather, command, trident, etc.)
-
So, there was this thing in ProjectE, where all items had it's emc value (equivalent cost or smth) and it's was computed from sum of it's ingredients (some items had pre-written emcs, so pretty much all of items' values could be calculated from its crafting recipe). I want to do something similar: store an array in each itemStack of all ids of item's that was used to craft this item, default value is array, contining only current item's id and when items used in crafting (workbench only), product gains all data from ingredients' arrays merged. Example: if you find a iron ingot in a chest, its value should be "{"iron_ingot"}", but if you crafted an ingot into a nuggets, and then back, then it should be "{"iron_ingot","iron_nugget"}". Question is how do i store it, initialize it to every item and how do i generate it on crafting result?
-
Dear all, I am trying to port a mod which worked for 1.19.3 to 1.21.3, but I get an exception on startup: [19:21:15] [Render thread/ERROR]:Exception caught during firing event: 'boolean net.minecraft.world.entity.player.Player.m_6147_()' The problem seems to be a call to `player.onClimbable();`, which is a method of Player. Does anyone have any idea on why this breaks? The source code is available on GitHub here: github.com/blizzard4591/FasterLadderClimbing/blob/master/src/main/java/net/jaspr/fasterladderclimbing/PlayerEventListener.java Thank you for your input!
-
I try to get some information about other players when joining a server. For example, I want to listen to the `AttackEntityEvent` to observe if one player hits another. However, this event works only if my own player hits other entities. Also, I want to read the information in the chat on a server with `ClientChatReceivedEvent` but that only works in Singleplayer. I know these problems are kind of separate ones but maybe they are linked because I register my Event listeners in a wrong way. I don't know. I have the same problem with many other events like `ArrowNockEvent`, `LivingHurtEvent`. The only event that works correctly is my `TickEvent.PlayerTickEvent`. Could you help me please. Are these events wrong? If so, are they other events that I can consider? If not, how can I gather information about other players on the server? Thanks for your help! @Mod(Main.MODID) public class Main { // Define mod id in a common place for everything to reference public static final String MODID = "tttdatacollector"; // Directly reference a slf4j logger private static final Logger LOGGER = LogUtils.getLogger(); public Main(FMLJavaModLoadingContext context) { IEventBus modEventBus = context.getModEventBus(); // Register the commonSetup method for modloading modEventBus.addListener(this::commonSetup); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new PlayerTickEventHandler()); MinecraftForge.EVENT_BUS.register(new PlayerHurtEventHandler()); MinecraftForge.EVENT_BUS.register(new PlayerAttackEntityEventHandler()); MinecraftForge.EVENT_BUS.register(new ChatMessageEventHandler()); MinecraftForge.EVENT_BUS.register(new KillEventHandler()); } } public class ChatMessageEventHandler { private static final Logger log = LogUtils.getLogger(); @SubscribeEvent public void onChatMessageServer(ClientChatReceivedEvent event) { log.info("ClientChatReceivedEvent"); log.info(event.getMessage().getString()); } } public class BowShotEventHandler { private static final Logger log = LogUtils.getLogger(); @SubscribeEvent public void onArrowNock(ArrowNockEvent event) { log.info("onArrowNock"); if (event.getEntity() instanceof ServerPlayer player) { log.info("Player nocked an arrow: {}", player.getName().getString()); } } } public class PlayerAttackEntityEventHandler { private static final Logger log = LogUtils.getLogger(); @SubscribeEvent public void onPlayerAttack(AttackEntityEvent event) { log.info("Player Attack by {} to {}", event.getEntity().getName().getString(), event.getTarget().getName().getString()); } } public class PlayerTickEventHandler { private static final Logger log = LogUtils.getLogger(); private final AggregatedPlayerDataCache aggregatedPlayerDataCache = AggregatedPlayerDataCache.getInstance(); private final PlayerPositionCache playerPositionCache = PlayerPositionCache.getInstance(); private final PlayerDistanceScoreCalculator playerDistanceScoreCalculator = PlayerDistanceScoreCalculator.getInstance(); @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { var player = event.player; String playerName = player.getName().getString(); var playerData = aggregatedPlayerDataCache.getPlayerData(playerName); playerData.setPlayerName(playerName); var oldPos = playerPositionCache.getPlayerPosition(playerName); this.calculateAndSetDistanceAndScore(oldPos, playerData, player); } }
-
Hello! I recently approached modding and Java programming in general. But I'm very used to programming in Minecraft "code", so .json files and commands. In fact, for example, with Terrabalnder it was quite simple and intuitive to convert biome, surface rules and positioning files to run whit forge. Instead what I'm having difficulty with is switching Minecraft things I used to do whit commands to java format. Things like execute a condition or position checks on a specific type of entity, even simple things like "if block ~ ~-1 ~ dirt" or "run particle...". There aren't many tutorials, so I would like to know if there are any tools, documentation or a list of procedures, methods and classes, or useful IntelliJ tooltips. Let me know leterally how from zero I can get the location of methods and informations I need to use. Thanks
-
I have a tool that harvests multiple crops at once, that either replants or harvests the crops depending on an enchant on the tool. The harvesting and loot dropping works fine, but when it comes to updating what block is rendering, only the clicked block is updated properly, while the others drop the loot but appear to say as the fully grown crop, until right clicked again. The normal path for the tool is to just break the crop, as if the player harvested the crop. The other path is to reset the growth of the crop and drop the crop's loot, minus one seed. I have already tried all combinations of method parameters for setBlock() and destroyBlock(), and the updateing of the crop blocks still does not happen. The code thus far: public class ScytheItem extends HoeItem { public ScytheItem(Tier tier, int atkBase, float atkSpeed) { super(tier, atkBase, atkSpeed, new Item.Properties().stacksTo(1)); } @Override public @NotNull InteractionResult useOn(@NotNull UseOnContext context) { Level level = context.getLevel(); Player player = context.getPlayer(); InteractionHand hand = context.getHand(); ItemStack stack = context.getItemInHand(); if (!level.isClientSide() && player != null) { BlockPos pos = context.getClickedPos(); Block block = level.getBlockState(pos).getBlock(); if(block instanceof CropBlock) { level.playSound(null, pos, block.getSoundType(level.getBlockState(pos), level, pos, player).getBreakSound(), SoundSource.BLOCKS, 1.0F, AOTMain.RANDOM.nextFloat()); Map<Enchantment, Integer> enchantments = stack.getAllEnchantments(); int harvestSize = 1 + enchantments.getOrDefault(EnchantmentInit.HARVESTING_SIZE.get(), 0); for (int xOff = -harvestSize; xOff <= harvestSize; xOff++) { for (int zOff = -harvestSize; zOff <= harvestSize; zOff++) { BlockPos newPos = pos.offset(xOff, 0, zOff); Block blockAt = level.getBlockState(newPos).getBlock(); if (blockAt instanceof CropBlock crop) { if (crop.isMaxAge(level.getBlockState(newPos))) { if (enchantments.containsKey(EnchantmentInit.AUTO_PLANTER.get())) { dropLoot(level, newPos, level.getBlockState(newPos), block); level.setBlock(newPos, crop.getStateForAge(0), Block.UPDATE_CLIENTS); // the broken bit } else level.destroyBlock(newPos, true); // the broken bit } } } } stack.hurtAndBreak(1, player, (p) -> p.broadcastBreakEvent(hand)); } } return super.useOn(context); } private void dropLoot(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull Block block) { List<ItemStack> drops = getDrops(level, pos, state); findSeeds(block, drops).ifPresent(seed -> seed.shrink(1)); drops.forEach((drop) -> Block.popResource(level, pos, drop)); } private List<ItemStack> getDrops(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state) { return Block.getDrops(state, (ServerLevel) level, pos, null); } private Optional<ItemStack> findSeeds(@NotNull Block block, final Collection<ItemStack> stacks) { Item seedsItem = block.asItem(); return stacks.stream().filter((stack) -> stack.getItem() == seedsItem).findAny(); } }
-
sorry,i found the issues just some stupid reasons. but idont know how to delete the post
-
1.20.1 LivingAttackEvent dont effect Witches .. help pls
NoahKassem posted a topic in Modder Support
Hello my fellow Modders this is the event code it's working fine with every mob and attack except witches it didn't trigger when witches attacked the player .. can you help me with this problem ... this is the code I'm new to coding in general @SubscribeEvent(priority = EventPriority.HIGH) public void AttackEvent(LivingAttackEvent event) { if (!event.getEntity().getCommandSenderWorld().isClientSide) { if (!(event.getEntity() instanceof ServerPlayer player)) return; ItemStack ring = Utils.getFirstCurio(ModItemGod.divinering.get(), player); Entity attacker2 = event.getSource().getEntity(); Entity attacker = event.getSource().getDirectEntity(); if (ring != null && attacker instanceof SummonedZombie summonedzombie || attacker instanceof SummonedSkeleton summoneskeleton || attacker instanceof SummonedVex summonedvex || attacker instanceof Vex vex ) { ((Monster) attacker).knockback(10,2 ,10); attacker.kill(); event.setCanceled(true); } else if (ring != null && attacker2 instanceof SummonedZombie summonedzombie || attacker2 instanceof SummonedSkeleton summoneskeleton || attacker2 instanceof SummonedVex summonedvex || attacker2 instanceof Vex vex) { ((Monster) attacker2).knockback(10,2 ,10); attacker2.kill(); event.setCanceled(true); } else if (ring != null) { ((LivingEntity) attacker2).addEffect((new MobEffectInstance(MobEffects.BLINDNESS, 200, 2, false, false))); ((LivingEntity) attacker2).setHealth(((LivingEntity) attacker2).getHealth() / 2); ((LivingEntity) attacker2).knockback(10, 3, 10); event.setCanceled(true); } } } -
How to make an entity have a short animation when an event is triggered?
-
Topic for making tags
-
- 1.10.2
- 1.11.2
-
(and 81 more)
Tagged with:
- 1.10.2
- 1.11.2
- 1.12.2
- 1.13.2
- 1.14.4
- 1.15.2
- 1.16.5
- 1.17.1
- 1.18.2
- 1.19.0
- 1.19.1
- 1.19.2
- 1.19.3
- 1.19.4
- 1.2.5
- 1.20.0
- 1.3.2
- 1.4.7
- 1.5.2
- 1.6.4
- 1.7.10
- 1.8.9
- 1.9.4
- armour
- bad jvm args
- biomes
- blocks
- broken mod
- bug
- capabilities
- client
- client-only mods on server
- codecs
- commands
- dimensions
- effects
- enchantments
- entities
- events
- feature request
- fluids
- food
- gradle
- groovy
- guis
- ide
- installer
- items
- java
- kotlin
- launcher
- libraries
- loot
- metadata
- missing jar association
- missing java
- missing mods
- mixin
- needs more info
- networking
- news
- optifine
- ores
- out of memory
- outdated drivers
- particles
- performance
- porting
- potions
- recipes
- registries
- rendering
- scala
- server
- solved
- sounds
- textures
- tools
- tutorial
- weapons
- worldgen
- wrong java version
- wrong mod version
-
Hello, Mr./Ms. My current requirement is to perform some behavior if the player's oxygen value decreases and some other behavior if the player's oxygen increases. I didn't find an event that `listened to the player's oxygen value` change, so I used `TickEvent.ClientTickEvent` to try to listen to each player's oxygen change per tick. I tried to get the instance of the player using `getEntity` and looked for methods related to oxygen in it, I found `getAirSupply` and `setAirSupply` methods. These two methods do allow me to modify the player's oxygen, but if the player is in air, minecraft automatically restores 1 oxygen per tick, and when flooded, minecraft makes the player consume 1 oxygen per tick. If I want my Mod to rigorously reduce the player's oxygen based on my conditions, can I just calculate and write multiple `if` judgments to rigorously reduce the player's oxygen? Or does `forge` provide a way to cancel the `oxygen consumed/increased` event? Like canceling the injury event. Addendum: What I said about strictly consuming the player's oxygen is the behavior of my Mod. For example, I need to consume 3 oxygen per tick, but if the player is in air, the player will only actually consume 2 oxygen. And if I need to regain 4 oxygen per tick, but if the player is in water, the player will actually only regain 3 oxygen.