Jump to content

FoxBox

Members
  • Posts

    20
  • Joined

  • Last visited

Posts posted by FoxBox

  1. 47 minutes ago, warjort said:

    If the block is in the server's spawn chunks then yes.

    Those are the chunks where the player initially spawns in the overworld and are always loaded.

     

    Otherwise, you are maybe force loading chunks somehow. e.g. using Level.getBlockState() without first checking Level.isLoaded(BlockPos) ?

    Trying to get BlockState or BlockEntity from Level force chunks to be loaded? I didn't know it, thanks.

  2. Is it normal that my BlockEntity keeps ticking even if it is on a chunk that is out of the player's view? (even if I teleport more than 10000 blocks away, the entity will continue to process ticks (at least from the server side. I also get true when calling Level#isLoadedChunk)).

     

    I'm not sure if I should look for any problems in the code until I'm convinced that this is incorrect behavior.

  3. 23 minutes ago, Fluffs said:

    I'm not sure if this is the correct place to ask but recently we started up a server in aternos using the new paying/credit system and we added mods and it seems to keep crashing, I'm not very good at reading errors and seeing which mod is causing the error 

    Thank you in advance for anybody who stops by and reads<3
    Here are the logs:
    https://mclo.gs/W99Rk18

    Immersive Portals mixin fatal error, submit a crash log to the mod developer.

  4. What is the best way to handle the motion of a custom vehicle extended from Entity? At the moment, the processing on both sides (client and server with Entity$move) works best for me, however, there are small synchronization issues when movement occurs without a player-passenger. I don't think I'm using the correct way.

  5. 4 hours ago, ChampionAsh5357 said:

    Sure, that's how the treasure maps for buried treasure work. Take a look at the shipwreck_map loot table or the TreasureMapForEmeralds villager trade for an example on how to create them.

    Thanks, I figured out how to generate maps

  6. 2 hours ago, ChampionAsh5357 said:

    Currently no, MapDecoration$Type is a non-extended enum. You could attempt to make a PR for it, but that would require a lot of work since the value is essentially hardcoded into a specific texture with only bytes to represent some amount of data.

    Then another question - can I generate a map pointing to a custom structure but with a vanilla icon?

  7. On 12/9/2022 at 10:48 PM, warjort said:

    Can't say I understand the new way of doing the builtin registries in 1.19.3. 🙂

     

    But you can always register your features using json files in your src/main/resources/data

    That's probably the way most likely to be portable across versions?

    Although, Mojang still describe the new worldgen first introduced in 1.16 as "experimental".

     

    The only part that needs to be registered manually is the Feature, because that is code.

     

    e.g. vanilla iron ore's configured and placed feature as json

    https://github.com/misode/mcmeta/blob/data/data/minecraft/worldgen/configured_feature/ore_iron.json

    https://github.com/misode/mcmeta/blob/data/data/minecraft/worldgen/placed_feature/ore_iron_middle.json

    Thanks, now I've figured it out, ConfiguredFeature and PlacedFeature have indeed been moved to the datapack files

  8. I'm trying to add features to a biome via a datapack, but for a long time I can't figure out how to register ConfiguredFeature and PlacedFeature after the last update...

    DifferedRegister has only FEATURES key, and the old way (as in 1.19.2) to register a PlacedFeature does not work, because the registration methods in PlacementUtils have been significantly changed and I don’t understand if it’s possible to use them at all now.

    How should I register ConfiguredFeature and PlacedFeature now? T_T

  9. 9 hours ago, warjort said:

    Entity.isPickable() controls whether a ray trace can target your entity.

    Thanks! 

    Also, is everything okay with my registration code? What confuses me is that I have to specify the mob category for a non-living entity. I didn't find any other way to register, only EntityType.Builder

  10. I'm trying to create an entity that extends Entity class. I can collide with it, but can't hit or interact with RMB. What is the problem?

     

    public class ReliquaryEntity extends Entity {
    
        public ReliquaryEntity(PlayMessages.SpawnEntity message, Level level) {
            this(LumecoreMod.Entities.RELIQUARY.get(), level);
        }
        public ReliquaryEntity(EntityType<?> type, Level level) {
            super(type, level);
            this.blocksBuilding = true;
        }
    
        @Override
        public @NotNull Packet<?> getAddEntityPacket() {
            return NetworkHooks.getEntitySpawningPacket(this);
        }
    
        @Override
        public void defineSynchedData() {
        }
    
        @Override
        public void readAdditionalSaveData(@NotNull CompoundTag data) {
        }
    
        @Override
        public void addAdditionalSaveData(@NotNull CompoundTag data) {
        }
    
        @Override
        public boolean canBeCollidedWith() {
            return true;
        }
    
        @Override
        public boolean isPushable() {
            return true;
        }
    
        @Override
        public @NotNull InteractionResult interact(Player player, InteractionHand hand) {
            System.out.println(1);
            this.kill();
            return InteractionResult.SUCCESS;
        }
    }


     

    public static class Entities {
            public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, MODID);
    
            public static final RegistryObject<EntityType<ReliquaryEntity>> RELIQUARY = register("reliquary",
                    EntityType.Builder.<ReliquaryEntity>of(ReliquaryEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true)
                            .setTrackingRange(64).setUpdateInterval(3).fireImmune().sized(0.6f, 1.8f));
    
            private static <T extends Entity> RegistryObject<EntityType<T>> register(String name, EntityType.Builder<T> entityTypeBuilder) {
                return ENTITY_TYPES.register(name, () -> entityTypeBuilder.build(name));
            }
        }

     

  11. 44 minutes ago, warjort said:

    You need to show what you are actually doing.

    I already guessed (wrongly) once on this thread that you were doing custom rendering.

    I shouldn't have to guess.

    From that small snippet of code out of context it looks like you are calling Screen's renderTooltip() which should do it for you.

    There is something else you are doing wrong.

    @SubscribeEvent
        public static void onPlayerInventory(@NotNull ScreenEvent.InitScreenEvent.Post event) {
            if (event.getScreen() instanceof InventoryScreen inventory && event.getScreen().getMinecraft().player != null) {
                //ACTIONS
                Button.OnPress attributes = button -> event.getScreen().getMinecraft().setScreen(new ObscureBookScreen(
                        new ObscureBookMenu(1, event.getScreen().getMinecraft().player.getInventory(), new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(new BlockPos(0,0,0)) ),
                        event.getScreen().getMinecraft().player.getInventory(),
                        new TextComponent("attributes")));
                Button.OnPress factions = button -> event.getScreen().getMinecraft().setScreen(new ObscureBookScreen(
                        new ObscureBookMenu(1, event.getScreen().getMinecraft().player.getInventory(), new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(new BlockPos(0,0,0)) ),
                        event.getScreen().getMinecraft().player.getInventory(),
                        new TextComponent("factions")));
                //TOOLTIPS
                Button.OnTooltip tooltipStats = new Button.OnTooltip() {
                    public void onTooltip(Button button, PoseStack pose, int mouseX, int mouseY) {
                        List<Component> lines = new ArrayList<>();
                        for (String line : getStats().split(">"))
                            lines.add(FontHelper.component(line));
                        pose.pushPose();
                        assert Minecraft.getInstance().screen != null;
                        final float scale = Math.max(1, (float) Minecraft.getInstance().options.guiScale -
                                (ObscureAPIConfig.Client.reduceTooltips.get() ? 1F : 0)) / (float) Minecraft.getInstance().options.guiScale;
                        pose.scale(scale, scale, 1F);
                        pose.translate(mouseX, mouseY, 500F);
                        inventory.renderTooltip(pose, lines, Optional.empty(), 0, 0);
                        pose.popPose();
                    }
                    public void narrateTooltip(Consumer<Component> text) {
                        text.accept(new TextComponent(""));
                    }
                };
                Button.OnTooltip tooltipFractions = new Button.OnTooltip() {
                    public void onTooltip(@NotNull Button button, @NotNull PoseStack pose, int mouseX, int mouseY) {
                        List<Component> lines = new ArrayList<>();
                        for (String line : getFactions().split(">"))
                            lines.add(FontHelper.component(line));
                        pose.pushPose();
                        assert Minecraft.getInstance().screen != null;
                        final float scale = Math.max(1, (float) Minecraft.getInstance().options.guiScale -
                                (ObscureAPIConfig.Client.reduceTooltips.get() ? 1F : 0)) / (float) Minecraft.getInstance().options.guiScale;
                        pose.translate(mouseX, mouseY, 0F);
                        pose.scale(scale, scale, 1F);
                        inventory.renderTooltip(pose, lines, Optional.empty(), 0, 0);
                        pose.popPose();
                    }
                    public void narrateTooltip(Consumer<Component> text) {
                        text.accept(new TextComponent(""));
                    }
                };
                final int width = 20;
                final int height = 20;
                event.addListener(new ImageButton(0, 0, width, height,0, 0, 20, BUTTONS_LOCATION, 200, 200, attributes, tooltipStats, new TextComponent("")) {
                    @Override
                    public void renderButton(PoseStack pose, int mouseX, int mouseY, float partialTicks) {
                        assert Minecraft.getInstance().screen != null;
                        final int posX = Math.max(16, Math.min(Minecraft.getInstance().screen.width - 16,
                                (inventory.getGuiLeft() - width / 2) + 162 + ObscureAPIConfig.Client.buttonsOffsetX.get()));
                        final int posY = Math.max(16, Math.min(Minecraft.getInstance().screen.width - 16,
                                (Minecraft.getInstance().screen.height / 2 - height / 2) - 96 + ObscureAPIConfig.Client.buttonsOffsetY.get()));
                        this.x = posX;
                        this.y = posY;
                        super.renderButton(pose, mouseX, mouseY, partialTicks);
                    }
                });
                event.addListener(new ImageButton(0, 0, width, height,20, 0, 20, BUTTONS_LOCATION, 200, 200, factions, tooltipFractions, new TextComponent("")) {
                    @Override
                    public void renderButton(PoseStack pose, int mouseX, int mouseY, float partialTicks) {
                        assert Minecraft.getInstance().screen != null;
                        final int posX = Math.max(16, Math.min(Minecraft.getInstance().screen.width - 16,
                                (inventory.getGuiLeft() - width / 2) + 140 + ObscureAPIConfig.Client.buttonsOffsetX.get()));
                        final int posY = Math.max(16, Math.min(Minecraft.getInstance().screen.width - 16,
                                (Minecraft.getInstance().screen.height / 2 - height / 2) - 96 + ObscureAPIConfig.Client.buttonsOffsetY.get()));
                        this.x = posX;
                        this.y = posY;
                        super.renderButton(pose, mouseX, mouseY, partialTicks);
                    }
                });
            }
        }

     

  12. 49 minutes ago, warjort said:

    GUI screens are actually 3d in minecraft. The z direction is the distance out of the screen.

    Look at how the class Screen handles tool tips by both translating the z co-ord of the PoseStack and changing ItemRenderer.blitOffset which controls the same thing for the drawing items.

    Note how it uses +400 in renderTooltipInternal() and +200 in ItemRender.renderGuiItemDecorations() - the latter being things like the damage bar.

    How exactly can I move the tooltip closer? Nothing changes when I move the PoseStack before the tooltip renders until the tooltip goes out of the camera...

    pose.pushPose();

    pose.translate(mouseX, mouseY, 500F);

    inventory.renderTooltip(pose, lines, Optional.empty(), 0, 0);

    pose.popPose();

  13. I tried to do it like this, but with shaders the animations are 2x faster..

    private static long LAST_TIME = 0;
    public static float DELTA_TIME = 0;

    @SubscribeEvent
    public static void onRenderTick(TickEvent.RenderTickEvent event) {
            if (event.phase == TickEvent.Phase.START) {
                final long time = Util.getNanos();
                DELTA_TIME = (time - LAST_TIME) / 16666666F;
                LAST_TIME = time;
            }
    }

  14. How to get DeltaTime variable?  I tried to take one from the Minecraft instance and multiply by 3 (because the default is not 60 but 20 fps). This works, except that with shaders the variable becomes several times larger and the animations become too fast.

×
×
  • Create New...

Important Information

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