• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Okay, motions and velocity have to be handled on the client side as well. The reason why nothing happens is because you have !World#isRemote check; only the server is notified of the velocity change, the client is not, so you won't witness anything happening.   Also, use PlayerEntity###getItemStackFromSlot to check if the boots are equipped.   Lastly, you don't need to include your Mod ID in the EventBusSubscriber annotation.   P.S. was the Entity#world field removed? If not, just use PlayerEntity#world instead of PlayerEntity###getEntityWorld.
    • I wan't to put all faces and parts of block in one texture instead of putting them in separate files limited by 16x16 resolution. How can use sprite set for block that contains all textures of block? I tried to put all textures of block in one file, it threw warning that says that I broke aspect ratio of resource.  
    • Did some debugging, apparently the data I'm trying to send from the CapabilityStorage is the default value (0) for the village and clan tags, but only in the login event. Why could that be?
    • Hey. I need to sync the player's capabilities to them when they log in, respawn, etc., but the events that worked for this purpose in 1.12.2 for some reason no longer work. The capabilities just don't sync when those events happen. CapabilityStorage: public class PlayerBaseCapStorage implements IStorage<IPlayerBaseCap> { @Override public INBT writeNBT(Capability<IPlayerBaseCap> capability, IPlayerBaseCap instance, Direction side) { CompoundNBT tag = new CompoundNBT(); tag.putBoolean("firstspawn", instance.getFirstSpawn()); tag.putInt("village", instance.getVillage()); tag.putInt("clan", instance.getClan()); tag.putInt("rank", instance.getRank()); tag.putInt("level", instance.getLevel()); tag.putInt("exp", instance.getExp()); tag.putInt("chakra", instance.getChakra()); tag.putInt("maxchakra", instance.getMaxChakra()); return tag; } @Override public void readNBT(Capability<IPlayerBaseCap> capability, IPlayerBaseCap instance, Direction side, INBT nbt) { CompoundNBT tag = new CompoundNBT(); instance.setFirstSpawn(tag.getBoolean("firstspawn")); instance.setVillage(tag.getInt("village")); instance.setClan(tag.getInt("clan")); instance.setRank(tag.getInt("rank")); instance.setLevel(tag.getInt("level")); instance.setExp(tag.getInt("exp")); instance.setChakra(tag.getInt("chakra")); instance.setMaxChakra(tag.getInt("maxchakra")); } @Mod.EventBusSubscriber(modid = Main.modid) private static class EventHandler { @SubscribeEvent public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof PlayerEntity) { event.addCapability(new ResourceLocation(Main.modid, "base"), new PlayerBaseCapProvider()); } } @SubscribeEvent public static void playerClone(final PlayerEvent.Clone event) { final IPlayerBaseCap oldBaseCap = event.getOriginal().getCapability(PlayerBaseCapProvider.PLAYER_BASE_CAP).orElseThrow(() -> new RuntimeException("No player capability found!")); final IPlayerBaseCap newBaseCap = event.getPlayer().getCapability(PlayerBaseCapProvider.PLAYER_BASE_CAP).orElseThrow(() -> new RuntimeException("No player capability found!")); if (oldBaseCap != null && newBaseCap != null) { newBaseCap.setFirstSpawn(oldBaseCap.getFirstSpawn()); newBaseCap.setVillage(oldBaseCap.getVillage()); newBaseCap.setClan(oldBaseCap.getClan()); newBaseCap.setRank(oldBaseCap.getRank()); newBaseCap.setExp(oldBaseCap.getExp()); newBaseCap.setLevel(oldBaseCap.getLevel()); newBaseCap.setChakra(oldBaseCap.getChakra()); newBaseCap.setMaxChakra(oldBaseCap.getMaxChakra()); } } @SubscribeEvent public static void serverLoginEvent(final PlayerLoggedInEvent event) { PlayerEntity player = event.getPlayer(); PacketDispatcher.INSTANCE.sendTo(new PacketFirstSpawn(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); PacketDispatcher.INSTANCE.sendTo(new PacketVillageC(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); PacketDispatcher.INSTANCE.sendTo(new PacketClanC(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); if (player.getCapability(PlayerBaseCapProvider.PLAYER_BASE_CAP).orElseThrow(() -> new RuntimeException("No player capability found!")).getFirstSpawn() == true) { player.getCapability(PlayerBaseCapProvider.PLAYER_BASE_CAP).orElseThrow(() -> new RuntimeException("No player capability found!")).setFirstSpawn(false); PacketDispatcher.INSTANCE.sendTo(new PacketFirstSpawn(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); player.sendMessage(new TranslationTextComponent("msgs.firstjoin", "")); ItemStack stack = new ItemStack(ItemList.character_creation, 1); player.addItemStackToInventory(stack); } } @SubscribeEvent public static void changeDimesionEvent(final PlayerChangedDimensionEvent event) { PlayerEntity player = event.getPlayer(); PacketDispatcher.INSTANCE.sendTo(new PacketFirstSpawn(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); PacketDispatcher.INSTANCE.sendTo(new PacketVillageC(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); PacketDispatcher.INSTANCE.sendTo(new PacketClanC(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); } @SubscribeEvent public static void respawnEvent(final PlayerRespawnEvent event) { PlayerEntity player = event.getPlayer(); PacketDispatcher.INSTANCE.sendTo(new PacketFirstSpawn(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); PacketDispatcher.INSTANCE.sendTo(new PacketVillageC(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); PacketDispatcher.INSTANCE.sendTo(new PacketClanC(player), ((ServerPlayerEntity)player).connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); } } }   Packet: public class PacketFirstSpawn { private boolean data; private static PlayerEntity player; public PacketFirstSpawn() {} public PacketFirstSpawn(PlayerEntity player) { PacketFirstSpawn.player = player; IPlayerBaseCap playercap = player.getCapability(PlayerBaseCapProvider.PLAYER_BASE_CAP).orElseThrow(() -> new RuntimeException("No player capability found!")); data = playercap.getFirstSpawn(); } public static void encode(PacketFirstSpawn msg, PacketBuffer buf) { buf.writeBoolean(msg.data); } public static PacketFirstSpawn decode(PacketBuffer buf) { return new PacketFirstSpawn(player); } public static void handle(PacketFirstSpawn msg, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> { Main.proxy.handleClientBooleanPackets(0, msg.data); }); ctx.get().setPacketHandled(true); } }   Proxy: public class ClientProxy extends CommonProxy { public void handleClientBooleanPackets(int id, boolean b) { IPlayerBaseCap basecap = Minecraft.getInstance().player.getCapability(PlayerBaseCapProvider.PLAYER_BASE_CAP).orElseThrow(() -> new RuntimeException("No player capability found!")); switch(id) { case 0: basecap.setFirstSpawn(b); } } public void handleClientIntPackets(int id, int i) { IPlayerBaseCap basecap = Minecraft.getInstance().player.getCapability(PlayerBaseCapProvider.PLAYER_BASE_CAP).orElseThrow(() -> new RuntimeException("No player capability found!")); switch(id) { case 0: basecap.setVillage(i); case 1: basecap.setClan(i); } } } What am I doing wrong? Also, oddly enough firstspawn doesn't even need syncing for some reason, its default value is true but even without syncing it on those events it stays false after it gets set to false.
    • Hello mod-makers. I am trying to create a pair of boots that make the player bounce upon falling while wearing them. So I have this item class that does nothing special apart from extending ArmorItem, and a PlayerEvent class that does the following:   @Mod.EventBusSubscriber(modid = PegasusVanguard.ID) public class ModPlayerEvents { @SubscribeEvent public static void onPlayerFall(LivingFallEvent event) { LivingEntity entity = event.getEntityLiving(); if (entity instanceof PlayerEntity && !entity.getEntityWorld().isRemote) { Iterator<ItemStack> armorSlots = entity.getArmorInventoryList().iterator(); entity = (PlayerEntity) entity; while (armorSlots.hasNext()) { if (armorSlots.next().getItem() instanceof ItemAirForceBoots) { event.setDamageMultiplier(0); entity.setFire(1); // why not Vec3d v = entity.getMotion(); entity.setMotion(v.x, -v.y * 5.0D, v.z); entity.setJumping(true); entity.isAirBorne = true; } } } } }   The only problem is setting the Y motion yields no result. First thing I tried is copying vanilla SlimeBlock code, but that didn't work. Then I played around with setMotion, setVelocity and travel, but I only managed to modify the X and Z components of the motion vector (and it works). I also tried, as you can see, to set some boolean flags to no avail. I am out of ideas at this point, the event fires just fine and code above setMotion is perfectly working. I don't see why just the Y axis is problematic... Hoping someone can help out! Cheers!
  • Topics

  • Who's Online (See full list)