Jump to content

Meldexun

Members
  • Posts

    184
  • Joined

  • Last visited

Everything posted by Meldexun

  1. Ok, i'm sorry that really is a bad description... So the GUI shows up with all the normal inventory slots of the player and i can use them normally. But when i hover over my extra slot it makes that white overlay. So the slot is there but i can't put any item in it. What other code do you want to see? I have also thought that but when i change the ID to 0 my extra slot is just a copy of the vanilla inventory slot with the ID 0.
  2. I made an entity which can be ridden. But when the player turns to the left or to the right to body of the player isn't fixed to the rotation of the head/entity which is ridden. How can i achieve that the body of a player is rotating the same. You can compare a Minecart and a Boat from vanilla. With a boat the rotation of the body of the player is fixed.
  3. Ok i now added a model to my entity and the movement is looking good now. I don't really understand why it's working with a real model instead of such a white cube.
  4. Thanks for the explanation. But i now tried to set the frequency higher/lower with updates true/false with no difference. I can change that. Yes my code is often messy and buggy with the server/client side stuff. I usually clean that when my stuff works probably. Or when i forget that i normally try my mod in singleplayer and on a dedicated server and then when something crashes i go and clean the code. (Thanks anyway) Edit: Also the entity moves a bit faster than the player who rides it.
  5. I'm extending my class the Entity class directly so i have to call it myself since it's not called in the Entity class. But that's no my issue anymore. Now i have this code to update the movement: @Override public void onUpdate() { super.onUpdate(); if (this.world.isRemote) { if (this.getControllingPassenger() instanceof EntityPlayer) { GameSettings settings = Minecraft.getMinecraft().gameSettings; this.inputForward = settings.keyBindForward.isKeyDown(); this.inputRight = settings.keyBindRight.isKeyDown(); this.inputBack = settings.keyBindBack.isKeyDown(); this.inputLeft = settings.keyBindLeft.isKeyDown(); this.inputUp = settings.keyBindJump.isKeyDown(); this.inputDown = settings.keyBindSneak.isKeyDown(); } else { this.inputForward = false; this.inputRight = false; this.inputBack = false; this.inputLeft = false; this.inputUp = false; this.inputDown = false; } this.updateRotation(); this.updateMotion(); this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); } } Now my entity seems to move correctly. But the problem now is that the movement looks laggy. So the movement of the player who is riding the entity is smooth similar to movement with a boat. But the entity is a lagging behind and it's movement is jerkily. Also it's a bit faster than the player. Here i registered my entity because i read something about velocity updates but i don't really know where they are defined (i think it has something to do with the tracker but i don't know excatly what that does either): public static final EntityEntry ENTITY_ENTRY_C_ENTITY = createEntityEntry(EntityCEntity.class, "entity_c_entity", 0xFFFFFF, 0xAAAAAA); @SubscribeEvent public static void registerTileEntities(RegistryEvent.Register<EntityEntry> event) { event.getRegistry().registerAll( ENTITY_ENTRY_C_ENTITY ); } private static EntityEntry createEntityEntry(Class entityClass, String name, int eggCcolor1, int eggColor2) { return EntityEntryBuilder.create().entity(entityClass).id(new ResourceLocation(BetterDiving.MOD_ID, name), ID++).name(name).egg(eggCcolor1, eggColor2).tracker(64, 80, true).build(); }
  6. So i have created a custom entity which can be ridden but when i ride the entity it stops moving and it won't move in any way. That's my entity class: public boolean inputForward = false; public boolean inputRight = false; public boolean inputBack = false; public boolean inputLeft = false; public boolean inputUp = false; public boolean inputDown = false; private int debug = 0; public EntitySeamoth(World worldIn) { super(worldIn); setSize(1.0f, 1.0f); isImmuneToFire = true; } @Override public boolean canBeCollidedWith() { return !this.isDead; } @Override public boolean canBePushed() { return true; } @Override protected boolean canBeRidden(Entity entityIn) { return true; } @Override public boolean canRiderInteract() { return true; } @Override public boolean shouldDismountInWater(Entity rider) { return false; } @Override public double getMountedYOffset() { return 0.0d; } @Override public boolean canPassengerSteer() { return getControllingPassenger() instanceof EntityPlayer; } @Override public boolean processInitialInteract(EntityPlayer player, EnumHand hand) { if (player.isSneaking()) { return false; } else { if (!this.world.isRemote) { player.startRiding(this); } return true; } } @Override public AxisAlignedBB getCollisionBox(Entity entityIn) { return getEntityBoundingBox(); } @Override public boolean attackEntityFrom(DamageSource source, float amount) { if (source.getTrueSource() instanceof EntityPlayer) { this.setDead(); return true; } return false; } @Override public Entity getControllingPassenger() { List<Entity> list = this.getPassengers(); return list.isEmpty() ? null : (Entity) list.get(0); } @Override public AxisAlignedBB getCollisionBoundingBox() { return null; } @Override public void onUpdate() { super.onUpdate(); if (this.world.isRemote) { BetterDiving.CONNECTION.sendToServer(new PacketVehicleKeyPress()); } this.updateRotation(); this.updateMotion(); this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); } public void updateRotation() { if (this.getControllingPassenger() instanceof EntityPlayer) { this.rotationYaw = MathHelper.wrapDegrees(this.getControllingPassenger().rotationYaw); this.rotationPitch = this.getControllingPassenger().rotationPitch; } } public void updateMotion() { double rotX = -MathHelper.sin(this.rotationYaw * 0.017453292F); double rotZ = MathHelper.cos(this.rotationYaw * 0.017453292F); float fakeRotationPitch = this.rotationPitch; double speed = 0.02d; if (inputDown && !inputUp) { if (inputForward) { fakeRotationPitch = (fakeRotationPitch + 90f) / 2f; } else if (inputBack) { fakeRotationPitch = (fakeRotationPitch - 90f) / 2f; } else { this.motionY -= speed; } } if (inputUp && !inputDown) { if (inputForward) { fakeRotationPitch = (fakeRotationPitch - 90f) / 2f; } else if (inputBack) { fakeRotationPitch = (fakeRotationPitch + 90f) / 2f; } else { this.motionY += speed; } } double lookVecX = rotX * MathHelper.cos(fakeRotationPitch * 0.017453292F); double lookVecY = -MathHelper.sin(fakeRotationPitch * 0.017453292F); double lookVecZ = rotZ * MathHelper.cos(fakeRotationPitch * 0.017453292F); if (inputForward) { this.motionX += speed * lookVecX; this.motionY += speed * lookVecY; this.motionZ += speed * lookVecZ; } if (inputBack) { this.motionX -= speed * lookVecX; this.motionY -= speed * lookVecY; this.motionZ -= speed * lookVecZ; } if (inputLeft) { this.motionX += speed * rotZ; this.motionZ += speed * -rotX; } if (inputRight) { this.motionX += speed * -rotZ; this.motionZ += speed * rotZ; } this.motionX *= 0.90d; if (this.motionX < 0.0001d) this.motionX = 0; this.motionY *= 0.90d; if (this.motionY < 0.0001d) this.motionY = 0; this.motionZ *= 0.90d; if (this.motionZ < 0.0001d) this.motionZ = 0; } @Override protected void entityInit() { } @Override protected void readEntityFromNBT(NBTTagCompound compound) { } @Override protected void writeEntityToNBT(NBTTagCompound compound) { } The update methods are fine because i tried this without success: @Override public void onUpdate() { super.onUpdate(); this.motionY += 0.001d; this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); } I seem to miss something...
  7. I want to create an extra inventory slot for the player. But i can't use the slot when the GUI is opened. I think it has to do with how i use the capability. Also I'm not that much familiar with capabilities . Provider: Attach Capabilies: Container: Any help is appreciated.
  8. I have created a config with the @Config annotation but the categories always remain unsorted. Is there a way to sort them? Issue:
  9. How would i check if a player has small arms. Because my custom armor isn't moving properly when a player uses a skin with small arms.
  10. This parameter does not exist in the onBlockActivated method.
  11. The onBlockActivated method exists in the Block class. So extending your class with Block should work. Maybe post how you tried overriding the method in your class.
  12. Now i got this: private static final Gson GSON_INSTANCE = (new GsonBuilder()).registerTypeAdapter(RandomValueRange.class, new RandomValueRange.Serializer()).registerTypeAdapter(LootPool.class, new LootPool.Serializer()).registerTypeAdapter(LootTable.class, new LootTable.Serializer()).registerTypeHierarchyAdapter(LootEntry.class, new LootEntry.Serializer()).registerTypeHierarchyAdapter(LootFunction.class, new LootFunctionManager.Serializer()).registerTypeHierarchyAdapter(LootCondition.class, new LootConditionManager.Serializer()).registerTypeHierarchyAdapter(LootContext.EntityTarget.class, new LootContext.EntityTarget.Serializer()).create(); @SubscribeEvent public static void loadLootTable(LootTableLoadEvent event) { if (event.getName() == TileEntityChestArmor.LOOT_TABLE) { File f = new File(CrystalicVoid.configFolderLoot + "/chest_armor.json"); if (f.exists() && f.isFile()) { String s = null; try { s = Files.toString(f, StandardCharsets.UTF_8); } catch (IOException e) { e.printStackTrace(); } event.setTable(GSON_INSTANCE.fromJson(s, LootTable.class)); } } But it just says Invalid call stack, could not grab json context! The json loot table that i try to load is fine. So someone has any idea?
  13. The event seems to work but i don't know how i can get a LootTable from a String. I mean i have the content of the loot_table.json file in the config folder as String but how can i generate a LootTable out of it?
  14. I want to generate a chest with my loot table. This works fine when i use a loot table from my assets. But is there a way to spawn a chest with a loot table from the config folder? Edit: I just found the LootTableLoadEvent. Could i just pass the loot table from the config folder when the loot table from my mod is loaded?
  15. Thank you. I tried to pass something likesrc/main/resources/foo/bar/baz.png. Now it works.
  16. I always get null returned when using one of these methods. I have my CrystalicVoid Class in src/main/java/meldexun/crystalicVoid and i want to get a file in src/main/resources/assets/crystalicVoid. When using CrystalicVoid.class.getResource("") it gives me the path to that class. I just don't know how to use the method properly. (also changed the \)
  17. How could i copy a file from my assets to the config folder? I currently have this in FMLPreInitializationEvent: File source = new File(/*assets folder of my mod*/, "tower.nbt"); File destination = new File(event.getModConfigurationDirectory().getPath() + "\\CrystalicVoidStructures", "tower.nbt"); try { Files.copy(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { e.printStackTrace(); } But i don't know how to get the file in my assets folder.
  18. It looks like i have to open the GUI server side. I'm using a GuiHandler and when calling player#openGui at the end of my packet handler on the client side it seems to create a broken gui. So what i now try to do is: When the block is right clicked on server side it will send a packet to the client which tells him to update the tile entity with the data sent from the server. As an answer the client then sends a packet which requests the server to open the gui. When received on the server it checks if the player is in creative mode and then opens the gui.
  19. I thought vanilla sends more packets. But that doesn't matter. You are right. I will change it so it only sends a packet from server to client when the block is right clicked. Often opening the gui will cause much traffic but when not opening the gui it causes zero traffic. Seems the best option.
  20. But then it always sends a packet from server to the client when the block is right clicked. When you right click the block it 3 times in a short period of time it sends 3 packets. Currently it sends only a packet when the tile entity is loaded. So it sends just 1 packet. I don't understand how a new second packet solves this issue. I could check when the packet is received server side if the sender is in creative mode.
  21. I need the data for opening the gui. It should display the data from the server. I have read that i should create my own packet and handler to sync my tile entity most efficiently. And my tile entity should just sync when someone interactes with it. I think vanilla always syncs the tile entities and that would create much network traffic (i just think so. Correct me when i'm wrong) It should be kind of cheating. The block is creative only and the client should say "This is the new data, use it from now on"
×
×
  • Create New...

Important Information

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