Jump to content

Dzuchun

Members
  • Posts

    98
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Dzuchun

  1. Nope, same render and tick methods as everywhere, except handling dancing near jukebox
  2. Here You are: https://youtu.be/gZ-8F94UT7k he uses BufferBuilder for rendering TE, but same can be done anywhere, you only need to accuire a correct BufferBuilder. Of course, it's not complete guide, and someone may propose better one, would be gracefull, too.
  3. I think, this is rendered as gui. So probably you need to subscribe on RenderGameOverlayEvent, but instead use Pre subclass, if you need to be behind the actual gui (not sure). Here is my code example: @SubscribeEvent public static void drawManaBar(RenderGameOverlayEvent.Post event) { if (event.getType().equals(ElementType.HEALTH)) { if (minecraft == null) { minecraft = Minecraft.getInstance(); } if (!Minecraft.isGuiEnabled()) { return; } if (minecraft.world == null) { return; } minecraft.getTextureManager().bindTexture(TestMod.MANA_BAR); RenderSystem.pushTextureAttributes(); RenderSystem.enableAlphaTest(); //I experimented with these a lot, not sure it works now as intended. fullPartial = getCurrentMana()/getMaxMana(); //Not sure this works well, but it's the main idea. bufferbuilder = Tessellator.getInstance().getBuffer(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); //Here is actual render code: //Rendering empty part bufferbuilder.pos(80f, 20f, 0).tex(0f, 0f).endVertex(); bufferbuilder.pos(120f, 20f, 0).tex(0.5f, 0f).endVertex(); bufferbuilder.pos(120f, 20f + (1-fullPartial) * 80f, 0).tex(0.5f, 1-fullPartial).endVertex(); bufferbuilder.pos(80f, 20f + (1-fullPartial) * 80f, 0).tex(0f, 1-fullPartial).endVertex(); //Rendering full part bufferbuilder.pos(80f, 20f + (1-fullPartial) * 80f, 0).tex(0.5f, 1-fullPartial).endVertex(); bufferbuilder.pos(120f, 20f + (1-fullPartial) * 80f, 0).tex(1f, 1-fullPartial).endVertex(); bufferbuilder.pos(120f, 100f, 0).tex(1f, 1).endVertex(); bufferbuilder.pos(80f, 100f, 0).tex(0.5f, 1).endVertex(); bufferbuilder.finishDrawing(); WorldVertexBufferUploader.draw(bufferbuilder); RenderSystem.disableAlphaTest(); RenderSystem.popAttributes(); minecraft.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION); //I'm using .Post event, but anyway gui breaks, if you won's do that. } } Also you may look at other ElementType instances and find HELMET one there. I suspect, that's what you need. You won't find any mention about rendering at pumpkin Block/Item instance, because, I believe, render is made through subscribing to event, so actual render code can be anywhere.
  4. You may have a log limit in your IDE or terminal. You should search for some messages like "something was not found at ...". If you're missing only textures, but the models are correct (in inventory you can actually see something block-shaped, not plane missing-texture; in-world stairs are actually stars, but with missing texture) then most likely you don't have textures at all, or placed them in wrong directory, otherwise - same applies to models and blockstates. For any precise help, you should post a full log.
  5. Wut? You mean, extend it? Generate another feature near randomly generated? Here is a class of my test structure: public class TestStructure extends ScatteredStructure<NoFeatureConfig>{ private static final int seedModifier = 2521523; private static final Random random = new Random(seedModifier); public TestStructure(Function<Dynamic<?>, ? extends NoFeatureConfig> configFactoryIn) { super(configFactoryIn); } @Override protected int getSeedModifier() { return seedModifier; } @Override public IStartFactory getStartFactory() { // TODO Auto-generated method stub return TestStructure.Start::new; } @Override public String getStructureName() { // TODO Auto-generated method stub return TestMod.TEST_STRUCTURE_PIECE_LOCATION.toString(); } @Override public int getSize() { return 1; } public class Start extends StructureStart { public Start(Structure<?> structIn, int int_1, int int_2, MutableBoundingBox mutableBB, int int_3, long long_1) { super(structIn, int_1, int_2, mutableBB, int_3, long_1); } @Override public void init(ChunkGenerator<?> generator, TemplateManager templateManagerIn, int chunkX, int chunkZ, Biome biomeIn) { int worldX = chunkX * 16; int worldZ = chunkZ * 16; BlockPos blockpos = new BlockPos(worldX + random.nextInt(15), 0, worldZ + random.nextInt(15)); this.components.add(new TestStructurePiece(templateManagerIn, TestMod.TEST_STRUCTURE_PIECE_LOCATION, blockpos, Rotation.randomRotation(random), 1)); this.recalculateStructureSize(); } } } (TestStructurePiece is a separate class, extending TemplateStructurePiece) Take a look at init(....) method of Start subclass. I suspect, structure may consist of multiple pieces, that can be additionaly configured, rotated and placed. Here is TestStructurePiece class: public class TestStructurePiece extends TemplateStructurePiece { public TestStructurePiece(TemplateManager templateMng, CompoundNBT nbt) { super(TestMod.TEST_STRUCTURE_PIECE, nbt); this.setupTemplate(templateMng); } public TestStructurePiece(TemplateManager templateMgr, ResourceLocation resLoc, BlockPos blockPos, Rotation rot, int offsetY) { super(TestMod.TEST_STRUCTURE_PIECE, 0); this.templatePosition = new BlockPos(blockPos.getX(), blockPos.getY() - offsetY, blockPos.getZ()); this.setupTemplate(templateMgr); } private void setupTemplate(TemplateManager templateMgr) { Template template = templateMgr.getTemplateDefaulted(TestMod.TEST_STRUCTURE_PIECE_LOCATION); PlacementSettings placementsettings = (new PlacementSettings()) .setRotation(Rotation.NONE) .setMirror(Mirror.NONE) .setCenterOffset(BlockPos.ZERO) .addProcessor(BlockIgnoreStructureProcessor.STRUCTURE_BLOCK); this.setup(template, this.templatePosition, placementsettings); } @Override public boolean func_225577_a_(IWorld worldIn, ChunkGenerator<?> chunkGenIn, Random rand, MutableBoundingBox mutableBB, ChunkPos chunkPos) { PlacementSettings placementsettings = (new PlacementSettings()).setRotation(Rotation.NONE) .setMirror(Mirror.NONE).setCenterOffset(BlockPos.ZERO) .addProcessor(BlockIgnoreStructureProcessor.STRUCTURE_BLOCK); BlockPos blockpos1 = this.templatePosition .add(Template.transformedBlockPos(placementsettings, new BlockPos(3, 0, 0))); int strucHeight = worldIn.getHeight(Heightmap.Type.WORLD_SURFACE_WG, blockpos1.getX(), blockpos1.getZ()); this.templatePosition = this.templatePosition.add(0, strucHeight, 0); boolean superReturn = super.func_225577_a_(worldIn, chunkGenIn, rand, mutableBB, chunkPos); return superReturn; } @Override protected void handleDataMarker(String function, BlockPos pos, IWorld worldIn, Random rand, MutableBoundingBox sbb) { // No need } } Of course, I mostly copied it from some guide, and I don't really remember where from... Yeah, TestMod.TEST_STRUCTURE_PIECE declaration: TEST_STRUCTURE_PIECE = Registry.register(Registry.STRUCTURE_PIECE, TEST_STRUCTURE_PIECE_LOCATION, TestStructurePiece::new); And "..._LOCATION" is a RecourceLocation of structure file (.nbt one)
  6. Looks like you're missing StartupCommon class registration for events. You may try to put @Mod.EventBusSubscriber(bus = Bus.MOD, modid = YOUR_MOD_ID) before class declaration. Make sure that StartupCommon class is initialized - execute any method in it.
  7. What exactly happened? You can find all possible methods at net.minecraft.item.Item, in Properties inner class. Just looking through them bring me idea, that you need to specify maxStackSize or defaultMaxDamage. Anyway, describe your problem
  8. I'm not sure, but I heard that, since, like, minecraft 1.8 biome spawning respects temperature and humidity. So now taiga can't be spawned next to a desert, etc. You may try to set humidity less than in desert and a temperature higher than in it, so minecraft will be allowed to spawn a biome only in a center of big desert. But I can't figure out, how would you achieve a guaranteed single lake generation in a biome, so I'd choose to create a feature.
  9. Output looks all good, I got same for Eclipse, so, I think, your problem is in how you use IDE.
  10. I feel like these things are defined by item's model, so take a look on them - https://minecraft.gamepedia.com/Model#Item_models. But I'm not sure it is possible to do what you want.
  11. What do you mean by thickness?
  12. Now I achieved the end of line: every tick on server, entity sends a custom packet to all tracking clients. Clientside entity instance has separate variables for storing previous tick position and real position change during last tick, for me to use them in rendering. And move vector looks like this: Vector3d move = entityIn.getRealMotion().scale(partialTicks).add(entityIn.getRealPos().add(entityIn.getPositionVec().scale(-1))); So, I calculate position change due to moving for last partialTiks (getRealMotion() returns REAL motion I calculated with sending packets) AND add to it difference between my entity position and wherever minecraft thinks entity is. This means, that after matrixStackIn.translate(move.x, move.y, move.z) I am at my coordinates (that were certainly unchanged during last tick) + offset from MY personal calculated speed (that couldn't be changed too). And in the game, like, 70% of the time it looks flawless, but then entity starts jumping over the movement direction. Looks like minecraft changes coordinates of the entity during rendering, so even with such a complicated code you can't adapt for it. NOTE: No, I can't use Entity.lastTickPos- variables, because they are updated, like, 6-7 times per second, or once in 3 ticks.
  13. The only difference I can see between your and mine code, that worked, is: I deleted TileEntity(final TileEntityType<?> tileEntityTypeIn) constructor from my TE class. And then I used super(TestMod.TEST_TILE_ENTITY_REGISTRY_OBJECT.get()); (in my case) in constructor with no arguments.
  14. Previous time I've tried to make this mod, I tried to start with this. the problem is, this event is not called, if you're using 1st perspective view (default one). But I want for player to see entity from any perspective. Of cource, I solved this problem with overriding one more event - something about GUI. But this requires twice as much render methods, and separate matrixStack transformations - GUI matrix at start is bound to camera pos and rotation, when RenderPlayerEvent just to PlayerEntity's position. But yeah, that rendered without any shaking and so on. How would I get it? Should I store last tick pos separately, because It looks like Entity.lastTickPos- variables store position at begining of current tick. Actually, I don't really get how Entity.prevPos- and Entity.lastTickPos- differ - as I can see, the only place they are reassigned is Entity#forceSetPosition(double x, double y, double z), and here is reassignment: this.prevPosX = x; this.prevPosY = y; this.prevPosZ = z; this.lastTickPosX = x; this.lastTickPosY = y; this.lastTickPosZ = z; ... Isn't it what I've done here?: Or again, should I calculate speed by myself? How would I do that? Also, using owner's motion gets less jumping than using it's own motion, I suspect no matter what it's motion is always 0, despite I'm calling MyEntity.setMotion(owner.getMotion()); every tick on both client and server. EDIT: And where can I see minecraft doing this things? None of renderers are handling that, they're just using matrixStack to render what they need, not even calling entity#getMotion(). Should I use some event?
  15. I'm definitely doing something wrong, because even setting constant motion to entity (gravitation was asked to be disabled both on client and server) results jumps with a little shaking. WHAT SHOULD BE DONE, TO MOVE ENTITY SMOOTH?? (I'm really desprate)
  16. Yep, I think so too, and now I tried to get speed with: Vector3d ownerSpeed = new Vector3d(owner_.getPosX() - owner_.lastTickPosX, owner_.getPosY() - owner_.lastTickPosY, owner_.getPosZ() - owner_.lastTickPosZ); and looks like it works correctly. So i determined move vector as: move = ownerSpeed.scale(partialTicks); And translated matrixStack with it: matrixStackIn.translate(move.x, move.y, move.z); (Of course, I make pushes and pops) But entity still renders as hell, am I missing something? UPDATE: I realized, that ownerSpeed vector actually determines player's movement during current partialTicks time. So I removed scale method and assigned directly move=ownerSpeed. Result is a bit better now.
  17. If you're talking about AI, looking at net.minecraft.entity.ai.brain.schedule.Schedule class may help you. Can't help more.
  18. Right to the question: how minecraft achieves smooth entity rendering? As far as I know and experimented with Logging of entity's position in render method, it is updated, like, 20 times per second, which equals to 1 tick.(No, it isn't!) So it seems like while rendering, minecraft uses entity's speed to determine where it should be, or what? The problem is, while standing still, player's getMotion().toString() returns (0.0, -0.0784000015258789, 0.0). Is this really gives velocity? Is -0.0784... a deviation? If so, what is a unit velocity here? 1 block/tick? 1 px/tick? (Here by px i mean 1/16 block) Ok, here is the problem I met. I need to render an entity at a fixed position for the player, as if it is a part of it. Here is my render method in renderer class: public void render(MyEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) { if (entityIn.getOwner() != null) { PlayerEntity owner = entityIn.world.getPlayerByUuid(entityIn.getOwner().getUniqueID()); //Will optimize that later, nevermind. Owner is a player I should stick to. // entityIn.setRawPosition(owner.getPosX(), owner.getPosY(), owner.getPosZ()); (first try to stick entity to player, resulted 20 times per second jumping) LOG.info("Entity's position: {}", entityIn.getPositionVec().toString()); //Used to see, that position updates every 3 frames with 60FPS. matrixStackIn.push(); // Vector3d move = owner.getPositionVec().add(entityIn.getPositionVec().scale(-1)).add(owner.getMotion().scale(partialTicks-1f)); //Uses player motion, so while standing still, entity vibrates. I'm sure it's caused my motion, because without last component entity stops vibrating. // Vector3d move = owner.getMotion().scale(partialTicks); //Upwards you may see other attempts to achieve a goal. None worked. Vector3d move = owner.getPositionVec().add(entityIn.getPositionVec().scale(-1)); // matrixStackIn.translate(move.x+1D, move.y, move.z); //Tried to move 1 block, to see if it works //TODO definitely should find a better way for that! LOG.info("Moving matrix a bit: {}, owner's motion: {}", move.toString(), owner.getMotion().toString()); //This is what outputs that strange -0.07... motion. model.setRotationAngles(entityIn, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F); // TODO describe (does nothing yet, will describe after achieving smooth) IVertexBuilder ivertexbuilder = bufferIn.getBuffer(model.getRenderType(this.getEntityTexture(entityIn))); //Copied form boat renderer, as far as I remember... model.render(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); matrixStackIn.pop(); } else { LOG.info("Owner is null, not rendering"); } super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn); } Also, I included raw this.setPositionAndUpdate(owner.getPosX(), owner.getPosY(), owner.getPosZ()); to entity's tick() method, and I'm sure it's executed on both client and server (Both Server and Render thread are logging message). By entity in the world start jumping a bit along player's moving direction, as you start to move. Jump distances are proportional to player's velocity. Obviously, this indicates low position update rate, because while using 20FPS render everything works as I'd like to. Would be graceful for any help about all that, thank you.
  19. For a while, I`m trying to add a custom villager house to a village house pool, so it could be generated in villages as vanilla houses do. I looked through a vanilla code, this forum, googled it, checked some other mod sources, and actually all I've found about that is to: (copy+paste+renaming from net.minecraft.world.gen.feature.structure.PlainsVillagePools) JigsawManager.REGISTRY.register(new JigsawPattern( new ResourceLocation("village/plains/houses"), new ResourceLocation("village/plains/terminators"), ImmutableList.of( new Pair<>(new SingleJigsawPiece("testmod:test_structure"), 10) //10 is to increase probabillity, as I've understood related code ), PlacementBehaviour.RIGID )); , invoked within setupWorldGen: (actually, in a static initializer of a class, whose method is called in setupWorldGen; I`m sure the code is executed, due to my special log message sent) @SubscribeEvent public static void commonSetup(final FMLCommonSetupEvent event) { DeferredWorkQueue.runLater( ()-> setupWorldGen()); } with valid NBT structure file stored at data/testmod/structures. But I couldn't find my house within newly-generated villages. This structure includes single Jigsaw block, configured as one in vanilla structure village/plains/houses/plains_small_house_1 except "Turns into" value, which i left as minecraft:air. Structure file is definitely valid, because I succeed it`s generation as a ScatteredStructure randomly in the world. Actually, the question is: what is actually done to properly add JigsawPiece to a pool? I'd be graceful for any help here or useful links to guides, documentations, etc. Sadly, provision of a full source code would be very uncultured, because It`s my first mod, so a source code looks like hell. (But if You want to check it out - here it is) I`m sorry for any misunderstanding and mistakes, due to I`m very new to forge. Thanks again for help.
×
×
  • Create New...

Important Information

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