• Recently Browsing

    No registered users viewing this page.

  • Posts

    • 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. 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.
    • 1.7 is not supported on this forum. Please update to a modern version of Minecraft to receive support.
    • There seems to be a lot of conflicting information out there on creating capabilities. On what classes/interfaces you need, what needs to implement what, whether serializeNBT should call writeNBT or the other way around, etc. I understand there's probably a lot of ways to create a capability, but I just want the simplest possible thing. I have a capability which I only want 1 item to use. It'll be able to store an EntityType, and serialize it into a String or deserialize it from a String when needed. Right now I have 2 classes, Pet and PetCapability: public class Pet implements INBTSerializable<CompoundNBT> { private EntityType<?> entityType; public Pet() { this.entityType = null; } @Override public CompoundNBT serializeNBT() { CompoundNBT result = new CompoundNBT(); String entityTypeString = EntityType.getKey(this.entityType).toString(); result.putString("entityType", entityTypeString); return result; } @Override public void deserializeNBT(CompoundNBT nbt) { if (nbt.contains("entityType")) { String entityTypeString = nbt.getString("entityType"); this.entityType = EntityType.byKey(entityTypeString).get(); } } } public class PetCapability { @CapabilityInject(Pet.class) public static Capability<Pet> CAPABILITY_PET = null; public static void register() { CapabilityManager.INSTANCE.register(Pet.class, new PetStorage(), () -> new Pet()); } public static class PetStorage implements IStorage<Pet> { @Override public void readNBT(Capability<Pet> capability, Pet instance, Direction side, INBT nbt) { instance.deserializeNBT((CompoundNBT) nbt); } @Override public INBT writeNBT(Capability<Pet> capability, Pet instance, Direction side) { return instance.serializeNBT(); } } } Where do I go from here? I need a provider to attach to capability to the item right? Are my classes ok? Am I doing something where I shouldn't be doing it? Thanks!
    • I get an error message saying I am missing blocks and items although I am not? I have all the same mods. The engine is thermos 1614. fml-server-latest.log
    • I followed a tutorial on how to make custom potions for a minecraft mod, however, this was before deferred registries were used frequently. So I pieced together things from regular registries and deferred registries, however, I am having trouble. All but one of my custom recipes that use the Awkward Potion as a base results in an uncraftable potion, even though I can see, obtain, and use my custom potions from the creative tabs. The recipes that use my custom potions don't work at all.   I think this is all because of the way I inputted my custom potions into the recipes, because the one recipe that uses all vanilla items works fine (an awkward potion and an emerald, creating a Potion of Luck). Am I missing something? Am I way off as to where the problem lies? My main class: package com.oberonpuck.minormagicks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.oberonpuck.minormagicks.util.ItemRegistryHandler; import com.oberonpuck.minormagicks.util.PotionRegistryHandler; // The value here should match an entry in the META-INF/mods.toml file @Mod("minormagicks") public class MinorMagicks { private static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "minormagicks"; public MinorMagicks() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); ItemRegistryHandler.init(); PotionRegistryHandler.init(); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event){} private void doClientStuff(final FMLClientSetupEvent event){} }   My potion class for registering potions and recipes: package com.oberonpuck.minormagicks.util; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.function.Supplier; import com.oberonpuck.minormagicks.MinorMagicks; import com.oberonpuck.minormagicks.items.ItemBase; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectType; import net.minecraft.potion.Effects; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionBrewing; import net.minecraft.potion.Potions; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ObjectHolder; public class PotionRegistryHandler { public static final DeferredRegister<Potion> POTIONS = DeferredRegister.create(ForgeRegistries.POTION_TYPES, MinorMagicks.MOD_ID); public static final DeferredRegister<Effect> EFFECTS = DeferredRegister.create(ForgeRegistries.POTIONS, MinorMagicks.MOD_ID); public static void init () { POTIONS.register(FMLJavaModLoadingContext.get().getModEventBus()); PotionRegistryHandler.addBrewingRecipes(); } //Potions public static final RegistryObject<Potion> HUNGER = POTIONS.register("hunger", () -> new Potion(new EffectInstance(Effects.HUNGER, 3600))); public static final RegistryObject<Potion> RESISTANCE = POTIONS.register("resistance", () -> new Potion(new EffectInstance(Effects.RESISTANCE, 3600))); public static final RegistryObject<Potion> ABSORPTION = POTIONS.register("absorption", () -> new Potion(new EffectInstance(Effects.ABSORPTION, 3600))); public static final RegistryObject<Potion> HEALTH_BOOST = POTIONS.register("health_boost", () -> new Potion(new EffectInstance(Effects.HEALTH_BOOST, 3600))); public static final RegistryObject<Potion> HASTE = POTIONS.register("haste", () -> new Potion(new EffectInstance(Effects.HASTE, 3600))); public static final RegistryObject<Potion> MINING_FATIGUE = POTIONS.register("mining_fatigue", () -> new Potion(new EffectInstance(Effects.MINING_FATIGUE, 3600))); public static final RegistryObject<Potion> NASUEA = POTIONS.register("nausea", () -> new Potion(new EffectInstance(Effects.NAUSEA, 3600))); public static final RegistryObject<Potion> BLINDNESS = POTIONS.register("blindness", () -> new Potion(new EffectInstance(Effects.BLINDNESS, 3600))); public static final RegistryObject<Potion> GLOWING = POTIONS.register("glowing", () -> new Potion(new EffectInstance(Effects.GLOWING, 3600))); public static final RegistryObject<Potion> LEVITATION = POTIONS.register("levitation", () -> new Potion(new EffectInstance(Effects.LEVITATION, 3600))); public static final RegistryObject<Potion> DOLPHINS_GRACE = POTIONS.register("dolphins_grace", () -> new Potion(new EffectInstance(Effects.DOLPHINS_GRACE, 3600))); public static final RegistryObject<Potion> UNLUCK = POTIONS.register("unluck", () -> new Potion(new EffectInstance(Effects.UNLUCK, 3600))); private static Method brewing_mixes; private static void addMix(Potion start, Item ingredient, Potion result) { if(brewing_mixes == null) { brewing_mixes = ObfuscationReflectionHelper.findMethod(PotionBrewing.class, "addMix", Potion.class, Item.class, Potion.class); brewing_mixes.setAccessible(true); } try { brewing_mixes.invoke(null, start, ingredient, result); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } } static ResourceLocation nausea = new ResourceLocation("minormagicks:nausea"); static ResourceLocation hunger = new ResourceLocation("minormagicks:hunger"); static ResourceLocation unluck = new ResourceLocation("minormagicks:unluck"); static ResourceLocation dolphins_grace = new ResourceLocation("minormagicks:dolphins_grace"); static ResourceLocation resistance = new ResourceLocation("minormagicks:resistance"); static ResourceLocation health_boost = new ResourceLocation("minormagicks:health_boost"); static ResourceLocation haste = new ResourceLocation("minormagicks:haste"); static ResourceLocation mining_fatigue = new ResourceLocation("minormagicks:mining_fatigue"); static ResourceLocation absorption = new ResourceLocation("minormagicks:absorption"); static ResourceLocation levitation = new ResourceLocation("minormagicks:levitation"); public static void addBrewingRecipes() { addMix(Potions.AWKWARD, Items.ROTTEN_FLESH, ForgeRegistries.POTION_TYPES.getValue(nausea)); addMix(ForgeRegistries.POTION_TYPES.getValue(nausea), Items.FERMENTED_SPIDER_EYE, ForgeRegistries.POTION_TYPES.getValue(hunger)); addMix(Potions.AWKWARD, Items.EMERALD, Potions.LUCK); addMix(Potions.LUCK, Items.FERMENTED_SPIDER_EYE, ForgeRegistries.POTION_TYPES.getValue(unluck)); addMix(Potions.WATER_BREATHING, Items.FERMENTED_SPIDER_EYE, ForgeRegistries.POTION_TYPES.getValue(dolphins_grace)); addMix(Potions.AWKWARD, Items.SHULKER_SHELL, ForgeRegistries.POTION_TYPES.getValue(resistance)); addMix(ForgeRegistries.POTION_TYPES.getValue(resistance), Items.FERMENTED_SPIDER_EYE, ForgeRegistries.POTION_TYPES.getValue(health_boost)); addMix(Potions.AWKWARD, Items.PRISMARINE_CRYSTALS, ForgeRegistries.POTION_TYPES.getValue(haste)); addMix(ForgeRegistries.POTION_TYPES.getValue(haste), Items.FERMENTED_SPIDER_EYE, ForgeRegistries.POTION_TYPES.getValue(mining_fatigue)); addMix(Potions.FIRE_RESISTANCE, Items.FERMENTED_SPIDER_EYE, ForgeRegistries.POTION_TYPES.getValue(absorption)); addMix(Potions.SLOW_FALLING, Items.FERMENTED_SPIDER_EYE, ForgeRegistries.POTION_TYPES.getValue(levitation)); } }  
  • Topics

  • Who's Online (See full list)